Skip to contentSkip to conversation

mmc: sdhci: Fix HISPD bit handling

PATCH Superseded Jagan Teki 3 participants 8 messages Jun 18, 2020 – Jun 24, 2020 MMC, SD and SDIO

lore
Share & tools
lore

Jagan Teki

author
#0 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v4:
- update commit message
- simplify the logic.

 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c +17 -6
index 92cc8434af..6cb702111b 100644
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)
 #endif
 	u32 ctrl;
 	struct sdhci_host *host = mmc->priv;
+	bool no_hispd_bit = false;
 
 	if (host->ops && host->ops->set_control_reg)
 		host->ops->set_control_reg(host);
@@ -594,14 +595,24 @@ static int sdhci_set_ios(struct mmc *mmc)
 			ctrl &= ~SDHCI_CTRL_4BITBUS;
 	}
 
-	if (mmc->clock > 26000000)
-		ctrl |= SDHCI_CTRL_HISPD;
-	else
-		ctrl &= ~SDHCI_CTRL_HISPD;
-
 	if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
 	    (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-		ctrl &= ~SDHCI_CTRL_HISPD;
+		no_hispd_bit = true;
+
+	if (!no_hispd_bit) {
+		if (mmc->selected_mode == MMC_HS ||
+		    mmc->selected_mode == SD_HS ||
+		    mmc->selected_mode == MMC_DDR_52 ||
+		    mmc->selected_mode == MMC_HS_200 ||
+		    mmc->selected_mode == MMC_HS_400 ||
+		    mmc->selected_mode == UHS_SDR25 ||
+		    mmc->selected_mode == UHS_SDR50 ||
+		    mmc->selected_mode == UHS_SDR104 ||
+		    mmc->selected_mode == UHS_DDR50)
+			ctrl |= SDHCI_CTRL_HISPD;
+		else
+			ctrl &= ~SDHCI_CTRL_HISPD;
+	}
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks,
Peng.

Quoted 79 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v4:
- update commit message
- simplify the logic.

 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +17 -7
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)  #endif
 	u32 ctrl;
 	struct sdhci_host *host = mmc->priv;
+	bool no_hispd_bit = false;
 
 	if (host->ops && host->ops->set_control_reg)
 		host->ops->set_control_reg(host);
@@ -594,14 +595,24 @@ static int sdhci_set_ios(struct mmc *mmc)
 			ctrl &= ~SDHCI_CTRL_4BITBUS;
 	}
 
-	if (mmc->clock > 26000000)
-		ctrl |= SDHCI_CTRL_HISPD;
-	else
-		ctrl &= ~SDHCI_CTRL_HISPD;
-
 	if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
 	    (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-		ctrl &= ~SDHCI_CTRL_HISPD;
+		no_hispd_bit = true;
+
+	if (!no_hispd_bit) {
+		if (mmc->selected_mode == MMC_HS ||
+		    mmc->selected_mode == SD_HS ||
+		    mmc->selected_mode == MMC_DDR_52 ||
+		    mmc->selected_mode == MMC_HS_200 ||
+		    mmc->selected_mode == MMC_HS_400 ||
+		    mmc->selected_mode == UHS_SDR25 ||
+		    mmc->selected_mode == UHS_SDR50 ||
+		    mmc->selected_mode == UHS_SDR104 ||
+		    mmc->selected_mode == UHS_DDR50)
+			ctrl |= SDHCI_CTRL_HISPD;
+		else
+			ctrl &= ~SDHCI_CTRL_HISPD;
+	}
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
--

2.25.1

#2 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 54 lines

Thanks,
Peng.

Quoted 50 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v4:
- update commit message
- simplify the logic.

 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +1 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)  #endif
 	u32 ctrl;
 	struct sdhci_host *host = mmc->priv;
+	bool no_hispd_bit = false;
 
 	if (host->ops && host->ops->set_control_reg)
 		host->ops->set_control_reg(host);
@@ -594,14 +595,24 @@ static int sdhci_set_ios(struct mmc *mmc)
 			ctrl &= ~SDHCI_CTRL_4BITBUS;
 	}
 
Quoted 9 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 600

