mx6cuboxi: enable support for OF_CONTROL and DM in SPL
Subsystems (2)
cover mx6cuboxi: enable support for OF_CONTROL and DM in SPL
Make an additional step to add full DM support to mx6cuboxi, including its support for SPL
With this new configuration SPL image is 50 KB, higher than the 38 KB from the previous version, but it still under the 68 KB limit.
Walter Lozano (4):
mx6cuboxi: enable MMC and eMMC in DT for SPL
mx6cuboxi: enable MMC iomux on board_early_init_f
mx6cuboxi: customize board_boot_order to access eMMC
mx6cuboxi: enable OF_CONTROL and DM in SPL
...qdl-hummingboard2-emmc-som-v15-u-boot.dtsi | 8 ++ board/solidrun/mx6cuboxi/mx6cuboxi.c | 74 +++++++++++++++++++ configs/mx6cuboxi_defconfig | 3 + 3 files changed, 85 insertions(+)
Signature · 1 line
2.20.1
PATCH 1/4 mx6cuboxi: enable MMC and eMMC in DT for SPL
--- .../dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi +8 -0
@@ -34,3 +34,11 @@ &usdhc1 { status = "disabled"; }; + +&usdhc2 { + u-boot,dm-pre-reloc; +}; + +&usdhc3 { + u-boot,dm-pre-reloc; +};
Signature · 1 line
2.20.1
PATCH 2/4 mx6cuboxi: enable MMC iomux on board_early_init_f
In reply to Walter LozanoMMC iomux is done on board_mmc_init which is valid when DM_MMC is not enabled. After enabling it, the iomux setup needs to be moved to a valid place.
This patch moves the MMC iomux to board_early_init_f where other iomux is done.
--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
board/solidrun/mx6cuboxi/mx6cuboxi.c +25 -0
@@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4) +static int setup_iomux_mmc (void ) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned reg =readl (&psrc->sbmr1) >>11 ; + +/* +* Upon reading BOOT_CFG register the following map is done: +* Bit 11 and 12 of BOOT_CFG register can determine the current +* mmc port +* 0x1 SD2 +* 0x2 SD3 +*/ +switch (reg &0x3 ) { +case 0x1 : +SETUP_IOMUX_PADS (usdhc2_pads); +case 0x2 : +SETUP_IOMUX_PADS (usdhc3_pads); + } + +return 0 ; +} +int board_mmc_getcd (struct mmc *mmc) {struct fsl_esdhc_cfg *cfg = mmc->priv;
@@ -432,9 +454,12 @@ int board_early_init_f(void) {setup_iomux_uart (); +setup_iomux_mmc (); +#ifdef CONFIG_CMD_SATA setup_sata ();#endif +return 0 ; }
Signature · 1 line
2.20.1
PATCH 2/4 mx6cuboxi: enable MMC iomux on board_early_init_f
Hi Walter,
Thanks for your SPL_DM support work on this platform.
One comment inline below.
Quoted 17 lines · Walter Lozano
MMC iomux is done on
board_mmc_initwhich is valid whenDM_MMCis not enabled. After enabling it, the iomux setup needs to be moved to a valid place.This patch moves the MMC iomux to
board_early_init_fwhere other iomux is done.Signed-off-by Walter Lozano <[email protected]>--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)board/solidrun/mx6cuboxi/mx6cuboxi.c +0
-0
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_mmc_get_env_dev(int devno) · line 185
Quoted 7 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +4
-0@@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4) +static int setup_iomux_mmc (void ) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned reg =readl (&psrc->sbmr1) >>11 ;
This mostly duplicates the existing mmc_init_spl() routine. As I understand, mmc_init_spl() becomes dead code once you enable CONFIG_SPL_DM in patch #4 of this series. Can you remove mmc_init_spl() in a followup patch? Both struct fsl_esdhc_cfg can also be removed, I believe.
baruch
Quoted 33 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +21
-0+ +/* +* Upon reading BOOT_CFG register the following map is done: +* Bit 11 and 12 of BOOT_CFG register can determine the current +* mmc port +* 0x1 SD2 +* 0x2 SD3 +*/ +switch (reg &0x3 ) { +case 0x1 : +SETUP_IOMUX_PADS (usdhc2_pads); +case 0x2 : +SETUP_IOMUX_PADS (usdhc3_pads); + } + +return 0 ; +} +int board_mmc_getcd (struct mmc *mmc) {struct fsl_esdhc_cfg *cfg = mmc->priv;@@ -432,9 +454,12 @@ int board_early_init_f(void) {setup_iomux_uart (); +setup_iomux_mmc (); +#ifdef CONFIG_CMD_SATA setup_sata ();#endif +return 0 ; }
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -PATCH 2/4 mx6cuboxi: enable MMC iomux on board_early_init_f
Hi Baruch,
Thanks for you comments.
Quoted 27 lines · Baruch Siach
Hi Walter,
Thanks for your
SPL_DMsupport work on this platform.One comment inline below.
Quoted 20 lines · Walter Lozano
MMC iomux is done on
board_mmc_initwhich is valid whenDM_MMCis not enabled. After enabling it, the iomux setup needs to be moved to a valid place.This patch moves the MMC iomux to
board_early_init_fwhere other iomux is done.Signed-off-by Walter Lozano <[email protected]>--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)board/solidrun/mx6cuboxi/mx6cuboxi.c +0
-0@@ -179,6 +179,28 @@ int board_mmc_get_env_dev(int devno)#define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
Quoted 8 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_mmc_get_env_dev(int devno) · line 185
Quoted 4 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +4
-0+static int setup_iomux_mmc (void ) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned reg =readl (&psrc->sbmr1) >>11 ;This mostly duplicates the existing
mmc_init_spl()routine. As I understand,mmc_init_spl()becomes dead code once you enableCONFIG_SPL_DMin patch #4 of this series. Can you removemmc_init_spl()in a followup patch? Both structfsl_esdhc_cfgcan also be removed, I believe.
You are right, if we enable both CONFIG_SPL_DM and CONFIG_SPL_DM_MMC the function mmc_init_spl is useless, so I understand we can safety remove it.
Quoted 2 lines
baruch
Regards,
Walter
PATCH 3/4 mx6cuboxi: customize board_boot_order to access eMMC
In reply to Walter LozanoIn SPL legacy code only one MMC device is created, based on BOOT_CFG register, which can be either SD or eMMC. In this context board_boot_order return always MMC1 when configure to boot from SD/eMMC. After switching to DM both SD and eMMC devices are created based on the information available on DT, but as board_boot_order only returns MMC1 is not possible to boot from eMMC.
This patch customizes board_boot_order taking into account BOOT_CFG register to point to correct MMC1 / MMC2 device.
--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
board/solidrun/mx6cuboxi/mx6cuboxi.c +49 -0
@@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)return strcmp (name, tmp_name); } +void board_boot_order (u32 *spl_boot_list) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned int reg =readl (&psrc->sbmr1) >>11 ; +u32 boot_mode =imx6_src_get_boot_mode () &IMX6_BMODE_MASK ; +unsigned int bmode =readl (&src_base->sbmr2); + +/* If bmode is serial or USB phy is active, return serial */ +if (((bmode >>24 ) &0x03 ) ==0x01 ||is_usbotg_phy_active ()) { + spl_boot_list[0 ] =BOOT_DEVICE_BOARD ; +return ; + } + +switch (boot_mode >>IMX6_BMODE_SHIFT ) { + case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: + spl_boot_list[0 ] =BOOT_DEVICE_NAND ; +break ; +case IMX6_BMODE_SD : +case IMX6_BMODE_ESD : +case IMX6_BMODE_MMC : +case IMX6_BMODE_EMMC : +/* +* Upon reading BOOT_CFG register the following map is done: +* Bit 11 and 12 of BOOT_CFG register can determine the current +* mmc port +* 0x1 SD2 +* 0x2 SD3 +*/ + + reg &=0x3 ;/* Only care about bottom 2 bits */ +switch (reg) { +case 1 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC1 ; +break ; +case 2 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC2 ; +break ; + } +break ; +default : +/* By default use USB downloader */ + spl_boot_list[0 ] =BOOT_DEVICE_BOARD ; +break ; + } + +/* As a last resort, use serial downloader */ + spl_boot_list[1 ] =BOOT_DEVICE_BOARD ; +} +#ifdef CONFIG_SPL_BUILD #include <asm/arch/mx6-ddr.h> static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
Signature · 1 line
2.20.1
PATCH 3/4 mx6cuboxi: customize board_boot_order to access eMMC
Hi Walter,
Quoted 20 lines · Walter Lozano
In SPL legacy code only one MMC device is created, based on
BOOT_CFGregister, which can be either SD or eMMC. In this contextboard_boot_orderreturn always MMC1 when configure to boot from SD/eMMC. After switching to DM both SD and eMMC devices are created based on the information available on DT, but asboard_boot_orderonly returns MMC1 is not possible to boot from eMMC.This patch customizes
board_boot_ordertaking into accountBOOT_CFGregister to point to correct MMC1 / MMC2 device.Signed-off-by Walter Lozano <[email protected]>--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/solidrun/mx6cuboxi/mx6cuboxi.c +0
-0
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 657
Quoted 9 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +6
-0@@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)return strcmp (name, tmp_name); } +void board_boot_order (u32 *spl_boot_list) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned int reg =readl (&psrc->sbmr1) >>11 ; +u32 boot_mode =imx6_src_get_boot_mode () &IMX6_BMODE_MASK ; +unsigned int bmode =readl (&src_base->sbmr2);
This is duplication of the logicpd/imx6 board code. But..
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 668
Quoted 11 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +11
-0+ +/* If bmode is serial or USB phy is active, return serial */ +if (((bmode >>24 ) &0x03 ) ==0x01 ||is_usbotg_phy_active ()) { + spl_boot_list[0 ] =BOOT_DEVICE_BOARD ; +return ; + } + +switch (boot_mode >>IMX6_BMODE_SHIFT ) { + case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: + spl_boot_list[0 ] =BOOT_DEVICE_NAND ; +break ;
... we have no raw NAND device on Hummingboard.
Quoted 10 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +10
-0+case IMX6_BMODE_SD : +case IMX6_BMODE_ESD : +case IMX6_BMODE_MMC : +case IMX6_BMODE_EMMC : +/* +* Upon reading BOOT_CFG register the following map is done: +* Bit 11 and 12 of BOOT_CFG register can determine the current +* mmc port +* 0x1 SD2 +* 0x2 SD3
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 688
Quoted 10 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +10
-0+*/ + + reg &=0x3 ;/* Only care about bottom 2 bits */ +switch (reg) { +case 1 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC1 ; +break ; +case 2 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC2 ; +break ;
This code is very similar to setup_iomux_mmc(). Maybe an opportunity to share code between functions?
Thanks,
baruch
Quoted 15 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +12
-0+ } +break ; +default : +/* By default use USB downloader */ + spl_boot_list[0 ] =BOOT_DEVICE_BOARD ; +break ; + } + +/* As a last resort, use serial downloader */ + spl_boot_list[1 ] =BOOT_DEVICE_BOARD ; +} +#ifdef CONFIG_SPL_BUILD #include <asm/arch/mx6-ddr.h> static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
Signature · 3 lines
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -PATCH 3/4 mx6cuboxi: customize board_boot_order to access eMMC
Hi Baruch
Quoted 34 lines · Baruch Siach
Hi Walter,
Quoted 20 lines · Walter Lozano
In SPL legacy code only one MMC device is created, based on
BOOT_CFGregister, which can be either SD or eMMC. In this contextboard_boot_orderreturn always MMC1 when configure to boot from SD/eMMC. After switching to DM both SD and eMMC devices are created based on the information available on DT, but asboard_boot_orderonly returns MMC1 is not possible to boot from eMMC.This patch customizes
board_boot_ordertaking into accountBOOT_CFGregister to point to correct MMC1 / MMC2 device.Signed-off-by Walter Lozano <[email protected]>--- board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)board/solidrun/mx6cuboxi/mx6cuboxi.c +0
-0board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 657
Quoted 9 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +6
-0@@ -649,6 +649,55 @@ int board_fit_config_name_match(const char *name)return strcmp (name, tmp_name); } +void board_boot_order (u32 *spl_boot_list) +{ +struct src *psrc = (struct src *)SRC_BASE_ADDR ; +unsigned int reg =readl (&psrc->sbmr1) >>11 ; +u32 boot_mode =imx6_src_get_boot_mode () &IMX6_BMODE_MASK ; +unsigned int bmode =readl (&src_base->sbmr2);This is duplication of the logicpd/imx6 board code. But..
Quoted 12 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 668
Quoted 11 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +11
-0+ +/* If bmode is serial or USB phy is active, return serial */ +if (((bmode >>24 ) &0x03 ) ==0x01 ||is_usbotg_phy_active ()) { + spl_boot_list[0 ] =BOOT_DEVICE_BOARD ; +return ; + } + +switch (boot_mode >>IMX6_BMODE_SHIFT ) { + case IMX6_BMODE_NAND_MIN ... IMX6_BMODE_NAND_MAX: + spl_boot_list[0 ] =BOOT_DEVICE_NAND ; +break ;... we have no raw NAND device on Hummingboard.
Yes, you are right, I use the logicpd/imx6 as reference and forgot about the NAND. Thanks you pointing at it.
Quoted 15 lines
Quoted 15 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +14
-0+case IMX6_BMODE_SD : +case IMX6_BMODE_ESD : +case IMX6_BMODE_MMC : +case IMX6_BMODE_EMMC : +/* +* Upon reading BOOT_CFG register the following map is done: +* Bit 11 and 12 of BOOT_CFG register can determine the current +* mmc port +* 0x1 SD2 +* 0x2 SD3 +*/ + + reg &=0x3 ;/* Only care about bottom 2 bits */ +switch (reg) {
Quoted 8 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c int board_fit_config_name_match(const char *name) · line 688
Quoted 6 lines
board/solidrun/mx6cuboxi/mx6cuboxi.c +6
-0+case 1 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC1 ; +break ; +case 2 : + spl_boot_list[0 ] =BOOT_DEVICE_MMC2 ; +break ;This code is very similar to
setup_iomux_mmc(). Maybe an opportunity to share code between functions?
Thanks for your suggestion, I will do a little rework.
Quoted 2 lines
Thanks,
baruch
Regards,
Walter
PATCH 4/4 mx6cuboxi: enable OF_CONTROL and DM in SPL
In reply to Walter LozanoIn order to take the beneficts of DT and DM in SPL, like reusing the code and avoid redundancy, enable SPL_OF_CONTROL, SPL_DM and SPL_DM_MMC.
With this new configuration SPL image is 50 KB, higher than the 38 KB from the previous version, but it still under the 68 KB limit.
--- configs/mx6cuboxi_defconfig | 3 +++ 1 file changed, 3 insertions(+)
configs/mx6cuboxi_defconfig +3 -0
@@ -25,6 +25,7 @@ CONFIG_USE_PREBOOT=y CONFIG_PREBOOT="if hdmidet; then usb start; setenv stdin serial,usbkbd; setenv stdout serial,vga; setenv stderr serial,vga; else setenv stdin serial; setenv stdout serial; setenv stderr serial; fi;" CONFIG_BOUNCE_BUFFER=y CONFIG_BOARD_EARLY_INIT_F=y +CONFIG_SPL_SEPARATE_BSS=y CONFIG_SPL_FS_EXT4=y CONFIG_SPL_I2C_SUPPORT=y CONFIG_SPL_WATCHDOG_SUPPORT=y
@@ -37,6 +38,7 @@ CONFIG_CMD_CACHE=y CONFIG_CMD_EXT4_WRITE=y # CONFIG_SPL_PARTITION_UUIDS is not set CONFIG_OF_CONTROL=y +CONFIG_SPL_OF_CONTROL=y CONFIG_DEFAULT_DEVICE_TREE="imx6dl-hummingboard2-emmc-som-v15" CONFIG_OF_LIST="imx6dl-hummingboard2-emmc-som-v15 imx6q-hummingboard2-emmc-som-v15" CONFIG_MULTI_DTB_FIT=y
@@ -45,6 +47,7 @@ CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y CONFIG_NET_RANDOM_ETHADDR=y CONFIG_DM=y +CONFIG_SPL_DM=y CONFIG_DWC_AHSATA=y CONFIG_DM_MMC=y CONFIG_FSL_USDHC=y
Signature · 1 line
2.20.1