UPSTREAM: mmc: sdhci: Fix sdhci_card_busy()
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 23 Jun 2016 11:00:58 +0000 (14:00 +0300)
committerZiyuan Xu <xzy.xu@rock-chips.com>
Fri, 12 Aug 2016 01:30:20 +0000 (09:30 +0800)
host->card_busy() was introduced for SD voltage switching which checks all
4 data lines.

Increasingly, host->card_busy is being used to poll the the busy signal
which is only data line 0 (DAT[0]).

The current logic in sdhci_card_busy() does not work in that case because
it returns false if any of the data lines is high.  It also ignores
possibilities:
- data lines 1-3 are not connected and could show at any level
- data lines 1-2 can be used by SDIO for other purposes

According to the SD specification, it is OK to check any of the data lines
for voltage switching, so change to use DAT[0] only.

(cherry picked from commit e613cc477c777a175c89d607d1f7a8ef528d2c43)

Change-Id: I11862e4ab67867271caedc01c0e74c5e24daea37
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
drivers/mmc/host/sdhci.c

index 1a802af827ed24bd4f385bdbfd68cb643a2e3e10..ae1dff1db905eee7ab8647f6781ef6e4a4d6251b 100644 (file)
@@ -1870,11 +1870,11 @@ static int sdhci_card_busy(struct mmc_host *mmc)
        u32 present_state;
 
        sdhci_runtime_pm_get(host);
-       /* Check whether DAT[3:0] is 0000 */
+       /* Check whether DAT[0] is 0 */
        present_state = sdhci_readl(host, SDHCI_PRESENT_STATE);
        sdhci_runtime_pm_put(host);
 
-       return !(present_state & SDHCI_DATA_LVL_MASK);
+       return !(present_state & SDHCI_DATA_0_LVL_MASK);
 }
 
 static int sdhci_prepare_hs400_tuning(struct mmc_host *mmc, struct mmc_ios *ios)