Quoted 9 lines
drivers/mmc/sdhci.c +1 -6
-	if (mmc->clock > 26000000)
-		ctrl |= SDHCI_CTRL_HISPD;
-	else
-		ctrl &= ~SDHCI_CTRL_HISPD;
-
 	if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
 	    (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-		ctrl &= ~SDHCI_CTRL_HISPD;
+		no_hispd_bit = true;

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

Best Regards,
Jaehoon Chung

Quoted 22 lines
Quoted 20 lines
drivers/mmc/sdhci.c +15 -1
+
+	if (!no_hispd_bit) {
+		if (mmc->selected_mode == MMC_HS ||
+		    mmc->selected_mode == SD_HS ||
+		    mmc->selected_mode == MMC_DDR_52 ||
+		    mmc->selected_mode == MMC_HS_200 ||
+		    mmc->selected_mode == MMC_HS_400 ||
+		    mmc->selected_mode == UHS_SDR25 ||
+		    mmc->selected_mode == UHS_SDR50 ||
+		    mmc->selected_mode == UHS_SDR104 ||
+		    mmc->selected_mode == UHS_DDR50)
+			ctrl |= SDHCI_CTRL_HISPD;
+		else
+			ctrl &= ~SDHCI_CTRL_HISPD;
+	}
 
 	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
--

2.25.1

author
#3 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

Quoted 81 lines · Jaehoon Chung

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 54 lines

Thanks,
Peng.

Quoted 50 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v4:
- update commit message
- simplify the logic.

 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +1 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)  #endif
     u32 ctrl;
     struct sdhci_host *host = mmc->priv;
+    bool no_hispd_bit = false;
 
     if (host->ops && host->ops->set_control_reg)
             host->ops->set_control_reg(host);
@@ -594,14 +595,24 @@ static int sdhci_set_ios(struct mmc *mmc)
                     ctrl &= ~SDHCI_CTRL_4BITBUS;
     }
 
Quoted 9 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 600

Quoted 9 lines
drivers/mmc/sdhci.c +1 -6
-    if (mmc->clock > 26000000)
-            ctrl |= SDHCI_CTRL_HISPD;
-    else
-            ctrl &= ~SDHCI_CTRL_HISPD;
-
     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-            ctrl &= ~SDHCI_CTRL_HISPD;
+            no_hispd_bit = true;

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

Quoted 1 line

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

So, what are you suggesting? could you please elaborate?

Jagan.

#4 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

Quoted 82 lines · Jagan Teki
Quoted 81 lines · Jaehoon Chung

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 54 lines

Thanks,
Peng.

Quoted 50 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

So, handle the HISPD bit based on the mmc computed selected mode(timing parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix SDHCI_QUIRK_NO_HISPD_BIT handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

---
Changes for v4:
- update commit message
- simplify the logic.

 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +1 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)  #endif
     u32 ctrl;
     struct sdhci_host *host = mmc->priv;
+    bool no_hispd_bit = false;
 
     if (host->ops && host->ops->set_control_reg)
             host->ops->set_control_reg(host);
@@ -594,14 +595,24 @@ static int sdhci_set_ios(struct mmc *mmc)
                     ctrl &= ~SDHCI_CTRL_4BITBUS;
     }
 
Quoted 9 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc) · line 600

Quoted 9 lines
drivers/mmc/sdhci.c +1 -6
-    if (mmc->clock > 26000000)
-            ctrl |= SDHCI_CTRL_HISPD;
-    else
-            ctrl &= ~SDHCI_CTRL_HISPD;
-
     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-            ctrl &= ~SDHCI_CTRL_HISPD;
+            no_hispd_bit = true;

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

Quoted 3 lines
Quoted 1 line

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

So, what are you suggesting? could you please elaborate?

if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

    (host->quirks & SDHCI_QUIRK_NO_BROKEN_HISPD_MODE)) {
	ctrl &= ~SDHCI_CTRL_HISPD;
	no_hispd_bit = true;
}

Just adding "ctrl &= ~SDHCI_CTRL_HISPD;" into its condition. Then it's helpful to me.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Jagan.

#5 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

All:

Quoted 96 lines

Subject: Re: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Quoted 1 line · Jagan Teki

On Mon, Jun 22, 2020 at 2:54 PM Jaehoon Chung

Quoted 20 lines · <[email protected]> wrote:
Quoted 20 lines

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 8 lines

Thanks,
Peng.

Quoted 4 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

