Skip to contentSkip to conversation

Fix V1P8_SIGNAL_ENA and HIGH_SPEED_ENA

PATCH In review Judith Mendez 5 participants 19 messages Apr 7, 2025 – Apr 17, 2025

Subsystems (5)
lore
Share & tools
lore

Judith Mendez

author maintainer
#0 lore raw

cover Fix V1P8_SIGNAL_ENA and HIGH_SPEED_ENA

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

[0] https://lore.kernel.org/linux-mmc/[email protected]/

Judith Mendez (2):
PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops
mmc: sdhci_am654: Add sdhci_am654_start_signal_voltage_switch

 drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
 drivers/mmc/host/sdhci.h       |  2 ++
 drivers/mmc/host/sdhci_am654.c | 48 +++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+), 20 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH 1/2 PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops

This patch adds set_hs_ena call to sdhci_ops so that host controller drivers have the option to implement a custom callback for SDHCI_CTRL_HISPD control.

On TI devices (for HS modes and legacy mode), timing was closed on half cycle timing. If any of HIGH_SPEED_ENA, UHS_MODE_SELECT, or V1P8_SIGNAL_ENA is set for these modes, host controller switches to full cycle timing which may cause read/write failures and/or cqe error logs.

So add set_hs_ena() to sdhci_ops so each host controller driver can implement their own .set_hs_ena callback.

Also add sdhci_am654_set_hs_ena to sdhci_am654 driver and only set HIGH_SPEED_ENA, for modes > MMC_TIMING_SD_HS.

---
 drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
 drivers/mmc/host/sdhci.h       |  2 ++
 drivers/mmc/host/sdhci_am654.c | 16 ++++++++++
 3 files changed, 53 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci.c +35 -20
index 5f78be7ae16d7..3a878cf0c59b9 100644
@@ -2355,6 +2355,27 @@ static bool sdhci_presetable_values_change(struct sdhci_host *host, struct mmc_i
 	       (sdhci_preset_needed(host, ios->timing) || host->drv_type != ios->drv_type);
 }
 
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+	u8 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+
+	if (timing == MMC_TIMING_SD_HS ||
+	    timing == MMC_TIMING_MMC_HS ||
+	    timing == MMC_TIMING_MMC_HS400 ||
+	    timing == MMC_TIMING_MMC_HS200 ||
+	    timing == MMC_TIMING_MMC_DDR52 ||
+	    timing == MMC_TIMING_UHS_SDR50 ||
+	    timing == MMC_TIMING_UHS_SDR104 ||
+	    timing == MMC_TIMING_UHS_DDR50 ||
+	    timing == MMC_TIMING_UHS_SDR25)
+		ctrl |= SDHCI_CTRL_HISPD;
+	else
+		ctrl &= ~SDHCI_CTRL_HISPD;
+
+	sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+}
+EXPORT_SYMBOL_GPL(sdhci_set_hs_ena);
+
 void sdhci_set_ios_common(struct mmc_host *mmc, struct mmc_ios *ios)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
@@ -2436,23 +2457,6 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 	    !sdhci_presetable_values_change(host, ios))
 		return;
 
-	ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-
-	if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
-		if (ios->timing == MMC_TIMING_SD_HS ||
-		     ios->timing == MMC_TIMING_MMC_HS ||
-		     ios->timing == MMC_TIMING_MMC_HS400 ||
-		     ios->timing == MMC_TIMING_MMC_HS200 ||
-		     ios->timing == MMC_TIMING_MMC_DDR52 ||
-		     ios->timing == MMC_TIMING_UHS_SDR50 ||
-		     ios->timing == MMC_TIMING_UHS_SDR104 ||
-		     ios->timing == MMC_TIMING_UHS_DDR50 ||
-		     ios->timing == MMC_TIMING_UHS_SDR25)
-			ctrl |= SDHCI_CTRL_HISPD;
-		else
-			ctrl &= ~SDHCI_CTRL_HISPD;
-	}
-
 	if (host->version >= SDHCI_SPEC_300) {
 		u16 clk, ctrl_2;
 
@@ -2468,7 +2472,12 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 			sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
 		}
 
-		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+		if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+			if (host->ops->set_hs_ena)
+				host->ops->set_hs_ena(host, ios->timing);
+			else
+				sdhci_set_hs_ena(host, ios->timing);
+		}
 
 		if (!host->preset_enabled) {
 			/*
@@ -2510,8 +2519,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
 		/* Re-enable SD Clock */
 		host->ops->set_clock(host, host->clock);
-	} else
-		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+	} else {
+		if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+			if (host->ops->set_hs_ena)
+				host->ops->set_hs_ena(host, ios->timing);
+			else
+				sdhci_set_hs_ena(host, ios->timing);
+		}
+	}
 }
 EXPORT_SYMBOL_GPL(sdhci_set_ios);
 
drivers/mmc/host/sdhci.h +2 -0
index cd0e35a805427..ebecb49792ca1 100644
@@ -704,6 +704,7 @@ struct sdhci_ops {
 	void		(*set_timeout)(struct sdhci_host *host,
 				       struct mmc_command *cmd);
 	void		(*set_bus_width)(struct sdhci_host *host, int width);
+	void		(*set_hs_ena)(struct sdhci_host *host, unsigned char timing);
 	void (*platform_send_init_74_clocks)(struct sdhci_host *host,
 					     u8 power_mode);
 	unsigned int    (*get_ro)(struct sdhci_host *host);
@@ -857,6 +858,7 @@ int sdhci_get_ro(struct mmc_host *mmc);
 void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq);
 int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq);
 void sdhci_set_bus_width(struct sdhci_host *host, int width);
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing);
 void sdhci_reset(struct sdhci_host *host, u8 mask);
 bool sdhci_do_reset(struct sdhci_host *host, u8 mask);
 void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
drivers/mmc/host/sdhci_am654.c +16 -0
index f75c31815ab00..67a64de4972c9 100644
@@ -429,6 +429,19 @@ static int sdhci_am654_execute_tuning(struct mmc_host *mmc, u32 opcode)
 	return 0;
 }
 
