mmc: fsl_esdhc: Set fallback mode to 1-bit
PATCH 1/2 mmc: fsl_esdhc: Set fallback mode to 1-bit
8-bit mode is not supported by SD cards and on P2020 are four SDHC pins shared with SPI (so if P2020 board have also SPI then only 4-bit SDHC mode is provided). So 8-bit SDHC mode is really bad default.
When max bus width is not provided then set mode to 1-bit. This mode is supported by all cards, so it is the best option for fallback mode.
Also P2020 bootrom sets mode to 1-bit when booting from SD/MMC card.
--- drivers/mmc/fsl_esdhc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mmc/fsl_esdhc.c +2 -3
@@ -963,9 +963,8 @@ int fsl_esdhc_initialize(struct bd_info *bis, struct fsl_esdhc_cfg *cfg) }else if (cfg->max_bus_width ==1 ) { mmc_cfg->host_caps |=MMC_MODE_1BIT ; }else { - mmc_cfg->host_caps |=MMC_MODE_1BIT |MMC_MODE_4BIT | -MMC_MODE_8BIT ; -printf ("No max bus width provided. Assume 8-bit supported.\n" ); + mmc_cfg->host_caps |=MMC_MODE_1BIT ; +printf ("No max bus width provided. Fallback to 1-bit mode.\n" ); }if (IS_ENABLED (CONFIG_ESDHC_DETECT_8_BIT_QUIRK ))
Signature · 1 line
2.20.1
PATCH 2/2 mmc: fsl_esdhc: Add new config option for default fallback mode
Currently default fallback SDHC mode is 1-bit. Add new config option CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH to allow specifying default fallback mode. This is useful e.g. for SPL builds which loads other parts from SD card during boot process.
--- drivers/mmc/Kconfig | 5 +++++ drivers/mmc/fsl_esdhc.c | 1 + 2 files changed, 6 insertions(+)
drivers/mmc/Kconfig +5 -0
@@ -826,6 +826,11 @@ config FSL_ESDHC_VS33_NOT_SUPPORT For eSDHC, power supply is through peripheral circuit. 3.3V support is common. Select this if 3.3V power supply not supported. +config SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH + int + depends on FSL_ESDHC + default 1 + config FSL_ESDHC_IMX bool "Freescale/NXP i.MX eSDHC controller support" help
drivers/mmc/fsl_esdhc.c +1 -0
@@ -988,6 +988,7 @@ int fsl_esdhc_mmc_init(struct bd_info *bis) cfg =calloc (sizeof (struct fsl_esdhc_cfg ),1 ); cfg->esdhc_base =CONFIG_SYS_FSL_ESDHC_ADDR ; + cfg->max_bus_width =CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH ;/* Prefer peripheral clock which provides higher frequency. */ if (gd->arch.sdhc_per_clk) cfg->sdhc_clk = gd->arch.sdhc_per_clk;
Signature · 1 line
2.20.1
Re: [PATCH 2/2] mmc: fsl_esdhc: Add new config option for default fallback mode
Quoted 16 lines · Pali Rohár
Currently default fallback SDHC mode is 1-bit. Add new config option
CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTHto allow specifying default fallback mode. This is useful e.g. for SPL builds which loads other parts from SD card during boot process.Signed-off-by Pali Rohár <[email protected]>--- drivers/mmc/Kconfig | 5 +++++ drivers/mmc/fsl_esdhc.c | 1 + 2 files changed, 6 insertions(+)drivers/mmc/Kconfig +0
-0
drivers/mmc/Kconfig config FSL_ESDHC_VS33_NOT_SUPPORT · line 832
Quoted 7 lines
drivers/mmc/Kconfig +4
-0@@ -826,6 +826,11 @@ config FSL_ESDHC_VS33_NOT_SUPPORT For eSDHC, power supply is through peripheral circuit. 3.3V support is common. Select this if 3.3V power supply not supported. +config SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH + int + depends on FSL_ESDHC + default 1
Is there any reason not to use dt?
Best Regards,
Jaehoon Chung
Quoted 16 lines
drivers/mmc/Kconfig +1
-0+ config FSL_ESDHC_IMX bool "Freescale/NXP i.MX eSDHC controller support" helpdrivers/mmc/fsl_esdhc.c +1
-0@@ -988,6 +988,7 @@ int fsl_esdhc_mmc_init(struct bd_info *bis) cfg =calloc (sizeof (struct fsl_esdhc_cfg ),1 ); cfg->esdhc_base =CONFIG_SYS_FSL_ESDHC_ADDR ; + cfg->max_bus_width =CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH ;/* Prefer peripheral clock which provides higher frequency. */ if (gd->arch.sdhc_per_clk) cfg->sdhc_clk = gd->arch.sdhc_per_clk;
Re: [PATCH 2/2] mmc: fsl_esdhc: Add new config option for default fallback mode
Quoted 20 lines · On Tuesday 17 May 2022 08:40:48 Jaehoon Chung wrote:
Quoted 19 lines · Pali Rohár
Currently default fallback SDHC mode is 1-bit. Add new config option
CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTHto allow specifying default fallback mode. This is useful e.g. for SPL builds which loads other parts from SD card during boot process.Signed-off-by Pali Rohár <[email protected]>--- drivers/mmc/Kconfig | 5 +++++ drivers/mmc/fsl_esdhc.c | 1 + 2 files changed, 6 insertions(+)drivers/mmc/Kconfig +0
-0@@ -826,6 +826,11 @@ config FSL_ESDHC_VS33_NOT_SUPPORT For eSDHC, power supply is through peripheral circuit. 3.3V support is common. Select this if 3.3V power supply not supported.
Quoted 6 lines
drivers/mmc/Kconfig config FSL_ESDHC_VS33_NOT_SUPPORT · line 832
Quoted 4 lines
drivers/mmc/Kconfig +4
-0+config SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH + int + depends on FSL_ESDHC + default 1Is there any reason not to use dt?
This is fallback value for function fsl_esdhc_mmc_init() which is called when DT is not parsed or used (yet). E.g. this applies for P2020 SPL.
Quoted 20 lines
Best Regards,
Jaehoon ChungQuoted 16 lines
drivers/mmc/Kconfig +1
-0+ config FSL_ESDHC_IMX bool "Freescale/NXP i.MX eSDHC controller support" helpdrivers/mmc/fsl_esdhc.c +1
-0@@ -988,6 +988,7 @@ int fsl_esdhc_mmc_init(struct bd_info *bis) cfg =calloc (sizeof (struct fsl_esdhc_cfg ),1 ); cfg->esdhc_base =CONFIG_SYS_FSL_ESDHC_ADDR ; + cfg->max_bus_width =CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH ;/* Prefer peripheral clock which provides higher frequency. */ if (gd->arch.sdhc_per_clk) cfg->sdhc_clk = gd->arch.sdhc_per_clk;
Jaehoon Chung
Reviewed-byRe: [PATCH 2/2] mmc: fsl_esdhc: Add new config option for default fallback mode
Quoted 8 lines · Pali Rohár
Quoted 7 lines · On Tuesday 17 May 2022 08:40:48 Jaehoon Chung wrote:
Quoted 6 lines · Pali Rohár
Currently default fallback SDHC mode is 1-bit. Add new config option
CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTHto allow specifying default fallback mode. This is useful e.g. for SPL builds which loads other parts from SD card during boot process.Signed-off-by Pali Rohár <[email protected]>
Best Regards,
Jaehoon Chung
Quoted 44 lines
Quoted 13 lines
Quoted 13 lines
--- drivers/mmc/Kconfig | 5 +++++ drivers/mmc/fsl_esdhc.c | 1 + 2 files changed, 6 insertions(+)drivers/mmc/Kconfig +0
-0@@ -826,6 +826,11 @@ config FSL_ESDHC_VS33_NOT_SUPPORT For eSDHC, power supply is through peripheral circuit. 3.3V support is common. Select this if 3.3V power supply not supported.Quoted 6 lines
drivers/mmc/Kconfig config FSL_ESDHC_VS33_NOT_SUPPORT · line 832
Quoted 4 lines
drivers/mmc/Kconfig +4
-0+config SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH + int + depends on FSL_ESDHC + default 1Is there any reason not to use dt?
This is fallback value for function
fsl_esdhc_mmc_init()which is called when DT is not parsed or used (yet). E.g. this applies for P2020 SPL.Quoted 20 lines
Best Regards,
Jaehoon ChungQuoted 16 lines
drivers/mmc/Kconfig +1
-0+ config FSL_ESDHC_IMX bool "Freescale/NXP i.MX eSDHC controller support" helpdrivers/mmc/fsl_esdhc.c +1
-0@@ -988,6 +988,7 @@ int fsl_esdhc_mmc_init(struct bd_info *bis) cfg =calloc (sizeof (struct fsl_esdhc_cfg ),1 ); cfg->esdhc_base =CONFIG_SYS_FSL_ESDHC_ADDR ; + cfg->max_bus_width =CONFIG_SYS_FSL_ESDHC_DEFAULT_BUS_WIDTH ;/* Prefer peripheral clock which provides higher frequency. */ if (gd->arch.sdhc_per_clk) cfg->sdhc_clk = gd->arch.sdhc_per_clk;
Quoted 10 lines · Pali Rohár
8-bit mode is not supported by SD cards and on P2020 are four SDHC pins shared with SPI (so if P2020 board have also SPI then only 4-bit SDHC mode is provided). So 8-bit SDHC mode is really bad default.
When max bus width is not provided then set mode to 1-bit. This mode is supported by all cards, so it is the best option for fallback mode.
Also P2020 bootrom sets mode to 1-bit when booting from SD/MMC card.
Signed-off-by Pali Rohár <[email protected]>
Add minor comment.
Quoted 9 lines
--- drivers/mmc/fsl_esdhc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/mmc/fsl_esdhc.c +0
-0
drivers/mmc/fsl_esdhc.c int fsl_esdhc_initialize(struct bd_info *bis, struct fsl_esdhc_cfg *cfg) · line 966
Quoted 7 lines
drivers/mmc/fsl_esdhc.c +1
-3@@ -963,9 +963,8 @@ int fsl_esdhc_initialize(struct bd_info *bis, struct fsl_esdhc_cfg *cfg) }else if (cfg->max_bus_width ==1 ) { mmc_cfg->host_caps |=MMC_MODE_1BIT ; }else { - mmc_cfg->host_caps |=MMC_MODE_1BIT |MMC_MODE_4BIT | -MMC_MODE_8BIT ; -printf ("No max bus width provided. Assume 8-bit supported.\n" ); + mmc_cfg->host_caps |=MMC_MODE_1BIT ;
I'm not sure that it really needs to use "|".
Best Regards,
Jaehoon Chung
Quoted 4 lines
drivers/mmc/fsl_esdhc.c +1
-0+printf ("No max bus width provided. Fallback to 1-bit mode.\n" ); }if (IS_ENABLED (CONFIG_ESDHC_DETECT_8_BIT_QUIRK ))