[PATCH 2/8] board/tq: Add common SoM API

Alexander Feilke Alexander.Feilke at ew.tq-group.com
Thu Mar 12 15:31:12 CET 2026


From: Alexander Feilke <alexander.feilke at ew.tq-group.com>

The default implementation reduces code duplication for empty functions.

Signed-off-by: Alexander Feilke <alexander.feilke at ew.tq-group.com>
Signed-off-by: Max Merchel <Max.Merchel at ew.tq-group.com>
---
 board/tq/common/Kconfig  |  3 +++
 board/tq/common/Makefile |  1 +
 board/tq/common/tq_som.c | 31 +++++++++++++++++++++++++++++++
 board/tq/common/tq_som.h | 34 ++++++++++++++++++++++++++++++++++
 4 files changed, 69 insertions(+)
 create mode 100644 board/tq/common/tq_som.c
 create mode 100644 board/tq/common/tq_som.h

diff --git a/board/tq/common/Kconfig b/board/tq/common/Kconfig
index a1896929ea3..2fe2ca30072 100644
--- a/board/tq/common/Kconfig
+++ b/board/tq/common/Kconfig
@@ -11,3 +11,6 @@ config TQ_COMMON_BB
 
 config TQ_COMMON_SDMMC
 	bool
+
+config TQ_COMMON_SOM
+	bool
diff --git a/board/tq/common/Makefile b/board/tq/common/Makefile
index ac564a713fd..4af9207da4a 100644
--- a/board/tq/common/Makefile
+++ b/board/tq/common/Makefile
@@ -6,4 +6,5 @@
 #
 
 obj-$(CONFIG_TQ_COMMON_BB) += tq_bb.o
+obj-$(CONFIG_TQ_COMMON_SOM) += tq_som.o
 obj-$(CONFIG_TQ_COMMON_SDMMC) += tq_sdmmc.o
diff --git a/board/tq/common/tq_som.c b/board/tq/common/tq_som.c
new file mode 100644
index 00000000000..791f896fcaf
--- /dev/null
+++ b/board/tq/common/tq_som.c
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025-2026 TQ-Systems GmbH <u-boot at ew.tq-group.com>,
+ * D-82229 Seefeld, Germany.
+ * Author: Alexander Feilke, Max Merchel
+ */
+
+#include <init.h>
+#include <asm/io.h>
+#include <linux/sizes.h>
+
+#include "tq_som.h"
+
+void __weak tq_som_ram_init(void)
+{
+	;
+}
+
+/*
+ * checks if the accessible range equals the requested RAM size.
+ * returns true if successful, false otherwise
+ */
+bool tq_som_ram_check_size(long ram_size)
+{
+	long size;
+
+	size = get_ram_size((void *)PHYS_SDRAM, ram_size);
+	debug("SPL: requested RAM size %lu MiB. accessible %lu MiB\n", ram_size / (SZ_1M), size / (SZ_1M));
+
+	return (size == ram_size);
+}
diff --git a/board/tq/common/tq_som.h b/board/tq/common/tq_som.h
new file mode 100644
index 00000000000..d7168eb7e46
--- /dev/null
+++ b/board/tq/common/tq_som.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2025-2026 TQ-Systems GmbH <u-boot at ew.tq-group.com>,
+ * D-82229 Seefeld, Germany.
+ * Author: Alexander Feilke, Max Merchel
+ */
+
+#ifndef __TQ_SOM_H
+#define __TQ_SOM_H
+
+#include <init.h>
+#include <asm/io.h>
+
+void tq_som_ram_init(void);
+
+/* used as a wrapper to write to specific register addresses */
+static inline void tq_som_init_write_reg(u32 address, u32 value)
+{
+	writel_relaxed(value, address);
+}
+
+/*
+ * checks if the accessible range equals the requested ram size.
+ * returns true if successful, false otherwise
+ */
+bool tq_som_ram_check_size(long ram_size);
+
+static inline void tq_som_check_bits_set(u32 address, u32 mask)
+{
+	while ((readl(address) & mask) != mask)
+		;
+}
+
+#endif /* __TQ_SOM_H */
-- 
2.34.1



More information about the U-Boot mailing list