summaryrefslogtreecommitdiff
path: root/board/toradex
diff options
context:
space:
mode:
authorEmanuele Ghidoli <emanuele.ghidoli@toradex.com>2024-02-23 10:11:41 +0100
committerTom Rini <trini@konsulko.com>2024-03-01 09:10:44 -0500
commit2abc3bbe0cefee8f150af851a6625a6cb32dad63 (patch)
tree15d4ae678c84ddf8f86a19e4c914fc634b09c938 /board/toradex
parent100121d51b32567d9401cbf4764cf12d4fdfd248 (diff)
downloadu-boot-2abc3bbe0cefee8f150af851a6625a6cb32dad63.tar.gz
u-boot-2abc3bbe0cefee8f150af851a6625a6cb32dad63.tar.bz2
u-boot-2abc3bbe0cefee8f150af851a6625a6cb32dad63.zip
toradex: common: Add sysinfo driver
This commit introduces support for the Toradex sysinfo driver in U-Boot, which uses information from Toradex config block to print correct board model. In case the Toradex config block is not present sysinfo prints the model of the board provided by device tree removing per board specific prints. Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> Tested-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> # Verdin iMX8M Plus Signed-off-by: Emanuele Ghidoli <emanuele.ghidoli@toradex.com> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Fabio Estevam <festevam@gmail.com>
Diffstat (limited to 'board/toradex')
-rw-r--r--board/toradex/common/Kconfig1
-rw-r--r--board/toradex/common/tdx-common.c50
2 files changed, 44 insertions, 7 deletions
diff --git a/board/toradex/common/Kconfig b/board/toradex/common/Kconfig
index 1f6a5e4db5..b85893ab44 100644
--- a/board/toradex/common/Kconfig
+++ b/board/toradex/common/Kconfig
@@ -4,6 +4,7 @@
menuconfig TDX_CFG_BLOCK
bool "Enable Toradex config block support"
select OF_BOARD_SETUP
+ select SYSINFO
help
The Toradex config block stored production data on the on-module
flash device (NAND, NOR or eMMC). The area is normally preserved by
diff --git a/board/toradex/common/tdx-common.c b/board/toradex/common/tdx-common.c
index 6084436b48..1f3253f422 100644
--- a/board/toradex/common/tdx-common.c
+++ b/board/toradex/common/tdx-common.c
@@ -3,15 +3,16 @@
* Copyright (c) 2016 Toradex, Inc.
*/
+#include <dm.h>
#include <common.h>
#include <env.h>
#include <g_dnl.h>
#include <init.h>
#include <linux/libfdt.h>
+#include <sysinfo.h>
#ifdef CONFIG_VIDEO
#include <bmp_logo.h>
-#include <dm.h>
#include <splash.h>
#include <video.h>
#endif
@@ -103,13 +104,8 @@ __weak int print_bootinfo(void)
int checkboard(void)
{
- if (valid_cfgblock) {
- printf("Model: Toradex %04d %s %s\n",
- tdx_hw_tag.prodid,
- toradex_modules[tdx_hw_tag.prodid].name,
- tdx_board_rev_str);
+ if (valid_cfgblock)
printf("Serial#: %s\n", tdx_serial_str);
- }
#ifdef CONFIG_TDX_CFG_BLOCK_EXTRA
if (tdx_carrier_board_name)
@@ -188,6 +184,46 @@ static int settings_r(void)
}
EVENT_SPY_SIMPLE(EVT_SETTINGS_R, settings_r);
+static int tdx_detect(struct udevice *dev)
+{
+ return valid_cfgblock ? 0 : -EINVAL;
+}
+
+static int tdx_get_str(struct udevice *dev, int id, size_t size, char *val)
+{
+ int ret = -ENOTSUPP;
+
+ switch (id) {
+ case SYSINFO_ID_BOARD_MODEL:
+ snprintf(val, size,
+ "Toradex %04d %s %s",
+ tdx_hw_tag.prodid,
+ toradex_modules[tdx_hw_tag.prodid].name,
+ tdx_board_rev_str);
+
+ ret = 0;
+ }
+
+ return ret;
+}
+
+static const struct udevice_id sysinfo_tdx_ids[] = {
+ { .compatible = "toradex,sysinfo" },
+ { /* sentinel */ }
+};
+
+static const struct sysinfo_ops sysinfo_tdx_ops = {
+ .detect = tdx_detect,
+ .get_str = tdx_get_str,
+};
+
+U_BOOT_DRIVER(sysinfo_toradex) = {
+ .name = "sysinfo_toradex",
+ .id = UCLASS_SYSINFO,
+ .of_match = sysinfo_tdx_ids,
+ .ops = &sysinfo_tdx_ops,
+};
+
#ifdef CONFIG_TDX_CFG_BLOCK_USB_GADGET_PID
int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
{