The existing logic for handling receiving a devicetree from a previous
phase is quite complicated. Simplify it in preparation for introducing
standard passage.

Add a Kconfig called OF_PASSAGE which indicates that the devicetree
must come from standard passage.

Signed-off-by: Simon Glass <s...@chromium.org>
---

Changes in v3:
- Add new patch to redo how a devicetree is set up

 dts/Kconfig  |  8 ++++++++
 lib/fdtdec.c | 34 ++++++----------------------------
 2 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/dts/Kconfig b/dts/Kconfig
index c544f948a15..57101bddabb 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -159,6 +159,14 @@ config OF_EMBED
          and development only and is not recommended for production devices.
          Boards in the mainline U-Boot tree should not use it.
 
+config OF_PASSAGE
+       bool "DTB is provided by a standard passage, in a bloblist"
+       help
+         Select this to read the devicetree using the standard passage
+         mechanism, i.e. from a previous phase in bloblist using arch-specific
+         register conventions. If enabled, the previous phase must provide
+         the devicetree, or U-Boot will not function correctly.
+
 endchoice
 
 config OF_INITIAL_DTB_READONLY
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index f09c9926a7a..8559616873b 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1689,35 +1689,13 @@ void fdtdec_setup_embed(void)
 
 int fdtdec_setup(void)
 {
-       int ret = -ENOENT;
-
-       /*
-        * If allowing a bloblist, check that first. There was discussion about
-        * adding an OF_BLOBLIST Kconfig, but this was rejected.
-        *
-        * The necessary test is whether the previous phase passed a bloblist,
-        * not whether this phase creates one.
-        */
-       if (CONFIG_IS_ENABLED(BLOBLIST) &&
-           (xpl_prev_phase() != PHASE_TPL ||
-            IS_ENABLED(CONFIG_TPL_BLOBLIST))) {
-               ret = bloblist_maybe_init();
-               if (!ret) {
-                       gd->fdt_blob = bloblist_find(BLOBLISTT_CONTROL_FDT, 0);
-                       if (gd->fdt_blob) {
-                               gd->fdt_src = FDTSRC_BLOBLIST;
-                               log_debug("Devicetree is in bloblist at %p\n",
-                                         gd->fdt_blob);
-                               ret = 0;
-                       } else {
-                               log_debug("No FDT found in bloblist\n");
-                               ret = -ENOENT;
-                       }
-               }
-       }
+       int ret;
 
-       /* Otherwise, the devicetree is typically appended to U-Boot */
-       if (ret) {
+       if (CONFIG_IS_ENABLED(OF_BLOBLIST)) {
+               printf("Previous phase failed to provide standard passage\n");
+               return -ENOENT;
+       } else {
+               /* The devicetree is typically appended to U-Boot */
                if (IS_ENABLED(CONFIG_OF_SEPARATE)) {
                        gd->fdt_blob = fdt_find_separate();
                        gd->fdt_src = FDTSRC_SEPARATE;
-- 
2.43.0

Reply via email to