diff options
author | Cooper Jr., Franklin <fcooper@ti.com> | 2017-06-16 17:25:05 -0500 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-07-10 14:24:39 -0400 |
commit | 3863f840fa03f6b93672a5afff74f15d460cb911 (patch) | |
tree | 60d1922970f5732c042ccf2e70a72f7274bcd58f /common/common_fit.c | |
parent | e936f997a956dbcd7ccd414770951f981fa586a1 (diff) | |
download | u-boot-3863f840fa03f6b93672a5afff74f15d460cb911.tar.gz u-boot-3863f840fa03f6b93672a5afff74f15d460cb911.tar.bz2 u-boot-3863f840fa03f6b93672a5afff74f15d460cb911.zip |
spl: fit: Break out some functions into a common file
Some of the functions within spl_fit will be used for non spl purposes.
Instead of duplicating functions simply break the functions to be reused
into its own file.
Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
[trini: Only add the new define to image.h, otherwise we see breakage
due to massive include leakage into host tools in some cases]
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'common/common_fit.c')
-rw-r--r-- | common/common_fit.c | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/common/common_fit.c b/common/common_fit.c new file mode 100644 index 0000000000..5f5f3f9a44 --- /dev/null +++ b/common/common_fit.c @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2016 Google, Inc + * Written by Simon Glass <sjg@chromium.org> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <errno.h> +#include <image.h> +#include <libfdt.h> +#include <spl.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); +} + +/* + * 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; + + conf = fdt_path_offset(fdt, FIT_CONFS_PATH); + if (conf < 0) { + debug("%s: Cannot find /configurations node: %d\n", __func__, + conf); + return -EINVAL; + } + 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 (board_fit_config_name_match(name)) + continue; + + debug("Selecting config '%s'", name); + + return node; + } + + return -ENOENT; +} |