diff options
| author | Simon Glass <[email protected]> | 2022-07-30 15:52:08 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2022-08-12 08:14:23 -0400 |
| commit | 331048471dee5c1d9cede54382256e6cfaee2370 (patch) | |
| tree | d12f08911b3f33b1da5ec9970ee1995aef23e6fe /include/dm/ofnode.h | |
| parent | 72b338aa2cd4afff8e92ab28199bc2db073cfea7 (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 <[email protected]>
Diffstat (limited to 'include/dm/ofnode.h')
| -rw-r--r-- | include/dm/ofnode.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 5a5309d79a7..d7ad5dccc14 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -177,6 +177,23 @@ static inline ofnode ofnode_root(void) } /** + * oftree_default() - Returns the default device tree (U-Boot's control FDT) + * + * Returns: reference to the control FDT + */ +static inline oftree oftree_default(void) +{ + oftree tree; + + if (of_live_active()) + tree.np = gd_of_root(); + else + tree.fdt = (void *)gd->fdt_blob; + + return tree; +} + +/** * ofnode_name_eq() - Check if the node name is equivalent to a given name * ignoring the unit address * @@ -640,12 +657,23 @@ int ofnode_count_phandle_with_args(ofnode node, const char *list_name, /** * ofnode_path() - find a node by full path * + * This uses the control FDT. + * * @path: Full path to node, e.g. "/bus/spi@1" * Return: reference to the node found. Use ofnode_valid() to check if it exists */ ofnode ofnode_path(const char *path); /** + * ofnode_path_root() - find a node by full path from a root node + * + * @tree: Device tree to use + * @path: Full path to node, e.g. "/bus/spi@1" + * Return: reference to the node found. Use ofnode_valid() to check if it exists + */ +ofnode ofnode_path_root(oftree tree, const char *path); + +/** * ofnode_read_chosen_prop() - get the value of a chosen property * * This looks for a property within the /chosen node and returns its value |
