From patchwork Wed Mar 4 14:41:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 243206 List-Id: U-Boot discussion From: walter.lozano at collabora.com (Walter Lozano) Date: Wed, 4 Mar 2020 11:41:22 -0300 Subject: [PATCH 1/4] mx6cuboxi: enable MMC and eMMC in DT for SPL In-Reply-To: <20200304144125.8564-1-walter.lozano@collabora.com> References: <20200304144125.8564-1-walter.lozano@collabora.com> Message-ID: <20200304144125.8564-2-walter.lozano@collabora.com> Signed-off-by: Walter Lozano --- .../dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi b/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi index d302b2e275..400b885e43 100644 --- a/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi +++ b/arch/arm/dts/imx6qdl-hummingboard2-emmc-som-v15-u-boot.dtsi @@ -34,3 +34,11 @@ &usdhc1 { status = "disabled"; }; + +&usdhc2 { + u-boot,dm-pre-reloc; +}; + +&usdhc3 { + u-boot,dm-pre-reloc; +}; From patchwork Wed Mar 4 14:41:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 243207 List-Id: U-Boot discussion From: walter.lozano at collabora.com (Walter Lozano) Date: Wed, 4 Mar 2020 11:41:23 -0300 Subject: [PATCH 2/4] mx6cuboxi: enable MMC iomux on board_early_init_f In-Reply-To: <20200304144125.8564-1-walter.lozano@collabora.com> References: <20200304144125.8564-1-walter.lozano@collabora.com> Message-ID: <20200304144125.8564-3-walter.lozano@collabora.com> MMC 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. Signed-off-by: Walter Lozano --- board/solidrun/mx6cuboxi/mx6cuboxi.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c index 6a96f9ecdb..71c77ad2a2 100644 --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c @@ -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; } From patchwork Wed Mar 4 14:41:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 243208 List-Id: U-Boot discussion From: walter.lozano at collabora.com (Walter Lozano) Date: Wed, 4 Mar 2020 11:41:24 -0300 Subject: [PATCH 3/4] mx6cuboxi: customize board_boot_order to access eMMC In-Reply-To: <20200304144125.8564-1-walter.lozano@collabora.com> References: <20200304144125.8564-1-walter.lozano@collabora.com> Message-ID: <20200304144125.8564-4-walter.lozano@collabora.com> In 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. Signed-off-by: Walter Lozano --- board/solidrun/mx6cuboxi/mx6cuboxi.c | 49 ++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/board/solidrun/mx6cuboxi/mx6cuboxi.c b/board/solidrun/mx6cuboxi/mx6cuboxi.c index 71c77ad2a2..3ce122e8b9 100644 --- a/board/solidrun/mx6cuboxi/mx6cuboxi.c +++ b/board/solidrun/mx6cuboxi/mx6cuboxi.c @@ -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 static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = { From patchwork Wed Mar 4 14:41:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Walter Lozano X-Patchwork-Id: 243209 List-Id: U-Boot discussion From: walter.lozano at collabora.com (Walter Lozano) Date: Wed, 4 Mar 2020 11:41:25 -0300 Subject: [PATCH 4/4] mx6cuboxi: enable OF_CONTROL and DM in SPL In-Reply-To: <20200304144125.8564-1-walter.lozano@collabora.com> References: <20200304144125.8564-1-walter.lozano@collabora.com> Message-ID: <20200304144125.8564-5-walter.lozano@collabora.com> In 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. Signed-off-by: Walter Lozano --- configs/mx6cuboxi_defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configs/mx6cuboxi_defconfig b/configs/mx6cuboxi_defconfig index bee7d280f0..7ea79b9064 100644 --- a/configs/mx6cuboxi_defconfig +++ b/configs/mx6cuboxi_defconfig @@ -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