提交 619ef4b4 编写于 作者: A Anton Vorontsov 提交者: Pierre Ossman

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: NAnton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: NPierre Ossman <drzeus@drzeus.cx>
上级 28f52482
...@@ -1131,11 +1131,20 @@ static int mmc_spi_get_ro(struct mmc_host *mmc) ...@@ -1131,11 +1131,20 @@ static int mmc_spi_get_ro(struct mmc_host *mmc)
return 0; return 0;
} }
static int mmc_spi_get_cd(struct mmc_host *mmc)
{
struct mmc_spi_host *host = mmc_priv(mmc);
if (host->pdata && host->pdata->get_cd)
return !!host->pdata->get_cd(mmc->parent);
return -ENOSYS;
}
static const struct mmc_host_ops mmc_spi_ops = { static const struct mmc_host_ops mmc_spi_ops = {
.request = mmc_spi_request, .request = mmc_spi_request,
.set_ios = mmc_spi_set_ios, .set_ios = mmc_spi_set_ios,
.get_ro = mmc_spi_get_ro, .get_ro = mmc_spi_get_ro,
.get_cd = mmc_spi_get_cd,
}; };
...@@ -1319,17 +1328,23 @@ static int mmc_spi_probe(struct spi_device *spi) ...@@ -1319,17 +1328,23 @@ static int mmc_spi_probe(struct spi_device *spi)
goto fail_glue_init; goto fail_glue_init;
} }
/* pass platform capabilities, if any */
if (host->pdata)
mmc->caps |= host->pdata->caps;
status = mmc_add_host(mmc); status = mmc_add_host(mmc);
if (status != 0) if (status != 0)
goto fail_add_host; goto fail_add_host;
dev_info(&spi->dev, "SD/MMC host %s%s%s%s\n", dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n",
mmc->class_dev.bus_id, mmc->class_dev.bus_id,
host->dma_dev ? "" : ", no DMA", host->dma_dev ? "" : ", no DMA",
(host->pdata && host->pdata->get_ro) (host->pdata && host->pdata->get_ro)
? "" : ", no WP", ? "" : ", no WP",
(host->pdata && host->pdata->setpower) (host->pdata && host->pdata->setpower)
? "" : ", no poweroff"); ? "" : ", no poweroff",
(mmc->caps & MMC_CAP_NEEDS_POLL)
? ", cd polling" : "");
return 0; return 0;
fail_add_host: fail_add_host:
......
...@@ -23,6 +23,15 @@ struct mmc_spi_platform_data { ...@@ -23,6 +23,15 @@ struct mmc_spi_platform_data {
/* sense switch on sd cards */ /* sense switch on sd cards */
int (*get_ro)(struct device *); int (*get_ro)(struct device *);
/*
* If board does not use CD interrupts, driver can optimize polling
* using this function.
*/
int (*get_cd)(struct device *);
/* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */
unsigned long caps;
/* how long to debounce card detect, in msecs */ /* how long to debounce card detect, in msecs */
u16 detect_delay; u16 detect_delay;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册