aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-09-06 20:27:19 -0600
committerTom Rini <trini@konsulko.com>2022-09-29 16:11:31 -0400
commit3af777959a128a26281e60e20fbeaa52c01a6f7e (patch)
treecaa337c76cbd409a249480a8af4a4b6c6a68b16d
parentc4b45206ee65123864b4eb5225b9c2ca135c2335 (diff)
downloadu-boot-3af777959a128a26281e60e20fbeaa52c01a6f7e.zip
u-boot-3af777959a128a26281e60e20fbeaa52c01a6f7e.tar.gz
u-boot-3af777959a128a26281e60e20fbeaa52c01a6f7e.tar.bz2
dm: core: Provide a way to reset the device tree
At present there is only one device tree used by the ofnode functions, except for some esoteric use of live tree. In preparation for supporting more than one, add a way to reset the list of device trees. For now this does nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--common/board_r.c2
-rw-r--r--include/dm/ofnode.h8
-rw-r--r--lib/fdtdec.c5
-rw-r--r--test/test-main.c2
4 files changed, 16 insertions, 1 deletions
diff --git a/common/board_r.c b/common/board_r.c
index 50670b5..6e1ad2b 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -234,6 +234,8 @@ static int initr_dm(void)
{
int ret;
+ oftree_reset();
+
/* Save the pre-reloc driver model and start a new one */
gd->dm_root_f = gd->dm_root;
gd->dm_root = NULL;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 8b0a108..7e9d3be 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -28,6 +28,14 @@ struct ofnode_phandle_args {
};
/**
+ * oftree_reset() - reset the state of the oftree list
+ *
+ * Reset the oftree list so it can be started again. This should be called
+ * once the control FDT is in place, but before the ofnode interface is used.
+ */
+static inline void oftree_reset(void) {}
+
+/**
* ofnode_to_np() - convert an ofnode to a live DT node pointer
*
* This cannot be called if the reference contains an offset.
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index eca0108..64c5b3d 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -13,7 +13,6 @@
#include <log.h>
#include <malloc.h>
#include <net.h>
-#include <dm/of_extra.h>
#include <env.h>
#include <errno.h>
#include <fdtdec.h>
@@ -24,6 +23,8 @@
#include <serial.h>
#include <asm/global_data.h>
#include <asm/sections.h>
+#include <dm/ofnode.h>
+#include <dm/of_extra.h>
#include <linux/ctype.h>
#include <linux/lzo.h>
#include <linux/ioport.h>
@@ -1668,6 +1669,8 @@ int fdtdec_setup(void)
ret = fdtdec_prepare_fdt();
if (!ret)
ret = fdtdec_board_setup(gd->fdt_blob);
+ oftree_reset();
+
return ret;
}
diff --git a/test/test-main.c b/test/test-main.c
index 1fcbae3..d74df29 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -11,6 +11,7 @@
#include <event.h>
#include <of_live.h>
#include <os.h>
+#include <dm/ofnode.h>
#include <dm/root.h>
#include <dm/test.h>
#include <dm/uclass-internal.h>
@@ -99,6 +100,7 @@ static int dm_test_pre_run(struct unit_test_state *uts)
/* Determine whether to make the live tree available */
gd_set_of_root(of_live ? uts->of_root : NULL);
+ oftree_reset();
ut_assertok(dm_init(of_live));
uts->root = dm_root();