[PATCH] pico-imx7d: add baseboard SD card boot detect

egyszeregy at freemail.hu egyszeregy at freemail.hu
Sun Aug 21 22:32:53 CEST 2022


Migrate SD card boot detection from Technexion u-boot for pico-imx7d SoM.

>From ecd4f6ecbec290c63504f7ec3a9b478425235d14 Mon Sep 17 00:00:00 2001
From: "Benjamin Szőke"
 <egyszeregy at freemail.hu>
Date: Sun, 21 Aug 2022 21:08:55 +0200
Subject: [PATCH] pico-imx7d: add baseboard SD card boot detect

Add SD card boot detection from Technexion u-boot for pico-imx7d SoM.
---
 arch/arm/dts/imx7d-pico-hobbit.dts            |   7 +-
 arch/arm/dts/imx7d-pico-pi.dts                |   7 +-
 board/technexion/pico-imx7d/Makefile          |   2 +-
 board/technexion/pico-imx7d/pico-imx7d.c      | 132 +++++++++++++++++-
 .../pico-imx7d/{spl.c => pico-imx7d_spl.c}    | 125 +++++++++++++++--
 common/splash.c                               |   2 +-
 configs/pico-dwarf-imx7d_defconfig            |   5 +
 configs/pico-hobbit-imx7d_defconfig           |   5 +
 configs/pico-imx7d_bl33_defconfig             |   5 +
 configs/pico-imx7d_defconfig                  |   5 +
 configs/pico-nymph-imx7d_defconfig            |   5 +
 configs/pico-pi-imx7d_defconfig               |   5 +
 include/configs/pico-imx7d.h                  |  23 +--
 13 files changed, 299 insertions(+), 29 deletions(-)
 rename board/technexion/pico-imx7d/{spl.c => pico-imx7d_spl.c} (50%)

diff --git a/arch/arm/dts/imx7d-pico-hobbit.dts b/arch/arm/dts/imx7d-pico-hobbit.dts
index d917dc4f2f..78b10e12f6 100644
--- a/arch/arm/dts/imx7d-pico-hobbit.dts
+++ b/arch/arm/dts/imx7d-pico-hobbit.dts
@@ -13,6 +13,11 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_gpio_leds>;
 
+		aliases {
+			mmc0 = &usdhc1;
+			mmc2 = &usdhc3;
+		};
+
 		led {
 			label = "gpio-led";
 			gpios = <&gpio2 13 GPIO_ACTIVE_HIGH>;
@@ -102,4 +107,4 @@
 			MX7D_PAD_EPDC_DATA13__GPIO2_IO13	0x14
 		>;
 	};
-};
+};
\ No newline at end of file
diff --git a/arch/arm/dts/imx7d-pico-pi.dts b/arch/arm/dts/imx7d-pico-pi.dts
index f263e391e2..7405fcd2a0 100644
--- a/arch/arm/dts/imx7d-pico-pi.dts
+++ b/arch/arm/dts/imx7d-pico-pi.dts
@@ -13,6 +13,11 @@
 		pinctrl-names = "default";
 		pinctrl-0 = <&pinctrl_gpio_leds>;
 
+		aliases {
+			mmc0 = &usdhc1;
+			mmc2 = &usdhc3;
+		};
+
 		led {
 			label = "gpio-led";
 			gpios = <&gpio2 6 GPIO_ACTIVE_HIGH>;
@@ -90,4 +95,4 @@
 		>;
 	};
 
-};
+};
\ No newline at end of file
diff --git a/board/technexion/pico-imx7d/Makefile b/board/technexion/pico-imx7d/Makefile
index 4ae3d606b5..b45b127884 100644
--- a/board/technexion/pico-imx7d/Makefile
+++ b/board/technexion/pico-imx7d/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 # (C) Copyright 2017 NXP Semiconductors
 
-obj-y  := pico-imx7d.o spl.o
+obj-y  := pico-imx7d.o pico-imx7d_spl.o
diff --git a/board/technexion/pico-imx7d/pico-imx7d.c b/board/technexion/pico-imx7d/pico-imx7d.c
index 1c0cc238df..a693e7b917 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -4,13 +4,11 @@
  */
 
 #include <init.h>
-#include <net.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/crm_regs.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/mx7-pins.h>
 #include <asm/arch/sys_proto.h>
-#include <asm/global_data.h>
 #include <asm/gpio.h>
 #include <asm/mach-imx/iomux-v3.h>
 #include <asm/mach-imx/mxc_i2c.h>
@@ -21,6 +19,9 @@
 #include <power/pmic.h>
 #include <power/pfuze3000_pmic.h>
 #include "../../freescale/common/pfuze.h"
+#include <mmc.h>
+#include <splash.h>
+#include <asm/mach-imx/boot_mode.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -159,6 +160,100 @@ int board_phy_config(struct phy_device *phydev)
 }
 #endif
 
+#ifdef CONFIG_SPLASH_SCREEN
+static struct splash_location imx_splash_locations[] = {
+	{
+		.name = "sf",
+		.storage = SPLASH_STORAGE_SF,
+		.flags = SPLASH_STORAGE_RAW,
+		.offset = 0x100000,
+	},
+	{
+		.name = "mmc_fs",
+		.storage = SPLASH_STORAGE_MMC,
+		.flags = SPLASH_STORAGE_FS,
+		.devpart = "0:1",
+	},
+	{
+		.name = "usb_fs",
+		.storage = SPLASH_STORAGE_USB,
+		.flags = SPLASH_STORAGE_FS,
+		.devpart = "0:1",
+	},
+	{
+		.name = "sata_fs",
+		.storage = SPLASH_STORAGE_SATA,
+		.flags = SPLASH_STORAGE_FS,
+		.devpart = "0:1",
+	},
+};
+
+/*This function is defined in common/splash.c.
+  Declare here to remove warning. */
+int splash_video_logo_load(void);
+
+int splash_screen_prepare(void)
+{
+	imx_splash_locations[1].devpart[0] = mmc_get_env_dev() + '0';
+	int ret;
+	ret = splash_source_load(imx_splash_locations, ARRAY_SIZE(imx_splash_locations));
+	if (!ret)
+		return 0;
+	else {
+		printf("\nNo splash.bmp in boot partition!!\n");
+		printf("Using default logo!!\n\n");
+		return splash_video_logo_load();
+	}
+}
+#endif /* CONFIG_SPLASH_SCREEN */
+
+#if CONFIG_IS_ENABLED(FSL_ESDHC_IMX)
+int check_mmc_autodetect(void)
+{
+	char *autodetect_str = env_get("mmcautodetect");
+
+	if ((autodetect_str != NULL) &&
+		(strcmp(autodetect_str, "yes") == 0)) {
+		return 1;
+	}
+
+	return 0;
+}
+
+void board_late_mmc_init(void)
+{
+	int dev_no = 0;
+	char cmd[32];
+	char mmcblk[32];
+	
+	if (!check_mmc_autodetect())
+		return;
+
+	switch (get_boot_device()) {
+		case SD3_BOOT:
+		case MMC3_BOOT:
+			env_set("bootdev", "MMC3");
+			dev_no = 2;
+			break;
+		case SD1_BOOT:
+			env_set("bootdev", "SD1");
+			dev_no = 0;
+			break;
+		default:
+			printf("Wrong boot device!");
+	}
+	
+	env_set_ulong("mmcdev", dev_no);
+	
+	/* Set mmcblk env */
+	sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw", dev_no);
+	env_set("mmcroot", mmcblk);
+	
+	sprintf(cmd, "mmc dev %d", dev_no);
+	run_command(cmd, 0);
+}
+#endif
+
 static void setup_iomux_uart(void)
 {
 	imx_iomux_v3_setup_multiple_pads(uart5_pads, ARRAY_SIZE(uart5_pads));
@@ -210,6 +305,10 @@ int board_late_init(void)
 
 	set_wdog_reset(wdog);
 
+#if defined(CONFIG_ENV_IS_IN_MMC) || defined(CONFIG_ENV_IS_NOWHERE)
+	board_late_mmc_init();
+#endif /* CONFIG_ENV_IS_IN_MMC or CONFIG_ENV_IS_NOWHERE */
+
 	/*
 	 * Do not assert internal WDOG_RESET_B_DEB(controlled by bit 4),
 	 * since we use PMIC_PWRON to reset the board.
@@ -219,6 +318,29 @@ int board_late_init(void)
 	return 0;
 }
 
+#ifdef CONFIG_OF_BOARD_SETUP
+int ft_board_setup(void *blob, struct bd_info *bd)
+{
+	const int *cell;
+	int offs;
+	uint32_t cma_size;
+	unsigned int dram_size;
+
+	dram_size = imx_ddr_size() / 1024 / 1024;
+	offs = fdt_path_offset(blob, "/reserved-memory/linux,cma");
+	cell = fdt_getprop(blob, offs, "size", NULL);
+	cma_size = fdt32_to_cpu(cell[0]);
+	if (dram_size == 512) {
+		/* CMA is aligned by 32MB on i.mx8mq,
+		   so CMA size can only be multiple of 32MB */
+		cma_size = env_get_ulong("cma_size", 10, (6 * 32) * 1024 * 1024);
+		fdt_setprop_u32(blob, offs, "size", (uint64_t)cma_size);
+	}
+
+	return 0;
+}
+#endif
+
 int checkboard(void)
 {
 	puts("Board: i.MX7D PICOSOM\n");
@@ -244,3 +366,9 @@ int board_ehci_hcd_init(int port)
 	}
 	return 0;
 }
