Skip to content

Commit b0921d5

Browse files
mwallestorulf
authored andcommitted
mmc: sdhci-of-esdhc: fixup PRESENT_STATE read
Since commit 87a18a6 ("mmc: mmc: Use ->card_busy() to detect busy cards in __mmc_switch()") the ESDHC driver is broken: mmc0: Card stuck in programming state! __mmc_switch mmc0: error -110 whilst initialising MMC card Since this commit __mmc_switch() uses ->card_busy(), which is sdhci_card_busy() for the esdhc driver. sdhci_card_busy() uses the PRESENT_STATE register, specifically the DAT0 signal level bit. But the ESDHC uses a non-conformant PRESENT_STATE register, thus a read fixup is required to make the driver work again. Signed-off-by: Michael Walle <[email protected]> Fixes: 87a18a6 ("mmc: mmc: Use ->card_busy() to detect busy cards in __mmc_switch()") Acked-by: Yangbo Lu <[email protected]> Acked-by: Adrian Hunter <[email protected]> Cc: <[email protected]> # v4.8+ Signed-off-by: Ulf Hansson <[email protected]>
1 parent a25f094 commit b0921d5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/mmc/host/sdhci-of-esdhc.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ static u32 esdhc_readl_fixup(struct sdhci_host *host,
6666
return ret;
6767
}
6868
}
69+
/*
70+
* The DAT[3:0] line signal levels and the CMD line signal level are
71+
* not compatible with standard SDHC register. The line signal levels
72+
* DAT[7:0] are at bits 31:24 and the command line signal level is at
73+
* bit 23. All other bits are the same as in the standard SDHC
74+
* register.
75+
*/
76+
if (spec_reg == SDHCI_PRESENT_STATE) {
77+
ret = value & 0x000fffff;
78+
ret |= (value >> 4) & SDHCI_DATA_LVL_MASK;
79+
ret |= (value << 1) & SDHCI_CMD_LVL;
80+
return ret;
81+
}
82+
6983
ret = value;
7084
return ret;
7185
}

drivers/mmc/host/sdhci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#define SDHCI_DATA_LVL_MASK 0x00F00000
7474
#define SDHCI_DATA_LVL_SHIFT 20
7575
#define SDHCI_DATA_0_LVL_MASK 0x00100000
76+
#define SDHCI_CMD_LVL 0x01000000
7677

7778
#define SDHCI_HOST_CONTROL 0x28
7879
#define SDHCI_CTRL_LED 0x01

0 commit comments

Comments
 (0)