From: Nora Schiffer <[email protected]>

Add a number of helpers based on the tq_eeprom sysinfo driver and
related hardware detection features. The helpers set up the U-Boot
environment and fixup the OS Device Tree.

Signed-off-by: Nora Schiffer <[email protected]>
Signed-off-by: Alexander Feilke <[email protected]>
---
 board/tq/common/Kconfig      | 27 +++++++++++++++++++++++++++
 board/tq/common/Makefile     |  4 ++++
 board/tq/common/tq_sysinfo.c | 32 ++++++++++++++++++++++++++++++++
 board/tq/common/tq_sysinfo.h | 18 ++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 board/tq/common/tq_sysinfo.c
 create mode 100644 board/tq/common/tq_sysinfo.h

diff --git a/board/tq/common/Kconfig b/board/tq/common/Kconfig
index 2fe2ca30072..9d32051e02e 100644
--- a/board/tq/common/Kconfig
+++ b/board/tq/common/Kconfig
@@ -14,3 +14,30 @@ config TQ_COMMON_SDMMC
 
 config TQ_COMMON_SOM
        bool
+
+config TQ_COMMON_SPL_BOARD_SETUP
+       bool
+       depends on SPL
+
+config TQ_COMMON_SYSINFO
+       bool
+       select SYSINFO
+       imply SYSINFO_TQ_EEPROM
+
+if TQ_COMMON_SYSINFO
+
+config TQ_COMMON_SYSINFO_MACADDR_OFFSET
+       int "TQ EEPROM MAC address offset"
+       default 1
+       help
+         Set ethXaddr variables based on EEPROM contents
+         starting with this offset
+
+config TQ_COMMON_SYSINFO_MACADDR_NUM
+       int "TQ EEPROM MAC address number"
+       default 1
+       help
+         Number of ethXaddr variables to set
+         based on EEPROM contents
+
+endif
diff --git a/board/tq/common/Makefile b/board/tq/common/Makefile
index 4af9207da4a..af8506dd1bd 100644
--- a/board/tq/common/Makefile
+++ b/board/tq/common/Makefile
@@ -8,3 +8,7 @@
 obj-$(CONFIG_TQ_COMMON_BB) += tq_bb.o
 obj-$(CONFIG_TQ_COMMON_SOM) += tq_som.o
 obj-$(CONFIG_TQ_COMMON_SDMMC) += tq_sdmmc.o
+
+ifneq ($(CONFIG_XPL_BUILD),y)
+obj-$(CONFIG_TQ_COMMON_SYSINFO) += tq_sysinfo.o
+endif
diff --git a/board/tq/common/tq_sysinfo.c b/board/tq/common/tq_sysinfo.c
new file mode 100644
index 00000000000..6ba6e26f275
--- /dev/null
+++ b/board/tq/common/tq_sysinfo.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Common sysinfo helpers for TQ-Systems SOMs
+ *
+ * Copyright (c) 2020-2026 TQ-Systems GmbH <[email protected]>
+ * D-82229 Seefeld, Germany.
+ * Author: Nora Schiffer
+ */
+
+#include <env.h>
+#include <sysinfo/tq_eeprom.h>
+
+#define MAX_NAME_LENGTH        80
+
+void tq_common_sysinfo_setup(void)
+{
+       struct udevice *sysinfo;
+       char buf[MAX_NAME_LENGTH] = "";
+       int ret;
+
+       ret = sysinfo_get_and_detect(&sysinfo);
+       if (ret) {
+               pr_err("Failed to get sysinfo data: %d\n", ret);
+               return;
+       }
+
+       if (!sysinfo_get_str(sysinfo, SYSID_TQ_MODEL, sizeof(buf), buf))
+               env_set_runtime("boardtype", buf);
+
+       if (!sysinfo_get_str(sysinfo, SYSID_TQ_SERIAL, sizeof(buf), buf))
+               env_set_runtime("serial#", buf);
+}
diff --git a/board/tq/common/tq_sysinfo.h b/board/tq/common/tq_sysinfo.h
new file mode 100644
index 00000000000..f72281f75c0
--- /dev/null
+++ b/board/tq/common/tq_sysinfo.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Common sysinfo helpers for TQ-Systems SOMs
+ *
+ * Copyright (c) 2025-2026 TQ-Systems GmbH <[email protected]>
+ * D-82229 Seefeld, Germany.
+ * Author: Nora Schiffer
+ */
+
+#ifndef __TQ_SYSINFO_H
+
+#ifndef CONFIG_XPL_BUILD
+
+void tq_common_sysinfo_setup(void);
+
+#endif
+
+#endif /* __TQ_SYSINFO_H */
-- 
2.34.1

Reply via email to