提交 505a8680 编写于 作者: S Shawn Guo 提交者: Chris Ball

mmc: sdhci: query card presence from cd-gpio before asking SDHCI

Call mmc_gpio_get_cd() to query card presence from cd-gpio before
asking SDHCI.  The rationale behind this change is that flag
SDHCI_QUIRK_BROKEN_CARD_DETECTION is designed for SDHCI controller to
tell that SDHCI_PRESENT_STATE is broken, and it should be used for this
case only.  So when cd-gpio is being used, the controller should set
the flag to tell that SDHCI_PRESENT_STATE is not available.

However, the existing code will skip checking cd-gpio as long as flag
SDHCI_QUIRK_BROKEN_CARD_DETECTION is set.  Change the querying order
between cd-gpio and SDHCI to support the rationale above.
Signed-off-by: NShawn Guo <shawn.guo@linaro.org>
Signed-off-by: NChris Ball <cjb@laptop.org>
上级 77e2ff08
...@@ -1258,7 +1258,7 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power) ...@@ -1258,7 +1258,7 @@ static int sdhci_set_power(struct sdhci_host *host, unsigned short power)
static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
{ {
struct sdhci_host *host; struct sdhci_host *host;
bool present; int present;
unsigned long flags; unsigned long flags;
u32 tuning_opcode; u32 tuning_opcode;
...@@ -1287,18 +1287,21 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq) ...@@ -1287,18 +1287,21 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
host->mrq = mrq; host->mrq = mrq;
/* If polling, assume that the card is always present. */ /*
if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) * Firstly check card presence from cd-gpio. The return could
present = true; * be one of the following possibilities:
else * negative: cd-gpio is not available
present = sdhci_readl(host, SDHCI_PRESENT_STATE) & * zero: cd-gpio is used, and card is removed
SDHCI_CARD_PRESENT; * one: cd-gpio is used, and card is present
*/
/* If we're using a cd-gpio, testing the presence bit might fail. */ present = mmc_gpio_get_cd(host->mmc);
if (!present) { if (present < 0) {
int ret = mmc_gpio_get_cd(host->mmc); /* If polling, assume that the card is always present. */
if (ret > 0) if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
present = true; present = 1;
else
present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
SDHCI_CARD_PRESENT;
} }
if (!present || host->flags & SDHCI_DEVICE_DEAD) { if (!present || host->flags & SDHCI_DEVICE_DEAD) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册