]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - common/common_fit.c
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>
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
);
26 * Iterate over all /configurations subnodes and call a platform specific
27 * function to find the matching configuration.
28 * Returns the node offset or a negative error number.
30 int fit_find_config_node(const void *fdt
)
34 const char *dflt_conf_name
;
35 const char *dflt_conf_desc
= NULL
;
36 int dflt_conf_node
= -ENOENT
;
38 conf
= fdt_path_offset(fdt
, FIT_CONFS_PATH
);
40 debug("%s: Cannot find /configurations node: %d\n", __func__
,
45 dflt_conf_name
= fdt_getprop(fdt
, conf
, "default", &len
);
47 for (node
= fdt_first_subnode(fdt
, conf
);
49 node
= fdt_next_subnode(fdt
, node
)) {
50 name
= fdt_getprop(fdt
, node
, "description", &len
);
52 #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
53 printf("%s: Missing FDT description in DTB\n",
60 const char *node_name
= fdt_get_name(fdt
, node
, NULL
);
61 if (strcmp(dflt_conf_name
, node_name
) == 0) {
62 dflt_conf_node
= node
;
63 dflt_conf_desc
= name
;
67 if (board_fit_config_name_match(name
))
70 debug("Selecting config '%s'", name
);
75 if (dflt_conf_node
!= -ENOENT
) {
76 debug("Selecting default config '%s'\n", dflt_conf_desc
);
77 return dflt_conf_node
;