Skip to content

Commit ae64985

Browse files
Wenchao Chengregkh
authored andcommitted
mmc: sdhci-sprd: Fix eMMC init failure after hw reset
commit 8abf77c upstream. Some eMMC devices that do not close the auto clk gate after hw reset will cause eMMC initialization to fail. Let's fix this. Signed-off-by: Wenchao Chen <[email protected]> Fixes: ff874db ("mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K") Reviewed-by: Baolin Wang <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f7796d7 commit ae64985

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/mmc/host/sdhci-sprd.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,19 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
224224
div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
225225
sdhci_enable_clk(host, div);
226226

227+
val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
228+
mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN | SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
227229
/* Enable CLK_AUTO when the clock is greater than 400K. */
228230
if (clk > 400000) {
229-
val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
230-
mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
231-
SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
232231
if (mask != (val & mask)) {
233232
val |= mask;
234233
sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
235234
}
235+
} else {
236+
if (val & mask) {
237+
val &= ~mask;
238+
sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
239+
}
236240
}
237241
}
238242

0 commit comments

Comments
 (0)