Skip to contentSkip to conversation

mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K

PATCH In review Wenchao Chen 2 participants 2 messages Dec 7, 2022 – Dec 9, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K

When the clock is less than 400K, some SD cards fail to initialize because CLK_AUTO is enabled.

Fixes fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
---
 drivers/mmc/host/sdhci-sprd.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-sprd.c +9 -7
index bec3f9e3cd3f..525f979e2a97 100644
@@ -228,13 +228,15 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
 	div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
 	sdhci_enable_clk(host, div);
 
-	/* enable auto gate sdhc_enable_auto_gate */
-	val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
-	mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
-	       SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
-	if (mask != (val & mask)) {
-		val |= mask;
-		sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+	/* Enable CLK_AUTO when the clock is greater than 400K. */
+	if (clk > 400000) {
+		val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
+		mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
+			SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
+		if (mask != (val & mask)) {
+			val |= mask;
+			sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+		}
 	}
 }
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 6 lines · Wenchao Chen

When the clock is less than 400K, some SD cards fail to initialize because CLK_AUTO is enabled.

Fixes fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")

Applied for next, and by adding a stable tag, thanks!

Kind regards
Uffe

Quoted 34 lines
---
 drivers/mmc/host/sdhci-sprd.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-sprd.c +9 -8
index bec3f9e3cd3f..525f979e2a97 100644
@@ -228,13 +228,15 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
        div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
        sdhci_enable_clk(host, div);
 
-       /* enable auto gate sdhc_enable_auto_gate */
-       val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
-       mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
-              SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
-       if (mask != (val & mask)) {
-               val |= mask;
-               sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+       /* Enable CLK_AUTO when the clock is greater than 400K. */
+       if (clk > 400000) {
+               val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
+               mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
+                       SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
+               if (mask != (val & mask)) {
+                       val |= mask;
+                       sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+               }
        }
 }
 
--

2.17.1