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>
This commit is contained in:
Simon Glass 2022-09-06 20:27:19 -06:00 committed by Tom Rini
parent 66d0d0c188
commit ee88ba71ac
4 changed files with 16 additions and 1 deletions

View File

@ -234,6 +234,8 @@ static int initr_dm(void)
{ {
int ret; int ret;
oftree_reset();
/* Save the pre-reloc driver model and start a new one */ /* Save the pre-reloc driver model and start a new one */
gd->dm_root_f = gd->dm_root; gd->dm_root_f = gd->dm_root;
gd->dm_root = NULL; gd->dm_root = NULL;

View File

@ -27,6 +27,14 @@ struct ofnode_phandle_args {
uint32_t args[OF_MAX_PHANDLE_ARGS]; uint32_t args[OF_MAX_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 * ofnode_to_np() - convert an ofnode to a live DT node pointer
* *

View File

@ -13,7 +13,6 @@
#include <log.h> #include <log.h>
#include <malloc.h> #include <malloc.h>
#include <net.h> #include <net.h>
#include <dm/of_extra.h>
#include <env.h> #include <env.h>
#include <errno.h> #include <errno.h>
#include <fdtdec.h> #include <fdtdec.h>
@ -24,6 +23,8 @@
#include <serial.h> #include <serial.h>
#include <asm/global_data.h> #include <asm/global_data.h>
#include <asm/sections.h> #include <asm/sections.h>
#include <dm/ofnode.h>
#include <dm/of_extra.h>
#include <linux/ctype.h> #include <linux/ctype.h>
#include <linux/lzo.h> #include <linux/lzo.h>
#include <linux/ioport.h> #include <linux/ioport.h>
@ -1668,6 +1669,8 @@ int fdtdec_setup(void)
ret = fdtdec_prepare_fdt(); ret = fdtdec_prepare_fdt();
if (!ret) if (!ret)
ret = fdtdec_board_setup(gd->fdt_blob); ret = fdtdec_board_setup(gd->fdt_blob);
oftree_reset();
return ret; return ret;
} }

View File

@ -11,6 +11,7 @@
#include <event.h> #include <event.h>
#include <of_live.h> #include <of_live.h>
#include <os.h> #include <os.h>
#include <dm/ofnode.h>
#include <dm/root.h> #include <dm/root.h>
#include <dm/test.h> #include <dm/test.h>
#include <dm/uclass-internal.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 */ /* Determine whether to make the live tree available */
gd_set_of_root(of_live ? uts->of_root : NULL); gd_set_of_root(of_live ? uts->of_root : NULL);
oftree_reset();
ut_assertok(dm_init(of_live)); ut_assertok(dm_init(of_live));
uts->root = dm_root(); uts->root = dm_root();