]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sysinfo: Allow displaying more info on startup
authorSimon Glass <sjg@chromium.org>
Mon, 13 Nov 2023 02:58:28 +0000 (19:58 -0700)
committerTom Rini <trini@konsulko.com>
Tue, 28 Nov 2023 17:53:04 +0000 (12:53 -0500)
At present only the model name is shown on start. Some boards want to
display more information. Add some more options to allow display of the
manufacturer as well as the version and date of any prior-stage
firmware.

This is useful for coreboot, at least. If other boards have more
information to display, it is easy to add it, now.

Signed-off-by: Simon Glass <sjg@chromium.org>
common/board_info.c
drivers/sysinfo/Kconfig
include/sysinfo.h

index a62c04794b90e303ee8a7a880b64b3c6fb397d68..f4c385add90c7b92299b6ffe2b1cf321f0f98cae 100644 (file)
@@ -15,35 +15,65 @@ int __weak checkboard(void)
        return 0;
 }
 
+static const struct to_show {
+       const char *name;
+       enum sysinfo_id id;
+} to_show[] = {
+       { "Manufacturer", SYSINFO_ID_BOARD_MANUFACTURER},
+       { "Prior-stage version", SYSINFO_ID_PRIOR_STAGE_VERSION },
+       { "Prior-stage date", SYSINFO_ID_PRIOR_STAGE_DATE },
+       { /* sentinel */ }
+};
+
+static int try_sysinfo(void)
+{
+       struct udevice *dev;
+       char str[80];
+       int ret;
+
+       /* This might provide more detail */
+       ret = sysinfo_get(&dev);
+       if (ret)
+               return ret;
+
+       ret = sysinfo_detect(dev);
+       if (ret)
+               return ret;
+
+       ret = sysinfo_get_str(dev, SYSINFO_ID_BOARD_MODEL, sizeof(str), str);
+       if (ret)
+               return ret;
+       printf("Model: %s\n", str);
+
+       if (IS_ENABLED(CONFIG_SYSINFO_EXTRA)) {
+               const struct to_show *item;
+
+               for (item = to_show; item->id; item++) {
+                       ret = sysinfo_get_str(dev, item->id, sizeof(str), str);
+                       if (!ret)
+                               printf("%s: %s\n", item->name, str);
+               }
+       }
+
+       return 0;
+}
+
 int show_board_info(void)
 {
        if (IS_ENABLED(CONFIG_OF_CONTROL)) {
-               struct udevice *dev;
-               const char *model;
-               char str[80];
                int ret = -ENOSYS;
 
-               if (IS_ENABLED(CONFIG_SYSINFO)) {
-                       /* This might provide more detail */
-                       ret = sysinfo_get(&dev);
-                       if (!ret) {
-                               ret = sysinfo_detect(dev);
-                               if (!ret) {
-                                       ret = sysinfo_get_str(dev,
-                                                     SYSINFO_ID_BOARD_MODEL,
-                                                     sizeof(str), str);
-                               }
-                       }
-               }
+               if (IS_ENABLED(CONFIG_SYSINFO))
+                       ret = try_sysinfo();
 
                /* Fail back to the main 'model' if available */
-               if (ret)
-                       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
-               else
-                       model = str;
+               if (ret) {
+                       const char *model;
 
-               if (model)
-                       printf("Model: %s\n", model);
+                       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+                       if (model)
+                               printf("Model: %s\n", model);
+               }
        }
 
        return checkboard();
index e35f7cb17914a238997b96a1b8ea595096e5557d..2030e4babc9fe0c714a61dbdf4d79e17ba59926a 100644 (file)
@@ -8,6 +8,13 @@ menuconfig SYSINFO
 
 if SYSINFO
 
+config SYSINFO_EXTRA
+       bool "Show extra information on startup"
+       help
+         Enable this to see extra information on startup. Normally only the
+         model is shown, but with this option the vendor and any prior-stage
+         firmware's version and date are shown as well.
+
 config SPL_SYSINFO
        depends on SPL_DM
        bool "Enable board driver support in SPL"
index b140d742e93d1c4126c2e37e81ac5c47b9c07055..f2c1aa29d18ed3bdb82cf117da4d6b372eeaae3b 100644 (file)
@@ -46,6 +46,9 @@ enum sysinfo_id {
 
        /* For show_board_info() */
        SYSINFO_ID_BOARD_MODEL,
+       SYSINFO_ID_BOARD_MANUFACTURER,
+       SYSINFO_ID_PRIOR_STAGE_VERSION,
+       SYSINFO_ID_PRIOR_STAGE_DATE,
 
        /* First value available for downstream/board used */
        SYSINFO_ID_USER = 0x1000,