Add Support for eMMC boot in AM65x and J721e
Subsystems (5)
cover Add Support for eMMC boot in AM65x and J721e
The following patches add support for eMMC boot in TI's Am65x and J721e devices.
Faiz Abbas (10):
mmc: Add a saved_clock member
arm: K3: sysfw-loader: Add a config_pm_pre_callback()
configs: am65x_evm: Add CONFIG_SUPPORT_EMMC_BOOT
spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation
mmc: Merge SD_LEGACY and MMC_LEGACY bus modes
mmc: sdhci_am654: Update output tap delay writes
configs: j721e_evm: Add Support for eMMC boot
mmc: Add init() API
mmc: sdhci: Expose sdhci_init() as non-static
mmc: am654_sdhci: Implement workaround for card detect
arch/arm/dts/k3-am65-main.dtsi | 12 ++- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 11 +- arch/arm/dts/k3-j721e-main.dtsi | 15 ++- arch/arm/mach-imx/imx8/image.c | 3 +- arch/arm/mach-k3/am6_init.c | 33 +++++- arch/arm/mach-k3/include/mach/sysfw-loader.h | 2 +- arch/arm/mach-k3/j721e_init.c | 33 +++++- arch/arm/mach-k3/sysfw-loader.c | 6 +- common/spl/spl_mmc.c | 11 +- configs/am65x_evm_a53_defconfig | 1 + configs/am65x_evm_r5_defconfig | 1 + configs/j721e_evm_a72_defconfig | 3 + configs/j721e_evm_r5_defconfig | 3 + drivers/mmc/am654_sdhci.c | 105 ++++++++++++++++--- drivers/mmc/fsl_esdhc_imx.c | 1 - drivers/mmc/mmc.c | 33 +++--- drivers/mmc/omap_hsmmc.c | 1 - drivers/mmc/sdhci.c | 2 +- drivers/mmc/zynq_sdhci.c | 1 - include/configs/am65x_evm.h | 2 - include/mmc.h | 9 +- include/sdhci.h | 1 + 22 files changed, 236 insertions(+), 53 deletions(-)
Signature · 1 line
2.19.2
PATCH 1/10 mmc: Add a saved_clock member
Add a saved_clock member to struct mmc to store the previous clock speed in the clock needs to be stopped for some time.
--- include/mmc.h | 1 + 1 file changed, 1 insertion(+)
include/mmc.h +1 -0
@@ -602,6 +602,7 @@ struct mmc {bool clk_disable;/* true if the clock can be turned off */ uint bus_width;uint clock; +uint saved_clock;enum mmc_voltage signal_voltage;uint card_caps;uint host_caps;
Signature · 1 line
2.19.2
PATCH 2/10 arm: K3: sysfw-loader: Add a config_pm_pre_callback()
In reply to Faiz AbbasSystem firmware does not guarantee that clocks going out of the device will be stable during power management configuration. There are some DCRC errors when SPL tries to get the next stage during eMMC boot after sysfw pm configuration.
Therefore add a config_pm_pre_callback() to switch off the eMMC clock before power management and restart it after it is done.
--- arch/arm/mach-k3/am6_init.c | 33 +++++++++++++++++++- arch/arm/mach-k3/include/mach/sysfw-loader.h | 2 +- arch/arm/mach-k3/j721e_init.c | 33 +++++++++++++++++++- arch/arm/mach-k3/sysfw-loader.c | 6 +++- 4 files changed, 70 insertions(+), 4 deletions(-)
arch/arm/mach-k3/am6_init.c +32 -1
@@ -17,6 +17,7 @@#include <dm/uclass-internal.h> #include <dm/pinctrl.h> #include <linux/soc/ti/ti_sci_protocol.h> +#include <mmc.h> #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW
@@ -86,6 +87,33 @@ static void store_boot_index_from_rom(void) bootindex = *(u32 *)(CONFIG_SYS_K3_BOOT_PARAM_TABLE_INDEX ); } +#if defined(CONFIG_K3_LOAD_SYSFW ) +void k3_mmc_stop_clock (void ) +{ +if (spl_boot_device () ==BOOT_DEVICE_MMC1 ) { +struct mmc *mmc =find_mmc_device (0 ); + +if (!mmc) +return ; + + mmc->saved_clock = mmc->clock; +mmc_set_clock (mmc,0 , true); + } +} + +void k3_mmc_restart_clock (void ) +{ +if (spl_boot_device () ==BOOT_DEVICE_MMC1 ) { +struct mmc *mmc =find_mmc_device (0 ); + +if (!mmc) +return ; + +mmc_set_clock (mmc, mmc->saved_clock, false); + } +} +#endif +void board_init_f (ulong dummy) {#if defined(CONFIG_K3_LOAD_SYSFW ) || defined(CONFIG_K3_AM654_DDRSS )
@@ -128,7 +156,10 @@ void board_init_f(ulong dummy)* callback hook, effectively switching on (or over) the console * output. */ -k3_sysfw_loader (preloader_console_init); +k3_sysfw_loader (k3_mmc_stop_clock, k3_mmc_restart_clock); + +/* Prepare console output */ +preloader_console_init ();/* Disable ROM configured firewalls right after loading sysfw */ #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/include/mach/sysfw-loader.h +1 -1
@@ -7,6 +7,6 @@#ifndef _SYSFW_LOADER_H_#define _SYSFW_LOADER_H_ -void k3_sysfw_loader (void (*config_pm_done_callback)(void )); +void k3_sysfw_loader (void (*config_pm_pre_callback)(void ),void (*config_pm_done_callback)(void ));#endif
arch/arm/mach-k3/j721e_init.c +32 -1
@@ -18,6 +18,7 @@#include <dm.h> #include <dm/uclass-internal.h> #include <dm/pinctrl.h> +#include <mmc.h> #ifdef CONFIG_SPL_BUILD #ifdef CONFIG_K3_LOAD_SYSFW
@@ -100,6 +101,33 @@ static void ctrl_mmr_unlock(void)mmr_unlock (CTRL_MMR0_BASE ,7 ); } +#if defined(CONFIG_K3_LOAD_SYSFW ) +void k3_mmc_stop_clock (void ) +{ +if (spl_boot_device () ==BOOT_DEVICE_MMC1 ) { +struct mmc *mmc =find_mmc_device (0 ); + +if (!mmc) +return ; + + mmc->saved_clock = mmc->clock; +mmc_set_clock (mmc,0 , true); + } +} + +void k3_mmc_restart_clock (void ) +{ +if (spl_boot_device () ==BOOT_DEVICE_MMC1 ) { +struct mmc *mmc =find_mmc_device (0 ); + +if (!mmc) +return ; + +mmc_set_clock (mmc, mmc->saved_clock, false); + } +} +#endif +/* * This uninitialized global variable would normal end up in the .bss section, * but the .bss is cleared between writing and reading this variable, so move
@@ -154,7 +182,10 @@ void board_init_f(ulong dummy)* callback hook, effectively switching on (or over) the console * output. */ -k3_sysfw_loader (preloader_console_init); +k3_sysfw_loader (k3_mmc_stop_clock, k3_mmc_restart_clock); + +/* Prepare console output */ +preloader_console_init ();/* Disable ROM configured firewalls right after loading sysfw */ #ifdef CONFIG_TI_SECURE_DEVICE
arch/arm/mach-k3/sysfw-loader.c +5 -1
@@ -172,7 +172,8 @@ static void k3_sysfw_configure_using_fit(void *fit, ret); } -void k3_sysfw_loader (void (*config_pm_done_callback)(void )) +void k3_sysfw_loader (void (*config_pm_pre_callback) (void ), +void (*config_pm_done_callback)(void )) {struct spl_image_info spl_image = {0 };struct spl_boot_device bootdev = {0 };
@@ -264,6 +265,9 @@ void k3_sysfw_loader(void (*config_pm_done_callback)(void))/* Parse and apply the different SYSFW configuration fragments */ k3_sysfw_configure_using_fit (sysfw_load_address, ti_sci); +if (config_pm_pre_callback) +config_pm_pre_callback (); +/* * Now that all clocks and PM aspects are setup, invoke a user- * provided callback function. Usually this callback would be used
Signature · 1 line
2.19.2
PATCH 3/10 configs: am65x_evm: Add CONFIG_SUPPORT_EMMC_BOOT
In reply to Faiz AbbasWith CONFIG_SUPPORT_EMMC_BOOT moved to Kconfig, move it to defconfig files.
--- configs/am65x_evm_a53_defconfig | 1 + configs/am65x_evm_r5_defconfig | 1 + include/configs/am65x_evm.h | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-)
configs/am65x_evm_a53_defconfig +1 -0
@@ -75,6 +75,7 @@ CONFIG_DM_KEYBOARD=y CONFIG_DM_MAILBOX=y CONFIG_K3_SEC_PROXY=y CONFIG_DM_MMC=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y
configs/am65x_evm_r5_defconfig +1 -0
@@ -73,6 +73,7 @@ CONFIG_K3_SEC_PROXY=y CONFIG_MISC=y CONFIG_K3_AVS0=y CONFIG_DM_MMC=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y
include/configs/am65x_evm.h +0 -2
@@ -127,8 +127,6 @@#define CONFIG_SYS_MMC_ENV_PART 1#endif -#define CONFIG_SUPPORT_EMMC_BOOT -/* Now for the remaining common defines */ #include <configs/ti_armv7_common.h>
Signature · 1 line
2.19.2
PATCH 4/10 spl: mmc: Fix spl_mmc_get_uboot_raw_sector() implementation
In reply to Faiz AbbasThe call to spl_mmc_get_uboot_raw_sector() completely ignores and overwrites the raw_sect value passed from the caller of spl_mmc_load().
Fix this by passing raw_sect to the function and returning the same value in the default case.
--- arch/arm/mach-imx/imx8/image.c | 3 ++- common/spl/spl_mmc.c | 11 ++++------- 2 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-imx/imx8/image.c +2 -1
@@ -196,7 +196,8 @@ unsigned long spl_spi_get_uboot_offs(struct spi_flash *flash)#endif #ifdef CONFIG_SPL_MMC_SUPPORT -unsigned long spl_mmc_get_uboot_raw_sector (struct mmc *mmc) +unsigned long spl_mmc_get_uboot_raw_sector (struct mmc *mmc, +unsigned long raw_sect) {int end;
common/spl/spl_mmc.c +4 -7
@@ -317,13 +317,10 @@ int spl_boot_partition(const u32 boot_device) }#endif -unsigned long __weak spl_mmc_get_uboot_raw_sector (struct mmc *mmc) +unsigned long __weak spl_mmc_get_uboot_raw_sector (struct mmc *mmc, +unsigned long raw_sect) { -#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR -return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR ; -#else -return 0 ; -#endif +return raw_sect; } int spl_mmc_load(struct spl_image_info *spl_image,
@@ -392,7 +389,7 @@ int spl_mmc_load(struct spl_image_info *spl_image,return err; } - raw_sect =spl_mmc_get_uboot_raw_sector (mmc); + raw_sect =spl_mmc_get_uboot_raw_sector (mmc, raw_sect);#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION err = mmc_load_image_raw_partition(spl_image, mmc, raw_part,
Signature · 1 line
2.19.2
PATCH 5/10 mmc: Merge SD_LEGACY and MMC_LEGACY bus modes
In reply to Faiz AbbasMMC_LEGACY & SD_LEGACY are not differentiated timings in the spec and don't have any meaningful differences. Therefore, get rid of all references to SD_LEGACY and use MMC_LEGACY to mean both of them.
--- drivers/mmc/fsl_esdhc_imx.c | 1 - drivers/mmc/mmc.c | 18 ++++++++---------- drivers/mmc/omap_hsmmc.c | 1 - drivers/mmc/zynq_sdhci.c | 1 - include/mmc.h | 1 - 5 files changed, 8 insertions(+), 14 deletions(-)
drivers/mmc/fsl_esdhc_imx.c +0 -1
@@ -741,7 +741,6 @@ static int esdhc_set_timing(struct mmc *mmc)switch (mmc->selected_mode) {case MMC_LEGACY : -case SD_LEGACY :esdhc_reset_tuning (mmc);writel (mixctrl, ®s->mixctrl);break ;
drivers/mmc/mmc.c +8 -10
@@ -136,7 +136,6 @@ const char *mmc_mode_name(enum bus_mode mode) {static const char *const names[] = { [MMC_LEGACY ] ="MMC legacy" , - [SD_LEGACY ] ="SD Legacy" , [MMC_HS ] ="MMC High Speed (26MHz)" , [SD_HS ] ="SD High Speed (50MHz)" , [UHS_SDR12 ] ="UHS SDR12 (25MHz)" ,
@@ -162,7 +161,6 @@ static uint mmc_mode2freq(struct mmc *mmc, enum bus_mode mode) {static const int freqs[] = { [MMC_LEGACY ] =25000000 , - [SD_LEGACY ] =25000000 , [MMC_HS ] =26000000 , [SD_HS ] =50000000 , [MMC_HS_52 ] =52000000 ,
@@ -1241,7 +1239,7 @@ static int sd_get_capabilities(struct mmc *mmc)u32 sd3_bus_mode;#endif - mmc->card_caps =MMC_MODE_1BIT |MMC_CAP (SD_LEGACY ); + mmc->card_caps =MMC_MODE_1BIT |MMC_CAP (MMC_LEGACY );if (mmc_host_is_spi (mmc))return 0 ;
@@ -1354,7 +1352,7 @@ static int sd_set_card_speed(struct mmc *mmc, enum bus_mode mode)return 0 ;switch (mode) { -case SD_LEGACY : +case MMC_LEGACY : speed =UHS_SDR12_BUS_SPEED ;break ;case SD_HS :
@@ -1697,7 +1695,7 @@ static const struct mode_width_tuning sd_modes_by_pref[] = { },#endif { - .mode = SD_LEGACY, + .mode = MMC_LEGACY, .widths = MMC_MODE_4BIT | MMC_MODE_1BIT, } };
@@ -1727,7 +1725,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps)if (mmc_host_is_spi (mmc)) {mmc_set_bus_width (mmc,1 ); -mmc_select_mode (mmc,SD_LEGACY ); +mmc_select_mode (mmc,MMC_LEGACY );mmc_set_clock (mmc, mmc->tran_speed,MMC_CLK_ENABLE );return 0 ; }
@@ -1786,7 +1784,7 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) error:/* revert to a safer bus speed */ -mmc_select_mode (mmc,SD_LEGACY ); +mmc_select_mode (mmc,MMC_LEGACY );mmc_set_clock (mmc, mmc->tran_speed,MMC_CLK_ENABLE ); }
@@ -2563,7 +2561,7 @@ static int mmc_startup(struct mmc *mmc)#if CONFIG_IS_ENABLED (MMC_TINY )mmc_set_clock (mmc, mmc->legacy_speed, false); -mmc_select_mode (mmc,IS_SD (mmc) ?SD_LEGACY :MMC_LEGACY ); +mmc_select_mode (mmc,MMC_LEGACY );mmc_set_bus_width (mmc,1 );#else if (IS_SD (mmc)) {
@@ -2845,8 +2843,8 @@ int mmc_start_init(struct mmc *mmc)* all hosts are capable of 1 bit bus-width and able to use the legacy * timings. */ - mmc->host_caps = mmc->cfg->host_caps |MMC_CAP (SD_LEGACY ) | -MMC_CAP (MMC_LEGACY ) |MMC_MODE_1BIT ; + mmc->host_caps = mmc->cfg->host_caps |MMC_CAP (MMC_LEGACY ) | +MMC_MODE_1BIT ;#if !defined(CONFIG_MMC_BROKEN_CD ) no_card =mmc_getcd (mmc) ==0 ;
drivers/mmc/omap_hsmmc.c +0 -1
@@ -390,7 +390,6 @@ static void omap_hsmmc_set_timing(struct mmc *mmc)break ;case MMC_LEGACY :case MMC_HS : -case SD_LEGACY :case UHS_SDR12 : val |=AC12_UHSMC_SDR12 ;break ;
drivers/mmc/zynq_sdhci.c +0 -1
@@ -35,7 +35,6 @@ struct arasan_sdhci_priv {static const u8 mode2timing[] = { [MMC_LEGACY ] =UHS_SDR12_BUS_SPEED , - [SD_LEGACY ] =UHS_SDR12_BUS_SPEED , [MMC_HS ] =HIGH_SPEED_BUS_SPEED , [SD_HS ] =HIGH_SPEED_BUS_SPEED , [MMC_HS_52 ] =HIGH_SPEED_BUS_SPEED ,
include/mmc.h +0 -1
@@ -532,7 +532,6 @@ struct sd_ssr {enum bus_mode {MMC_LEGACY , -SD_LEGACY ,MMC_HS ,SD_HS ,MMC_HS_52 ,
Signature · 1 line
2.19.2
PATCH 6/10 mmc: sdhci_am654: Update output tap delay writes
In reply to Faiz AbbasWith the latest RIOT, there is a different otap delay value for each speed mode. Add a new binding with every supported speed mode. Also disable a given speed mode in the host caps if its corresponding otap-del-sel is not present.
--- arch/arm/dts/k3-am65-main.dtsi | 12 +++- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 11 ++- arch/arm/dts/k3-j721e-main.dtsi | 15 ++++- drivers/mmc/am654_sdhci.c | 70 +++++++++++++++++--- 4 files changed, 95 insertions(+), 13 deletions(-)
arch/arm/dts/k3-am65-main.dtsi +11 -1
@@ -98,7 +98,17 @@ interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>; mmc-ddr-1_8v; mmc-hs200-1_8v; - ti,otap-del-sel = <0x2>; + ti,otap-del-sel-legacy = <0x0>; + ti,otap-del-sel-mmc-hs = <0x0>; + ti,otap-del-sel-sd-hs = <0x0>; + ti,otap-del-sel-sdr12 = <0x0>; + ti,otap-del-sel-sdr25 = <0x0>; + ti,otap-del-sel-sdr50 = <0x8>; + ti,otap-del-sel-sdr104 = <0x5>; + ti,otap-del-sel-ddr50 = <0x5>; + ti,otap-del-sel-ddr52 = <0x5>; + ti,otap-del-sel-hs200 = <0x5>; + ti,otap-del-sel-hs400 = <0x0>; ti,trm-icp = <0x8>; dma-coherent; };
arch/arm/dts/k3-am654-base-board-u-boot.dtsi +10 -1
@@ -29,7 +29,16 @@ clock-names = "clk_ahb", "clk_xin"; power-domains = <&k3_pds 48 TI_SCI_PD_EXCLUSIVE>; max-frequency = <25000000>; - ti,otap-del-sel = <0x2>; + ti,otap-del-sel-legacy = <0x0>; + ti,otap-del-sel-mmc-hs = <0x0>; + ti,otap-del-sel-sd-hs = <0x0>; + ti,otap-del-sel-sdr12 = <0x0>; + ti,otap-del-sel-sdr25 = <0x0>; + ti,otap-del-sel-sdr50 = <0x8>; + ti,otap-del-sel-sdr104 = <0x7>; + ti,otap-del-sel-ddr50 = <0x4>; + ti,otap-del-sel-ddr52 = <0x4>; + ti,otap-del-sel-hs200 = <0x7>; ti,trm-icp = <0x8>; };
arch/arm/dts/k3-j721e-main.dtsi +13 -2
@@ -210,9 +210,14 @@ assigned-clocks = <&k3_clks 91 1>; assigned-clock-parents = <&k3_clks 91 2>; bus-width = <8>; - ti,otap-del-sel = <0x2>; ti,trm-icp = <0x8>; dma-coherent; + mmc-ddr-1_8v; + ti,otap-del-sel-legacy = <0x0>; + ti,otap-del-sel-mmc-hs = <0x0>; + ti,otap-del-sel-ddr52 = <0x5>; + ti,otap-del-sel-hs200 = <0x6>; + ti,otap-del-sel-hs400 = <0x0>; }; main_sdhci1: sdhci at 4fb0000 {
@@ -224,7 +229,13 @@ clocks = <&k3_clks 92 0>, <&k3_clks 92 5>; assigned-clocks = <&k3_clks 92 0>; assigned-clock-parents = <&k3_clks 92 1>; - ti,otap-del-sel = <0x2>; + ti,otap-del-sel-legacy = <0x0>; + ti,otap-del-sel-sd-hs = <0xf>; + ti,otap-del-sel-sdr12 = <0xf>; + ti,otap-del-sel-sdr25 = <0xf>; + ti,otap-del-sel-sdr50 = <0xc>; + ti,otap-del-sel-sdr104 = <0x5>; + ti,otap-del-sel-ddr50 = <0xc>; ti,trm-icp = <0x8>; dma-coherent; };
drivers/mmc/am654_sdhci.c +61 -9
122 lines not on this page · raw message
Signature · 1 line
2.19.2
PATCH 7/10 configs: j721e_evm: Add Support for eMMC boot
In reply to Faiz AbbasEnable configs to support eMMC boot support.
--- configs/j721e_evm_a72_defconfig | 3 +++ configs/j721e_evm_r5_defconfig | 3 +++ 2 files changed, 6 insertions(+)
configs/j721e_evm_a72_defconfig +3 -0
@@ -26,6 +26,8 @@ CONFIG_SPL_BOARD_INIT=y CONFIG_SPL_SYS_MALLOC_SIMPLE=y CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x1400 CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y
@@ -91,6 +93,7 @@ CONFIG_DM_MAILBOX=y CONFIG_K3_SEC_PROXY=y CONFIG_MISC=y CONFIG_DM_MMC=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_MMC_SDHCI_ADMA=y CONFIG_SPL_MMC_SDHCI_ADMA=y
configs/j721e_evm_r5_defconfig +3 -0
@@ -24,6 +24,8 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_SPL_STACK_R=y CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_EARLY_BSS=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR=y +CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x400 CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_DM_MAILBOX=y
@@ -72,6 +74,7 @@ CONFIG_MISC=y CONFIG_FS_LOADER=y CONFIG_K3_AVS0=y CONFIG_DM_MMC=y +CONFIG_SUPPORT_EMMC_BOOT=y CONFIG_MMC_SDHCI=y CONFIG_SPL_MMC_SDHCI_ADMA=y CONFIG_MMC_SDHCI_AM654=y
Signature · 1 line
2.19.2
PATCH 8/10 mmc: Add init() API
In reply to Faiz AbbasAdd an init() API for platform specific init() operations.
--- drivers/mmc/mmc.c | 15 +++++++-------- include/mmc.h | 7 +++++++ 2 files changed, 14 insertions(+), 8 deletions(-)
drivers/mmc/mmc.c +7 -8
@@ -2752,6 +2752,7 @@ static int mmc_power_cycle(struct mmc *mmc)int mmc_get_op_cond (struct mmc *mmc) { +struct dm_mmc_ops *ops =mmc_get_ops (mmc->dev);bool uhs_en =supports_uhs (mmc->cfg->host_caps);int err;
@@ -2786,14 +2787,12 @@ int mmc_get_op_cond(struct mmc *mmc)if (err)return err; -#if CONFIG_IS_ENABLED (DM_MMC ) -/* The device has already been probed ready for use */ -#else -/* made sure it's not NULL earlier */ - err = mmc->cfg->ops->init (mmc); -if (err) -return err; -#endif +if (ops->init) { + err = ops->init (mmc->dev); +if (err) +return err; + } + mmc->ddr_mode =0 ; retry:
include/mmc.h +7 -0
@@ -406,6 +406,13 @@ struct mmc; #if CONFIG_IS_ENABLED(DM_MMC) struct dm_mmc_ops { + /** + * init() - platform specific initialization for the host controller + * + * @dev: Device to init + * @return 0 if Ok, -ve if error + */ + int (*init)(struct udevice *dev); /** * send_cmd() - Send a command to the MMC device *
Signature · 1 line
2.19.2
PATCH 9/10 mmc: sdhci: Expose sdhci_init() as non-static
In reply to Faiz AbbasExpose sdhci_init() as non-static.
--- drivers/mmc/sdhci.c | 2 +- include/sdhci.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +1 -1
@@ -618,7 +618,7 @@ static int sdhci_set_ios(struct mmc *mmc)return 0 ; } -static int sdhci_init (struct mmc *mmc) +int sdhci_init (struct mmc *mmc) {struct sdhci_host *host = mmc->priv;#if CONFIG_IS_ENABLED (DM_MMC ) &&CONFIG_IS_ENABLED (DM_GPIO )
include/sdhci.h +1 -0
@@ -487,6 +487,7 @@ void sdhci_set_uhs_timing(struct sdhci_host *host);#ifdef CONFIG_DM_MMC /* Export the operations to drivers */ int sdhci_probe (struct udevice *dev); +int sdhci_init (struct mmc *mmc);int sdhci_set_clock (struct mmc *mmc,unsigned int clock);extern const struct dm_mmc_ops sdhci_ops;#else
Signature · 1 line
2.19.2
PATCH 10/10 mmc: am654_sdhci: Implement workaround for card detect
In reply to Faiz AbbasThe 4 bit MMC controllers have an internal debounce for the SDCD line with a debounce delay of 1 second. Therefore, after clocks to the IP are enabled, software has to wait for this time before it can power on the controller.
Add an init() callback which polls on sdcd for a maximum of 2 seconds before switching on power to the controller or (in the case of no card) returning a ENOMEDIUM. This pushes the 1 second wait time to when the card is actually needed rather than at every probe() making sure that users who don't insert an SD card in the slot don't have to wait such a long time.
--- drivers/mmc/am654_sdhci.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-)
drivers/mmc/am654_sdhci.c +32 -3
@@ -254,7 +254,7 @@ const struct am654_driver_data j721e_4bit_drv_data = { .flags = IOMUX_PRESENT, }; -int am654_sdhci_init (struct am654_sdhci_plat *plat) +int am654_sdhci_init_phy (struct am654_sdhci_plat *plat) {u32 ctl_cfg_2 =0 ;u32 mask, val;
@@ -331,8 +331,37 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,return 0 ; } +#define MAX_SDCD_DEBOUNCE_TIME 2000 +int am654_sdhci_init (struct udevice *dev) +{ +struct am654_sdhci_plat *plat =dev_get_platdata (dev); +struct mmc *mmc =mmc_get_mmc_dev (dev); +struct sdhci_host *host = mmc->priv; +unsigned long start; +int val; + +/* +* The controller takes about 1 second to debounce the card detect line +* and doesn't let us power on until that time is up. Instead of waiting +* for 1 second at every stage, poll on the CARD_PRESENT bit upto a +* maximum of 2 seconds to be safe.. +*/ + start =get_timer (0 ); +do { +if (get_timer (start) >MAX_SDCD_DEBOUNCE_TIME ) +return -ENOMEDIUM ; + + val =mmc_getcd (host->mmc); + }while (!val); + +am654_sdhci_init_phy (plat); + +return sdhci_init (mmc); +} +static int am654_sdhci_probe (struct udevice *dev) { +struct dm_mmc_ops *ops =mmc_get_ops (dev);struct am654_driver_data *drv_data = (struct am654_driver_data *)dev_get_driver_data (dev);struct am654_sdhci_plat *plat =dev_get_platdata (dev);
@@ -373,9 +402,9 @@ static int am654_sdhci_probe(struct udevice *dev)regmap_init_mem_index (dev_ofnode (dev), &plat->base,1 ); -am654_sdhci_init (plat); + ops->init = am654_sdhci_init; -return sdhci_probe (dev); +return 0 ; }static int am654_sdhci_ofdata_to_platdata (struct udevice *dev)
Signature · 1 line
2.19.2
cover Add Support for eMMC boot in AM65x and J721e
In reply to Faiz AbbasQuoted 2 lines · Faiz Abbas
The following patches add support for eMMC boot in TI's Am65x and J721e devices.
Can you re order the series something like below?
- Bring all mmc related driver changes in the beginning
- Then introduce SoC related changes(arch/arm/*)
Also please split driver and dts changes.
Thanks and regards,
Lokesh
Quoted 37 lines
Faiz Abbas (10):
mmc: Add asaved_clockmember
arm: K3: sysfw-loader: Add aconfig_pm_pre_callback()
configs:am65x_evm: AddCONFIG_SUPPORT_EMMC_BOOT
spl: mmc: Fixspl_mmc_get_uboot_raw_sector()implementation
mmc: MergeSD_LEGACYandMMC_LEGACYbus modes
mmc:sdhci_am654: Update output tap delay writes
configs:j721e_evm: Add Support for eMMC boot
mmc: Addinit()API
mmc: sdhci: Exposesdhci_init()as non-static
mmc:am654_sdhci: Implement workaround for card detectarch/arm/dts/k3-am65-main.dtsi | 12 ++- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 11 +- arch/arm/dts/k3-j721e-main.dtsi | 15 ++- arch/arm/mach-imx/imx8/image.c | 3 +- arch/arm/mach-k3/am6_init.c | 33 +++++- arch/arm/mach-k3/include/mach/sysfw-loader.h | 2 +- arch/arm/mach-k3/j721e_init.c | 33 +++++- arch/arm/mach-k3/sysfw-loader.c | 6 +- common/spl/spl_mmc.c | 11 +- configs/am65x_evm_a53_defconfig | 1 + configs/am65x_evm_r5_defconfig | 1 + configs/j721e_evm_a72_defconfig | 3 + configs/j721e_evm_r5_defconfig | 3 + drivers/mmc/am654_sdhci.c | 105 ++++++++++++++++--- drivers/mmc/fsl_esdhc_imx.c | 1 - drivers/mmc/mmc.c | 33 +++--- drivers/mmc/omap_hsmmc.c | 1 - drivers/mmc/sdhci.c | 2 +- drivers/mmc/zynq_sdhci.c | 1 - include/configs/am65x_evm.h | 2 - include/mmc.h | 9 +- include/sdhci.h | 1 + 22 files changed, 236 insertions(+), 53 deletions(-)
cover Add Support for eMMC boot in AM65x and J721e
Quoted 11 lines · Lokesh Vutla
Quoted 2 lines · Faiz Abbas
The following patches add support for eMMC boot in TI's Am65x and J721e devices.
Can you re order the series something like below?
- Bring all mmc related driver changes in the beginning
- Then introduce SoC relatedchanges(arch/arm/*)Also please split driver and dts changes.
Can you please fix the following build errors as well?
Stage: test.py
Name: vexpress_ca9x4 test.py
Trace: + ^~
+cc1: all warnings being treated as errors +make[3]: *** [drivers/mmc/mmc.o] Error 1
+make[2]: *** [drivers/mmc] Error 2
+make[1]: *** [drivers] Error 2
+make: *** [sub-make] Error 2 section_end:1579837800:build_script [0Ksection_start:1579837800:after_script [0K[32;1mRunning after script...[0;m
[32;1m$ rm -rf ~/grub2* /tmp/uboot-test-hooks /tmp/venv[0;m section_end:1579837802:after_script [0Ksection_start:1579837802:upload_artifacts_on_failure [0Ksection_end:1579837805:upload_artifacts_on_failure [0K[31;1mERROR: Job failed: exit code 128
[0;m
Job #50296 ( https://gitlab.denx.de/u-boot/custodians/u-boot-ti/-/jobs/50296/raw )
Stage: test.py
Name: vexpress_ca15_tc2 test.py
Trace: + ^~
+cc1: all warnings being treated as errors +make[3]: *** [drivers/mmc/mmc.o] Error 1
+make[2]: *** [drivers/mmc] Error 2
+make[1]: *** [drivers] Error 2
+make: *** [sub-make] Error 2 section_end:1579837767:build_script [0Ksection_start:1579837767:after_script [0K[32;1mRunning after script...[0;m
[32;1m$ rm -rf ~/grub2* /tmp/uboot-test-hooks /tmp/venv[0;m section_end:1579837769:after_script [0Ksection_start:1579837769:upload_artifacts_on_failure [0Ksection_end:1579837771:upload_artifacts_on_failure [0K[31;1mERROR: Job failed: exit code 128
Thanks and regards,
Lokesh
Quoted 41 lines
Thanks and regards,
LokeshQuoted 37 lines
Faiz Abbas (10):
mmc: Add asaved_clockmember
arm: K3: sysfw-loader: Add aconfig_pm_pre_callback()
configs:am65x_evm: AddCONFIG_SUPPORT_EMMC_BOOT
spl: mmc: Fixspl_mmc_get_uboot_raw_sector()implementation
mmc: MergeSD_LEGACYandMMC_LEGACYbus modes
mmc:sdhci_am654: Update output tap delay writes
configs:j721e_evm: Add Support for eMMC boot
mmc: Addinit()API
mmc: sdhci: Exposesdhci_init()as non-static
mmc:am654_sdhci: Implement workaround for card detectarch/arm/dts/k3-am65-main.dtsi | 12 ++- arch/arm/dts/k3-am654-base-board-u-boot.dtsi | 11 +- arch/arm/dts/k3-j721e-main.dtsi | 15 ++- arch/arm/mach-imx/imx8/image.c | 3 +- arch/arm/mach-k3/am6_init.c | 33 +++++- arch/arm/mach-k3/include/mach/sysfw-loader.h | 2 +- arch/arm/mach-k3/j721e_init.c | 33 +++++- arch/arm/mach-k3/sysfw-loader.c | 6 +- common/spl/spl_mmc.c | 11 +- configs/am65x_evm_a53_defconfig | 1 + configs/am65x_evm_r5_defconfig | 1 + configs/j721e_evm_a72_defconfig | 3 + configs/j721e_evm_r5_defconfig | 3 + drivers/mmc/am654_sdhci.c | 105 ++++++++++++++++--- drivers/mmc/fsl_esdhc_imx.c | 1 - drivers/mmc/mmc.c | 33 +++--- drivers/mmc/omap_hsmmc.c | 1 - drivers/mmc/sdhci.c | 2 +- drivers/mmc/zynq_sdhci.c | 1 - include/configs/am65x_evm.h | 2 - include/mmc.h | 9 +- include/sdhci.h | 1 + 22 files changed, 236 insertions(+), 53 deletions(-)
cover Add Support for eMMC boot in AM65x and J721e
In reply to Lokesh VutlaLokesh,
Quoted 12 lines · Lokesh Vutla
Quoted 2 lines · Faiz Abbas
The following patches add support for eMMC boot in TI's Am65x and J721e devices.
Can you re order the series something like below?
- Bring all mmc related driver changes in the beginning
- Then introduce SoC relatedchanges(arch/arm/*)Also please split driver and dts changes.
I like this order.
Quoted 5 lines
Quoted 5 lines
Faiz Abbas (10):
mmc: Add asaved_clockmember
arm: K3: sysfw-loader: Add aconfig_pm_pre_callback()
^ these two patches add pm_pre_callback()
Quoted 5 lines
Quoted 5 lines
configs:
am65x_evm: AddCONFIG_SUPPORT_EMMC_BOOT
spl: mmc: Fixspl_mmc_get_uboot_raw_sector()implementation
mmc: MergeSD_LEGACYandMMC_LEGACYbus modes
mmc:sdhci_am654: Update output tap delay writes
configs:j721e_evm: Add Support for eMMC boot
^ All these patches add eMMC support for AM65x and J721e
Quoted 3 lines
Quoted 3 lines
mmc: Add
init()API
mmc: sdhci: Exposesdhci_init()as non-static
mmc:am654_sdhci: Implement workaround for card detect
^ All these workaround the 1 second sdcd issue.
DTS and driver changes have to go together in "Update output tap delay writes" because otherwise boot will be broken.
Thanks,
Faiz