On blackfin we need to relocate the device tree early on during boot
because it breaks the rules of not accessing BSS before relocation. To
accommodate this, add a check to see if the device tree pointer is already
set up. If it is, leave it alone.

Signed-off-by: Simon Glass <[email protected]>
---

 lib/fdtdec.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 4e619c4..c484950 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1177,26 +1177,31 @@ int fdtdec_decode_display_timing(const void *blob, int 
parent, int index,
 int fdtdec_setup(void)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
+       if (!gd->fdt_blob) {
 # ifdef CONFIG_OF_EMBED
-       /* Get a pointer to the FDT */
-       gd->fdt_blob = __dtb_dt_begin;
+               /* Get a pointer to the FDT */
+               gd->fdt_blob = __dtb_dt_begin;
 # elif defined CONFIG_OF_SEPARATE
 #  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))
-               gd->fdt_blob = (ulong *)&_image_binary_end;
-       else
-               gd->fdt_blob = (ulong *)&__bss_end;
+               /*
+                * FDT is at end of BSS unless it is in a different memory
+                * region
+                */
+               if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
+                       gd->fdt_blob = (ulong *)&_image_binary_end;
+               else
+                       gd->fdt_blob = (ulong *)&__bss_end;
 #  else
-       /* FDT is at end of image */
-       gd->fdt_blob = (ulong *)&_end;
+               /* FDT is at end of image */
+               gd->fdt_blob = (ulong *)&_end;
 #  endif
 # elif defined(CONFIG_OF_HOSTFILE)
-       if (sandbox_read_fdt_from_file()) {
-               puts("Failed to read control FDT\n");
-               return -1;
-       }
+               if (sandbox_read_fdt_from_file()) {
+                       puts("Failed to read control FDT\n");
+                       return -1;
+               }
 # endif
+       }
 # ifndef CONFIG_SPL_BUILD
        /* Allow the early environment to override the fdt address */
        gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16,
-- 
2.8.0.rc3.226.g39d4020

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to