aboutsummaryrefslogtreecommitdiffstats
path: root/roms/u-boot/common/board_info.c
diff options
context:
space:
mode:
Diffstat (limited to 'roms/u-boot/common/board_info.c')
-rw-r--r--roms/u-boot/common/board_info.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/roms/u-boot/common/board_info.c b/roms/u-boot/common/board_info.c
new file mode 100644
index 000000000..1cfe34f70
--- /dev/null
+++ b/roms/u-boot/common/board_info.c
@@ -0,0 +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;
+}
+
+/*
+ * 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)
+{
+ 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);
+ }
+
+ /* 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);
+ }
+
+ return checkboard();
+}