Commit 044fc14bcbcd2a344a2e63c083852fb4af82b96d

Authored by Tom Rini
1 parent 418b7f3aff

am335x_evm: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support

We add CONFIG_ENV_VARS_UBOOT_CONFIG,
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG and CONFIG_BOARD_LATE_INIT to set
the variables and then fdtfile and findfdt to make us of this.  It is
now possible to do 'run findfdt' to have fdtfile be set to the value of
the dtb file to load for the board we are running on.

Signed-off-by: Tom Rini <trini@ti.com>

Showing 2 changed files with 31 additions and 0 deletions Side-by-side Diff

board/ti/am335x/board.c
... ... @@ -299,6 +299,26 @@
299 299 return 0;
300 300 }
301 301  
  302 +#ifdef CONFIG_BOARD_LATE_INIT
  303 +int board_late_init(void)
  304 +{
  305 +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
  306 + char safe_string[HDR_NAME_LEN + 1];
  307 +
  308 + /* Now set variables based on the header. */
  309 + strncpy(safe_string, (char *)header.name, sizeof(header.name));
  310 + safe_string[sizeof(header.name)] = 0;
  311 + setenv("board_name", safe_string);
  312 +
  313 + strncpy(safe_string, (char *)header.version, sizeof(header.version));
  314 + safe_string[sizeof(header.version)] = 0;
  315 + setenv("board_rev", safe_string);
  316 +#endif
  317 +
  318 + return 0;
  319 +}
  320 +#endif
  321 +
302 322 #ifdef CONFIG_DRIVER_TI_CPSW
303 323 static void cpsw_control(int enabled)
304 324 {
include/configs/am335x_evm.h
... ... @@ -29,6 +29,7 @@
29 29 #define CONFIG_SYS_LONGHELP /* undef to save memory */
30 30 #define CONFIG_SYS_HUSH_PARSER /* use "hush" command parser */
31 31 #define CONFIG_SYS_PROMPT "U-Boot# "
  32 +#define CONFIG_BOARD_LATE_INIT
32 33 #define CONFIG_SYS_NO_FLASH
33 34 #define MACH_TYPE_TIAM335EVM 3589 /* Until the next sync */
34 35 #define CONFIG_MACH_TYPE MACH_TYPE_TIAM335EVM
35 36  
... ... @@ -46,11 +47,14 @@
46 47  
47 48 /* set to negative value for no autoboot */
48 49 #define CONFIG_BOOTDELAY 1
  50 +#define CONFIG_ENV_VARS_UBOOT_CONFIG
  51 +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
49 52 #define CONFIG_EXTRA_ENV_SETTINGS \
50 53 "loadaddr=0x80200000\0" \
51 54 "fdtaddr=0x80F80000\0" \
52 55 "rdaddr=0x81000000\0" \
53 56 "bootfile=/boot/uImage\0" \
  57 + "fdtfile=\0" \
54 58 "console=ttyO0,115200n8\0" \
55 59 "optargs=\0" \
56 60 "mmcdev=0\0" \
... ... @@ -79,6 +83,13 @@
79 83 "ramboot=echo Booting from ramdisk ...; " \
80 84 "run ramargs; " \
81 85 "bootm ${loadaddr}\0" \
  86 + "findfdt="\
  87 + "if test $board_name = A335BONE; then " \
  88 + "setenv fdtfile am335x-bone.dtb; fi; " \
  89 + "if test $board_name = A33515BB; then " \
  90 + "setenv fdtfile am335x-evm.dtb; fi; " \
  91 + "if test $board_name = A335X_SK; then " \
  92 + "setenv fdtfile am335x-evmsk.dtb; fi\0" \
82 93  
83 94 #define CONFIG_BOOTCOMMAND \
84 95 "mmc dev ${mmcdev}; if mmc rescan; then " \