summaryrefslogtreecommitdiff
path: root/drivers/core/ofnode.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-07-30 15:52:08 -0600
committerTom Rini <trini@konsulko.com>2022-08-12 08:14:23 -0400
commit331048471dee5c1d9cede54382256e6cfaee2370 (patch)
treed12f08911b3f33b1da5ec9970ee1995aef23e6fe /drivers/core/ofnode.c
parent72b338aa2cd4afff8e92ab28199bc2db073cfea7 (diff)
dm: core: Introduce support for multiple trees
At present ofnode only works with a single device tree, for the most part. This is the control FDT used by U-Boot. When booting an OS we may obtain a different device tree and want to modify it. Add some initial support for this into the ofnode API. Note that we don't permit aliases in this other device tree, since the of_access implementation maintains a list of aliases collected at start-up. Also, we don't need aliases to do fixups in the other FDT. So make sure that flat tree and live tree processing are consistent in this area. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/core/ofnode.c')
-rw-r--r--drivers/core/ofnode.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index a59832ebbfb..bd41ef503c2 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -552,6 +552,17 @@ ofnode ofnode_path(const char *path)
return offset_to_ofnode(fdt_path_offset(gd->fdt_blob, path));
}
+ofnode ofnode_path_root(oftree tree, const char *path)
+{
+ if (of_live_active())
+ return np_to_ofnode(of_find_node_opts_by_path(tree.np, path,
+ NULL));
+ else if (*path != '/' && tree.fdt != gd->fdt_blob)
+ return ofnode_null(); /* Aliases only on control FDT */
+ else
+ return offset_to_ofnode(fdt_path_offset(tree.fdt, path));
+}
+
const void *ofnode_read_chosen_prop(const char *propname, int *sizep)
{
ofnode chosen_node;