aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2008-06-17 10:17:21 -0400
committerPierre Ossman <drzeus@drzeus.cx>2008-07-15 08:14:41 -0400
commit619ef4b42128709de4d89d209b2c874f560deecd (patch)
tree9c813630ed396b5efb590303c84a1f2935502ca7
parent28f52482b41edc88cdf575aa6ed414c6e116ce10 (diff)
mmc_spi: add support for card-detection polling
This patch adds new platform data variable "caps", so platforms could pass theirs capabilities into MMC core (for example, platforms without interrupt on the CD line will most probably want to pass MMC_CAP_NEEDS_POLL). New platform get_cd() callback provided to optimize polling. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
-rw-r--r--drivers/mmc/host/mmc_spi.c19
-rw-r--r--include/linux/spi/mmc_spi.h9
2 files changed, 26 insertions, 2 deletions
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 35508584ac2a..547eb857b1b3 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1131,11 +1131,20 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
1131 return 0; 1131 return 0;
1132} 1132}
1133 1133
1134static int mmc_spi_get_cd(struct mmc_host *mmc)
1135{
1136 struct mmc_spi_host *host = mmc_priv(mmc);
1137
1138 if (host->pdata && host->pdata->get_cd)
1139 return !!host->pdata->get_cd(mmc->parent);
1140 return -ENOSYS;
1141}
1134 1142
1135static const struct mmc_host_ops mmc_spi_ops = { 1143static const struct mmc_host_ops mmc_spi_ops = {
1136 .request = mmc_spi_request, 1144 .request = mmc_spi_request,
1137 .set_ios = mmc_spi_set_ios, 1145 .set_ios = mmc_spi_set_ios,
1138 .get_ro = mmc_spi_get_ro, 1146 .get_ro = mmc_spi_get_ro,
1147 .get_cd = mmc_spi_get_cd,
1139}; 1148};
1140 1149
1141 1150
@@ -1319,17 +1328,23 @@ static int mmc_spi_probe(struct spi_device *spi)
1319 goto fail_glue_init; 1328 goto fail_glue_init;
1320 } 1329 }
1321 1330
1331 /* pass platform capabilities, if any */
1332 if (host->pdata)
1333 mmc->caps |= host->pdata->caps;
1334
1322 status = mmc_add_host(mmc); 1335 status = mmc_add_host(mmc);
1323 if (status != 0) 1336 if (status != 0)
1324 goto fail_add_host; 1337 goto fail_add_host;
1325 1338
1326 dev_info(&spi->dev, "SD/MMC host %s%s%s%s\n", 1339 dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n",
1327 mmc->class_dev.bus_id, 1340 mmc->class_dev.bus_id,
1328 host->dma_dev ? "" : ", no DMA", 1341 host->dma_dev ? "" : ", no DMA",
1329 (host->pdata && host->pdata->get_ro) 1342 (host->pdata && host->pdata->get_ro)
1330 ? "" : ", no WP", 1343 ? "" : ", no WP",
1331 (host->pdata && host->pdata->setpower) 1344 (host->pdata && host->pdata->setpower)
1332 ? "" : ", no poweroff"); 1345 ? "" : ", no poweroff",
1346 (mmc->caps & MMC_CAP_NEEDS_POLL)
1347 ? ", cd polling" : "");
1333 return 0; 1348 return 0;
1334 1349
1335fail_add_host: 1350fail_add_host:
diff --git a/include/linux/spi/mmc_spi.h b/include/linux/spi/mmc_spi.h
index d5ca78b93a3b..a3626aedaec9 100644
--- a/include/linux/spi/mmc_spi.h
+++ b/include/linux/spi/mmc_spi.h
@@ -23,6 +23,15 @@ struct mmc_spi_platform_data {
23 /* sense switch on sd cards */ 23 /* sense switch on sd cards */
24 int (*get_ro)(struct device *); 24 int (*get_ro)(struct device *);
25 25
26 /*
27 * If board does not use CD interrupts, driver can optimize polling
28 * using this function.
29 */
30 int (*get_cd)(struct device *);
31
32 /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */
33 unsigned long caps;
34
26 /* how long to debounce card detect, in msecs */ 35 /* how long to debounce card detect, in msecs */
27 u16 detect_delay; 36 u16 detect_delay;
28 37