diff options
author | Simon Glass <sjg@chromium.org> | 2021-10-14 12:47:54 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-11-11 19:01:56 -0500 |
commit | 19a91f2464a89402a925fd4a2d8b7e28c804c7cc (patch) | |
tree | 35d48b06f479acac201447cb32fea47a78c87eb5 /boot/common_fit.c | |
parent | 1e72ad6b387c599f477f83cda67ab525c089a9b0 (diff) |
Create a new boot/ directory
Quite a lot of the code in common/relates to booting and images. Before
adding more it seems like a good time to move the code into its own
directory.
Most files with 'boot' or 'image' in them are moved, except:
- autoboot.c which relates to U-Boot automatically running a script
- bootstage.c which relates to U-Boot timing
Drop the removal of boot* files from the output directory, since this
interfers with the symlinks created by tools and there does not appear
to be any such file from my brief testing.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Artem Lapkin <email2tema@gmail.com>
Tested-by: Artem Lapkin <email2tema@gmail.com>
Diffstat (limited to 'boot/common_fit.c')
-rw-r--r-- | boot/common_fit.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/boot/common_fit.c b/boot/common_fit.c new file mode 100644 index 0000000000..cde2dc45e9 --- /dev/null +++ b/boot/common_fit.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (C) 2016 Google, Inc + * Written by Simon Glass <sjg@chromium.org> + */ + +#include <common.h> +#include <errno.h> +#include <image.h> +#include <log.h> +#include <linux/libfdt.h> + +ulong fdt_getprop_u32(const void *fdt, int node, const char *prop) +{ + const u32 *cell; + int len; + + cell = fdt_getprop(fdt, node, prop, &len); + if (!cell || len != sizeof(*cell)) + return FDT_ERROR; + + return fdt32_to_cpu(*cell); +} + +__weak int board_fit_config_name_match(const char *name) +{ + return -EINVAL; +} + +/* + * Iterate over all /configurations subnodes and call a platform specific + * function to find the matching configuration. + * Returns the node offset or a negative error number. + */ +int fit_find_config_node(const void *fdt) +{ + const char *name; + int conf, node, len; + const char *dflt_conf_name; + const char *dflt_conf_desc = NULL; + int dflt_conf_node = -ENOENT; + + conf = fdt_path_offset(fdt, FIT_CONFS_PATH); + if (conf < 0) { + debug("%s: Cannot find /configurations node: %d\n", __func__, + conf); + return -EINVAL; + } + + dflt_conf_name = fdt_getprop(fdt, conf, "default", &len); + + for (node = fdt_first_subnode(fdt, conf); + node >= 0; + node = fdt_next_subnode(fdt, node)) { + name = fdt_getprop(fdt, node, "description", &len); + if (!name) { +#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT + printf("%s: Missing FDT description in DTB\n", + __func__); +#endif + return -EINVAL; + } + + if (dflt_conf_name) { + const char *node_name = fdt_get_name(fdt, node, NULL); + if (strcmp(dflt_conf_name, node_name) == 0) { + dflt_conf_node = node; + dflt_conf_desc = name; + } + } + + if (board_fit_config_name_match(name)) + continue; + + debug("Selecting config '%s'\n", name); + + return node; + } + + if (dflt_conf_node != -ENOENT) { + debug("Selecting default config '%s'\n", dflt_conf_desc); + return dflt_conf_node; + } + + return -ENOENT; +} |