So, handle the HISPD bit based on the mmc computed selected mode(timing
parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix

SDHCI_QUIRK_NO_HISPD_BIT

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

roc-rk3399-pc

---
Changes for v4:
- update commit message
- simplify the logic.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 8 lines
 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +0 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)

#endif

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 6 lines
drivers/mmc/sdhci.c +1 -0
     u32 ctrl;
     struct sdhci_host *host = mmc->priv;
+    bool no_hispd_bit = false;
 
     if (host->ops && host->ops->set_control_reg)
             host->ops->set_control_reg(host); @@ -594,14

+595,24

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
drivers/mmc/sdhci.c +0 -0
 @@ static int sdhci_set_ios(struct mmc *mmc)
                     ctrl &= ~SDHCI_CTRL_4BITBUS;
     }
drivers/mmc/sdhci.c +1 -6
-    if (mmc->clock > 26000000)
-            ctrl |= SDHCI_CTRL_HISPD;
-    else
-            ctrl &= ~SDHCI_CTRL_HISPD;
-
     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-            ctrl &= ~SDHCI_CTRL_HISPD;
+            no_hispd_bit = true;
Quoted 8 lines
Quoted 6 lines

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

So, what are you suggesting? could you please elaborate?

Quoted 7 lines

if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

    (host->quirks & SDHCI_QUIRK_NO_BROKEN_HISPD_MODE)) {
	ctrl &= ~SDHCI_CTRL_HISPD;
	no_hispd_bit = true;
}

Just adding "ctrl &= ~SDHCI_CTRL_HISPD;" into its condition.

I pushed this patch with the upper code added to my CI with a update in commit log:
https://travis-ci.org/github/MrVan/u-boot/builds/701486010

Please let me know if any objections.

Thanks,
Peng.

Quoted 8 lines

Then it's helpful to me.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Jagan.

#6 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

Quoted 104 lines · Peng Fan

All:

Quoted 102 lines

Subject: Re: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Quoted 1 line · Jagan Teki

On Mon, Jun 22, 2020 at 2:54 PM Jaehoon Chung

Quoted 20 lines · <[email protected]> wrote:
Quoted 20 lines

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 8 lines

Thanks,
Peng.

Quoted 4 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

So, handle the HISPD bit based on the mmc computed selected mode(timing
parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix

SDHCI_QUIRK_NO_HISPD_BIT

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

roc-rk3399-pc

---
Changes for v4:
- update commit message
- simplify the logic.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 8 lines
 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +0 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)

#endif

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 6 lines
drivers/mmc/sdhci.c +1 -0
     u32 ctrl;
     struct sdhci_host *host = mmc->priv;
+    bool no_hispd_bit = false;
 
     if (host->ops && host->ops->set_control_reg)
             host->ops->set_control_reg(host); @@ -594,14

+595,24

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
drivers/mmc/sdhci.c +0 -0
 @@ static int sdhci_set_ios(struct mmc *mmc)
                     ctrl &= ~SDHCI_CTRL_4BITBUS;
     }
drivers/mmc/sdhci.c +1 -6
-    if (mmc->clock > 26000000)
-            ctrl |= SDHCI_CTRL_HISPD;
-    else
-            ctrl &= ~SDHCI_CTRL_HISPD;
-
     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-            ctrl &= ~SDHCI_CTRL_HISPD;
+            no_hispd_bit = true;
Quoted 8 lines
Quoted 6 lines

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

So, what are you suggesting? could you please elaborate?

if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

    (host->quirks & SDHCI_QUIRK_NO_BROKEN_HISPD_MODE)) {
	ctrl &= ~SDHCI_CTRL_HISPD;
	no_hispd_bit = true;
}
Quoted 7 lines
Quoted 1 line

Just adding "ctrl &= ~SDHCI_CTRL_HISPD;" into its condition.

I pushed this patch with the upper code added to my CI with a update in commit log:
https://protect2.fireeye.com/url?k=a0ad72d4-fd674763-a0acf99b-0cc47a3003e8-b7ff57d36725a01c&q=1&u=https%3A%2F%2Ftravis-ci.org%2Fgithub%2FMrVan%2Fu-boot%2Fbuilds%2F701486010

Please let me know if any objections.

Thanks!

Quoted 13 lines

Thanks,
Peng.

Quoted 8 lines

