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 2 participants 2 messages Aug 27, 2020 – Aug 28, 2020

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +6 -1
index 788677984b..8f7ac5b7a3 100644
@@ -36,6 +36,7 @@
 #include <dt-structs.h>
 #include <mapmem.h>
 #include <dm/ofnode.h>
+#include <linux/iopoll.h>
 
 #if !CONFIG_IS_ENABLED(BLK)
 #include "mmc_private.h"
@@ -631,6 +632,8 @@ 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 tmp;
+	int ret;
 #ifdef ARCH_MXC
 #ifdef CONFIG_MX53
 	/* For i.MX53 eSDHCv3, SYSCTL.SDCLKFS may not be set to 0. */
@@ -664,7 +667,9 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
-	udelay(10000);
+	ret = readl_poll_timeout(&regs->prsstat, tmp, tmp & PRSSTAT_SDSTB, 100);
+	if (ret)
+		pr_warn("fsl_esdhc_imx: Internal clock never stabilised.\n");
 
 #ifdef CONFIG_FSL_USDHC
 	esdhc_setbits32(&regs->vendorspec, VENDORSPEC_PEREN | VENDORSPEC_CKEN);
Signature · 1 line
2.17.1
#1 lore raw

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

Quoted 38 lines

Subject: [PATCH v2] 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 | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mmc/fsl_esdhc_imx.c +3 -1
index 788677984b..8f7ac5b7a3 100644
@@ -36,6 +36,7 @@
 #include <dt-structs.h>
 #include <mapmem.h>
 #include <dm/ofnode.h>
+#include <linux/iopoll.h>
 
 #if !CONFIG_IS_ENABLED(BLK)
 #include "mmc_private.h"
@@ -631,6 +632,8 @@ 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 tmp;
+	int ret;
 #ifdef ARCH_MXC
 #ifdef CONFIG_MX53
 	/* For i.MX53 eSDHCv3, SYSCTL.SDCLKFS may not be set to 0. */ @@
-664,7 +667,9 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct

mmc *mmc, uint clock)

drivers/mmc/fsl_esdhc_imx.c static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)

Quoted 4 lines
drivers/mmc/fsl_esdhc_imx.c +1 -1
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
-	udelay(10000);
+	ret = readl_poll_timeout(&regs->prsstat, tmp, tmp & PRSSTAT_SDSTB,

To avoid breaking others, not i.MX, please add access io.

Thanks,
Peng.

Quoted 9 lines

100);

drivers/mmc/fsl_esdhc_imx.c +2 -0
+	if (ret)
+		pr_warn("fsl_esdhc_imx: Internal clock never stabilised.\n");
 
 #ifdef CONFIG_FSL_USDHC
 	esdhc_setbits32(&regs->vendorspec, VENDORSPEC_PEREN |

VENDORSPEC_CKEN);
--
2.17.1