imx: mx6sabresd/sabreauto runtime setting fdt_file
authorPeng Fan <Peng.Fan@freescale.com>
Sat, 11 Jul 2015 03:38:46 +0000 (11:38 +0800)
committerStefano Babic <sbabic@denx.de>
Sun, 2 Aug 2015 08:47:05 +0000 (10:47 +0200)
Detect the SOC and board variant at runtime and change the dtb name,
but not hardcoding the fdt_file env variable.

Take the following patch as a reference.
Íd58699b157df75f1aa0b363ea9c21add21a0c
"mx6cuboxi: Load the correct 'fdtfile' variable"

Signed-off-by: Peng Fan <Peng.Fan@freescale.com>
Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Acked-by: Stefano Babic <sbabic@denx.de>
board/freescale/mx6qsabreauto/mx6qsabreauto.c
board/freescale/mx6sabresd/mx6sabresd.c
include/configs/mx6qsabreauto.h
include/configs/mx6sabre_common.h
include/configs/mx6sabresd.h

index b76e4eb528a1eb58d22f28fee74796b289e8a0a7..943a4bd5d5742099343832e6d521a1d3d5e8eab4 100644 (file)
@@ -522,6 +522,15 @@ int board_late_init(void)
        add_board_boot_modes(board_boot_modes);
 #endif
 
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       setenv("board_name", "SABREAUTO");
+
+       if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
+               setenv("board_rev", "MX6Q");
+       else if (is_cpu_type(MXC_CPU_MX6DL) || is_cpu_type(MXC_CPU_MX6SOLO))
+               setenv("board_rev", "MX6DL");
+#endif
+
        return 0;
 }
 
index fa800f4b22bfd2c07a90482cb5f9102d43370500..eb8a8b38266a7fa685f15066eb234d1a630386c1 100644 (file)
@@ -680,6 +680,16 @@ int board_late_init(void)
 #ifdef CONFIG_CMD_BMODE
        add_board_boot_modes(board_boot_modes);
 #endif
+
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       setenv("board_name", "SABRESD");
+
+       if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
+               setenv("board_rev", "MX6Q");
+       else if (is_cpu_type(MXC_CPU_MX6DL) || is_cpu_type(MXC_CPU_MX6SOLO))
+               setenv("board_rev", "MX6DL");
+#endif
+
        return 0;
 }
 
index 22603442d73f79903434584f7c68e7129585c3b1..11cf538b0adfcc63c3fd248e4718875dcc3cb263 100644 (file)
 #define CONFIG_MACH_TYPE       3529
 #define CONFIG_MXC_UART_BASE   UART4_BASE
 #define CONFIG_CONSOLE_DEV             "ttymxc3"
-#if defined CONFIG_MX6Q
-#define CONFIG_DEFAULT_FDT_FILE        "imx6q-sabreauto.dtb"
-#elif defined CONFIG_MX6DL
-#define CONFIG_DEFAULT_FDT_FILE        "imx6dl-sabreauto.dtb"
-#endif
 #define CONFIG_MMCROOT                 "/dev/mmcblk0p2"
 #define PHYS_SDRAM_SIZE                (2u * 1024 * 1024 * 1024)
 
index e42dfc90453dc3dec4de2d1de5d1f24516bc6abb..903ab1860e15f10f2fd869c5882f6ee43a361e21 100644 (file)
 #define EMMC_ENV ""
 #endif
 
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
        "script=boot.scr\0" \
        "image=zImage\0" \
-       "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
+       "fdt_file=undefined\0" \
        "fdt_addr=0x18000000\0" \
        "boot_fdt=try\0" \
        "ip_dyn=yes\0" \
                        "fi; " \
                "else " \
                        "bootz; " \
-               "fi;\0"
+               "fi;\0" \
+               "findfdt="\
+                       "if test $fdt_file = undefined; then " \
+                               "if test $board_name = SABREAUTO && test $board_rev = MX6Q; then " \
+                                       "setenv fdt_file imx6q-sabreauto.dtb; fi; " \
+                               "if test $board_name = SABREAUTO && test $board_rev = MX6DL; then " \
+                                       "setenv fdt_file imx6dl-sabreauto.dtb; fi; " \
+                               "if test $board_name = SABRESD && test $board_rev = MX6Q; then " \
+                                       "setenv fdt_file imx6q-sabresd.dtb; fi; " \
+                               "if test $board_name = SABRESD && test $board_rev = MX6DL; then " \
+                                       "setenv fdt_file imx6dl-sabresd.dtb; fi; " \
+                               "if test $fdt_file = undefined; then " \
+                                       "echo WARNING: Could not determine dtb to use; fi; " \
+                       "fi;\0" \
+
 
 #define CONFIG_BOOTCOMMAND \
+       "run findfdt;" \
        "mmc dev ${mmcdev};" \
        "if mmc rescan; then " \
                "if run loadbootscript; then " \
index 41162ca202160e86749284e20f99e5f4ac88955c..5f635ca6c5a9fc4cd897632d84f9e69b119ef9f5 100644 (file)
 #define CONFIG_MXC_UART_BASE   UART1_BASE
 #define CONFIG_CONSOLE_DEV             "ttymxc0"
 #define CONFIG_MMCROOT                 "/dev/mmcblk1p2"
-#if defined(CONFIG_MX6Q)
-#define CONFIG_DEFAULT_FDT_FILE        "imx6q-sabresd.dtb"
-#elif defined(CONFIG_MX6DL)
-#define CONFIG_DEFAULT_FDT_FILE        "imx6dl-sabresd.dtb"
-#endif
 #define PHYS_SDRAM_SIZE                (1u * 1024 * 1024 * 1024)
 
 #define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */