diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-08-08 06:38:32 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-08-24 23:45:22 -0400 |
commit | bf287a90ceedf86e3313ba0dcff606ac5399b39a (patch) | |
tree | a3337495e68fde2270c406574774a283c0b4e002 /drivers/mmc/host/mmc_spi.c | |
parent | 214fc309d1387e822d606a33a10e31cacfe83520 (diff) |
mmc: mmc_spi: Support CD/RO GPIOs
Add support for passing CD/RO GPIO numbers directly to the mmc_spi
driver instead of relying solely on board code callbacks to retrieve the
CD/RO signals values. The driver will enable debouncing on the card
detect GPIO if the cd_debounce field is set to a non-zero value.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host/mmc_spi.c')
-rw-r--r-- | drivers/mmc/host/mmc_spi.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 74145d1d51f5..62fb82d7c942 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c | |||
@@ -36,6 +36,7 @@ | |||
36 | 36 | ||
37 | #include <linux/mmc/host.h> | 37 | #include <linux/mmc/host.h> |
38 | #include <linux/mmc/mmc.h> /* for R1_SPI_* bit values */ | 38 | #include <linux/mmc/mmc.h> /* for R1_SPI_* bit values */ |
39 | #include <linux/mmc/slot-gpio.h> | ||
39 | 40 | ||
40 | #include <linux/spi/spi.h> | 41 | #include <linux/spi/spi.h> |
41 | #include <linux/spi/mmc_spi.h> | 42 | #include <linux/spi/mmc_spi.h> |
@@ -1278,11 +1279,8 @@ static int mmc_spi_get_ro(struct mmc_host *mmc) | |||
1278 | 1279 | ||
1279 | if (host->pdata && host->pdata->get_ro) | 1280 | if (host->pdata && host->pdata->get_ro) |
1280 | return !!host->pdata->get_ro(mmc->parent); | 1281 | return !!host->pdata->get_ro(mmc->parent); |
1281 | /* | 1282 | else |
1282 | * Board doesn't support read only detection; let the mmc core | 1283 | return mmc_gpio_get_ro(mmc); |
1283 | * decide what to do. | ||
1284 | */ | ||
1285 | return -ENOSYS; | ||
1286 | } | 1284 | } |
1287 | 1285 | ||
1288 | static int mmc_spi_get_cd(struct mmc_host *mmc) | 1286 | static int mmc_spi_get_cd(struct mmc_host *mmc) |
@@ -1291,7 +1289,8 @@ static int mmc_spi_get_cd(struct mmc_host *mmc) | |||
1291 | 1289 | ||
1292 | if (host->pdata && host->pdata->get_cd) | 1290 | if (host->pdata && host->pdata->get_cd) |
1293 | return !!host->pdata->get_cd(mmc->parent); | 1291 | return !!host->pdata->get_cd(mmc->parent); |
1294 | return -ENOSYS; | 1292 | else |
1293 | return mmc_gpio_get_cd(mmc); | ||
1295 | } | 1294 | } |
1296 | 1295 | ||
1297 | static const struct mmc_host_ops mmc_spi_ops = { | 1296 | static const struct mmc_host_ops mmc_spi_ops = { |
@@ -1324,6 +1323,7 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1324 | struct mmc_host *mmc; | 1323 | struct mmc_host *mmc; |
1325 | struct mmc_spi_host *host; | 1324 | struct mmc_spi_host *host; |
1326 | int status; | 1325 | int status; |
1326 | bool has_ro = false; | ||
1327 | 1327 | ||
1328 | /* We rely on full duplex transfers, mostly to reduce | 1328 | /* We rely on full duplex transfers, mostly to reduce |
1329 | * per-transfer overheads (by making fewer transfers). | 1329 | * per-transfer overheads (by making fewer transfers). |
@@ -1448,18 +1448,33 @@ static int mmc_spi_probe(struct spi_device *spi) | |||
1448 | } | 1448 | } |
1449 | 1449 | ||
1450 | /* pass platform capabilities, if any */ | 1450 | /* pass platform capabilities, if any */ |
1451 | if (host->pdata) | 1451 | if (host->pdata) { |
1452 | mmc->caps |= host->pdata->caps; | 1452 | mmc->caps |= host->pdata->caps; |
1453 | mmc->caps2 |= host->pdata->caps2; | ||
1454 | } | ||
1453 | 1455 | ||
1454 | status = mmc_add_host(mmc); | 1456 | status = mmc_add_host(mmc); |
1455 | if (status != 0) | 1457 | if (status != 0) |
1456 | goto fail_add_host; | 1458 | goto fail_add_host; |
1457 | 1459 | ||
1460 | if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) { | ||
1461 | status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio, | ||
1462 | host->pdata->cd_debounce); | ||
1463 | if (status != 0) | ||
1464 | goto fail_add_host; | ||
1465 | } | ||
1466 | |||
1467 | if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) { | ||
1468 | has_ro = true; | ||
1469 | status = mmc_gpio_request_ro(mmc, host->pdata->ro_gpio); | ||
1470 | if (status != 0) | ||
1471 | goto fail_add_host; | ||
1472 | } | ||
1473 | |||
1458 | dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", | 1474 | dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", |
1459 | dev_name(&mmc->class_dev), | 1475 | dev_name(&mmc->class_dev), |
1460 | host->dma_dev ? "" : ", no DMA", | 1476 | host->dma_dev ? "" : ", no DMA", |
1461 | (host->pdata && host->pdata->get_ro) | 1477 | has_ro ? "" : ", no WP", |
1462 | ? "" : ", no WP", | ||
1463 | (host->pdata && host->pdata->setpower) | 1478 | (host->pdata && host->pdata->setpower) |
1464 | ? "" : ", no poweroff", | 1479 | ? "" : ", no poweroff", |
1465 | (mmc->caps & MMC_CAP_NEEDS_POLL) | 1480 | (mmc->caps & MMC_CAP_NEEDS_POLL) |