Skip to contentSkip to conversation

mmc: fsl_esdhc: Fix 'Internal clock never stabilised.' error

PATCH In review Pali Rohár 4 participants 9 messages Apr 29, 2022 – Jul 10, 2022 MMC, SD and SDIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: fsl_esdhc: Fix 'Internal clock never stabilised.' error

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Pali Rohár

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")

Just add minor question.

Quoted 17 lines
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +1 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;

drivers/mmc/fsl_esdhc.c static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock) · line 550

Quoted 7 lines
drivers/mmc/fsl_esdhc.c +4 -0
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);

Is there any reason to use 10000?

Best Regards,
Jaehoon Chung

Quoted 29 lines
drivers/mmc/fsl_esdhc.c +12 -0
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
#2 lore raw
Quoted 34 lines · On Friday 06 May 2022 18:32:18 Jaehoon Chung wrote:
Quoted 10 lines · Pali Rohár

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")

Just add minor question.

Quoted 18 lines
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +1 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
Quoted 8 lines

drivers/mmc/fsl_esdhc.c static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock) · line 550

Quoted 6 lines
drivers/mmc/fsl_esdhc.c +4 -0
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);

Is there any reason to use 10000?

Hello! I really do not know. This value was there before commit 6f883e501b65. This is probably question for Freescale/NXP people.

Quoted 33 lines

Best Regards,
Jaehoon Chung

Quoted 29 lines
drivers/mmc/fsl_esdhc.c +12 -0
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
#3 lore raw
In reply to Pali Rohár

+Haibo

Quoted 64 lines · Pali Rohár

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")
---
  drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
  	u32 time_out;
  	u32 value;
  	uint clk;
+	u32 hostver;
 
  	if (clock < mmc->cfg->f_min)
  		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
  	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
  	time_out = 20;
  	value = PRSSTAT_SDSTB;
  	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
  	struct fsl_esdhc *regs = priv->esdhc_regs;
  	u32 value;
  	u32 time_out;
+	u32 hostver;
 
  	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
  	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
  	time_out = 20;
  	value = PRSSTAT_SDSTB;
  	while (!(esdhc_read32(&regs->prsstat) & value)) {
#4 lore raw

+Yangbo

Quoted 80 lines

-----Original Message-----
From: Peng Fan (OSS) <[email protected]>
Sent: 2022年5月9日 13:37
To: Pali Rohár <[email protected]>; Peng Fan <[email protected]>; Priyanka Jain <[email protected]>; Jaehoon Chung <[email protected]>; Sinan Akman <[email protected]>; Bough Chen <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH] mmc: fsl_esdhc: Fix 'Internal clock never stabilised.' error

+Haibo

Quoted 3 lines · Pali Rohár

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65

("mmc:

drivers/mmc/fsl_esdhc.c static void set_sysctl(struct fsl_esdhc_priv *priv, struct

Quoted 16 lines

fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")
---
  drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
  1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c index renamed from drivers/mmc/fsl_esdhc.c +0 -0

fdf2cc290e06..3b3587bd8d72 100644

drivers/mmc/fsl_esdhc.c +0 -0
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct

mmc *mmc, uint clock)

Quoted 47 lines
drivers/mmc/fsl_esdhc.c +9 -0
  	u32 time_out;
  	u32 value;
  	uint clk;
+	u32 hostver;
 
  	if (clock < mmc->cfg->f_min)
  		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv
 *priv, struct mmc *mmc, uint clock)
 
  	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
  	time_out = 20;
  	value = PRSSTAT_SDSTB;

