]> git.sur5r.net Git - u-boot/commitdiff
mx6cuboxi: Load the correct 'fdtfile' variable
authorFabio Estevam <fabio.estevam@freescale.com>
Sat, 25 Apr 2015 21:47:21 +0000 (18:47 -0300)
committerStefano Babic <sbabic@denx.de>
Mon, 27 Apr 2015 11:13:58 +0000 (13:13 +0200)
Instead of hardcoding the 'fdtfile' variable, let's detect the SoC and
board variant on the fly and change the dtb name.

Based on the scheme done on am335x board.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Tested-By: Vagrant Cascadian <vagrant@debian.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
board/solidrun/mx6cuboxi/mx6cuboxi.c
include/configs/mx6cuboxi.h

index 9123255889d2de698d380e938ba3c69701fa0b93..d3a32c1663954394e18d6c822acca77f4c5e6954 100644 (file)
@@ -212,6 +212,31 @@ int checkboard(void)
        return 0;
 }
 
+static bool is_mx6q(void)
+{
+       if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D))
+               return true;
+       else
+               return false;
+}
+
+int board_late_init(void)
+{
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+       if (is_hummingboard())
+               setenv("board_name", "HUMMINGBOARD");
+       else
+               setenv("board_name", "CUBOXI");
+
+       if (is_mx6q())
+               setenv("board_rev", "MX6Q");
+       else
+               setenv("board_rev", "MX6DL");
+#endif
+
+       return 0;
+}
+
 #ifdef CONFIG_SPL_BUILD
 #include <asm/arch/mx6-ddr.h>
 static const struct mx6dq_iomux_ddr_regs mx6q_ddr_ioregs = {
index 98b48d57cd439141b1c0a3de14c2b87c97cdcaa5..b569f344eb5f6e24be3a245edb6b3dc9182b3b66 100644 (file)
@@ -29,6 +29,7 @@
 
 #define CONFIG_SYS_MALLOC_LEN          (2 * SZ_1M)
 #define CONFIG_BOARD_EARLY_INIT_F
+#define CONFIG_BOARD_LATE_INIT
 #define CONFIG_MXC_GPIO
 #define CONFIG_MXC_UART
 #define CONFIG_CMD_FUSE
 #define CONFIG_MXC_UART_BASE   UART1_BASE
 #define CONFIG_CONSOLE_DEV     "ttymxc0"
 #define CONFIG_MMCROOT         "/dev/mmcblk0p2"
-#define CONFIG_DEFAULT_FDT_FILE        "imx6q-hummingboard.dtb"
 #define CONFIG_SYS_FSL_USDHC_NUM       1
 #define CONFIG_SYS_MMC_ENV_DEV         0       /* SDHC2 */
 
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 #define CONFIG_EXTRA_ENV_SETTINGS \
        "script=boot.scr\0" \
        "image=zImage\0" \
-       "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
+       "fdtfile=undefined\0" \
        "fdt_addr_r=0x18000000\0" \
        "boot_fdt=try\0" \
        "ip_dyn=yes\0" \
                        "fi; " \
                "else " \
                        "bootz; " \
-               "fi;\0"
+               "fi;\0" \
+       "findfdt="\
+               "if test $board_name = HUMMINGBOARD && test $board_rev = MX6Q ; then " \
+                       "setenv fdtfile imx6q-hummingboard.dtb; fi; " \
+               "if test $board_name = HUMMINGBOARD && test $board_rev = MX6DL ; then " \
+                       "setenv fdtfile imx6dl-hummingboard.dtb; fi; " \
+               "if test $board_name = CUBOXI && test $board_rev = MX6Q ; then " \
+                       "setenv fdtfile imx6q-cubox-i.dtb; fi; " \
+               "if test $board_name = CUBOXI && test $board_rev = MX6DL ; then " \
+                       "setenv fdtfile imx6dl-cubox-i.dtb; fi; " \
+               "if test $fdtfile = undefined; then " \
+                       "echo WARNING: Could not determine dtb to use; fi; \0" \
 
 #define CONFIG_BOOTCOMMAND \
+       "run findfdt; " \
        "mmc dev ${mmcdev};" \
        "if mmc rescan; then " \
                "if run loadbootscript; then " \