+
+/* This should be defined for each board */
+__weak int mmc_map_to_kernel_blk(int dev_no)
+{
+    return dev_no;
+}
diff --git a/board/technexion/pico-imx7d/spl.c b/board/technexion/pico-imx7d/pico-imx7d_spl.c
similarity index 50%
rename from board/technexion/pico-imx7d/spl.c
rename to board/technexion/pico-imx7d/pico-imx7d_spl.c
index df5f058577..537a6bd583 100644
--- a/board/technexion/pico-imx7d/spl.c
+++ b/board/technexion/pico-imx7d/pico-imx7d_spl.c
@@ -5,9 +5,9 @@
  * Author: Richard Hu <richard.hu at technexion.com>
  */
 
-#include <common.h>
-#include <cpu_func.h>
 #include <init.h>
+#include <command.h>
+#include <cpu_func.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/imx-regs.h>
 #include <asm/arch/crm_regs.h>
@@ -18,6 +18,7 @@
 #include <asm/gpio.h>
 #include <fsl_esdhc_imx.h>
 #include <spl.h>
+#include <asm/mach-imx/boot_mode.h>
 
 #if defined(CONFIG_SPL_BUILD)
 
@@ -61,6 +62,8 @@ static struct ddrc ddrc_regs_val = {
 	.dramtmg0	= 0x09081109,
 	.addrmap0	= 0x0000001f,
 	.addrmap1	= 0x00080808,
+	.addrmap2	= 0x00000000,
+	.addrmap3	= 0x00000000,
 	.addrmap4	= 0x00000f0f,
 	.addrmap5	= 0x07070707,
 	.addrmap6	= 0x0f0f0707,
@@ -100,17 +103,39 @@ static void gpr_init(void)
 	writel(0x4F400005, &gpr_regs->gpr[1]);
 }
 
