Skip to contentSkip to conversation

mmc: fsl_esdhc_imx: check the clock stable status after config the clock rate.

PATCH Superseded haibo.chen at nxp.com 1 participant 1 message Aug 27, 2020

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: fsl_esdhc_imx: check the clock stable status after config the clock rate.

From: Haibo Chen <[email protected]>

Currently, after config the clock rate, delay 10ms, this is quite a rough method. Check the clock stable status in the present status register is enough.

---
 drivers/mmc/fsl_esdhc_imx.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +9 -1
index 788677984b..b60623e0ce 100644
@@ -631,6 +631,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 {
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	int div = 1;
+	u32 time_out = 50;
 #ifdef ARCH_MXC
 #ifdef CONFIG_MX53
 	/* For i.MX53 eSDHCv3, SYSCTL.SDCLKFS may not be set to 0. */
@@ -664,7 +665,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
-	udelay(10000);
+	while (!(esdhc_read32(&regs->prsstat) & PRSSTAT_SDSTB)) {
+		if (time_out == 0) {
+			printf("fsl_esdhc_imx: Internal clock never stabilised.\n");
+			break;
+		}
+		time_out--;
+		udelay(2);
+	}
 
 #ifdef CONFIG_FSL_USDHC
 	esdhc_setbits32(&regs->vendorspec, VENDORSPEC_PEREN | VENDORSPEC_CKEN);
Signature · 1 line
2.17.1