+static void sdhci_am654_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+	u8 ctrl = 0;
+
+	if (timing > MMC_TIMING_SD_HS) {
+		sdhci_set_hs_ena(host, timing);
+	} else {
+		ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+		ctrl &= ~SDHCI_CTRL_HISPD;
+		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+	}
+}
+
 static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
 {
 	int cmd_error = 0;
@@ -578,6 +591,7 @@ static const struct sdhci_ops sdhci_am654_ops = {
 	.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 	.set_bus_width = sdhci_set_bus_width,
+	.set_hs_ena = sdhci_am654_set_hs_ena,
 	.set_power = sdhci_set_power_and_bus_voltage,
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
@@ -608,6 +622,7 @@ static const struct sdhci_ops sdhci_j721e_8bit_ops = {
 	.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 	.set_bus_width = sdhci_set_bus_width,
+	.set_hs_ena = sdhci_am654_set_hs_ena,
 	.set_power = sdhci_set_power_and_bus_voltage,
 	.set_clock = sdhci_am654_set_clock,
 	.write_b = sdhci_am654_write_b,
@@ -632,6 +647,7 @@ static const struct sdhci_ops sdhci_j721e_4bit_ops = {
 	.get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
 	.set_uhs_signaling = sdhci_set_uhs_signaling,
 	.set_bus_width = sdhci_set_bus_width,
+	.set_hs_ena = sdhci_am654_set_hs_ena,
 	.set_power = sdhci_set_power_and_bus_voltage,
 	.set_clock = sdhci_j721e_4bit_set_clock,
 	.write_b = sdhci_am654_write_b,
Signature · 1 line
2.49.0
#2 lore raw

Re: [PATCH 1/2] PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops

Quoted 11 lines · Judith Mendez

This patch adds set_hs_ena call to sdhci_ops so that host controller drivers have the option to implement a custom callback for SDHCI_CTRL_HISPD control.

On TI devices (for HS modes and legacy mode), timing was closed on half cycle timing. If any of HIGH_SPEED_ENA, UHS_MODE_SELECT, or V1P8_SIGNAL_ENA is set for these modes, host controller switches to full cycle timing which may cause read/write failures and/or cqe error logs.

Quoted 7 lines

So add set_hs_ena() to sdhci_ops so each host controller driver can implement their own .set_hs_ena callback.

Also add sdhci_am654_set_hs_ena to sdhci_am654 driver and only set HIGH_SPEED_ENA, for modes > MMC_TIMING_SD_HS.

What does "PENDING" mean or compared to "PATCH"? I guess you want some review and test of this - or there anything else?

Quoted 4 lines
---
 drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
 drivers/mmc/host/sdhci.h       |  2 ++
 drivers/mmc/host/sdhci_am654.c | 16 ++++++++++

I think it would be better to split this up in two parts. One for sdhci and one for sdhci_am654.

Other than that I am going to defer to Adrian to see what he thinks about this.

Kind regards
Uffe

Quoted 160 lines
 3 files changed, 53 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci.c +35 -20
index 5f78be7ae16d7..3a878cf0c59b9 100644
@@ -2355,6 +2355,27 @@ static bool sdhci_presetable_values_change(struct sdhci_host *host, struct mmc_i
               (sdhci_preset_needed(host, ios->timing) || host->drv_type != ios->drv_type);
 }
 
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+       u8 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+
+       if (timing == MMC_TIMING_SD_HS ||
+           timing == MMC_TIMING_MMC_HS ||
+           timing == MMC_TIMING_MMC_HS400 ||
+           timing == MMC_TIMING_MMC_HS200 ||
+           timing == MMC_TIMING_MMC_DDR52 ||
+           timing == MMC_TIMING_UHS_SDR50 ||
+           timing == MMC_TIMING_UHS_SDR104 ||
+           timing == MMC_TIMING_UHS_DDR50 ||
+           timing == MMC_TIMING_UHS_SDR25)
+               ctrl |= SDHCI_CTRL_HISPD;
+       else
+               ctrl &= ~SDHCI_CTRL_HISPD;
+
+       sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+}
+EXPORT_SYMBOL_GPL(sdhci_set_hs_ena);
+
 void sdhci_set_ios_common(struct mmc_host *mmc, struct mmc_ios *ios)
 {
        struct sdhci_host *host = mmc_priv(mmc);
@@ -2436,23 +2457,6 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
            !sdhci_presetable_values_change(host, ios))
                return;
 
-       ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-
-       if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
-               if (ios->timing == MMC_TIMING_SD_HS ||
-                    ios->timing == MMC_TIMING_MMC_HS ||
-                    ios->timing == MMC_TIMING_MMC_HS400 ||
-                    ios->timing == MMC_TIMING_MMC_HS200 ||
-                    ios->timing == MMC_TIMING_MMC_DDR52 ||
-                    ios->timing == MMC_TIMING_UHS_SDR50 ||
-                    ios->timing == MMC_TIMING_UHS_SDR104 ||
-                    ios->timing == MMC_TIMING_UHS_DDR50 ||
-                    ios->timing == MMC_TIMING_UHS_SDR25)
-                       ctrl |= SDHCI_CTRL_HISPD;
-               else
-                       ctrl &= ~SDHCI_CTRL_HISPD;
-       }
-
        if (host->version >= SDHCI_SPEC_300) {
                u16 clk, ctrl_2;
 
@@ -2468,7 +2472,12 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                        sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
                }
 
-               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+               if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+                       if (host->ops->set_hs_ena)
+                               host->ops->set_hs_ena(host, ios->timing);
+                       else
+                               sdhci_set_hs_ena(host, ios->timing);
+               }
 
                if (!host->preset_enabled) {
                        /*
@@ -2510,8 +2519,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
                /* Re-enable SD Clock */
                host->ops->set_clock(host, host->clock);
-       } else
-               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+       } else {
+               if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+                       if (host->ops->set_hs_ena)
+                               host->ops->set_hs_ena(host, ios->timing);
+                       else
+                               sdhci_set_hs_ena(host, ios->timing);
+               }
+       }
 }
 EXPORT_SYMBOL_GPL(sdhci_set_ios);
 
