From: Kevin Liu <kliu5@marvell.com>
To: linux-mmc@vger.kernel.org, Chris Ball <cjb@laptop.org>,
Guennadi Liakhovetski <g.liakhovetski@gmx.de>,
Sujit Reddy Thumma <sthumma@codeaurora.org>,
Jaehoon Chung <jh80.chung@samsung.com>,
Aaron Lu <aaron.lu@intel.com>,
Ulf Hansson <ulf.hansson@linaro.org>,
Wei WANG <wei_wang@realsil.com.cn>,
Fabio Estevam <fabio.estevam@freescale.com>
Cc: Stephen Warren <swarren@wwwdotorg.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Philip Rakity <prakity@nvidia.com>,
Shawn Guo <shawn.guo@linaro.org>,
Johan Rudholm <johan.rudholm@stericsson.com>,
Girish K S <girish.shivananjappa@linaro.org>,
Haijun Zhang <Haijun.Zhang@freescale.com>,
Zhangfei Gao <zhangfei.gao@gmail.com>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Chao Xie <cxie4@marvell.com>, Kevin Liu <keyuan.liu@gmail.com>,
Kevin Liu <kliu5@marvell.com>
Subject: [PATCH v3 2/2] mmc: sdhci: add function get_cd
Date: Thu, 28 Feb 2013 17:35:53 +0800 [thread overview]
Message-ID: <1362044153-8996-1-git-send-email-kliu5@marvell.com> (raw)
1. mmc_rescan will call get_cd to know whether the card is present
before mmc_rescan_try_freq to avoid useless trials during
card removal or start host is called when card is not present.
2. get_cd need to be checked to resolve slow card removal issue.
Signed-off-by: Kevin Liu <kliu5@marvell.com>
---
drivers/mmc/host/sdhci.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 51bbba4..c94fd6c 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1581,6 +1581,34 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
sdhci_runtime_pm_put(host);
}
+static int sdhci_do_get_cd(struct sdhci_host *host)
+{
+ int gpio_cd = mmc_gpio_get_cd(host->mmc);
+
+ if (host->flags & SDHCI_DEVICE_DEAD)
+ return 0;
+ /* If polling/nonremovable, assume that the card is always present. */
+ if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) ||
+ (host->mmc->caps & MMC_CAP_NONREMOVABLE))
+ return 1;
+ /* Try slot gpio detect */
+ if (!IS_ERR_VALUE(gpio_cd))
+ return !!gpio_cd;
+ /* Host native card detect */
+ return !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
+}
+
+static int sdhci_get_cd(struct mmc_host *mmc)
+{
+ struct sdhci_host *host = mmc_priv(mmc);
+ int ret;
+
+ sdhci_runtime_pm_get(host);
+ ret = sdhci_do_get_cd(host);
+ sdhci_runtime_pm_put(host);
+ return ret;
+}
+
static int sdhci_check_ro(struct sdhci_host *host)
{
unsigned long flags;
@@ -2038,6 +2066,7 @@ static void sdhci_card_event(struct mmc_host *mmc)
static const struct mmc_host_ops sdhci_ops = {
.request = sdhci_request,
.set_ios = sdhci_set_ios,
+ .get_cd = sdhci_get_cd,
.get_ro = sdhci_get_ro,
.hw_reset = sdhci_hw_reset,
.enable_sdio_irq = sdhci_enable_sdio_irq,
--
1.7.9.5
next reply other threads:[~2013-02-28 9:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 9:35 Kevin Liu [this message]
2013-03-22 16:25 ` [PATCH v3 2/2] mmc: sdhci: add function get_cd Chris Ball
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=1362044153-8996-1-git-send-email-kliu5@marvell.com \
--to=kliu5@marvell.com \
--cc=Haijun.Zhang@freescale.com \
--cc=aaron.lu@intel.com \
--cc=adrian.hunter@intel.com \
--cc=cjb@laptop.org \
--cc=cxie4@marvell.com \
--cc=fabio.estevam@freescale.com \
--cc=g.liakhovetski@gmx.de \
--cc=girish.shivananjappa@linaro.org \
--cc=haojian.zhuang@gmail.com \
--cc=jh80.chung@samsung.com \
--cc=johan.rudholm@stericsson.com \
--cc=keyuan.liu@gmail.com \
--cc=linux-mmc@vger.kernel.org \
--cc=prakity@nvidia.com \
--cc=shawn.guo@linaro.org \
--cc=sthumma@codeaurora.org \
--cc=swarren@wwwdotorg.org \
--cc=ulf.hansson@linaro.org \
--cc=wei_wang@realsil.com.cn \
--cc=zhangfei.gao@gmail.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