+/**********************************************
+* Revision Detection
+*
+* DDR_TYPE_DET_1   DDR_TYPE_DET_2
+*   GPIO_1           GPIO_2
+*     0                1           2GB DDR3
+*     0                0           1GB DDR3
+*     1                0           512MB DDR3
+***********************************************/
 static bool is_1g(void)
 {
 	gpio_direction_input(IMX_GPIO_NR(1, 12));
 	return !gpio_get_value(IMX_GPIO_NR(1, 12));
 }
 
-static void ddr_init(void)
+static bool is_2g(void)
 {
-	if (is_1g())
-		ddrc_regs_val.addrmap6	= 0x0f070707;
+	gpio_direction_input(IMX_GPIO_NR(1, 13));
+	return gpio_get_value(IMX_GPIO_NR(1, 13));
+}
 
+static void ddr_init(void)
+{
+	if (is_1g()) {
+		if (is_2g()) {
+			ddrc_regs_val.addrmap0	= 0x0000001f;
+			ddrc_regs_val.addrmap1	= 0x00181818;
+			ddrc_regs_val.addrmap4	= 0x00000f0f;
+			ddrc_regs_val.addrmap5	= 0x04040404;
+			ddrc_regs_val.addrmap6	= 0x04040404;
+		} else
+			ddrc_regs_val.addrmap6	= 0x0f070707;
+	}
 	mx7_dram_cfg(&ddrc_regs_val, &ddrc_mp_val, &ddr_phy_regs_val,
 		     &calib_param);
 }
@@ -134,7 +159,20 @@ void reset_cpu(void)
 #define USDHC_PAD_CTRL (PAD_CTL_DSE_3P3V_32OHM | PAD_CTL_SRE_SLOW | \
 	PAD_CTL_HYS | PAD_CTL_PUE | PAD_CTL_PUS_PU47KOHM)
 
