Skip to content

Commit 8abf77c

Browse files
Wenchao Chenstorulf
authored andcommitted
mmc: sdhci-sprd: Fix eMMC init failure after hw reset
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 <wenchao.chen@unisoc.com> Fixes: ff874db ("mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K") Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20231204064934.21236-1-wenchao.chen@unisoc.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent 1036f69 commit 8abf77c

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
@@ -239,15 +239,19 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
239239
div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
240240
sdhci_enable_clk(host, div);
241241

242+
val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
243+
mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN | SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
242244
/* Enable CLK_AUTO when the clock is greater than 400K. */
243245
if (clk > 400000) {
244-
val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
245-
mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
246-
SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
247246
if (mask != (val & mask)) {
248247
val |= mask;
249248
sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
250249
}
250+
} else {
251+
if (val & mask) {
252+
val &= ~mask;
253+
sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
254+
}
251255
}
252256
}
253257

0 commit comments

Comments
 (0)