1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Google, Inc
4 * Written by Simon Glass <sjg@chromium.org>
10 #include <linux/libfdt.h>
12 ulong
fdt_getprop_u32(const void *fdt
, int node
, const char *prop
)
17 cell
= fdt_getprop(fdt
, node
, prop
, &len
);
18 if (!cell
|| len
!= sizeof(*cell
))
21 return fdt32_to_cpu(*cell
);
25 * Iterate over all /configurations subnodes and call a platform specific
26 * function to find the matching configuration.
27 * Returns the node offset or a negative error number.
29 int fit_find_config_node(const void *fdt
)
33 const char *dflt_conf_name
;
34 const char *dflt_conf_desc
= NULL
;
35 int dflt_conf_node
= -ENOENT
;
37 conf
= fdt_path_offset(fdt
, FIT_CONFS_PATH
);
39 debug("%s: Cannot find /configurations node: %d\n", __func__
,
44 dflt_conf_name
= fdt_getprop(fdt
, conf
, "default", &len
);
46 for (node
= fdt_first_subnode(fdt
, conf
);
48 node
= fdt_next_subnode(fdt
, node
)) {
49 name
= fdt_getprop(fdt
, node
, "description", &len
);
51 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
52 printf("%s: Missing FDT description in DTB\n",
59 const char *node_name
= fdt_get_name(fdt
, node
, NULL
);
60 if (strcmp(dflt_conf_name
, node_name
) == 0) {
61 dflt_conf_node
= node
;
62 dflt_conf_desc
= name
;
66 if (board_fit_config_name_match(name
))
69 debug("Selecting config '%s'", name
);
74 if (dflt_conf_node
!= -ENOENT
) {
75 debug("Selecting default config '%s'\n", dflt_conf_desc
);
76 return dflt_conf_node
;