summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-21 06:50:06 +0300
committerSimon Glass <sjg@chromium.org>2021-03-27 06:26:48 +0300
commit96dedb0da2e8b27165c755fab8d06b15a8b8097a (patch)
tree3125fc55baefa3bd080010aad8588267bf6c7715 /common
parentc119528a1dd0ac719040d234c0a368a0ebaeb745 (diff)
downloadu-boot-96dedb0da2e8b27165c755fab8d06b15a8b8097a.tar.xz
sysinfo: Allow showing model info from sysinfo
Some boards may want to show the SKU ID or other information obtained at runtime. Allow this to come from sysinfo. The board can then provide a sysinfo driver to provide it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'common')
-rw-r--r--common/board_info.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/common/board_info.c b/common/board_info.c
index b54aa30a94..1cfe34f706 100644
--- a/common/board_info.c
+++ b/common/board_info.c
@@ -1,31 +1,52 @@
// SPDX-License-Identifier: GPL-2.0+
#include <common.h>
+#include <dm.h>
#include <init.h>
+#include <sysinfo.h>
#include <asm/global_data.h>
#include <linux/libfdt.h>
#include <linux/compiler.h>
+DECLARE_GLOBAL_DATA_PTR;
+
int __weak checkboard(void)
{
return 0;
}
/*
- * If the root node of the DTB has a "model" property, show it.
+ * Check sysinfo for board information. Failing that if the root node of the DTB
+ * has a "model" property, show it.
+ *
* Then call checkboard().
*/
int __weak show_board_info(void)
{
-#ifdef CONFIG_OF_CONTROL
- DECLARE_GLOBAL_DATA_PTR;
- const char *model;
+ 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 = uclass_first_device_err(UCLASS_SYSINFO, &dev);
+ if (!ret)
+ ret = sysinfo_get_str(dev,
+ SYSINFO_ID_BOARD_MODEL,
+ sizeof(str), str);
+ }
- model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+ /* Fail back to the main 'model' if available */
+ if (ret)
+ model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+ else
+ model = str;
- if (model)
- printf("Model: %s\n", model);
-#endif
+ if (model)
+ printf("Model: %s\n", model);
+ }
return checkboard();
}