mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] mmc: sdhci-esdhc-imx: map unsupported driver type to Type B
@ 2026-10-06 10:53 Ian Ray
  2026-10-06 11:51 ` Adrian Hunter
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Ray @ 2026-10-06 10:53 UTC (permalink / raw)
  To: Haibo Chen, Adrian Hunter, Ulf Hansson, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Shawn Lin, Kamal Dasu
  Cc: Ian Ray, stable, imx, linux-mmc, s32, linux-arm-kernel, linux-kernel

Since commit 5a52c5701a67 ("mmc: core: Fix host controller programming
for fixed driver type"), the eMMC driver strength is passed directly to
mmc_set_driver_type(), which propagates the value through ios.drv_type
all the way to sdhci_set_ios().  For 40 Ohm driver strength [1], SDHCI
correctly warns:

  mmc2: invalid driver type, default to driver type B

Hook ->set_ios() to map any driver type value outside of the SD-defined
range to default Type B, so that SDHCI always receives a valid value.

Tested on i.MX8MP (usdhc3, eMMC in HS400) with
`fixed-emmc-driver-type = <4>`: the warning is gone and the HS_TIMING
register contains 0x43 as expected.

[1] 'fixed-emmc-driver-type', see JESD84-B51 Table 206 and
    Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml

Fixes: 5a52c5701a67 ("mmc: core: Fix host controller programming for fixed driver type")
Link: https://lore.kernel.org/all/20260926122908.866-1-ian.ray@gehealthcare.com/
Cc: stable@vger.kernel.org
Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
---
v1 -> v2: Move fix from mmc core to sdhci-esdhc-imx driver per
          review (see "Link:" above);
          always provide a valid host driver type.

 drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index 6ab59d3e346f..33f63c6dc8ce 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -1142,6 +1142,14 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
 	}
 }
 
+static void sdhci_esdhc_imx_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
+{
+	if (ios->drv_type > MMC_SET_DRIVER_TYPE_D)
+		ios->drv_type = MMC_SET_DRIVER_TYPE_B;
+
+	sdhci_set_ios(mmc, ios);
+}
+
 static void usdhc_init_card(struct mmc_host *mmc, struct mmc_card *card)
 {
 	struct sdhci_host *host = mmc_priv(mmc);
@@ -1949,6 +1957,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
 		 */
 		host->mmc_host_ops.init_card = usdhc_init_card;
 
+		/*
+		 * Validate host driver type.
+		 */
+		host->mmc_host_ops.set_ios = sdhci_esdhc_imx_set_ios;
+
 		host->max_timeout_count = 0xF;
 	}
 
-- 
2.47.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mmc: sdhci-esdhc-imx: map unsupported driver type to Type B
  2026-10-06 10:53 [PATCH v2] mmc: sdhci-esdhc-imx: map unsupported driver type to Type B Ian Ray
@ 2026-10-06 11:51 ` Adrian Hunter
  0 siblings, 0 replies; 2+ messages in thread
From: Adrian Hunter @ 2026-10-06 11:51 UTC (permalink / raw)
  To: Ian Ray, Haibo Chen, Ulf Hansson, Frank Li, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Shawn Lin, Kamal Dasu
  Cc: stable, imx, linux-mmc, s32, linux-arm-kernel, linux-kernel

On 06/10/2026 13:53, Ian Ray wrote:
> Since commit 5a52c5701a67 ("mmc: core: Fix host controller programming
> for fixed driver type"), the eMMC driver strength is passed directly to
> mmc_set_driver_type(), which propagates the value through ios.drv_type
> all the way to sdhci_set_ios().  For 40 Ohm driver strength [1], SDHCI
> correctly warns:
> 
>   mmc2: invalid driver type, default to driver type B
> 
> Hook ->set_ios() to map any driver type value outside of the SD-defined
> range to default Type B, so that SDHCI always receives a valid value.
> 
> Tested on i.MX8MP (usdhc3, eMMC in HS400) with
> `fixed-emmc-driver-type = <4>`: the warning is gone and the HS_TIMING
> register contains 0x43 as expected.
> 
> [1] 'fixed-emmc-driver-type', see JESD84-B51 Table 206 and
>     Documentation/devicetree/bindings/mmc/mmc-controller-common.yaml
> 
> Fixes: 5a52c5701a67 ("mmc: core: Fix host controller programming for fixed driver type")
> Link: https://lore.kernel.org/all/20260926122908.866-1-ian.ray@gehealthcare.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Ian Ray <ian.ray@gehealthcare.com>
> ---
> v1 -> v2: Move fix from mmc core to sdhci-esdhc-imx driver per
>           review (see "Link:" above);
>           always provide a valid host driver type.
> 
>  drivers/mmc/host/sdhci-esdhc-imx.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)
> 
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
> index 6ab59d3e346f..33f63c6dc8ce 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -1142,6 +1142,14 @@ static void esdhc_reset_tuning(struct sdhci_host *host)
>  	}
>  }
>  
> +static void sdhci_esdhc_imx_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
> +{
> +	if (ios->drv_type > MMC_SET_DRIVER_TYPE_D)
> +		ios->drv_type = MMC_SET_DRIVER_TYPE_B;

Looking at esdhc_writew_le(), it seems that drv_type is not used
at all.  I'd prefer:

	/*
	 * drv_type is not used (see esdhc_writew_le()) but SDHCI rejects
	 * non-SDHCI values like 0x4 (eMMC 40 ohm) passed via device property
	 * fixed-emmc-driver-type. Force drv_type to an always-valid value.
	 */
	ios->drv_type = MMC_SET_DRIVER_TYPE_B;

> +
> +	sdhci_set_ios(mmc, ios);
> +}
> +
>  static void usdhc_init_card(struct mmc_host *mmc, struct mmc_card *card)
>  {
>  	struct sdhci_host *host = mmc_priv(mmc);
> @@ -1949,6 +1957,11 @@ static int sdhci_esdhc_imx_probe(struct platform_device *pdev)
>  		 */
>  		host->mmc_host_ops.init_card = usdhc_init_card;
>  
> +		/*
> +		 * Validate host driver type.

Not really "Validate".  Perhaps "No SDHCI driver type control"

> +		 */
> +		host->mmc_host_ops.set_ios = sdhci_esdhc_imx_set_ios;

Does this need to be conditional on esdhc_is_usdhc(imx_data)?
Seems like esdhc_writew_le() is used and drv_type ignored either way.

> +
>  		host->max_timeout_count = 0xF;
>  	}
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-10-06 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-06 10:53 [PATCH v2] mmc: sdhci-esdhc-imx: map unsupported driver type to Type B Ian Ray
2026-10-06 11:51 ` Adrian Hunter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®