-static iomux_v3_cfg_t const usdhc3_pads[] = {
+#define USDHC1_CD_GPIO	IMX_GPIO_NR(5, 0)
+/* EMMC/SD */
+static iomux_v3_cfg_t const usdhc1_pads[] = {
+	MX7D_PAD_SD1_CLK__SD1_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_CMD__SD1_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA0__SD1_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA1__SD1_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA2__SD1_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_DATA3__SD1_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+	MX7D_PAD_SD1_CD_B__GPIO5_IO0  | MUX_PAD_CTRL(USDHC_PAD_CTRL),
+};
+
+#define USDHC3_CD_GPIO IMX_GPIO_NR(1, 14)
+static iomux_v3_cfg_t const usdhc3_emmc_pads[] = {
 	MX7D_PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 	MX7D_PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 	MX7D_PAD_SD3_DATA0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
@@ -148,20 +186,83 @@ static iomux_v3_cfg_t const usdhc3_pads[] = {
 	MX7D_PAD_GPIO1_IO14__GPIO1_IO14 | MUX_PAD_CTRL(USDHC_PAD_CTRL),
 };
 
-static struct fsl_esdhc_cfg usdhc_cfg[1] = {
+static struct fsl_esdhc_cfg usdhc_cfg[2] = {
 	{USDHC3_BASE_ADDR},
+	{USDHC1_BASE_ADDR},
 };
 
 int board_mmc_getcd(struct mmc *mmc)
 {
-	/* Assume uSDHC3 emmc is always present */
-	return 1;
+	struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
+	int ret = 0;
+
+	switch (cfg->esdhc_base) {
+	case USDHC1_BASE_ADDR:
+		ret = !gpio_get_value(USDHC1_CD_GPIO); /* Assume uSDHC1 sd is always present */
+		break;
+	case USDHC3_BASE_ADDR:
+		ret = !gpio_get_value(USDHC3_CD_GPIO); /* Assume uSDHC3 emmc is always present */
+		break;
+	}
+
+	return ret;
 }
 
 int board_mmc_init(struct bd_info *bis)
 {
-	imx_iomux_v3_setup_multiple_pads(usdhc3_pads, ARRAY_SIZE(usdhc3_pads));
-	usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
-	return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
+	int ret;
+	u32 index = 0;
+
+	/*
+	 * Following map is done:
+	 * (USDHC)	(Physical Port)
+	 * usdhc3	SOM MicroSD/MMC
+	 * usdhc1	Carrier board MicroSD
+	 * Always set boot USDHC as mmc0
+	 */
+
+	imx_iomux_v3_setup_multiple_pads(
+				usdhc3_emmc_pads, ARRAY_SIZE(usdhc3_emmc_pads));
+	gpio_direction_input(USDHC3_CD_GPIO);
+
+	imx_iomux_v3_setup_multiple_pads(
+				usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
+	gpio_direction_input(USDHC1_CD_GPIO);
+
+	switch (get_boot_device()) {
+		case SD1_BOOT:
+			usdhc_cfg[0].esdhc_base = USDHC1_BASE_ADDR;
+			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+			usdhc_cfg[0].max_bus_width = 4;
+			usdhc_cfg[1].esdhc_base = USDHC3_BASE_ADDR;
+			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+			usdhc_cfg[1].max_bus_width = 4;
+			break;
+		case MMC3_BOOT:
+			usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
+			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+			usdhc_cfg[0].max_bus_width = 8;
+			usdhc_cfg[1].esdhc_base = USDHC1_BASE_ADDR;
+			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+			usdhc_cfg[1].max_bus_width = 4;
+			break;
+		case SD3_BOOT:
+		default:
+			usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
+			usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
+			usdhc_cfg[0].max_bus_width = 4;
+			usdhc_cfg[1].esdhc_base = USDHC1_BASE_ADDR;
+			usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
+			usdhc_cfg[1].max_bus_width = 4;
+			break;
+	}
+
+	for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
+		ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
+		if (ret)
+			return ret;
+	}
+
+	return 0;
 }
 #endif
diff --git a/common/splash.c b/common/splash.c
index 0e520cc103..d29e08c2ce 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -57,7 +57,7 @@ static struct splash_location default_splash_locations[] = {
 
 #include <bmp_logo_data.h>
 
-static int splash_video_logo_load(void)
+int splash_video_logo_load(void)
 {
 	char *splashimage;
 	ulong bmp_load_addr;
diff --git a/configs/pico-dwarf-imx7d_defconfig b/configs/pico-dwarf-imx7d_defconfig
index 3adba803dd..c90237487f 100644
--- a/configs/pico-dwarf-imx7d_defconfig
+++ b/configs/pico-dwarf-imx7d_defconfig
@@ -15,8 +15,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
diff --git a/configs/pico-hobbit-imx7d_defconfig b/configs/pico-hobbit-imx7d_defconfig
index cbfe346820..38070aac44 100644
--- a/configs/pico-hobbit-imx7d_defconfig
+++ b/configs/pico-hobbit-imx7d_defconfig
@@ -15,8 +15,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
diff --git a/configs/pico-imx7d_bl33_defconfig b/configs/pico-imx7d_bl33_defconfig
index a9d21eb02c..8dfdb30f46 100644
--- a/configs/pico-imx7d_bl33_defconfig
+++ b/configs/pico-imx7d_bl33_defconfig
@@ -14,8 +14,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_SYS_MEMTEST_START=0x80000000
 CONFIG_SYS_MEMTEST_END=0xa0000000
diff --git a/configs/pico-imx7d_defconfig b/configs/pico-imx7d_defconfig
index 6a2f87a8bb..1ab569ba7f 100644
--- a/configs/pico-imx7d_defconfig
+++ b/configs/pico-imx7d_defconfig
@@ -15,8 +15,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
diff --git a/configs/pico-nymph-imx7d_defconfig b/configs/pico-nymph-imx7d_defconfig
index 3adba803dd..c90237487f 100644
--- a/configs/pico-nymph-imx7d_defconfig
+++ b/configs/pico-nymph-imx7d_defconfig
@@ -15,8 +15,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
diff --git a/configs/pico-pi-imx7d_defconfig b/configs/pico-pi-imx7d_defconfig
index 79aa398e1e..6fb4da0b9e 100644
--- a/configs/pico-pi-imx7d_defconfig
+++ b/configs/pico-pi-imx7d_defconfig
@@ -15,8 +15,13 @@ CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="imx7d-pico-pi"
 CONFIG_TARGET_PICO_IMX7D=y
 CONFIG_SPL_MMC=y
+CONFIG_SPL_DM_MMC=y
+CONFIG_SPL_MMC_BOOT=y
+CONFIG_MMC_VERBOSE=y
 CONFIG_SPL_SERIAL=y
 CONFIG_SPL=y
+CONFIG_SUPPORT_SPL=y
+CONFIG_SPL_FS_FAT=y
 CONFIG_ARMV7_BOOT_SEC_DEFAULT=y
 CONFIG_IMX_RDC=y
 CONFIG_IMX_BOOTAUX=y
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index 7fbf2c3f55..0e13815952 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -9,19 +9,12 @@
 #define __PICO_IMX7D_CONFIG_H
 
 #include "mx7_common.h"
-
 #include "imx7_spl.h"
 
-#ifdef CONFIG_SPL_OS_BOOT
-/* Falcon Mode */
-
-/* Falcon Mode - MMC support: args at 1MB kernel at 2MB */
-#endif
-
 #define CONFIG_MXC_UART_BASE		UART5_IPS_BASE_ADDR
 
 /* MMC Config */
-#define CONFIG_SYS_FSL_ESDHC_ADDR	0
+#define CONFIG_SYS_FSL_ESDHC_ADDR	USDHC3_BASE_ADDR
 
 #define CONFIG_DFU_ENV_SETTINGS \
 	"dfu_alt_info=" \
@@ -87,9 +80,11 @@
 		"name=rootfs,size=0,uuid=${uuid_gpt_rootfs}\0" \
 	"fastboot_partition_alias_system=rootfs\0" \
 	"setup_emmc=mmc dev 0; gpt write mmc 0 $partitions; reset;\0" \
+	"mmcautodetect=yes\0" \
 	PICO_BOOT_ENV
 
 #define BOOT_TARGET_DEVICES(func) \
+	func(MMC, mmc, 3) \
 	func(MMC, mmc, 0) \
 	func(USB, usb, 0) \
 	func(PXE, pxe, na) \
@@ -98,6 +93,9 @@
 #include <config_distro_bootcmd.h>
 #include <linux/stringify.h>
 
+#define CONFIG_SYS_MEMTEST_START	0x80000000
+#define CONFIG_SYS_MEMTEST_END		(CONFIG_SYS_MEMTEST_START + 0x20000000)
+
 /* Physical Memory Map */
 #define PHYS_SDRAM			MMDC0_ARB_BASE_ADDR
 
@@ -113,10 +111,13 @@
 
 /* Environment starts at 768k = 768 * 1024 = 786432 */
 
-#define CONFIG_SYS_FSL_USDHC_NUM		2
+#define CONFIG_SYS_FSL_USDHC_NUM	2
+
+#define CONFIG_SYS_MMC_ENV_DEV		0
+#define CONFIG_SYS_MMC_ENV_PART		0
 
 /* USB Configs */
-#define CONFIG_MXC_USB_PORTSC			(PORT_PTS_UTMI | PORT_PTS_PTW)
-#define CONFIG_MXC_USB_FLAGS			0
+#define CONFIG_MXC_USB_PORTSC	(PORT_PTS_UTMI | PORT_PTS_PTW)
+#define CONFIG_MXC_USB_FLAGS	0
 
 #endif
-- 
2.35.1.windows.2


More information about the U-Boot mailing list