fdt: Report the devicetree source
authorSimon Glass <sjg@chromium.org>
Fri, 17 Dec 2021 03:59:34 +0000 (20:59 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 23 Dec 2021 15:24:40 +0000 (10:24 -0500)
It can be confusing to figure out where the devicetree came from. It seems
important enough to warrant a message during boot. Add information about
the number of devices and uclasses too since it is helpful to have some
idea what is going on with driver model.

Report the devicetree source in bdinfo too.

This looks something like this, with > marking the new line.

   U-Boot 2021.10-00190 (Oct 30 2021 - 09:01:29 -0600)

   DRAM:  128 MiB
>  Core:  42 devices, 11 uclasses, devicetree: passage
   Flash: 64 MiB

Signed-off-by: Simon Glass <sjg@chromium.org>
cmd/bdinfo.c
common/board_r.c
lib/fdtdec.c

index bf63cc6..c56b3f4 100644 (file)
@@ -128,6 +128,8 @@ int do_bdinfo(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
                lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob);
                lmb_dump_all_force(&lmb);
+               if (IS_ENABLED(CONFIG_OF_REAL))
+                       printf("devicetree  = %s\n", fdtdec_get_srcname());
        }
 
        arch_print_bdinfo();
index 31a59c5..99adff1 100644 (file)
@@ -586,6 +586,23 @@ 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");
+       }
+
+       return 0;
+}
+
 static int run_main_loop(void)
 {
 #ifdef CONFIG_SANDBOX
@@ -661,6 +678,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
index 8cfa958..118c100 100644 (file)
@@ -76,6 +76,19 @@ static const char * const compat_names[COMPAT_COUNT] = {
        COMPAT(ALTERA_SOCFPGA_CLK_INIT, "altr,socfpga-a10-clk-init")
 };
 
+static const char *const fdt_src_name[] = {
+       [FDTSRC_SEPARATE] = "separate",
+       [FDTSRC_FIT] = "fit",
+       [FDTSRC_BOARD] = "board",
+       [FDTSRC_EMBED] = "embed",
+       [FDTSRC_ENV] = "env",
+};
+
+const char *fdtdec_get_srcname(void)
+{
+       return fdt_src_name[gd->fdt_src];
+}
+
 const char *fdtdec_get_compatible(enum fdt_compat_id id)
 {
        /* We allow reading of the 'unknown' ID for testing purposes */