1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
11 #include <linux/libfdt.h>
13 ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
18 cell = fdt_getprop(fdt, node, prop, &len);
19 if (!cell || len != sizeof(*cell))
22 return fdt32_to_cpu(*cell);
25 __weak int board_fit_config_name_match(const char *name)
31 * Iterate over all /configurations subnodes and call a platform specific
32 * function to find the matching configuration.
33 * Returns the node offset or a negative error number.
35 int fit_find_config_node(const void *fdt)
39 const char *dflt_conf_name;
40 const char *dflt_conf_desc = NULL;
41 int dflt_conf_node = -ENOENT;
43 conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
45 debug("%s: Cannot find /configurations node: %d\n", __func__,
50 dflt_conf_name = fdt_getprop(fdt, conf, "default", &len);
52 for (node = fdt_first_subnode(fdt, conf);
54 node = fdt_next_subnode(fdt, node)) {
55 name = fdt_getprop(fdt, node, "description", &len);
57 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
58 printf("%s: Missing FDT description in DTB\n",
65 const char *node_name = fdt_get_name(fdt, node, NULL);
66 if (strcmp(dflt_conf_name, node_name) == 0) {
67 dflt_conf_node = node;
68 dflt_conf_desc = name;
72 if (board_fit_config_name_match(name))
75 debug("Selecting config '%s'\n", name);
80 if (dflt_conf_node != -ENOENT) {
81 debug("Selecting default config '%s'\n", dflt_conf_desc);
82 return dflt_conf_node;