diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-01-18 01:28:12 +0900 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2018-03-05 13:03:16 +0100 |
commit | 497d1f965c207f1d670066e9c87a2ffad1ce4e5e (patch) | |
tree | 00468aeab8231deb9f1d1c9d26cd832351770ba1 /drivers/mmc | |
parent | 788778b0d21a6d5cd5bc6c880591119e17932327 (diff) | |
download | blackbird-op-linux-497d1f965c207f1d670066e9c87a2ffad1ce4e5e.tar.gz blackbird-op-linux-497d1f965c207f1d670066e9c87a2ffad1ce4e5e.zip |
mmc: tmio: support IP-builtin card detection logic
A card detect GPIO is set up only for platforms with "cd-gpios"
DT property or TMIO_MMC_USE_GPIO_CD flag. However, the driver
core always uses mmc_gpio_get_cd, which just fails with -ENOSYS
if ctx->cd_gpio is unset.
The bit 5 of the status register provides the current signal level
of the CD line. Allow to use it if the GPIO is unused.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/tmio_mmc_core.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c index f5da8bbf6dd3..2abc425d45fd 100644 --- a/drivers/mmc/host/tmio_mmc_core.c +++ b/drivers/mmc/host/tmio_mmc_core.c @@ -1066,6 +1066,14 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc) TMIO_STAT_WRPROTECT); } +static int tmio_mmc_get_cd(struct mmc_host *mmc) +{ + struct tmio_mmc_host *host = mmc_priv(mmc); + + return !!(sd_ctrl_read16_and_16_as_32(host, CTL_STATUS) & + TMIO_STAT_SIGSTATE); +} + static int tmio_multi_io_quirk(struct mmc_card *card, unsigned int direction, int blk_size) { @@ -1081,7 +1089,7 @@ static const struct mmc_host_ops tmio_mmc_ops = { .request = tmio_mmc_request, .set_ios = tmio_mmc_set_ios, .get_ro = tmio_mmc_get_ro, - .get_cd = mmc_gpio_get_cd, + .get_cd = tmio_mmc_get_cd, .enable_sdio_irq = tmio_mmc_enable_sdio_irq, .multi_io_quirk = tmio_multi_io_quirk, .hw_reset = tmio_mmc_hw_reset, @@ -1234,6 +1242,9 @@ int tmio_mmc_host_probe(struct tmio_mmc_host *_host) if (mmc_can_gpio_ro(mmc)) _host->ops.get_ro = mmc_gpio_get_ro; + if (mmc_can_gpio_cd(mmc)) + _host->ops.get_cd = mmc_gpio_get_cd; + _host->native_hotplug = !(mmc_can_gpio_cd(mmc) || mmc->caps & MMC_CAP_NEEDS_POLL || !mmc_card_is_removable(mmc)); |