mmc: sdhci-esdhc-imx: add 1-bit bus width support
Subsystems (4)
v2 cover mmc: sdhci-esdhc-imx: add 1-bit bus width support
From: Luke Wang <[email protected]>
This series adds 1-bit bus width support for sdhci-esdhc-imx driver.
Currently sdhci-esdhc-imx doesn't support 1-bit width because it doesn't call sdhci_get_property() to parse "bus-width = <1>" and set SDHCI_QUIRK_FORCE_1_BIT_DATA quirk.
After adding sdhci_get_property(), another issue is exposed:mmc_select_hs200() returns 0 without switching when 1-bit bus is used, causing mmc_select_timing() to skip mmc_select_hs(). This leaves eMMC in legacy mode (26MHz) instead of High Speed (52MHz).
Fix by dropping incompatible UHS/DDR/HS200/HS400 caps in sdhci_setup_host() for 1-bit width, and clean up duplicate code now handled by common framework.
Luke Wang (4):
mmc: sdhci: fix timing selection for 1-bit bus width
mmc: sdhci-esdhc-imx: add 1-bit bus width support
mmc: sdhci-esdhc-imx: remove duplicate HS400 bus width validation
mmc: sdhci-pltfm: remove duplicate DTS property parsing
---
Changes in v2:
- Moved fix from mmc_validate_host_caps() to sdhci_setup_host()
--- drivers/mmc/host/sdhci-esdhc-imx.c | 6 +----- drivers/mmc/host/sdhci-pltfm.c | 7 ------- drivers/mmc/host/sdhci.c | 8 +++++++- 3 files changed, 8 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
PATCH v2 1/4 mmc: sdhci: fix timing selection for 1-bit bus width
From: Luke Wang <[email protected]>
When 1-bit bus width is used with HS200/HS400 capabilities set, mmc_select_hs200() returns 0 without actually switching. This causes mmc_select_timing() to skip mmc_select_hs(), leaving eMMC in legacy mode (26MHz) instead of High Speed SDR (52MHz).
Per JEDEC eMMC spec section 5.3.2, 1-bit mode supports High Speed SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing selection falls through to mmc_select_hs() correctly.
--- drivers/mmc/host/sdhci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +7 -1
@@ -4539,8 +4539,14 @@ int sdhci_setup_host(struct sdhci_host *host)* their platform code before calling sdhci_add_host(), and we * won't assume 8-bit width for hosts without that CAP. */ -if (!(host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA )) +if (host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA ) { + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |SDHCI_SUPPORT_SDR50 | +SDHCI_SUPPORT_DDR50 |SDHCI_SUPPORT_HS400 ); + mmc->caps2 &= ~(MMC_CAP2_HS200 |MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); + mmc->caps &= ~(MMC_CAP_DDR |MMC_CAP_UHS ); + }else { mmc->caps |=MMC_CAP_4_BIT_DATA ; + }if (host->quirks2 &SDHCI_QUIRK2_HOST_NO_CMD23 ) mmc->caps &= ~MMC_CAP_CMD23 ;
Signature · 1 line
2.34.1
Frank Li
maintainerRe: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus width
From: Frank Li (AI-BOT) <[email protected]>
Subject: Re: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus width
drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4549
Quoted 9 lines
drivers/mmc/host/sdhci.c +7
-1-if (!(host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA )) +if (host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA ) { + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |SDHCI_SUPPORT_SDR50 | +SDHCI_SUPPORT_DDR50 |SDHCI_SUPPORT_HS400 ); + mmc->caps2 &= ~(MMC_CAP2_HS200 |MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); + mmc->caps &= ~(MMC_CAP_DDR |MMC_CAP_UHS ); + }else { mmc->caps |=MMC_CAP_4_BIT_DATA ; + }
The logic inversion here is correct and the fix addresses the root cause per JEDEC spec. However, consider whether clearing MMC_CAP_UHS is necessary—UHS modes require 4-bit width anyway, so this may be redundant with the SDR104/SDR50/DDR50 clears. If intentional for belt-and-suspenders safety, add a brief comment explaining why.
Also verify that mmc pointer is always valid at this point in sdhci_setup_host(). If there's any path where mmc could be NULL, the new code will crash.
AI bot review and may be useless.
Adrian Hunter
maintainerRe: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus width
In reply to [email protected]Quoted 11 lines · On 03/03/2026 12:50, [email protected] wrote:
From: Luke Wang <[email protected]>
When 1-bit bus width is used with HS200/HS400 capabilities set,
mmc_select_hs200()returns 0 without actually switching. This causesmmc_select_timing()to skipmmc_select_hs(), leaving eMMC in legacy mode (26MHz) instead of High Speed SDR (52MHz).Per JEDEC eMMC spec section 5.3.2, 1-bit mode supports High Speed SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing selection falls through to
mmc_select_hs()correctly.
Quoted 10 lines
Signed-off-by Luke Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/mmc/host/sdhci.c +0
-0
drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4544
Quoted 7 lines
drivers/mmc/host/sdhci.c +3
-1@@ -4539,8 +4539,14 @@ int sdhci_setup_host(struct sdhci_host *host)* their platform code before calling sdhci_add_host(), and we * won't assume 8-bit width for hosts without that CAP. */ -if (!(host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA )) +if (host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA ) { + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |SDHCI_SUPPORT_SDR50 | +SDHCI_SUPPORT_DDR50 |SDHCI_SUPPORT_HS400 );
SDHCI_SUPPORT_HS400 is non-standard. Hence the check for SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 is needed:
host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50); if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400) host->caps1 &= ~SDHCI_SUPPORT_HS400;
Quoted 8 lines
drivers/mmc/host/sdhci.c +4
-0+ mmc->caps2 &= ~(MMC_CAP2_HS200 |MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); + mmc->caps &= ~(MMC_CAP_DDR |MMC_CAP_UHS ); + }else { mmc->caps |=MMC_CAP_4_BIT_DATA ; + }if (host->quirks2 &SDHCI_QUIRK2_HOST_NO_CMD23 ) mmc->caps &= ~MMC_CAP_CMD23 ;
RE: [EXT] Re: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus width
Quoted 52 lines
-----Original Message-----
From: Adrian Hunter <[email protected]>
Sent: Wednesday, March 11, 2026 5:05 PM
To: Luke Wang <[email protected]>; [email protected]; Bough Chen <[email protected]>
Cc: Frank Li <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; linux- [email protected]; dl-S32 <[email protected]>; linux-arm- [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v2 1/4] mmc: sdhci: fix timing selection for 1-bit bus widthCaution: This is an external email. Please take care when clicking links or opening attachments. When in doubt, report the message using the 'Report this email' button
Quoted 11 lines · On 03/03/2026 12:50, [email protected] wrote:
From: Luke Wang <[email protected]>
When 1-bit bus width is used with HS200/HS400 capabilities set,
mmc_select_hs200()returns 0 without actually switching. This causesmmc_select_timing()to skipmmc_select_hs(), leaving eMMC in legacy mode (26MHz) instead of High Speed SDR (52MHz).Per JEDEC eMMC spec section 5.3.2, 1-bit mode supports High Speed SDR. Drop incompatible HS200/HS400/UHS/DDR caps early so timing selection falls through to
mmc_select_hs()correctly.Fixes f2119df6b7646 ("mmc: sd: add support for signal voltage switchprocedure")
Quoted 10 lines
Signed-off-by Luke Wang <[email protected]>--- drivers/mmc/host/sdhci.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/mmc/host/sdhci.c +0
-0drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4543
Quoted 6 lines
drivers/mmc/host/sdhci.c +2
-1@@ -4539,8 +4539,14 @@ int sdhci_setup_host(struct sdhci_host *host)* their platform code before calling sdhci_add_host(), and we * won't assume 8-bit width for hosts without that CAP. */ -if (!(host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA )) +if (host->quirks &SDHCI_QUIRK_FORCE_1_BIT_DATA ) { + host->caps1 &= ~(SDHCI_SUPPORT_SDR104 |
SDHCI_SUPPORT_SDR50|
Quoted 4 lines
drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4544
Quoted 1 line
drivers/mmc/host/sdhci.c +1
-0+ SDHCI_SUPPORT_DDR50 | SDHCI_SUPPORT_HS400);
SDHCI_SUPPORT_HS400is non-standard. Hence the check forSDHCI_QUIRK2_CAPS_BIT63_FOR_HS400is needed:
Got it, thanks for the explanation. I'll keep the check in v3.
Quoted 15 lines
host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50); if (host->quirks2 & SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400) host->caps1 &= ~SDHCI_SUPPORT_HS400;drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4545
Quoted 1 line
drivers/mmc/host/sdhci.c +1
-0+ mmc->caps2 &= ~(MMC_CAP2_HS200 | MMC_CAP2_HS400 |
MMC_CAP2_HS400_ES);Quoted 7 lines
drivers/mmc/host/sdhci.c +3
-0+ mmc->caps &= ~(MMC_CAP_DDR |MMC_CAP_UHS ); + }else { mmc->caps |=MMC_CAP_4_BIT_DATA ; + }if (host->quirks2 &SDHCI_QUIRK2_HOST_NO_CMD23 ) mmc->caps &= ~MMC_CAP_CMD23 ;
PATCH v2 2/4 mmc: sdhci-esdhc-imx: add 1-bit bus width support
In reply to [email protected]From: Luke Wang <[email protected]>
Add sdhci_get_property() call to parse common SDHCI DT properties, including "bus-width = <1>" which sets SDHCI_QUIRK_FORCE_1_BIT_DATA quirk for 1-bit data bus width configuration.
Remove the duplicate "no-1-8-v" property parsing since sdhci_get_property() already handles it.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +2 -2
@@ -1813,8 +1813,6 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,of_property_read_u32 (np,"fsl,strobe-dll-delay-target" , &boarddata->strobe_dll_delay_target); -if (of_property_read_bool (np,"no-1-8-v" )) - host->quirks2 |=SDHCI_QUIRK2_NO_1_8_V ;if (of_property_read_u32 (np,"fsl,delay-line" , &boarddata->delay_line)) boarddata->delay_line =0 ;
@@ -1833,6 +1831,8 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,if (ret)return ret; +sdhci_get_property (pdev); +/* HS400/HS400ES require 8 bit bus */ if (!(host->mmc->caps &MMC_CAP_8_BIT_DATA )) host->mmc->caps2 &= ~(MMC_CAP2_HS400 |MMC_CAP2_HS400_ES );
Signature · 1 line
2.34.1
Frank Li
maintainerFrom: Frank Li (AI-BOT) <[email protected]>
drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1835
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +2
-0+sdhci_get_property (pdev); +
Missing argument: sdhci_get_property() expects (struct sdhci_host *host) as second parameter, not just pdev. Check function signature in sdhci.h.
drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1817
Quoted 2 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-2-if (of_property_read_bool (np,"no-1-8-v" )) - host->quirks2 |=SDHCI_QUIRK2_NO_1_8_V ;
Removal looks correct if sdhci_get_property() truly handles "no-1-8-v" internally. Verify this is documented in the commit message or code comment to avoid future confusion.
Review
Quoted 2 lines
(quoted diff) +0
-0
Line length at hunk context appears OK (under 80 chars).
---
AI bot review and may be useless.
Quoted 10 lines · On 03/03/2026 12:50, [email protected] wrote:
From: Luke Wang <[email protected]>
Add
sdhci_get_property()call to parse common SDHCI DT properties, including "bus-width = <1>" which setsSDHCI_QUIRK_FORCE_1_BIT_DATAquirk for 1-bit data bus width configuration.Remove the duplicate "no-1-8-v" property parsing since
sdhci_get_property()already handles it.Signed-off-by Luke Wang <[email protected]>
Quoted 26 lines
--- drivers/mmc/host/sdhci-esdhc-imx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +2
-2@@ -1813,8 +1813,6 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,of_property_read_u32 (np,"fsl,strobe-dll-delay-target" , &boarddata->strobe_dll_delay_target); -if (of_property_read_bool (np,"no-1-8-v" )) - host->quirks2 |=SDHCI_QUIRK2_NO_1_8_V ;if (of_property_read_u32 (np,"fsl,delay-line" , &boarddata->delay_line)) boarddata->delay_line =0 ;@@ -1833,6 +1831,8 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,if (ret)return ret; +sdhci_get_property (pdev); +/* HS400/HS400ES require 8 bit bus */ if (!(host->mmc->caps &MMC_CAP_8_BIT_DATA )) host->mmc->caps2 &= ~(MMC_CAP2_HS400 |MMC_CAP2_HS400_ES );
PATCH v2 3/4 mmc: sdhci-esdhc-imx: remove duplicate HS400 bus width validation
In reply to [email protected]From: Luke Wang <[email protected]>
mmc_validate_host_caps() already validates that HS400/HS400ES requires 8-bit bus width. Remove the duplicate validation.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +0 -4
@@ -1833,10 +1833,6 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,sdhci_get_property (pdev); -/* HS400/HS400ES require 8 bit bus */ -if (!(host->mmc->caps &MMC_CAP_8_BIT_DATA )) - host->mmc->caps2 &= ~(MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); -if (mmc_gpio_get_cd (host->mmc) >=0 ) host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION ;
Signature · 1 line
2.34.1
Frank Li
maintainerRe: [PATCH v2 3/4] mmc: sdhci-esdhc-imx: remove duplicate HS400 bus width validation
From: Frank Li (AI-BOT) <[email protected]>
AI bot review and may be useless.
The patch looks correct. The removal of duplicate validation is justified by the commit message stating that mmc_validate_host_caps() already performs this check.
A few observations:
drivers/mmc/host/sdhci-esdhc-imx.c sdhci_esdhc_imx_probe_dt(struct platform_device *pdev, · line 1839
Quoted 4 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-4-/* HS400/HS400ES require 8 bit bus */ -if (!(host->mmc->caps &MMC_CAP_8_BIT_DATA )) - host->mmc->caps2 &= ~(MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); -
Consider verifying in a follow-up that mmc_validate_host_caps() is indeed called after sdhci_get_property() in the probe flow, to ensure no window exists where invalid caps could be exposed to userspace or other subsystems.
The code removal itself is clean with no resource leaks or locking issues in the deleted section.
Re: [PATCH v2 3/4] mmc: sdhci-esdhc-imx: remove duplicate HS400 bus width validation
In reply to [email protected]Quoted 6 lines · On 03/03/2026 12:50, [email protected] wrote:
From: Luke Wang <[email protected]>
mmc_validate_host_caps()already validates that HS400/HS400ES requires 8-bit bus width. Remove the duplicate validation.Signed-off-by Luke Wang <[email protected]>
Quoted 19 lines
--- drivers/mmc/host/sdhci-esdhc-imx.c | 4 ---- 1 file changed, 4 deletions(-)drivers/mmc/host/sdhci-esdhc-imx.c +0
-4@@ -1833,10 +1833,6 @@ sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,sdhci_get_property (pdev); -/* HS400/HS400ES require 8 bit bus */ -if (!(host->mmc->caps &MMC_CAP_8_BIT_DATA )) - host->mmc->caps2 &= ~(MMC_CAP2_HS400 |MMC_CAP2_HS400_ES ); -if (mmc_gpio_get_cd (host->mmc) >=0 ) host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION ;
PATCH v2 4/4 mmc: sdhci-pltfm: remove duplicate DTS property parsing
In reply to [email protected]From: Luke Wang <[email protected]>
The "keep-power-in-suspend", "wakeup-source" and "enable-sdio-wakeup" properties are already parsed in mmc_of_parse(). All sdhci drivers that call sdhci_get_property() also call mmc_of_parse(). The only exception is sdhci-of-hlwd, which does not call mmc_of_parse(), but its devicetree does not use these properties anyway.
--- drivers/mmc/host/sdhci-pltfm.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +0 -7
@@ -95,13 +95,6 @@ void sdhci_get_property(struct platform_device *pdev)sdhci_get_compatibility (pdev);device_property_read_u32 (dev,"clock-frequency" , &pltfm_host->clock); - -if (device_property_present (dev,"keep-power-in-suspend" )) - host->mmc->pm_caps |=MMC_PM_KEEP_POWER ; - -if (device_property_read_bool (dev,"wakeup-source" ) || -device_property_read_bool (dev,"enable-sdio-wakeup" ))/* legacy */ - host->mmc->pm_caps |=MMC_PM_WAKE_SDIO_IRQ ; }EXPORT_SYMBOL_GPL (sdhci_get_property);
Signature · 1 line
2.34.1
Frank Li
maintainerRe: [PATCH v2 4/4] mmc: sdhci-pltfm: remove duplicate DTS property parsing
From: Frank Li (AI-BOT) <[email protected]>
AI bot review and may be useless.
The patch looks reasonable. The commit message correctly identifies that mmc_of_parse() already handles these three properties, and the analysis that all callers of sdhci_get_property() also invoke mmc_of_parse() (except sdhci-of-hlwd, which doesn't use them) is sound.
However, the commit message should explicitly state *where* these properties are parsed in mmc_of_parse(). A reader should be able to verify the claim by grepping drivers/mmc/core/host.c without guessing.
Also, the claim about sdhci-of-hlwd deserves a quick verification: does its devicetree binding documentation confirm these properties are unused? If so, mention the file path in the commit message for future maintainers.
The code deletion itself is correct—no resource leaks or logic errors.
Re: [PATCH v2 4/4] mmc: sdhci-pltfm: remove duplicate DTS property parsing
In reply to [email protected]Quoted 9 lines · On 03/03/2026 12:50, [email protected] wrote:
From: Luke Wang <[email protected]>
The "keep-power-in-suspend", "wakeup-source" and "enable-sdio-wakeup" properties are already parsed in
mmc_of_parse(). All sdhci drivers that callsdhci_get_property()also callmmc_of_parse(). The only exception is sdhci-of-hlwd, which does not callmmc_of_parse(), but its devicetree does not use these properties anyway.Signed-off-by Luke Wang <[email protected]>
Quoted 22 lines
--- drivers/mmc/host/sdhci-pltfm.c | 7 ------- 1 file changed, 7 deletions(-)drivers/mmc/host/sdhci-pltfm.c +0
-7@@ -95,13 +95,6 @@ void sdhci_get_property(struct platform_device *pdev)sdhci_get_compatibility (pdev);device_property_read_u32 (dev,"clock-frequency" , &pltfm_host->clock); - -if (device_property_present (dev,"keep-power-in-suspend" )) - host->mmc->pm_caps |=MMC_PM_KEEP_POWER ; - -if (device_property_read_bool (dev,"wakeup-source" ) || -device_property_read_bool (dev,"enable-sdio-wakeup" ))/* legacy */ - host->mmc->pm_caps |=MMC_PM_WAKE_SDIO_IRQ ; }EXPORT_SYMBOL_GPL (sdhci_get_property);