diff options
author | Simon Glass <sjg@chromium.org> | 2023-06-01 10:22:42 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2023-07-14 12:54:51 -0400 |
commit | a8f2ac2ae6f15b675a55bcf3a20181f3bb223562 (patch) | |
tree | 022b4468cec581d4b7457507dd787d656a709eb1 /drivers | |
parent | c8a4e293863348c27d0119cbbe425b91d500cec1 (diff) | |
download | u-boot-a8f2ac2ae6f15b675a55bcf3a20181f3bb223562.zip u-boot-a8f2ac2ae6f15b675a55bcf3a20181f3bb223562.tar.gz u-boot-a8f2ac2ae6f15b675a55bcf3a20181f3bb223562.tar.bz2 |
fdt: Allow more general use of livetree
At present livetree can only be used for the control FDT. It is useful
to be able to use the ofnode API for other FDTs, e.g. those used by
the upcoming configuration editor.
We already have most of the support present, and tests can be marked with
the UT_TESTF_OTHER_FDT flag to use another FDT as a special case. But
with this change, the functionality becomes more generally available.
Plumb in the require support.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/core/ofnode.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index dee890b..8df16e5 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -12,6 +12,7 @@ #include <fdt_support.h> #include <log.h> #include <malloc.h> +#include <of_live.h> #include <linux/libfdt.h> #include <dm/of_access.h> #include <dm/of_addr.h> @@ -51,6 +52,20 @@ static oftree oftree_ensure(void *fdt) oftree tree; int i; + if (of_live_active()) { + struct device_node *root; + int ret; + + ret = unflatten_device_tree(fdt, &root); + if (ret) { + log_err("Failed to create live tree: err=%d\n", ret); + return oftree_null(); + } + tree = oftree_from_np(root); + + return tree; + } + if (gd->flags & GD_FLG_RELOC) { i = oftree_find(fdt); if (i == -1) { @@ -60,11 +75,6 @@ static oftree oftree_ensure(void *fdt) return oftree_null(); } - if (of_live_active()) { - log_err("Cannot register a flattree when OF_LIVE is active\n"); - return oftree_null(); - } - /* register the new tree */ i = oftree_count++; oftree_list[i] = fdt; @@ -82,6 +92,12 @@ static oftree oftree_ensure(void *fdt) return tree; } +void oftree_dispose(oftree tree) +{ + if (of_live_active()) + of_live_free(tree.np); +} + void *ofnode_lookup_fdt(ofnode node) { if (gd->flags & GD_FLG_RELOC) { |