fdt: Show a runtime warning based on devicetree source
[platform/kernel/u-boot.git] / common / board_r.c
index 31a59c5..6d52066 100644 (file)
@@ -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