fdt: Show a runtime warning based on devicetree source
[platform/kernel/u-boot.git] / common / board_r.c
index 0cbe5f7..6d52066 100644 (file)
@@ -67,6 +67,7 @@
 #endif
 #include <asm/sections.h>
 #include <dm/root.h>
+#include <dm/ofnode.h>
 #include <linux/compiler.h>
 #include <linux/err.h>
 #include <efi_loader.h>
@@ -448,8 +449,7 @@ static int initr_pvblock(void)
 static int should_load_env(void)
 {
        if (IS_ENABLED(CONFIG_OF_CONTROL))
-               return fdtdec_get_config_int(gd->fdt_blob,
-                                               "load-environment", 1);
+               return ofnode_conf_read_int("load-environment", 1);
 
        if (IS_ENABLED(CONFIG_DELAY_ENVIRONMENT))
                return 0;
@@ -586,6 +586,29 @@ int initr_mem(void)
 }
 #endif
 
+static int dm_announce(void)
+{
+       int device_count;
+       int uclass_count;
+
+       if (IS_ENABLED(CONFIG_DM)) {
+               dm_get_stats(&device_count, &uclass_count);
+               printf("Core:  %d devices, %d uclasses", device_count,
+                      uclass_count);
+               if (CONFIG_IS_ENABLED(OF_REAL))
+                       printf(", devicetree: %s", fdtdec_get_srcname());
+               printf("\n");
+               if (IS_ENABLED(CONFIG_OF_HAS_PRIOR_STAGE) &&
+                   (gd->fdt_src == FDTSRC_SEPARATE ||
+                    gd->fdt_src == FDTSRC_EMBED)) {
+                       printf("Warning: Unexpected devicetree source (not from a prior stage)");
+                       printf("Warning: U-Boot may not function properly\n");
+               }
+       }
+
+       return 0;
+}
+
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -661,6 +684,7 @@ static init_fnc_t init_sequence_r[] = {
        stdio_init_tables,
        serial_initialize,
        initr_announce,
+       dm_announce,
 #if CONFIG_IS_ENABLED(WDT)
        initr_watchdog,
 #endif