Then it's helpful to me.

Best Regards,
Jaehoon Chung

Quoted 3 lines

Jagan.

author
#7 lore raw

PATCH v4 1/1 mmc: sdhci: Fix HISPD bit handling

In reply to Peng Fan
Quoted 105 lines · Peng Fan

All:

Quoted 102 lines

Subject: Re: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Quoted 1 line · Jagan Teki

On Mon, Jun 22, 2020 at 2:54 PM Jaehoon Chung

Quoted 20 lines · <[email protected]> wrote:
Quoted 20 lines

Hi Peng,

Quoted 5 lines · Peng Fan

Jaehoon,

Quoted 1 line

Subject: [PATCH v4] mmc: sdhci: Fix HISPD bit handling

Are you fine with this v4?

Thanks for sharing it. i didn't see patch v4.

Quoted 8 lines

Thanks,
Peng.

Quoted 4 lines

SDHCI HISPD bits need to be configured based on desired mmc timings mode and some HISPD quirks.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

So, handle the HISPD bit based on the mmc computed selected mode(timing
parameter) rather than fixed mmc card clock frequency.

Linux handle the HISPD similar like this in below commit but no SDHCI_QUIRK_BROKEN_HISPD_MODE,

commit <501639bf2173> ("mmc: sdhci: fix

SDHCI_QUIRK_NO_HISPD_BIT

Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines

handling")

This eventually fixed the mmc write issue observed in rk3399 sdhci controller.

Bug log for refernece,
=> gpt write mmc 0 $partitions
Writing GPT: mmc write failed
** Can't write to device 0 **
** Can't write to device 0 **
error!

roc-rk3399-pc

---
Changes for v4:
- update commit message
- simplify the logic.

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 8 lines
 drivers/mmc/sdhci.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
drivers/mmc/sdhci.c index renamed from drivers/mmc/sdhci.c +0 -0

92cc8434af..6cb702111b 100644

drivers/mmc/sdhci.c +0 -0
@@ -567,6 +567,7 @@ static int sdhci_set_ios(struct mmc *mmc)

#endif

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/mmc/sdhci.c static int sdhci_set_ios(struct mmc *mmc)

Quoted 6 lines
drivers/mmc/sdhci.c +1 -0
     u32 ctrl;
     struct sdhci_host *host = mmc->priv;
+    bool no_hispd_bit = false;
 
     if (host->ops && host->ops->set_control_reg)
             host->ops->set_control_reg(host); @@ -594,14

+595,24

Quoted 14 lines
Quoted 14 lines
Quoted 13 lines
Quoted 13 lines
drivers/mmc/sdhci.c +0 -0
 @@ static int sdhci_set_ios(struct mmc *mmc)
                     ctrl &= ~SDHCI_CTRL_4BITBUS;
     }
drivers/mmc/sdhci.c +1 -6
-    if (mmc->clock > 26000000)
-            ctrl |= SDHCI_CTRL_HISPD;
-    else
-            ctrl &= ~SDHCI_CTRL_HISPD;
-
     if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||
         (host->quirks & SDHCI_QUIRK_BROKEN_HISPD_MODE))
-            ctrl &= ~SDHCI_CTRL_HISPD;
+            no_hispd_bit = true;
Quoted 8 lines
Quoted 6 lines

No. ctrl variable is set to bit[2] of HOST_CONTROL register. But Some samsung SoCs are using its bit[2] as other purpose. So it needs to revert the value with "ctrl &= ~SDHCI_CTRL_HISPD". Because it's possible to set to 1.

SDHCI_QUIRK_NO_HISPD_BIT means that it's used other purpose.

So, what are you suggesting? could you please elaborate?

if ((host->quirks & SDHCI_QUIRK_NO_HISPD_BIT) ||

    (host->quirks & SDHCI_QUIRK_NO_BROKEN_HISPD_MODE)) {
      ctrl &= ~SDHCI_CTRL_HISPD;
      no_hispd_bit = true;
}
Quoted 7 lines
Quoted 1 line

Just adding "ctrl &= ~SDHCI_CTRL_HISPD;" into its condition.

I pushed this patch with the upper code added to my CI with a update in commit log:
https://travis-ci.org/github/MrVan/u-boot/builds/701486010

Please let me know if any objections.

Thanks for taking care of this.

Jagan.