diff options
author | Manuel Lauss <mano@roarinelk.homelinux.net> | 2008-06-27 12:25:18 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2008-07-15 08:14:44 -0400 |
commit | e2d2647702702ea08cb78cdc9eca8c24242aa9be (patch) | |
tree | caeb63386c1d4812aa924811ce045e2ad514d207 /drivers/mmc | |
parent | 08fcb7208c4a8913232e48931783270262ece954 (diff) |
au1xmmc: remove custom carddetect poll implementation.
The MMC core provides a carddetect poll feature, time to
remove the driver's own implementation of it.
Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/au1xmmc.c | 79 |
1 files changed, 18 insertions, 61 deletions
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index 718eb879587f..3f15eb204895 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -21,7 +21,7 @@ | |||
21 | * published by the Free Software Foundation. | 21 | * published by the Free Software Foundation. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* Why is a timer used to detect insert events? | 24 | /* Why don't we use the SD controllers' carddetect feature? |
25 | * | 25 | * |
26 | * From the AU1100 MMC application guide: | 26 | * From the AU1100 MMC application guide: |
27 | * If the Au1100-based design is intended to support both MultiMediaCards | 27 | * If the Au1100-based design is intended to support both MultiMediaCards |
@@ -30,8 +30,6 @@ | |||
30 | * In doing so, a MMC card never enters SPI-mode communications, | 30 | * In doing so, a MMC card never enters SPI-mode communications, |
31 | * but now the SecureDigital card-detect feature of CD/DAT3 is ineffective | 31 | * but now the SecureDigital card-detect feature of CD/DAT3 is ineffective |
32 | * (the low to high transition will not occur). | 32 | * (the low to high transition will not occur). |
33 | * | ||
34 | * So we use the timer to check the status manually. | ||
35 | */ | 33 | */ |
36 | 34 | ||
37 | #include <linux/module.h> | 35 | #include <linux/module.h> |
@@ -111,7 +109,6 @@ struct au1xmmc_host { | |||
111 | 109 | ||
112 | int irq; | 110 | int irq; |
113 | 111 | ||
114 | struct timer_list timer; | ||
115 | struct tasklet_struct finish_task; | 112 | struct tasklet_struct finish_task; |
116 | struct tasklet_struct data_task; | 113 | struct tasklet_struct data_task; |
117 | struct au1xmmc_platform_data *platdata; | 114 | struct au1xmmc_platform_data *platdata; |
@@ -198,29 +195,24 @@ static void au1xmmc_set_power(struct au1xmmc_host *host, int state) | |||
198 | host->platdata->set_power(host->mmc, state); | 195 | host->platdata->set_power(host->mmc, state); |
199 | } | 196 | } |
200 | 197 | ||
201 | static int au1xmmc_card_inserted(struct au1xmmc_host *host) | 198 | static int au1xmmc_card_inserted(struct mmc_host *mmc) |
202 | { | 199 | { |
203 | int ret; | 200 | struct au1xmmc_host *host = mmc_priv(mmc); |
204 | 201 | ||
205 | if (host->platdata && host->platdata->card_inserted) | 202 | if (host->platdata && host->platdata->card_inserted) |
206 | ret = host->platdata->card_inserted(host->mmc); | 203 | return !!host->platdata->card_inserted(host->mmc); |
207 | else | ||
208 | ret = 1; /* assume there is a card */ | ||
209 | 204 | ||
210 | return ret; | 205 | return -ENOSYS; |
211 | } | 206 | } |
212 | 207 | ||
213 | static int au1xmmc_card_readonly(struct mmc_host *mmc) | 208 | static int au1xmmc_card_readonly(struct mmc_host *mmc) |
214 | { | 209 | { |
215 | struct au1xmmc_host *host = mmc_priv(mmc); | 210 | struct au1xmmc_host *host = mmc_priv(mmc); |
216 | int ret; | ||
217 | 211 | ||
218 | if (host->platdata && host->platdata->card_readonly) | 212 | if (host->platdata && host->platdata->card_readonly) |
219 | ret = host->platdata->card_readonly(mmc); | 213 | return !!host->platdata->card_readonly(mmc); |
220 | else | ||
221 | ret = 0; /* assume card is read-write */ | ||
222 | 214 | ||
223 | return ret; | 215 | return -ENOSYS; |
224 | } | 216 | } |
225 | 217 | ||
226 | static void au1xmmc_finish_request(struct au1xmmc_host *host) | 218 | static void au1xmmc_finish_request(struct au1xmmc_host *host) |
@@ -698,7 +690,7 @@ static void au1xmmc_request(struct mmc_host* mmc, struct mmc_request* mrq) | |||
698 | host->status = HOST_S_CMD; | 690 | host->status = HOST_S_CMD; |
699 | 691 | ||
700 | /* fail request immediately if no card is present */ | 692 | /* fail request immediately if no card is present */ |
701 | if (0 == au1xmmc_card_inserted(host)) { | 693 | if (0 == au1xmmc_card_inserted(mmc)) { |
702 | mrq->cmd->error = -ENOMEDIUM; | 694 | mrq->cmd->error = -ENOMEDIUM; |
703 | au1xmmc_finish_request(host); | 695 | au1xmmc_finish_request(host); |
704 | return; | 696 | return; |
@@ -935,39 +927,10 @@ static const struct mmc_host_ops au1xmmc_ops = { | |||
935 | .request = au1xmmc_request, | 927 | .request = au1xmmc_request, |
936 | .set_ios = au1xmmc_set_ios, | 928 | .set_ios = au1xmmc_set_ios, |
937 | .get_ro = au1xmmc_card_readonly, | 929 | .get_ro = au1xmmc_card_readonly, |
930 | .get_cd = au1xmmc_card_inserted, | ||
938 | .enable_sdio_irq = au1xmmc_enable_sdio_irq, | 931 | .enable_sdio_irq = au1xmmc_enable_sdio_irq, |
939 | }; | 932 | }; |
940 | 933 | ||
941 | static void au1xmmc_poll_event(unsigned long arg) | ||
942 | { | ||
943 | struct au1xmmc_host *host = (struct au1xmmc_host *)arg; | ||
944 | int card = au1xmmc_card_inserted(host); | ||
945 | int controller = (host->flags & HOST_F_ACTIVE) ? 1 : 0; | ||
946 | |||
947 | if (card != controller) { | ||
948 | host->flags &= ~HOST_F_ACTIVE; | ||
949 | if (card) | ||
950 | host->flags |= HOST_F_ACTIVE; | ||
951 | mmc_detect_change(host->mmc, 0); | ||
952 | } | ||
953 | |||
954 | #ifdef DEBUG | ||
955 | if (host->mrq != NULL) { | ||
956 | u32 status = au_readl(HOST_STATUS(host)); | ||
957 | DBG("PENDING - %8.8x\n", host->pdev->id, status); | ||
958 | } | ||
959 | #endif | ||
960 | mod_timer(&host->timer, jiffies + AU1XMMC_DETECT_TIMEOUT); | ||
961 | } | ||
962 | |||
963 | static void au1xmmc_init_cd_poll_timer(struct au1xmmc_host *host) | ||
964 | { | ||
965 | init_timer(&host->timer); | ||
966 | host->timer.function = au1xmmc_poll_event; | ||
967 | host->timer.data = (unsigned long)host; | ||
968 | host->timer.expires = jiffies + AU1XMMC_DETECT_TIMEOUT; | ||
969 | } | ||
970 | |||
971 | static int __devinit au1xmmc_probe(struct platform_device *pdev) | 934 | static int __devinit au1xmmc_probe(struct platform_device *pdev) |
972 | { | 935 | { |
973 | struct mmc_host *mmc; | 936 | struct mmc_host *mmc; |
@@ -1042,13 +1005,11 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) | |||
1042 | if (host->platdata && host->platdata->cd_setup) { | 1005 | if (host->platdata && host->platdata->cd_setup) { |
1043 | ret = host->platdata->cd_setup(mmc, 1); | 1006 | ret = host->platdata->cd_setup(mmc, 1); |
1044 | if (ret) { | 1007 | if (ret) { |
1045 | dev_err(&pdev->dev, "board CD setup failed\n"); | 1008 | dev_warn(&pdev->dev, "board CD setup failed\n"); |
1046 | goto out4; | 1009 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
1047 | } | 1010 | } |
1048 | } else { | 1011 | } else |
1049 | /* poll the board-specific is-card-in-socket-? method */ | 1012 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
1050 | au1xmmc_init_cd_poll_timer(host); | ||
1051 | } | ||
1052 | 1013 | ||
1053 | tasklet_init(&host->data_task, au1xmmc_tasklet_data, | 1014 | tasklet_init(&host->data_task, au1xmmc_tasklet_data, |
1054 | (unsigned long)host); | 1015 | (unsigned long)host); |
@@ -1084,10 +1045,6 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) | |||
1084 | 1045 | ||
1085 | platform_set_drvdata(pdev, mmc); | 1046 | platform_set_drvdata(pdev, mmc); |
1086 | 1047 | ||
1087 | /* start the carddetect poll timer if necessary */ | ||
1088 | if (!(host->platdata && host->platdata->cd_setup)) | ||
1089 | add_timer(&host->timer); | ||
1090 | |||
1091 | printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X" | 1048 | printk(KERN_INFO DRIVER_NAME ": MMC Controller %d set up at %8.8X" |
1092 | " (mode=%s)\n", pdev->id, host->iobase, | 1049 | " (mode=%s)\n", pdev->id, host->iobase, |
1093 | host->flags & HOST_F_DMA ? "dma" : "pio"); | 1050 | host->flags & HOST_F_DMA ? "dma" : "pio"); |
@@ -1112,9 +1069,10 @@ out5: | |||
1112 | tasklet_kill(&host->data_task); | 1069 | tasklet_kill(&host->data_task); |
1113 | tasklet_kill(&host->finish_task); | 1070 | tasklet_kill(&host->finish_task); |
1114 | 1071 | ||
1115 | if (host->platdata && host->platdata->cd_setup) | 1072 | if (host->platdata && host->platdata->cd_setup && |
1073 | !(mmc->caps & MMC_CAP_NEEDS_POLL)) | ||
1116 | host->platdata->cd_setup(mmc, 0); | 1074 | host->platdata->cd_setup(mmc, 0); |
1117 | out4: | 1075 | |
1118 | free_irq(host->irq, host); | 1076 | free_irq(host->irq, host); |
1119 | out3: | 1077 | out3: |
1120 | iounmap((void *)host->iobase); | 1078 | iounmap((void *)host->iobase); |
@@ -1142,10 +1100,9 @@ static int __devexit au1xmmc_remove(struct platform_device *pdev) | |||
1142 | led_classdev_unregister(host->platdata->led); | 1100 | led_classdev_unregister(host->platdata->led); |
1143 | #endif | 1101 | #endif |
1144 | 1102 | ||
1145 | if (host->platdata && host->platdata->cd_setup) | 1103 | if (host->platdata && host->platdata->cd_setup && |
1104 | !(mmc->caps & MMC_CAP_NEEDS_POLL)) | ||
1146 | host->platdata->cd_setup(mmc, 0); | 1105 | host->platdata->cd_setup(mmc, 0); |
1147 | else | ||
1148 | del_timer_sync(&host->timer); | ||
1149 | 1106 | ||
1150 | au_writel(0, HOST_ENABLE(host)); | 1107 | au_writel(0, HOST_ENABLE(host)); |
1151 | au_writel(0, HOST_CONFIG(host)); | 1108 | au_writel(0, HOST_CONFIG(host)); |