while (!(esdhc_read32(&regs->prsstat) & value)) { @@ -562,6 +571,7
@@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
struct fsl_esdhc *regs = priv->esdhc_regs;
u32 value;
u32 time_out;

drivers/mmc/fsl_esdhc.c +8 -0
+	u32 hostver;
 
  	value = esdhc_read32(&regs->sysctl);
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct
 fsl_esdhc_priv *priv, bool enable)
 
  	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
  	time_out = 20;
  	value = PRSSTAT_SDSTB;
  	while (!(esdhc_read32(&regs->prsstat) & value)) {
#5 lore raw
In reply to Pali Rohár

PING?

Quoted 66 lines · On Friday 29 April 2022 20:27:34 Pali Rohár wrote:

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
Signature · 1 line
2.20.1
Reviewed-by
#6 lore raw

Hi,

Quoted 1 line · Pali Rohár

PING?

Sorry for too late.

Quoted 7 lines · On Friday 29 April 2022 20:27:34 Pali Rohár wrote:
Quoted 5 lines

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

Quoted 5 lines
Quoted 5 lines

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")

Best Regards,
Jaehoon Chung

Quoted 57 lines
Quoted 56 lines
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
Signature · 1 line
2.20.1
#7 lore raw
Quoted 6 lines · On Tuesday 14 June 2022 11:25:18 Jaehoon Chung wrote:

Hi,

Quoted 1 line · Pali Rohár

PING?

Sorry for too late.

When will be this fix patch processed and merged?

Quoted 76 lines
Quoted 7 lines · On Friday 29 April 2022 20:27:34 Pali Rohár wrote:
Quoted 5 lines

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

Quoted 5 lines
Quoted 5 lines

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")

Best Regards,
Jaehoon Chung

Quoted 57 lines
Quoted 56 lines
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
Signature · 1 line
2.20.1
#8 lore raw

PING?

Quoted 86 lines · On Thursday 23 June 2022 18:11:37 Pali Rohár wrote:
Quoted 6 lines · On Tuesday 14 June 2022 11:25:18 Jaehoon Chung wrote:

Hi,

Quoted 1 line · Pali Rohár

PING?

Sorry for too late.

When will be this fix patch processed and merged?

Quoted 76 lines
Quoted 7 lines · On Friday 29 April 2022 20:27:34 Pali Rohár wrote:
Quoted 5 lines

Only newer eSDHC controllers set PRSSTAT_SDSTB flag. So do not wait until flag PRSSTAT_SDSTB is set on old pre-2.2 controllers. Instead sleep for fixed amount of time like it was before commit 6f883e501b65 ("mmc:
fsl_esdhc: Add emmc hs200 support").

Quoted 5 lines
Quoted 5 lines

This change fixes error 'Internal clock never stabilised.' which is printed on P2020 board at every access to SD card.

Fixes 6f883e501b65 ("mmc: fsl_esdhc: Add emmc hs200 support")

Best Regards,
Jaehoon Chung

Quoted 57 lines
Quoted 56 lines
---
 drivers/mmc/fsl_esdhc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/mmc/fsl_esdhc.c +17 -0
index fdf2cc290e06..3b3587bd8d72 100644
@@ -503,6 +503,7 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 	u32 time_out;
 	u32 value;
 	uint clk;
+	u32 hostver;
 
 	if (clock < mmc->cfg->f_min)
 		clock = mmc->cfg->f_min;
@@ -543,6 +544,14 @@ static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
 
 	esdhc_clrsetbits32(&regs->sysctl, SYSCTL_CLOCK_MASK, clk);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		esdhc_setbits32(&regs->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
@@ -562,6 +571,7 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 	struct fsl_esdhc *regs = priv->esdhc_regs;
 	u32 value;
 	u32 time_out;
+	u32 hostver;
 
 	value = esdhc_read32(&regs->sysctl);
 
@@ -572,6 +582,13 @@ static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
 
 	esdhc_write32(&regs->sysctl, value);
 
+	/* Only newer eSDHC controllers set PRSSTAT_SDSTB flag */
+	hostver = esdhc_read32(&priv->esdhc_regs->hostver);
+	if (HOSTVER_VENDOR(hostver) <= VENDOR_V_22) {
+		udelay(10000);
+		return;
+	}
+
 	time_out = 20;
 	value = PRSSTAT_SDSTB;
 	while (!(esdhc_read32(&regs->prsstat) & value)) {
Signature · 1 line
2.20.1