diff options
Diffstat (limited to 'board')
-rw-r--r-- | board/beagle/beagleboneai64/beagleboneai64.c | 14 | ||||
-rw-r--r-- | board/beagle/beagleboneai64/beagleboneai64.env | 1 | ||||
-rw-r--r-- | board/beagle/beagleplay/beagleplay.c | 14 | ||||
-rw-r--r-- | board/beagle/beagleplay/beagleplay.env | 1 | ||||
-rw-r--r-- | board/ti/am62ax/am62ax.env | 1 | ||||
-rw-r--r-- | board/ti/am62ax/evm.c | 10 | ||||
-rw-r--r-- | board/ti/am62x/am62x.env | 1 | ||||
-rw-r--r-- | board/ti/am62x/evm.c | 8 | ||||
-rw-r--r-- | board/ti/am64x/am64x.env | 9 | ||||
-rw-r--r-- | board/ti/am64x/evm.c | 8 | ||||
-rw-r--r-- | board/ti/am65x/am65x.env | 3 | ||||
-rw-r--r-- | board/ti/am65x/evm.c | 2 | ||||
-rw-r--r-- | board/ti/common/Kconfig | 12 | ||||
-rw-r--r-- | board/ti/common/Makefile | 1 | ||||
-rw-r--r-- | board/ti/common/fdt_ops.c | 64 | ||||
-rw-r--r-- | board/ti/common/fdt_ops.h | 42 | ||||
-rw-r--r-- | board/ti/j721e/evm.c | 8 | ||||
-rw-r--r-- | board/ti/j721e/j721e.env | 10 | ||||
-rw-r--r-- | board/ti/j721s2/evm.c | 8 | ||||
-rw-r--r-- | board/ti/j721s2/j721s2.env | 8 | ||||
-rw-r--r-- | board/ti/omap3evm/Kconfig | 2 | ||||
-rw-r--r-- | board/ti/panda/Kconfig | 2 | ||||
-rw-r--r-- | board/ti/sdp4430/Kconfig | 2 |
23 files changed, 197 insertions, 34 deletions
diff --git a/board/beagle/beagleboneai64/beagleboneai64.c b/board/beagle/beagleboneai64/beagleboneai64.c index c8c1c78..c5b4ff7 100644 --- a/board/beagle/beagleboneai64/beagleboneai64.c +++ b/board/beagle/beagleboneai64/beagleboneai64.c @@ -28,3 +28,17 @@ int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); } + +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) +{ + char fdtfile[50]; + + snprintf(fdtfile, sizeof(fdtfile), "%s/%s.dtb", + CONFIG_TI_FDT_FOLDER_PATH, CONFIG_DEFAULT_DEVICE_TREE); + + env_set("fdtfile", fdtfile); + + return 0; +} +#endif diff --git a/board/beagle/beagleboneai64/beagleboneai64.env b/board/beagle/beagleboneai64/beagleboneai64.env index 4f0a94a..647b25d 100644 --- a/board/beagle/beagleboneai64/beagleboneai64.env +++ b/board/beagle/beagleboneai64/beagleboneai64.env @@ -1,5 +1,4 @@ #include <env/ti/ti_common.env> -#include <env/ti/default_findfdt.env> #include <env/ti/mmc.env> name_kern=Image diff --git a/board/beagle/beagleplay/beagleplay.c b/board/beagle/beagleplay/beagleplay.c index 1c376de..20819ec 100644 --- a/board/beagle/beagleplay/beagleplay.c +++ b/board/beagle/beagleplay/beagleplay.c @@ -27,3 +27,17 @@ int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); } + +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) +{ + char fdtfile[50]; + + snprintf(fdtfile, sizeof(fdtfile), "%s/%s.dtb", + CONFIG_TI_FDT_FOLDER_PATH, CONFIG_DEFAULT_DEVICE_TREE); + + env_set("fdtfile", fdtfile); + + return 0; +} +#endif diff --git a/board/beagle/beagleplay/beagleplay.env b/board/beagle/beagleplay/beagleplay.env index 4f0a94a..647b25d 100644 --- a/board/beagle/beagleplay/beagleplay.env +++ b/board/beagle/beagleplay/beagleplay.env @@ -1,5 +1,4 @@ #include <env/ti/ti_common.env> -#include <env/ti/default_findfdt.env> #include <env/ti/mmc.env> name_kern=Image diff --git a/board/ti/am62ax/am62ax.env b/board/ti/am62ax/am62ax.env index a6d967e..334374a 100644 --- a/board/ti/am62ax/am62ax.env +++ b/board/ti/am62ax/am62ax.env @@ -1,5 +1,4 @@ #include <env/ti/ti_common.env> -#include <env/ti/default_findfdt.env> #include <env/ti/mmc.env> name_kern=Image diff --git a/board/ti/am62ax/evm.c b/board/ti/am62ax/evm.c index cd3360a..62d3664 100644 --- a/board/ti/am62ax/evm.c +++ b/board/ti/am62ax/evm.c @@ -13,6 +13,8 @@ #include <fdt_support.h> #include <spl.h> +#include "../common/fdt_ops.h" + int board_init(void) { return 0; @@ -27,3 +29,11 @@ int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); } + +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) +{ + ti_set_fdt_env(NULL, NULL); + return 0; +} +#endif diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env index e53a55c..9cb186c 100644 --- a/board/ti/am62x/am62x.env +++ b/board/ti/am62x/am62x.env @@ -1,5 +1,4 @@ #include <env/ti/ti_common.env> -#include <env/ti/default_findfdt.env> #include <env/ti/mmc.env> name_kern=Image diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c index 88e0215..be578f1 100644 --- a/board/ti/am62x/evm.c +++ b/board/ti/am62x/evm.c @@ -54,6 +54,14 @@ int dram_init(void) return fdtdec_setup_mem_size_base(); } +#ifdef CONFIG_BOARD_LATE_INIT +int board_late_init(void) +{ + ti_set_fdt_env(NULL, NULL); + return 0; +} +#endif + int dram_init_banksize(void) { return fdtdec_setup_memory_banksize(); diff --git a/board/ti/am64x/am64x.env b/board/ti/am64x/am64x.env index efd736b..9a8812d 100644 --- a/board/ti/am64x/am64x.env +++ b/board/ti/am64x/am64x.env @@ -2,14 +2,6 @@ #include <env/ti/mmc.env> #include <env/ti/k3_dfu.env> -findfdt= - if test $board_name = am64x_gpevm; then - setenv name_fdt ti/k3-am642-evm.dtb; fi; - if test $board_name = am64x_skevm; then - setenv name_fdt ti/k3-am642-sk.dtb; fi; - if test $name_fdt = undefined; then - echo WARNING: Could not determine device tree to use; fi; - setenv fdtfile ${name_fdt} name_kern=Image console=ttyS2,115200n8 args_all=setenv optargs earlycon=ns16550a,mmio32,0x02800000 ${mtdparts} @@ -43,7 +35,6 @@ get_fit_usb=load usb ${bootpart} ${addr_fit} usbboot=setenv boot usb; setenv bootpart 0:2; usb start; - run findfdt; run init_usb; run get_kern_usb; run get_fdt_usb; diff --git a/board/ti/am64x/evm.c b/board/ti/am64x/evm.c index a7ca6be..b8de69d 100644 --- a/board/ti/am64x/evm.c +++ b/board/ti/am64x/evm.c @@ -16,6 +16,7 @@ #include <env.h> #include "../common/board_detect.h" +#include "../common/fdt_ops.h" #define board_is_am64x_gpevm() (board_ti_k3_is("AM64-GPEVM") || \ board_ti_k3_is("AM64-EVM") || \ @@ -181,6 +182,12 @@ int checkboard(void) } #ifdef CONFIG_BOARD_LATE_INIT +static struct ti_fdt_map ti_am64_evm_fdt_map[] = { + {"am64x_gpevm", "k3-am642-evm.dtb"}, + {"am64x_skevm", "k3-am642-sk.dtb"}, + { /* Sentinel. */ } +}; + static void setup_board_eeprom_env(void) { char *name = "am64x_gpevm"; @@ -198,6 +205,7 @@ static void setup_board_eeprom_env(void) invalid_eeprom: set_board_info_env_am6(name); + ti_set_fdt_env(name, ti_am64_evm_fdt_map); } static void setup_serial(void) diff --git a/board/ti/am65x/am65x.env b/board/ti/am65x/am65x.env index 286b9c3..814374d 100644 --- a/board/ti/am65x/am65x.env +++ b/board/ti/am65x/am65x.env @@ -5,9 +5,6 @@ #include <env/ti/k3_rproc.env> #endif -findfdt= - setenv name_fdt ti/k3-am654-base-board.dtb; - setenv fdtfile ${name_fdt} name_kern=Image console=ttyS2,115200n8 args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x02800000 diff --git a/board/ti/am65x/evm.c b/board/ti/am65x/evm.c index df20902..3109c9a 100644 --- a/board/ti/am65x/evm.c +++ b/board/ti/am65x/evm.c @@ -22,6 +22,7 @@ #include <linux/printk.h> #include "../common/board_detect.h" +#include "../common/fdt_ops.h" #define board_is_am65x_base_board() board_ti_is("AM6-COMPROCEVM") @@ -141,6 +142,7 @@ static void setup_board_eeprom_env(void) invalid_eeprom: set_board_info_env_am6(name); + ti_set_fdt_env(NULL, NULL); } static int init_daughtercard_det_gpio(char *gpio_name, struct gpio_desc *desc) diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig index 49edd98..de44e4d 100644 --- a/board/ti/common/Kconfig +++ b/board/ti/common/Kconfig @@ -49,3 +49,15 @@ config TI_COMMON_CMD_OPTIONS imply CMD_SPI imply CMD_TIME imply CMD_USB if USB + +config TI_FDT_FOLDER_PATH + string "Location of Folder path where dtb is present" + default "ti/davinci" if ARCH_DAVINCI + default "ti/keystone" if ARCH_KEYSTONE + default "ti/omap" if ARCH_OMAP2PLUS + default "ti" if ARCH_K3 + depends on ARCH_DAVINCI || ARCH_KEYSTONE || ARCH_OMAP2PLUS || ARCH_K3 + help + Folder path for kernel device tree default. + This is used along with fdtfile path to locate the kernel + device tree blob. diff --git a/board/ti/common/Makefile b/board/ti/common/Makefile index 26bf12e..5ac361b 100644 --- a/board/ti/common/Makefile +++ b/board/ti/common/Makefile @@ -3,3 +3,4 @@ obj-${CONFIG_TI_I2C_BOARD_DETECT} += board_detect.o obj-${CONFIG_CMD_EXTENSION} += cape_detect.o +obj-${CONFIG_OF_LIBFDT} += fdt_ops.o diff --git a/board/ti/common/fdt_ops.c b/board/ti/common/fdt_ops.c new file mode 100644 index 0000000..eb917be --- /dev/null +++ b/board/ti/common/fdt_ops.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Library to support FDT file operations which are common + * + * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com/ + */ + +#include <env.h> +#include <vsprintf.h> +#include "fdt_ops.h" + +void ti_set_fdt_env(const char *board_name, struct ti_fdt_map *fdt_map) +{ + char *fdt_file_name = NULL; + char fdtfile[TI_FDT_FILE_MAX]; + + if (board_name) { + while (fdt_map) { + /* Check for NULL terminator in the list */ + if (!fdt_map->board_name) + break; + if (!strncmp(fdt_map->board_name, board_name, TI_BOARD_NAME_MAX)) { + fdt_file_name = fdt_map->fdt_file_name; + break; + } + fdt_map++; + } + } + + /* match not found OR null board_name */ + if (!fdt_file_name) { + /* + * Prioritize CONFIG_DEFAULT_FDT_FILE - if that is not defined, + * or is empty, then use CONFIG_DEFAULT_DEVICE_TREE + */ +#ifdef CONFIG_DEFAULT_FDT_FILE + if (strlen(CONFIG_DEFAULT_FDT_FILE)) { + snprintf(fdtfile, sizeof(fdtfile), "%s/%s", + CONFIG_TI_FDT_FOLDER_PATH, CONFIG_DEFAULT_FDT_FILE); + } else +#endif + { + snprintf(fdtfile, sizeof(fdtfile), "%s/%s.dtb", + CONFIG_TI_FDT_FOLDER_PATH, CONFIG_DEFAULT_DEVICE_TREE); + } + } else { + snprintf(fdtfile, sizeof(fdtfile), "%s/%s", CONFIG_TI_FDT_FOLDER_PATH, + fdt_file_name); + } + + env_set("fdtfile", fdtfile); + + /* + * XXX: DEPRECATION WARNING: 2 u-boot versions (2024.10). + * + * Maintain compatibility with downstream scripts that may be using + * name_fdt + */ + if (board_name) + env_set("name_fdt", fdtfile); + /* Also set the findfdt legacy script to warn users to stop using this */ + env_set("findfdt", + "echo WARN: fdtfile already set. Stop using findfdt in script"); +} diff --git a/board/ti/common/fdt_ops.h b/board/ti/common/fdt_ops.h new file mode 100644 index 0000000..5d30499 --- /dev/null +++ b/board/ti/common/fdt_ops.h @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Library to support common device tree manipulation for TI EVMs + * + * Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com + */ + +#ifndef __FDT_OPS_H +#define __FDT_OPS_H + +#define TI_BOARD_NAME_MAX 20 +#define TI_FDT_FILE_MAX 200 + +/** + * struct ti_fdt_map - mapping of device tree blob name to board name + * @board_name: board_name up to TI_BOARD_NAME_MAX long + * @fdt_file_name: device tree blob name as described by kernel + */ +struct ti_fdt_map { + const char *board_name; + char *fdt_file_name; +}; + +/** + * ti_set_fdt_env - Find the correct device tree file name based on the + * board name and set 'fdtfile' env variable with correct folder + * structure appropriate to the architecture and Linux kernel's + * 'make install_dtbs' conventions. This function is invoked typically + * as part of board_late_init. + * + * fdt name is picked by: + * a) If a board name match is found, use the match + * b) If not, CONFIG_DEFAULT_FDT_FILE (Boot OS device tree) if that is defined + * and not null + * c) If not, Use CONFIG_DEFAULT_DEVICE_TREE (DT control for bootloader) + * + * @board_name: match to search with (max of TI_BOARD_NAME_MAX chars) + * @fdt_map: NULL terminated array of device tree file name matches. + */ +void ti_set_fdt_env(const char *board_name, struct ti_fdt_map *fdt_map); + +#endif /* __FDT_OPS_H */ diff --git a/board/ti/j721e/evm.c b/board/ti/j721e/evm.c index b77cffc..9dc3ed6 100644 --- a/board/ti/j721e/evm.c +++ b/board/ti/j721e/evm.c @@ -16,6 +16,7 @@ #include <dm.h> #include "../common/board_detect.h" +#include "../common/fdt_ops.h" #define board_is_j721e_som() (board_ti_k3_is("J721EX-PM1-SOM") || \ board_ti_k3_is("J721EX-PM2-SOM")) @@ -353,6 +354,12 @@ static int probe_daughtercards(void) #endif #ifdef CONFIG_BOARD_LATE_INIT +static struct ti_fdt_map ti_j721e_evm_fdt_map[] = { + {"j721e", "k3-j721e-common-proc-board.dtb"}, + {"j721e-sk", "k3-j721e-sk.dtb"}, + {"j7200", "k3-j7200-common-proc-board.dtb"}, + { /* Sentinel. */ } +}; static void setup_board_eeprom_env(void) { char *name = "j721e"; @@ -372,6 +379,7 @@ static void setup_board_eeprom_env(void) invalid_eeprom: set_board_info_env_am6(name); + ti_set_fdt_env(name, ti_j721e_evm_fdt_map); } static void setup_serial(void) diff --git a/board/ti/j721e/j721e.env b/board/ti/j721e/j721e.env index cb27bf5..38bfd7d 100644 --- a/board/ti/j721e/j721e.env +++ b/board/ti/j721e/j721e.env @@ -7,16 +7,6 @@ #include <env/ti/k3_rproc.env> #endif -default_device_tree=ti/k3-j721e-common-proc-board.dtb -findfdt= - setenv name_fdt ${default_device_tree}; - if test $board_name = j721e; then - setenv name_fdt ti/k3-j721e-common-proc-board.dtb; fi; - if test $board_name = j7200; then - setenv name_fdt ti/k3-j7200-common-proc-board.dtb; fi; - if test $board_name = j721e-eaik || test $board_name = j721e-sk; then - setenv name_fdt ti/k3-j721e-sk.dtb; fi; - setenv fdtfile ${name_fdt} name_kern=Image console=ttyS2,115200n8 args_all=setenv optargs earlycon=ns16550a,mmio32,0x02800000 diff --git a/board/ti/j721s2/evm.c b/board/ti/j721s2/evm.c index 1220cd8..5a0281d 100644 --- a/board/ti/j721s2/evm.c +++ b/board/ti/j721s2/evm.c @@ -23,6 +23,7 @@ #include <dm/root.h> #include "../common/board_detect.h" +#include "../common/fdt_ops.h" DECLARE_GLOBAL_DATA_PTR; @@ -114,6 +115,12 @@ int checkboard(void) return 0; } +static struct ti_fdt_map ti_j721s2_evm_fdt_map[] = { + {"j721s2", "k3-j721s2-common-proc-board.dtb"}, + {"am68-sk", "k3-am68-sk-base-board.dtb"}, + { /* Sentinel. */ } +}; + static void setup_board_eeprom_env(void) { char *name = "j721s2"; @@ -131,6 +138,7 @@ static void setup_board_eeprom_env(void) invalid_eeprom: set_board_info_env_am6(name); + ti_set_fdt_env(name, ti_j721s2_evm_fdt_map); } static void setup_serial(void) diff --git a/board/ti/j721s2/j721s2.env b/board/ti/j721s2/j721s2.env index 64e3d9d..9a03b9f 100644 --- a/board/ti/j721s2/j721s2.env +++ b/board/ti/j721s2/j721s2.env @@ -7,14 +7,6 @@ #include <env/ti/k3_rproc.env> #endif -default_device_tree=ti/k3-j721s2-common-proc-board.dtb -findfdt= - setenv name_fdt ${default_device_tree}; - if test $board_name = j721s2; then \ - setenv name_fdt ti/k3-j721s2-common-proc-board.dtb; fi; - if test $board_name = am68-sk; then - setenv name_fdt ti/k3-am68-sk-base-board.dtb; fi; - setenv fdtfile ${name_fdt} name_kern=Image console=ttyS2,115200n8 args_all=setenv optargs earlycon=ns16550a,mmio32,0x02880000 diff --git a/board/ti/omap3evm/Kconfig b/board/ti/omap3evm/Kconfig index 08a8aa2..cd71fe0 100644 --- a/board/ti/omap3evm/Kconfig +++ b/board/ti/omap3evm/Kconfig @@ -9,4 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "omap3_evm" +source "board/ti/common/Kconfig" + endif diff --git a/board/ti/panda/Kconfig b/board/ti/panda/Kconfig index 8f277b6..5912f69 100644 --- a/board/ti/panda/Kconfig +++ b/board/ti/panda/Kconfig @@ -9,4 +9,6 @@ config SYS_VENDOR config SYS_CONFIG_NAME default "omap4_panda" +source "board/ti/common/Kconfig" + endif diff --git a/board/ti/sdp4430/Kconfig b/board/ti/sdp4430/Kconfig index 36f1852..65e9107 100644 --- a/board/ti/sdp4430/Kconfig +++ b/board/ti/sdp4430/Kconfig @@ -12,4 +12,6 @@ config SYS_CONFIG_NAME config CMD_BAT bool "Enable board-specific battery command" +source "board/ti/common/Kconfig" + endif |