drivers/mmc/host/sdhci.h +2 -0
index cd0e35a805427..ebecb49792ca1 100644
@@ -704,6 +704,7 @@ struct sdhci_ops {
        void            (*set_timeout)(struct sdhci_host *host,
                                       struct mmc_command *cmd);
        void            (*set_bus_width)(struct sdhci_host *host, int width);
+       void            (*set_hs_ena)(struct sdhci_host *host, unsigned char timing);
        void (*platform_send_init_74_clocks)(struct sdhci_host *host,
                                             u8 power_mode);
        unsigned int    (*get_ro)(struct sdhci_host *host);
@@ -857,6 +858,7 @@ int sdhci_get_ro(struct mmc_host *mmc);
 void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq);
 int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq);
 void sdhci_set_bus_width(struct sdhci_host *host, int width);
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing);
 void sdhci_reset(struct sdhci_host *host, u8 mask);
 bool sdhci_do_reset(struct sdhci_host *host, u8 mask);
 void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
drivers/mmc/host/sdhci_am654.c +16 -1
index f75c31815ab00..67a64de4972c9 100644
@@ -429,6 +429,19 @@ static int sdhci_am654_execute_tuning(struct mmc_host *mmc, u32 opcode)
        return 0;
 }
 
+static void sdhci_am654_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+       u8 ctrl = 0;
+
+       if (timing > MMC_TIMING_SD_HS) {
+               sdhci_set_hs_ena(host, timing);
+       } else {
+               ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+               ctrl &= ~SDHCI_CTRL_HISPD;
+               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+       }
+}
+
 static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
 {
        int cmd_error = 0;
@@ -578,6 +591,7 @@ static const struct sdhci_ops sdhci_am654_ops = {
        .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
        .set_uhs_signaling = sdhci_set_uhs_signaling,
        .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
        .set_power = sdhci_set_power_and_bus_voltage,
        .set_clock = sdhci_am654_set_clock,
        .write_b = sdhci_am654_write_b,
@@ -608,6 +622,7 @@ static const struct sdhci_ops sdhci_j721e_8bit_ops = {
        .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
        .set_uhs_signaling = sdhci_set_uhs_signaling,
        .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
        .set_power = sdhci_set_power_and_bus_voltage,
        .set_clock = sdhci_am654_set_clock,
        .write_b = sdhci_am654_write_b,
@@ -632,6 +647,7 @@ static const struct sdhci_ops sdhci_j721e_4bit_ops = {
        .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
        .set_uhs_signaling = sdhci_set_uhs_signaling,
        .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
        .set_power = sdhci_set_power_and_bus_voltage,
        .set_clock = sdhci_j721e_4bit_set_clock,
        .write_b = sdhci_am654_write_b,
--

2.49.0

author maintainer
#3 lore raw

Re: [PATCH 1/2] PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops

Hi Ulf,

Quoted 15 lines · Ulf Hansson
Quoted 14 lines · Judith Mendez

This patch adds set_hs_ena call to sdhci_ops so that host controller drivers have the option to implement a custom callback for SDHCI_CTRL_HISPD control.

On TI devices (for HS modes and legacy mode), timing was closed on half cycle timing. If any of HIGH_SPEED_ENA, UHS_MODE_SELECT, or V1P8_SIGNAL_ENA is set for these modes, host controller switches to full cycle timing which may cause read/write failures and/or cqe error logs.

So add set_hs_ena() to sdhci_ops so each host controller driver can implement their own .set_hs_ena callback.

Quoted 7 lines
Quoted 4 lines

Also add sdhci_am654_set_hs_ena to sdhci_am654 driver and only set HIGH_SPEED_ENA, for modes > MMC_TIMING_SD_HS.

What does "PENDING" mean or compared to "PATCH"? I guess you want some review and test of this - or there anything else?

So sorry, I meant to remove this PENDING tag, will remove for v2. Review would be just fine.

Quoted 8 lines
Quoted 5 lines
---
  drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
  drivers/mmc/host/sdhci.h       |  2 ++
  drivers/mmc/host/sdhci_am654.c | 16 ++++++++++

I think it would be better to split this up in two parts. One for sdhci and one for sdhci_am654

Sure no problem. Thanks
.

Quoted 166 lines

Other than that I am going to defer to Adrian to see what he thinks about this.

Kind regards
Uffe

Quoted 160 lines
  3 files changed, 53 insertions(+), 20 deletions(-)
drivers/mmc/host/sdhci.c +35 -20
index 5f78be7ae16d7..3a878cf0c59b9 100644
@@ -2355,6 +2355,27 @@ static bool sdhci_presetable_values_change(struct sdhci_host *host, struct mmc_i
                (sdhci_preset_needed(host, ios->timing) || host->drv_type != ios->drv_type);
  }
 
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+       u8 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+
+       if (timing == MMC_TIMING_SD_HS ||
+           timing == MMC_TIMING_MMC_HS ||
+           timing == MMC_TIMING_MMC_HS400 ||
+           timing == MMC_TIMING_MMC_HS200 ||
+           timing == MMC_TIMING_MMC_DDR52 ||
+           timing == MMC_TIMING_UHS_SDR50 ||
+           timing == MMC_TIMING_UHS_SDR104 ||
+           timing == MMC_TIMING_UHS_DDR50 ||
+           timing == MMC_TIMING_UHS_SDR25)
+               ctrl |= SDHCI_CTRL_HISPD;
+       else
+               ctrl &= ~SDHCI_CTRL_HISPD;
+
+       sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+}
+EXPORT_SYMBOL_GPL(sdhci_set_hs_ena);
+
  void sdhci_set_ios_common(struct mmc_host *mmc, struct mmc_ios *ios)
  {
         struct sdhci_host *host = mmc_priv(mmc);
@@ -2436,23 +2457,6 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
             !sdhci_presetable_values_change(host, ios))
                 return;
 
-       ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
-
-       if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
-               if (ios->timing == MMC_TIMING_SD_HS ||
-                    ios->timing == MMC_TIMING_MMC_HS ||
-                    ios->timing == MMC_TIMING_MMC_HS400 ||
-                    ios->timing == MMC_TIMING_MMC_HS200 ||
-                    ios->timing == MMC_TIMING_MMC_DDR52 ||
-                    ios->timing == MMC_TIMING_UHS_SDR50 ||
-                    ios->timing == MMC_TIMING_UHS_SDR104 ||
-                    ios->timing == MMC_TIMING_UHS_DDR50 ||
-                    ios->timing == MMC_TIMING_UHS_SDR25)
-                       ctrl |= SDHCI_CTRL_HISPD;
-               else
-                       ctrl &= ~SDHCI_CTRL_HISPD;
-       }
-
         if (host->version >= SDHCI_SPEC_300) {
                 u16 clk, ctrl_2;
 
@@ -2468,7 +2472,12 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
                         sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
                 }
 
-               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+               if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+                       if (host->ops->set_hs_ena)
+                               host->ops->set_hs_ena(host, ios->timing);
+                       else
+                               sdhci_set_hs_ena(host, ios->timing);
+               }
 
                 if (!host->preset_enabled) {
                         /*
@@ -2510,8 +2519,14 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 
                 /* Re-enable SD Clock */
                 host->ops->set_clock(host, host->clock);
-       } else
-               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+       } else {
+               if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) {
+                       if (host->ops->set_hs_ena)
+                               host->ops->set_hs_ena(host, ios->timing);
+                       else
+                               sdhci_set_hs_ena(host, ios->timing);
+               }
+       }
  }
  EXPORT_SYMBOL_GPL(sdhci_set_ios);
 
drivers/mmc/host/sdhci.h +2 -0
index cd0e35a805427..ebecb49792ca1 100644
@@ -704,6 +704,7 @@ struct sdhci_ops {
         void            (*set_timeout)(struct sdhci_host *host,
                                        struct mmc_command *cmd);
         void            (*set_bus_width)(struct sdhci_host *host, int width);
+       void            (*set_hs_ena)(struct sdhci_host *host, unsigned char timing);
         void (*platform_send_init_74_clocks)(struct sdhci_host *host,
                                              u8 power_mode);
         unsigned int    (*get_ro)(struct sdhci_host *host);
@@ -857,6 +858,7 @@ int sdhci_get_ro(struct mmc_host *mmc);
  void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq);
  int sdhci_request_atomic(struct mmc_host *mmc, struct mmc_request *mrq);
  void sdhci_set_bus_width(struct sdhci_host *host, int width);
+void sdhci_set_hs_ena(struct sdhci_host *host, unsigned char timing);
  void sdhci_reset(struct sdhci_host *host, u8 mask);
  bool sdhci_do_reset(struct sdhci_host *host, u8 mask);
  void sdhci_set_uhs_signaling(struct sdhci_host *host, unsigned timing);
drivers/mmc/host/sdhci_am654.c +16 -1
index f75c31815ab00..67a64de4972c9 100644
@@ -429,6 +429,19 @@ static int sdhci_am654_execute_tuning(struct mmc_host *mmc, u32 opcode)
         return 0;
  }
 
