From: Masahiro Yamada <yamada.masahiro@socionext.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>,
linux-mmc@vger.kernel.org
Cc: Simon Horman <simon.horman@netronome.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Masahiro Yamada <yamada.masahiro@socionext.com>,
linux-kernel@vger.kernel.org,
Ulf Hansson <ulf.hansson@linaro.org>
Subject: [PATCH 3/3] mmc: tmio: support IP-builtin card detection logic
Date: Wed, 8 Nov 2017 19:17:00 +0900 [thread overview]
Message-ID: <1510136220-31853-4-git-send-email-yamada.masahiro@socionext.com> (raw)
In-Reply-To: <1510136220-31853-1-git-send-email-yamada.masahiro@socionext.com>
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>
---
drivers/mmc/host/tmio_mmc_core.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/host/tmio_mmc_core.c b/drivers/mmc/host/tmio_mmc_core.c
index 9fd0874..85a2944 100644
--- a/drivers/mmc/host/tmio_mmc_core.c
+++ b/drivers/mmc/host/tmio_mmc_core.c
@@ -1087,6 +1087,19 @@ static int tmio_mmc_get_ro(struct mmc_host *mmc)
return ret;
}
+static int tmio_mmc_get_cd(struct mmc_host *mmc)
+{
+ struct tmio_mmc_host *host = mmc_priv(mmc);
+ int ret;
+
+ ret = mmc_gpio_get_cd(mmc);
+ if (ret >= 0)
+ return ret;
+
+ 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)
{
@@ -1102,7 +1115,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,
--
2.7.4
next prev parent reply other threads:[~2017-11-08 10:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-08 10:16 [PATCH 0/3] mmc: tmio: fix card detection Masahiro Yamada
2017-11-08 10:16 ` [PATCH 1/3] mmc: tmio: move mmc_gpio_request_cd() before mmc_add_host() Masahiro Yamada
2017-11-08 10:16 ` [PATCH 2/3] mmc: tmio: use mmc_can_gpio_cd() instead of checking TMIO_MMC_USE_GPIO_CD Masahiro Yamada
2017-11-19 19:47 ` Wolfram Sang
2017-11-20 15:39 ` Masahiro Yamada
2017-11-20 20:54 ` Wolfram Sang
2017-11-08 10:17 ` Masahiro Yamada [this message]
2017-11-19 19:45 ` [PATCH 3/3] mmc: tmio: support IP-builtin card detection logic Wolfram Sang
2017-11-20 8:03 ` Masahiro Yamada
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1510136220-31853-4-git-send-email-yamada.masahiro@socionext.com \
--to=yamada.masahiro@socionext.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=simon.horman@netronome.com \
--cc=ulf.hansson@linaro.org \
--cc=wsa+renesas@sang-engineering.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).