diff options
Diffstat (limited to 'drivers/mmc/host/imxmmc.c')
-rw-r--r-- | drivers/mmc/host/imxmmc.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/drivers/mmc/host/imxmmc.c b/drivers/mmc/host/imxmmc.c index 5e880c0f1349..f61406da65d2 100644 --- a/drivers/mmc/host/imxmmc.c +++ b/drivers/mmc/host/imxmmc.c | |||
@@ -26,12 +26,6 @@ | |||
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #ifdef CONFIG_MMC_DEBUG | ||
30 | #define DEBUG | ||
31 | #else | ||
32 | #undef DEBUG | ||
33 | #endif | ||
34 | |||
35 | #include <linux/module.h> | 29 | #include <linux/module.h> |
36 | #include <linux/init.h> | 30 | #include <linux/init.h> |
37 | #include <linux/ioport.h> | 31 | #include <linux/ioport.h> |
@@ -907,31 +901,12 @@ static const struct mmc_host_ops imxmci_ops = { | |||
907 | .get_ro = imxmci_get_ro, | 901 | .get_ro = imxmci_get_ro, |
908 | }; | 902 | }; |
909 | 903 | ||
910 | static struct resource *platform_device_resource(struct platform_device *dev, unsigned int mask, int nr) | ||
911 | { | ||
912 | int i; | ||
913 | |||
914 | for (i = 0; i < dev->num_resources; i++) | ||
915 | if (dev->resource[i].flags == mask && nr-- == 0) | ||
916 | return &dev->resource[i]; | ||
917 | return NULL; | ||
918 | } | ||
919 | |||
920 | static int platform_device_irq(struct platform_device *dev, int nr) | ||
921 | { | ||
922 | int i; | ||
923 | |||
924 | for (i = 0; i < dev->num_resources; i++) | ||
925 | if (dev->resource[i].flags == IORESOURCE_IRQ && nr-- == 0) | ||
926 | return dev->resource[i].start; | ||
927 | return NO_IRQ; | ||
928 | } | ||
929 | |||
930 | static void imxmci_check_status(unsigned long data) | 904 | static void imxmci_check_status(unsigned long data) |
931 | { | 905 | { |
932 | struct imxmci_host *host = (struct imxmci_host *)data; | 906 | struct imxmci_host *host = (struct imxmci_host *)data; |
933 | 907 | ||
934 | if( host->pdata->card_present(mmc_dev(host->mmc)) != host->present ) { | 908 | if (host->pdata && host->pdata->card_present && |
909 | host->pdata->card_present(mmc_dev(host->mmc)) != host->present) { | ||
935 | host->present ^= 1; | 910 | host->present ^= 1; |
936 | dev_info(mmc_dev(host->mmc), "card %s\n", | 911 | dev_info(mmc_dev(host->mmc), "card %s\n", |
937 | host->present ? "inserted" : "removed"); | 912 | host->present ? "inserted" : "removed"); |
@@ -962,13 +937,12 @@ static int imxmci_probe(struct platform_device *pdev) | |||
962 | 937 | ||
963 | printk(KERN_INFO "i.MX mmc driver\n"); | 938 | printk(KERN_INFO "i.MX mmc driver\n"); |
964 | 939 | ||
965 | r = platform_device_resource(pdev, IORESOURCE_MEM, 0); | 940 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
966 | irq = platform_device_irq(pdev, 0); | 941 | irq = platform_get_irq(pdev, 0); |
967 | if (!r || irq == NO_IRQ) | 942 | if (!r || irq < 0) |
968 | return -ENXIO; | 943 | return -ENXIO; |
969 | 944 | ||
970 | r = request_mem_region(r->start, 0x100, "IMXMCI"); | 945 | if (!request_mem_region(r->start, 0x100, pdev->name)) |
971 | if (!r) | ||
972 | return -EBUSY; | 946 | return -EBUSY; |
973 | 947 | ||
974 | mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev); | 948 | mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev); |
@@ -995,6 +969,8 @@ static int imxmci_probe(struct platform_device *pdev) | |||
995 | host->mmc = mmc; | 969 | host->mmc = mmc; |
996 | host->dma_allocated = 0; | 970 | host->dma_allocated = 0; |
997 | host->pdata = pdev->dev.platform_data; | 971 | host->pdata = pdev->dev.platform_data; |
972 | if (!host->pdata) | ||
973 | dev_warn(&pdev->dev, "No platform data provided!\n"); | ||
998 | 974 | ||
999 | spin_lock_init(&host->lock); | 975 | spin_lock_init(&host->lock); |
1000 | host->res = r; | 976 | host->res = r; |
@@ -1047,7 +1023,11 @@ static int imxmci_probe(struct platform_device *pdev) | |||
1047 | if (ret) | 1023 | if (ret) |
1048 | goto out; | 1024 | goto out; |
1049 | 1025 | ||
1050 | host->present = host->pdata->card_present(mmc_dev(mmc)); | 1026 | if (host->pdata && host->pdata->card_present) |
1027 | host->present = host->pdata->card_present(mmc_dev(mmc)); | ||
1028 | else /* if there is no way to detect assume that card is present */ | ||
1029 | host->present = 1; | ||
1030 | |||
1051 | init_timer(&host->timer); | 1031 | init_timer(&host->timer); |
1052 | host->timer.data = (unsigned long)host; | 1032 | host->timer.data = (unsigned long)host; |
1053 | host->timer.function = imxmci_check_status; | 1033 | host->timer.function = imxmci_check_status; |
@@ -1073,7 +1053,7 @@ out: | |||
1073 | } | 1053 | } |
1074 | if (mmc) | 1054 | if (mmc) |
1075 | mmc_free_host(mmc); | 1055 | mmc_free_host(mmc); |
1076 | release_resource(r); | 1056 | release_mem_region(r->start, 0x100); |
1077 | return ret; | 1057 | return ret; |
1078 | } | 1058 | } |
1079 | 1059 | ||
@@ -1102,7 +1082,7 @@ static int imxmci_remove(struct platform_device *pdev) | |||
1102 | clk_disable(host->clk); | 1082 | clk_disable(host->clk); |
1103 | clk_put(host->clk); | 1083 | clk_put(host->clk); |
1104 | 1084 | ||
1105 | release_resource(host->res); | 1085 | release_mem_region(host->res->start, 0x100); |
1106 | 1086 | ||
1107 | mmc_free_host(mmc); | 1087 | mmc_free_host(mmc); |
1108 | } | 1088 | } |