+static void sdhci_am654_set_hs_ena(struct sdhci_host *host, unsigned char timing)
+{
+       u8 ctrl = 0;
+
+       if (timing > MMC_TIMING_SD_HS) {
+               sdhci_set_hs_ena(host, timing);
+       } else {
+               ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
+               ctrl &= ~SDHCI_CTRL_HISPD;
+               sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
+       }
+}
+
  static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask)
  {
         int cmd_error = 0;
@@ -578,6 +591,7 @@ static const struct sdhci_ops sdhci_am654_ops = {
         .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
         .set_uhs_signaling = sdhci_set_uhs_signaling,
         .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
         .set_power = sdhci_set_power_and_bus_voltage,
         .set_clock = sdhci_am654_set_clock,
         .write_b = sdhci_am654_write_b,
@@ -608,6 +622,7 @@ static const struct sdhci_ops sdhci_j721e_8bit_ops = {
         .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
         .set_uhs_signaling = sdhci_set_uhs_signaling,
         .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
         .set_power = sdhci_set_power_and_bus_voltage,
         .set_clock = sdhci_am654_set_clock,
         .write_b = sdhci_am654_write_b,
@@ -632,6 +647,7 @@ static const struct sdhci_ops sdhci_j721e_4bit_ops = {
         .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
         .set_uhs_signaling = sdhci_set_uhs_signaling,
         .set_bus_width = sdhci_set_bus_width,
+       .set_hs_ena = sdhci_am654_set_hs_ena,
         .set_power = sdhci_set_power_and_bus_voltage,
         .set_clock = sdhci_j721e_4bit_set_clock,
         .write_b = sdhci_am654_write_b,
--

2.49.0

author maintainer
#4 lore raw

PATCH 2/2 mmc: sdhci_am654: Add sdhci_am654_start_signal_voltage_switch

In reply to Judith Mendez

The sdhci_start_signal_voltage_switch function sets V1P8_SIGNAL_ENA by default after switching to 1v8 signaling. V1P8_SIGNAL_ENA determines whether to launch cmd/data on neg edge (half cycle timing) or pos edge (full cycle timing) of clock.

The sequence is to switch to 1.8 IO voltage, set V1P8_SIGNAL_ENA, change bus width, then update HIGH_SPEED_ENA & UHS_MODE_SELECT.

During bus width change is when eMMC failures are seen with Kingston eMMC. So, do not set V1P8_SIGNAL_ENA by default. V1P8_SIGNAL_ENA is anyways optional for eMMC and only affects timing on TI devices. For switching to DDR52, HS200, or HS400, we should rely on HIGH_SPEED_ENA, to switch to full cycle timing after the bus width is changed.

---
 drivers/mmc/host/sdhci_am654.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
drivers/mmc/host/sdhci_am654.c +32 -0
index 67a64de4972c9..4e1156a2f1b8e 100644
@@ -87,6 +87,7 @@
 #define CLOCK_TOO_SLOW_HZ	50000000
 #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
 #define RETRY_TUNING_MAX	10
+#define BUS_WIDTH_8		8
 
 /* Command Queue Host Controller Interface Base address */
 #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -155,6 +156,7 @@ struct sdhci_am654_data {
 	u32 tuning_loop;
 
 #define SDHCI_AM654_QUIRK_FORCE_CDTEST BIT(0)
+#define SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA BIT(1)
 };
 
 struct window {
@@ -356,6 +358,29 @@ static void sdhci_j721e_4bit_set_clock(struct sdhci_host *host,
 	sdhci_set_clock(host, clock);
 }
 
+static int sdhci_am654_start_signal_voltage_switch(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	struct sdhci_host *host = mmc_priv(mmc);
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host);
+	int ret;
+
+	if ((sdhci_am654->quirks & SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA) &&
+	    ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
+		if (!IS_ERR(mmc->supply.vqmmc)) {
+			ret = mmc_regulator_set_vqmmc(mmc, ios);
+			if (ret < 0) {
+				pr_err("%s: Switching to 1.8V signalling voltage failed,\n",
+				       mmc_hostname(mmc));
+				return -EIO;
+			}
+		}
+		return 0;
+	}
+
+	return sdhci_start_signal_voltage_switch(mmc, ios);
+}
+
 static u8 sdhci_am654_write_power_on(struct sdhci_host *host, u8 val, int reg)
 {
 	writeb(val, host->ioaddr + reg);
@@ -819,6 +844,7 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 	struct device *dev = &pdev->dev;
 	int drv_strength;
 	int ret;
+	u32 bus_width;
 
 	if (sdhci_am654->flags & DLL_PRESENT) {
 		ret = device_property_read_u32(dev, "ti,trm-icp",
@@ -860,6 +886,11 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 	if (device_property_read_bool(dev, "ti,fails-without-test-cd"))
 		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST;
 
+	/* Suppress V1P8_SIGNAL_ENA for eMMC */
+	device_property_read_u32(dev, "bus-width", &bus_width);
+	if (bus_width == BUS_WIDTH_8)
+		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
+
 	sdhci_get_of_property(pdev);
 
 	return 0;
@@ -956,6 +987,7 @@ static int sdhci_am654_probe(struct platform_device *pdev)
 		goto err_pltfm_free;
 	}
 
+	host->mmc_host_ops.start_signal_voltage_switch = sdhci_am654_start_signal_voltage_switch;
 	host->mmc_host_ops.execute_tuning = sdhci_am654_execute_tuning;
 
 	pm_runtime_get_noresume(dev);
Signature · 1 line
2.49.0
#5 lore raw
In reply to Judith Mendez

Hi Judith,

Quoted 22 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

[0] https://lore.kernel.org/linux-mmc/[email protected]/

Quoted 12 lines

Judith Mendez (2):
PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops
mmc: sdhci_am654: Add sdhci_am654_start_signal_voltage_switch

 drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
 drivers/mmc/host/sdhci.h       |  2 ++
 drivers/mmc/host/sdhci_am654.c | 48 +++++++++++++++++++++++++++++
 3 files changed, 85 insertions(+), 20 deletions(-)
Signature · 1 line
2.49.0

Thanks for the patches. We are currently experiencing this issue on the AM62 Solo SoC (hardware: Toradex Verdin AM62 Solo 512 MB), with the latest kernel 6.15-rc1. I tested your patches (added both on top of 6.15-rc1) and I can still see the issue, when the kernel boots:

root@verdin-am62-15412807:~# dmesg | grep -i mmc1
[    1.912123] mmc1: CQHCI version 5.10
[    1.985262] mmc1: SDHCI controller on fa00000.mmc [fa00000.mmc] using ADMA 64-bit
[    2.186954] mmc1: error -110 whilst initialising SD card
[    2.620625] mmc1: error -110 whilst initialising SD card
[    2.997642] mmc1: error -110 whilst initialising SD card
[    3.337071] mmc1: error -110 whilst initialising SD card

This does not happen if I use commit 941a7abd4666 ("mmc: sdhci_am654:
Add sdhci_am654_start_signal_voltage_switch"), as you described.

Is there anything I missing or should test to make it work?

Cheers,
Hiago.

author maintainer
#6 lore raw

Hi Hiago,

Quoted 51 lines · Hiago De Franco

Hi Judith,

Quoted 22 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

[0] https://lore.kernel.org/linux-mmc/[email protected]/

Quoted 12 lines

Judith Mendez (2):
PENDING: mmc: sdhci*: Add set_hs_ena to sdhci_ops
mmc: sdhci_am654: Add sdhci_am654_start_signal_voltage_switch

  drivers/mmc/host/sdhci.c       | 55 +++++++++++++++++++++-------------
  drivers/mmc/host/sdhci.h       |  2 ++
  drivers/mmc/host/sdhci_am654.c | 48 +++++++++++++++++++++++++++++
  3 files changed, 85 insertions(+), 20 deletions(-)
Signature · 1 line
2.49.0

Thanks for the patches. We are currently experiencing this issue on the AM62 Solo SoC (hardware: Toradex Verdin AM62 Solo 512 MB), with the latest kernel 6.15-rc1. I tested your patches (added both on top of 6.15-rc1) and I can still see the issue, when the kernel boots:

root@verdin-am62-15412807:~# dmesg | grep -i mmc1
[    1.912123] mmc1: CQHCI version 5.10
[    1.985262] mmc1: SDHCI controller on fa00000.mmc [fa00000.mmc] using ADMA 64-bit
[    2.186954] mmc1: error -110 whilst initialising SD card
[    2.620625] mmc1: error -110 whilst initialising SD card
[    2.997642] mmc1: error -110 whilst initialising SD card
[    3.337071] mmc1: error -110 whilst initialising SD card
Quoted 4 lines

This does not happen if I use commit 941a7abd4666 ("mmc: sdhci_am654:
Add sdhci_am654_start_signal_voltage_switch"), as you described.

Is there anything I missing or should test to make it work?

The reason that patches fixes SD init for you is because in original patch, quirk was applied for both SD and eMMC with the exception of SD for am64x SoC. This patch only applies the quirk for eMMC.

We cannot use the original implementation because the logic applying the quirk is based off of vmmc/vqmmc nodes in DT. The assumption was that am64x based boards will only have vmmc node since there is an internal LDO that is used to switch IO signal voltage instead of vqmmc. However, SolidRun HimmingBoard-T board has a different implementation on voltage regulator nodes in DT and the quirk applied to them as well and breaks their SD boot. So we now only apply the quirk for eMMC. Without this quirk applied to SD, am62x SD will continue having some stability issues.

~ Judith

#7 lore raw
Quoted 14 lines · Judith Mendez

The reason that patches fixes SD init for you is because in original patch, quirk was applied for both SD and eMMC with the exception of SD for am64x SoC. This patch only applies the quirk for eMMC.

We cannot use the original implementation because the logic applying the quirk is based off of vmmc/vqmmc nodes in DT. The assumption was that am64x based boards will only have vmmc node since there is an internal LDO that is used to switch IO signal voltage instead of vqmmc. However, SolidRun HimmingBoard-T board has a different implementation on voltage regulator nodes in DT and the quirk applied to them as well and breaks their SD boot. So we now only apply the quirk for eMMC. Without this quirk applied to SD, am62x SD will continue having some stability issues.

Quoted 1 line

~ Judith

I got the idea now, thanks for the explanation, I missed in the original patches this was only about the eMMC and *not* the SD card. Is there any plans to send patches to the SD card as well?

About that, I was wondering if instead of checking the bus_width to apply the fix for the eMMC, we could set a devicetree property to explicity apply the quirk. This way, we could also decide to apply it on the SD node without checking any bus width. As example:

arch/arm64/boot/dts/ti/k3-am62-verdin.dtsi +1 -0
index 1ea8f64b1b3b..c4423c09e809 100644
@@ -1466,6 +1466,7 @@ &sdhci1 {
 	vmmc-supply = <&reg_sdhc1_vmmc>;
 	vqmmc-supply = <&reg_sdhc1_vqmmc>;
 	ti,fails-without-test-cd;
+	ti,suppress-v1p8-ena;
 	status = "disabled";
 };
 
drivers/mmc/host/sdhci_am654.c +5 -5
index 4e1156a2f1b8..a0485c2bb549 100644
@@ -87,7 +87,6 @@
 #define CLOCK_TOO_SLOW_HZ	50000000
 #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
 #define RETRY_TUNING_MAX	10
-#define BUS_WIDTH_8		8
 
 /* Command Queue Host Controller Interface Base address */
 #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -844,7 +843,6 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 	struct device *dev = &pdev->dev;
 	int drv_strength;
 	int ret;
-	u32 bus_width;
 
 	if (sdhci_am654->flags & DLL_PRESENT) {
 		ret = device_property_read_u32(dev, "ti,trm-icp",
@@ -886,9 +884,11 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 	if (device_property_read_bool(dev, "ti,fails-without-test-cd"))
 		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST;
 
-	/* Suppress V1P8_SIGNAL_ENA for eMMC */
-	device_property_read_u32(dev, "bus-width", &bus_width);
-	if (bus_width == BUS_WIDTH_8)
+	/*
+	 * Suppress V1P8_SIGNAL_ENA for MMC devices if ti,suppress-v1p8-ena
+	 * flag is present.
+	 */
+	if (device_property_read_bool(dev, "ti,suppress-v1p8-ena"))
 		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
 
 	sdhci_get_of_property(pdev);

Which makes our Kingston SD card work again:

root@verdin-am62-15412807:~# dmesg | grep -i mmc1
[    1.897055] mmc1: CQHCI version 5.10
[    2.043673] mmc1: SDHCI controller on fa00000.mmc [fa00000.mmc] using ADMA 64-bit
[    2.260610] mmc1: new UHS-I speed SDR104 SDHC card at address 0001
[    2.268150] mmcblk1: mmc1:0001 SD32G 29.1 GiB

Sorry if I missed something, would also be a valid solution?

Cheers,
Hiago.

author maintainer
#8 lore raw

Hi Hilago,

Quoted 76 lines · Hiago De Franco
Quoted 14 lines · Judith Mendez

The reason that patches fixes SD init for you is because in original patch, quirk was applied for both SD and eMMC with the exception of SD for am64x SoC. This patch only applies the quirk for eMMC.

We cannot use the original implementation because the logic applying the quirk is based off of vmmc/vqmmc nodes in DT. The assumption was that am64x based boards will only have vmmc node since there is an internal LDO that is used to switch IO signal voltage instead of vqmmc. However, SolidRun HimmingBoard-T board has a different implementation on voltage regulator nodes in DT and the quirk applied to them as well and breaks their SD boot. So we now only apply the quirk for eMMC. Without this quirk applied to SD, am62x SD will continue having some stability issues.

Quoted 1 line

~ Judith

I got the idea now, thanks for the explanation, I missed in the original patches this was only about the eMMC and *not* the SD card. Is there any plans to send patches to the SD card as well?

About that, I was wondering if instead of checking the bus_width to apply the fix for the eMMC, we could set a devicetree property to explicity apply the quirk. This way, we could also decide to apply it on the SD node without checking any bus width. As example:

arch/arm64/boot/dts/ti/k3-am62-verdin.dtsi +1 -0
index 1ea8f64b1b3b..c4423c09e809 100644
@@ -1466,6 +1466,7 @@ &sdhci1 {
  	vmmc-supply = <&reg_sdhc1_vmmc>;
  	vqmmc-supply = <&reg_sdhc1_vqmmc>;
  	ti,fails-without-test-cd;
+	ti,suppress-v1p8-ena;
  	status = "disabled";
  };
 
drivers/mmc/host/sdhci_am654.c +5 -5
index 4e1156a2f1b8..a0485c2bb549 100644
@@ -87,7 +87,6 @@
  #define CLOCK_TOO_SLOW_HZ	50000000
  #define SDHCI_AM654_AUTOSUSPEND_DELAY	-1
  #define RETRY_TUNING_MAX	10
-#define BUS_WIDTH_8		8
 
  /* Command Queue Host Controller Interface Base address */
  #define SDHCI_AM654_CQE_BASE_ADDR 0x200
@@ -844,7 +843,6 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
  	struct device *dev = &pdev->dev;
  	int drv_strength;
  	int ret;
-	u32 bus_width;
 
  	if (sdhci_am654->flags & DLL_PRESENT) {
  		ret = device_property_read_u32(dev, "ti,trm-icp",
@@ -886,9 +884,11 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
  	if (device_property_read_bool(dev, "ti,fails-without-test-cd"))
  		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_FORCE_CDTEST;
 
-	/* Suppress V1P8_SIGNAL_ENA for eMMC */
-	device_property_read_u32(dev, "bus-width", &bus_width);
-	if (bus_width == BUS_WIDTH_8)
+	/*
+	 * Suppress V1P8_SIGNAL_ENA for MMC devices if ti,suppress-v1p8-ena
+	 * flag is present.
+	 */
+	if (device_property_read_bool(dev, "ti,suppress-v1p8-ena"))
  		sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
 
  	sdhci_get_of_property(pdev);

Which makes our Kingston SD card work again:

Quoted 7 lines
root@verdin-am62-15412807:~# dmesg | grep -i mmc1
[    1.897055] mmc1: CQHCI version 5.10
[    2.043673] mmc1: SDHCI controller on fa00000.mmc [fa00000.mmc] using ADMA 64-bit
[    2.260610] mmc1: new UHS-I speed SDR104 SDHC card at address 0001
[    2.268150] mmcblk1: mmc1:0001 SD32G 29.1 GiB

Sorry if I missed something, would also be a valid solution?

Actually this was one of the previous implementations, I should have that original patch somewhere. My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Adrian, is this fine with you?

~ Judith

#9 lore raw

Hi Judith,

Quoted 3 lines · Judith Mendez

Actually this was one of the previous implementations, I should have that original patch somewhere. My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

Got it, makes sense. This will work fine with eMMC, but for the SD card I am not seeing other option. Maybe we could use both implementations?

drivers/mmc/host/sdhci_am654.c +1 -1
index 4e1156a2f1b8..db8ee66e76d8 100644
@@ -888,7 +888,7 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 
        /* Suppress V1P8_SIGNAL_ENA for eMMC */
        device_property_read_u32(dev, "bus-width", &bus_width);
-       if (bus_width == BUS_WIDTH_8)
+       if (bus_width == BUS_WIDTH_8 || device_property_read_bool(dev, "ti,suppress-v1p8-ena"))
                sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
 

So the driver applies the quirk for eMMC and we set the DT property for SD card. Not sure which one is the best, but maybe it is another option. Let's see what Adrian also thinks about that.

Quoted 7 lines

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Adrian, is this fine with you?

~ Judith

Cheers,
Hiago.

author maintainer
#10 lore raw

Hi Hiago,

Quoted 22 lines · Hiago De Franco

Hi Judith,

Quoted 3 lines · Judith Mendez

Actually this was one of the previous implementations, I should have that original patch somewhere. My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

Got it, makes sense. This will work fine with eMMC, but for the SD card I am not seeing other option. Maybe we could use both implementations?

drivers/mmc/host/sdhci_am654.c +1 -1
index 4e1156a2f1b8..db8ee66e76d8 100644
@@ -888,7 +888,7 @@ static int sdhci_am654_get_of_property(struct platform_device *pdev,
 
         /* Suppress V1P8_SIGNAL_ENA for eMMC */
         device_property_read_u32(dev, "bus-width", &bus_width);
-       if (bus_width == BUS_WIDTH_8)
+       if (bus_width == BUS_WIDTH_8 || device_property_read_bool(dev, "ti,suppress-v1p8-ena"))
                 sdhci_am654->quirks |= SDHCI_AM654_QUIRK_SUPPRESS_V1P8_ENA;
 
Quoted 3 lines

So the driver applies the quirk for eMMC and we set the DT property for SD card. Not sure which one is the best, but maybe it is another option. Let's see what Adrian also thinks about that.

I like it, sure lets see what Adrian says, thanks for your suggestion.

~ Judith

#11 lore raw
In reply to Judith Mendez

Hello Judith

Quoted 2 lines · Judith Mendez

My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

...

Quoted 2 lines

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Not sure if this is clear, but this patch is NOT working according to our tests, we would need to fix it in a different way.

Francesco

Quoted 6 lines
author maintainer
#12 lore raw

Hi Francesco,

Quoted 5 lines · Francesco Dolcini

Hello Judith

Quoted 2 lines · Judith Mendez

My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

Quoted 7 lines

...

Quoted 2 lines

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Not sure if this is clear, but this patch is NOT working according to our tests, we would need to fix it in a different way.

Not sure if you are following the thread with Hiago, but we are fixing it a different way; add a new DT property: "ti,suppress-v1p8-ena" for SD card which allows us to have granular control on when v1p8 is suppressed for MMC1.

With this method, we make sure the quirk is never applied to your board (;

~ Judith

#13 lore raw
Quoted 16 lines · Judith Mendez

Hi Francesco,

Quoted 5 lines · Francesco Dolcini

Hello Judith

Quoted 2 lines · Judith Mendez

My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

Quoted 7 lines

...

Quoted 2 lines

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Not sure if this is clear, but this patch is NOT working according to our tests, we would need to fix it in a different way.

Quoted 6 lines

Not sure if you are following the thread with Hiago, but we are fixing it a different way; add a new DT property: "ti,suppress-v1p8-ena" for SD card which allows us to have granular control on when v1p8 is suppressed for MMC1.

With this method, we make sure the quirk is never applied to your board (;

My board needs the quirk ;-)
It was not clear to me that this change was going to be added to this patch, because without it's not working.

Thanks for the clarification.

Francesco

author maintainer
#14 lore raw

Hi Francesco,

Quoted 22 lines · Francesco Dolcini
Quoted 21 lines · Judith Mendez

Hi Francesco,

Quoted 5 lines · Francesco Dolcini

Hello Judith

Quoted 2 lines · Judith Mendez

My understanding was that we do not like adding new DT properties if we can find a way to apply the quirk in the driver.

Quoted 7 lines

...

Quoted 2 lines

If this implementation flies with the maintainers, then we can go back to DT property implementation.

Not sure if this is clear, but this patch is NOT working according to our tests, we would need to fix it in a different way.

Not sure if you are following the thread with Hiago, but we are fixing it a different way; add a new DT property: "ti,suppress-v1p8-ena" for SD card which allows us to have granular control on when v1p8 is suppressed for MMC1.

Quoted 7 lines
Quoted 1 line

With this method, we make sure the quirk is never applied to your board (;

My board needs the quirk ;-)
It was not clear to me that this change was going to be added to this patch, because without it's not working.

Thanks for the clarification.

Understood, Ok seems like we are just waiting on Adrian or another MMC maintainer to comment before sending v2 with Hiago's suggestion, thanks.

~ Judith

author maintainer
#15 lore raw
In reply to Judith Mendez

Hello Adrian,

Quoted 10 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

Quoted 9 lines

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

On this patch series, I am bringing back the fix for V1P8_SIGNAL_ENA, Ulf requested a change [0] which I am planning to do for v2. But I was hoping to get your opinion on whether Hiago's suggestion [1] is doable so I can add that as well to v2. Thanks for your attention.

[0] https://lore.kernel.org/linux-mmc/CAPDyKFqx-G4NynanFWrspz7-uXXF74RfjcU-Sw2nq2JhL3LPuQ@mail.gmail.com/
[1] https://lore.kernel.org/linux-mmc/20250412132012.xpjywokcpztb4jg4@hiago-nb/

~ Judith

maintainer
#16 lore raw
Quoted 24 lines · Judith Mendez

Hello Adrian,

Quoted 10 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

Quoted 9 lines

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

Quoted 9 lines

On this patch series, I am bringing back the fix for V1P8_SIGNAL_ENA, Ulf requested a change [0] which I am planning to do for v2. But I was hoping to get your opinion on whether Hiago's suggestion [1] is doable so I can add that as well to v2. Thanks for your attention.

[0] https://lore.kernel.org/linux-mmc/CAPDyKFqx-G4NynanFWrspz7-uXXF74RfjcU-Sw2nq2JhL3LPuQ@mail.gmail.com/
[1] https://lore.kernel.org/linux-mmc/20250412132012.xpjywokcpztb4jg4@hiago-nb/

Sorry for the slow reply - been a bit distracted.

I'll look at it properly tomorrow, but noticed sdhci_am654_write_b() already is dealing with SDHCI_HOST_CONTROL and SDHCI_CTRL_HISPD. Can you make use of that instead of a .set_hs_ena callback?

maintainer
#17 lore raw
Quoted 35 lines · Adrian Hunter
Quoted 24 lines · Judith Mendez

Hello Adrian,

Quoted 10 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

Quoted 9 lines

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

Quoted 9 lines

On this patch series, I am bringing back the fix for V1P8_SIGNAL_ENA, Ulf requested a change [0] which I am planning to do for v2. But I was hoping to get your opinion on whether Hiago's suggestion [1] is doable so I can add that as well to v2. Thanks for your attention.

[0] https://lore.kernel.org/linux-mmc/CAPDyKFqx-G4NynanFWrspz7-uXXF74RfjcU-Sw2nq2JhL3LPuQ@mail.gmail.com/
[1] https://lore.kernel.org/linux-mmc/20250412132012.xpjywokcpztb4jg4@hiago-nb/

Quoted 6 lines

Sorry for the slow reply - been a bit distracted.

I'll look at it properly tomorrow, but noticed sdhci_am654_write_b() already is dealing with SDHCI_HOST_CONTROL and SDHCI_CTRL_HISPD. Can you make use of that instead of a .set_hs_ena callback?

Patch 1 continues to look unneeded because sdhci_am654_write_b() seems to do the same thing.

WRT patch 2, the suggestion to add a DT property and check the bus width seems fine to me. DT properties can be added to identify "broken" hardware that cannot be identified by the compatible string.

author maintainer
#18 lore raw

Hi Adrian,

Quoted 38 lines · Adrian Hunter
Quoted 37 lines · Adrian Hunter
Quoted 24 lines · Judith Mendez

Hello Adrian,

Quoted 10 lines · Judith Mendez

For all TI devices, timing was closed For Legacy and HS modes in half cycle timing, where data is launched on the negative edge of clock and latched on the following positive edge of clock. The switch to full cycle timing happens when any of HIGH_SPEED_ENA, V1P8_SIGNAL_ENA, or UHS_MODE_SELECT is set.

Currently HIGH_SPEED_ENA is set for HS modes and violates timing requirements for TI devices so add a .set_hs_ena callback in sdhci_am654 driver so that HIGH_SPEED_ENA is not set for this mode.

Quoted 9 lines

There are eMMC boot failures seen with V1P8_SIGNAL_ENA with a specific Kingston eMMC due to the sequencing when enumerating to HS200 mode. Since V1P8_SIGNAL_ENA is optional for eMMC, do not set V1P8_SIGNAL_ENA be default. This fix was previously merged in the kernel, but was reverted due to the "heuristics for enabling the quirk"[0]. The new implementation applies the quirk based-off of bus width, which should not be an issue since there is no internal LDO for MMC0 8bit wide interface and hence V1P8_SIGNAL_ENA should only effect timing for MMC0 interface.

Quoted 9 lines

On this patch series, I am bringing back the fix for V1P8_SIGNAL_ENA, Ulf requested a change [0] which I am planning to do for v2. But I was hoping to get your opinion on whether Hiago's suggestion [1] is doable so I can add that as well to v2. Thanks for your attention.

[0] https://lore.kernel.org/linux-mmc/CAPDyKFqx-G4NynanFWrspz7-uXXF74RfjcU-Sw2nq2JhL3LPuQ@mail.gmail.com/
[1] https://lore.kernel.org/linux-mmc/20250412132012.xpjywokcpztb4jg4@hiago-nb/

Sorry for the slow reply - been a bit distracted.

Quoted 7 lines
Quoted 4 lines

I'll look at it properly tomorrow, but noticed sdhci_am654_write_b() already is dealing with SDHCI_HOST_CONTROL and SDHCI_CTRL_HISPD. Can you make use of that instead of a .set_hs_ena callback?

Patch 1 continues to look unneeded because sdhci_am654_write_b() seems to do the same thing.

You are right, I will drop the first patch then.

Quoted 6 lines

WRT patch 2, the suggestion to add a DT property and check the bus width seems fine to me. DT properties can be added to identify "broken" hardware that cannot be identified by the compatible string.

Cool, will add this functionality to v2, thanks

~ Judith