Commit e6fc8995d6654df23387ccac91543a2206cfcb36
Committed by
Stefano Babic
1 parent
8d7794615c
Exists in
v2017.01-smarct4x
and in
30 other branches
imx: mx6sabresd/sabreauto runtime setting fdt_file
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>
Showing 5 changed files with 38 additions and 12 deletions Side-by-side Diff
board/freescale/mx6qsabreauto/mx6qsabreauto.c
... | ... | @@ -522,6 +522,15 @@ |
522 | 522 | add_board_boot_modes(board_boot_modes); |
523 | 523 | #endif |
524 | 524 | |
525 | +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | |
526 | + setenv("board_name", "SABREAUTO"); | |
527 | + | |
528 | + if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) | |
529 | + setenv("board_rev", "MX6Q"); | |
530 | + else if (is_cpu_type(MXC_CPU_MX6DL) || is_cpu_type(MXC_CPU_MX6SOLO)) | |
531 | + setenv("board_rev", "MX6DL"); | |
532 | +#endif | |
533 | + | |
525 | 534 | return 0; |
526 | 535 | } |
527 | 536 |
board/freescale/mx6sabresd/mx6sabresd.c
... | ... | @@ -680,6 +680,16 @@ |
680 | 680 | #ifdef CONFIG_CMD_BMODE |
681 | 681 | add_board_boot_modes(board_boot_modes); |
682 | 682 | #endif |
683 | + | |
684 | +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | |
685 | + setenv("board_name", "SABRESD"); | |
686 | + | |
687 | + if (is_cpu_type(MXC_CPU_MX6Q) || is_cpu_type(MXC_CPU_MX6D)) | |
688 | + setenv("board_rev", "MX6Q"); | |
689 | + else if (is_cpu_type(MXC_CPU_MX6DL) || is_cpu_type(MXC_CPU_MX6SOLO)) | |
690 | + setenv("board_rev", "MX6DL"); | |
691 | +#endif | |
692 | + | |
683 | 693 | return 0; |
684 | 694 | } |
685 | 695 |
include/configs/mx6qsabreauto.h
... | ... | @@ -12,11 +12,6 @@ |
12 | 12 | #define CONFIG_MACH_TYPE 3529 |
13 | 13 | #define CONFIG_MXC_UART_BASE UART4_BASE |
14 | 14 | #define CONFIG_CONSOLE_DEV "ttymxc3" |
15 | -#if defined CONFIG_MX6Q | |
16 | -#define CONFIG_DEFAULT_FDT_FILE "imx6q-sabreauto.dtb" | |
17 | -#elif defined CONFIG_MX6DL | |
18 | -#define CONFIG_DEFAULT_FDT_FILE "imx6dl-sabreauto.dtb" | |
19 | -#endif | |
20 | 15 | #define CONFIG_MMCROOT "/dev/mmcblk0p2" |
21 | 16 | #define PHYS_SDRAM_SIZE (2u * 1024 * 1024 * 1024) |
22 | 17 |
include/configs/mx6sabre_common.h
... | ... | @@ -70,10 +70,12 @@ |
70 | 70 | #define EMMC_ENV "" |
71 | 71 | #endif |
72 | 72 | |
73 | +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG | |
74 | + | |
73 | 75 | #define CONFIG_EXTRA_ENV_SETTINGS \ |
74 | 76 | "script=boot.scr\0" \ |
75 | 77 | "image=zImage\0" \ |
76 | - "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \" \ | |
78 | + "fdt_file=undefined\0" \" \ | |
77 | 79 | "fdt_addr=0x18000000\0" \ |
78 | 80 | "boot_fdt=try\0" \ |
79 | 81 | "ip_dyn=yes\0" \ |
80 | 82 | |
81 | 83 | |
... | ... | @@ -143,9 +145,24 @@ |
143 | 145 | "fi; " \ |
144 | 146 | "else " \ |
145 | 147 | "bootz; " \ |
146 | - "fi;\0" | |
148 | + "fi;\0" \ | |
149 | + "findfdt="\ | |
150 | + "if test $fdt_file = undefined; then " \ | |
151 | + "if test $board_name = SABREAUTO && test $board_rev = MX6Q; then " \ | |
152 | + "setenv fdt_file imx6q-sabreauto.dtb; fi; " \ | |
153 | + "if test $board_name = SABREAUTO && test $board_rev = MX6DL; then " \ | |
154 | + "setenv fdt_file imx6dl-sabreauto.dtb; fi; " \ | |
155 | + "if test $board_name = SABRESD && test $board_rev = MX6Q; then " \ | |
156 | + "setenv fdt_file imx6q-sabresd.dtb; fi; " \ | |
157 | + "if test $board_name = SABRESD && test $board_rev = MX6DL; then " \ | |
158 | + "setenv fdt_file imx6dl-sabresd.dtb; fi; " \ | |
159 | + "if test $fdt_file = undefined; then " \ | |
160 | + "echo WARNING: Could not determine dtb to use; fi; " \ | |
161 | + "fi;\0" \ | |
147 | 162 | |
163 | + | |
148 | 164 | #define CONFIG_BOOTCOMMAND \ |
165 | + "run findfdt;" \ | |
149 | 166 | "mmc dev ${mmcdev};" \ |
150 | 167 | "if mmc rescan; then " \ |
151 | 168 | "if run loadbootscript; then " \ |
include/configs/mx6sabresd.h
... | ... | @@ -19,11 +19,6 @@ |
19 | 19 | #define CONFIG_MXC_UART_BASE UART1_BASE |
20 | 20 | #define CONFIG_CONSOLE_DEV "ttymxc0" |
21 | 21 | #define CONFIG_MMCROOT "/dev/mmcblk1p2" |
22 | -#if defined(CONFIG_MX6Q) | |
23 | -#define CONFIG_DEFAULT_FDT_FILE "imx6q-sabresd.dtb" | |
24 | -#elif defined(CONFIG_MX6DL) | |
25 | -#define CONFIG_DEFAULT_FDT_FILE "imx6dl-sabresd.dtb" | |
26 | -#endif | |
27 | 22 | #define PHYS_SDRAM_SIZE (1u * 1024 * 1024 * 1024) |
28 | 23 | |
29 | 24 | #define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */ |