[PATCH v1 08/17] colibri-imx8x: construct fdtfile dynamically

Andrejs Cainikovs andrejs.cainikovs at gmail.com
Fri Mar 3 14:26:33 CET 2023


The following expression is used to construct the device tree name:
fdtfile=${soc}-colibri-${fdt_board}.dtb

- soc is set dynamically (either imx8qxp or imx8dx)
- fdt_board can be modified by the user (eval-v3, aster, iris/iris-v2)

Signed-off-by: Andrejs Cainikovs <andrejs.cainikovs at toradex.com>
---
 board/toradex/colibri-imx8x/colibri-imx8x.c | 14 ++++++++++++++
 configs/colibri-imx8x_defconfig             |  2 ++
 include/configs/colibri-imx8x.h             |  3 +--
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c b/board/toradex/colibri-imx8x/colibri-imx8x.c
index 88eddbddaef..6ed9cc4fa80 100644
--- a/board/toradex/colibri-imx8x/colibri-imx8x.c
+++ b/board/toradex/colibri-imx8x/colibri-imx8x.c
@@ -123,6 +123,18 @@ int checkboard(void)
 	return 0;
 }
 
+static void select_dt_from_module_version(void)
+{
+	/*
+	 * The dtb filename is constructed from ${soc}-colibri-${fdt_board}.dtb.
+	 * Set soc depending on the used SoC.
+	 */
+	if (is_imx8dx())
+		env_set("soc", "imx8dx");
+	else
+		env_set("soc", "imx8qxp");
+}
+
 int board_init(void)
 {
 	board_gpio_init();
@@ -158,5 +170,7 @@ int board_late_init(void)
 	env_set("board_rev", "v1.0");
 #endif
 
+	select_dt_from_module_version();
+
 	return 0;
 }
diff --git a/configs/colibri-imx8x_defconfig b/configs/colibri-imx8x_defconfig
index 6a5c6e1d61b..6c1c9978d11 100644
--- a/configs/colibri-imx8x_defconfig
+++ b/configs/colibri-imx8x_defconfig
@@ -20,6 +20,8 @@ CONFIG_FIT=y
 CONFIG_FIT_EXTERNAL_OFFSET=0x3000
 CONFIG_FIT_VERBOSE=y
 CONFIG_OF_SYSTEM_SETUP=y
+CONFIG_USE_PREBOOT=y
+CONFIG_PREBOOT="test -n ${fdtfile} || setenv fdtfile ${soc}-colibri-${fdt_board}.dtb"
 CONFIG_LOG=y
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_DISPLAY_BOARDINFO_LATE=y
diff --git a/include/configs/colibri-imx8x.h b/include/configs/colibri-imx8x.h
index 7826596a331..9a4a5f3b5de 100644
--- a/include/configs/colibri-imx8x.h
+++ b/include/configs/colibri-imx8x.h
@@ -61,8 +61,7 @@
 	"boot_script_dhcp=boot.scr\0" \
 	"console=ttyLP3\0" \
 	"fdt_addr=0x83000000\0"	\
-	"fdt_file=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
-	"fdtfile=fsl-imx8qxp-colibri-dsihdmi-eval-v3.dtb\0" \
+	"fdt_board=eval-v3\0" \
 	"finduuid=part uuid mmc ${mmcdev}:2 uuid\0" \
 	"image=Image\0" \
 	"initrd_addr=0x83800000\0" \
-- 
2.34.1



More information about the U-Boot mailing list