
On 12:50-20240108, Andrew Davis wrote:
On 1/8/24 11:32 AM, Nishanth Menon wrote:
Introduce a common fdt operations library for basic device tree operations that are common between various boards.
The first library to introduce here is the capability to set up fdtfile as a standard variable as part of board identification rather than depend on scripted ifdeffery.
Signed-off-by: Nishanth Menon nm@ti.com
board/ti/common/Kconfig | 12 ++++++++ board/ti/common/Makefile | 1 + board/ti/common/fdt_ops.c | 65 +++++++++++++++++++++++++++++++++++++++ board/ti/common/fdt_ops.h | 41 ++++++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 board/ti/common/fdt_ops.c create mode 100644 board/ti/common/fdt_ops.h
diff --git a/board/ti/common/Kconfig b/board/ti/common/Kconfig index 49edd98014ab..06a8a36aa1cd 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_EVM_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 26bf12e2e6d5..5ac361ba7fcf 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 000000000000..f8770cae4a54 --- /dev/null +++ b/board/ti/common/fdt_ops.c @@ -0,0 +1,65 @@ +// 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 *name_fdt, struct ti_fdt_map *fdt_map) +{
- char *fdt_file_name = NULL;
- char fdtfile[TI_FDT_FILE_MAX];
- if (name_fdt) {
while (fdt_map) {
/* Check for NULL terminator in the list */
if (!fdt_map->name_fdt)
break;
if (!strncmp(fdt_map->name_fdt, name_fdt, TI_NAME_FDT_MAX)) {
fdt_file_name = fdt_map->fdt_file_name;
break;
}
fdt_map++;
}
- }
- /* match not found OR null name_fdt */
- 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_EVM_FDT_FOLDER_PATH, CONFIG_DEFAULT_FDT_FILE);
} else
+#endif
{
snprintf(fdtfile, sizeof(fdtfile), "%s/%s.dtb",
CONFIG_TI_EVM_FDT_FOLDER_PATH,
CONFIG_DEFAULT_DEVICE_TREE);
}
- } else {
snprintf(fdtfile, sizeof(fdtfile), "%s/%s", CONFIG_TI_EVM_FDT_FOLDER_PATH,
fdt_file_name);
- }
- env_set("fdtfile", fdtfile);
- /*
* XXX: DEPRECATION WARNING: 2 u-boot versions.
*
* Maintain compatibility with downstream scripts that may be using
* name_fdt
*/
- if (name_fdt)
env_set("name_fdt", name_fdt);
"name_fdt" should match "fdtfile", you should have just:
env_set("name_fdt", fdtfile);
are you mixing this up with "board_name"?
It should have been fdtfile. Thanks for catching it.