fdt: Don't call board_fdt_blob_setup() without OF_BOARD
authorSimon Glass <sjg@chromium.org>
Fri, 17 Dec 2021 03:59:31 +0000 (20:59 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 23 Dec 2021 15:24:40 +0000 (10:24 -0500)
At present this override function is called even when OF_BOARD is not
enabled. This makes it impossible to disable this feature and in fact
makes the OF_BOARD option useless.

Reinstate its intended purpose, so that it is possible to switch between
the appended devicetree and one provided by the board's custom function.

A follower patch adds warnings for this scenario, but for now we don't
have a Kconfig that definitively tells us that OF_BOARD should be used.

Signed-off-by: Simon Glass <sjg@chromium.org>
include/fdtdec.h
lib/fdtdec.c

index 6878611..68a36f1 100644 (file)
@@ -1170,10 +1170,13 @@ int fdtdec_resetup(int *rescan);
 
 /**
  * Board-specific FDT initialization. Returns the address to a device tree blob.
- * Called when CONFIG_OF_BOARD is defined, or if CONFIG_OF_SEPARATE is defined
- * and the board implements it.
+ *
+ * Called when CONFIG_OF_BOARD is defined.
+ *
+ * The existing devicetree is available at gd->fdt_blob
  *
  * @err internal error code if we fail to setup a DTB
+ * @returns new devicetree blob pointer
  */
 void *board_fdt_blob_setup(int *err);
 
index a7f6212..31a509b 100644 (file)
@@ -1203,15 +1203,15 @@ static int uncompress_blob(const void *src, ulong sz_src, void **dstp)
        return 0;
 }
 
-/*
- * For CONFIG_OF_SEPARATE, the board may optionally implement this to
- * provide and/or fixup the fdt.
+/**
+ * fdt_find_separate() - Find a devicetree at the end of the image
+ *
+ * @return pointer to FDT blob
  */
-__weak void *board_fdt_blob_setup(int *err)
+static void *fdt_find_separate(void)
 {
        void *fdt_blob = NULL;
 
-       *err = 0;
 #ifdef CONFIG_SPL_BUILD
        /* FDT is at end of BSS unless it is in a different memory region */
        if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
@@ -1626,13 +1626,16 @@ int fdtdec_setup(void)
        int ret;
 
        /* The devicetree is typically appended to U-Boot */
-       if (IS_ENABLED(CONFIG_OF_SEPARATE) || IS_ENABLED(CONFIG_OF_BOARD)) {
-               /* Allow the board to override the fdt address. */
+       if (IS_ENABLED(CONFIG_OF_SEPARATE))
+               gd->fdt_blob = fdt_find_separate();
+       else /* embed dtb in ELF file for testing / development */
+               gd->fdt_blob = dtb_dt_embedded();
+
+       /* Allow the board to override the fdt address. */
+       if (IS_ENABLED(CONFIG_OF_BOARD)) {
                gd->fdt_blob = board_fdt_blob_setup(&ret);
                if (ret)
                        return ret;
-       } else { /* embed dtb in ELF file for testing / development */
-               gd->fdt_blob = dtb_dt_embedded();
        }
 
        if (!IS_ENABLED(CONFIG_SPL_BUILD)) {