From: Simon Glass Date: Wed, 7 Sep 2022 02:27:19 +0000 (-0600) Subject: dm: core: Provide a way to reset the device tree X-Git-Tag: v2023.01-rc1~47^2^2~14 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee88ba71acce3455aadef18c725de715e6c9af21;p=pandora-u-boot.git 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 --- diff --git a/common/board_r.c b/common/board_r.c index 50670b5615a..6e1ad2bfce8 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 8b0a1087062..7e9d3be96a2 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -27,6 +27,14 @@ struct ofnode_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 * diff --git a/lib/fdtdec.c b/lib/fdtdec.c index eca01081c5d..64c5b3da15e 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -24,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -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 1fcbae3cd4e..d74df297c43 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -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();