]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
board/tq: Add common SoM API
authorAlexander Feilke <alexander.feilke@ew.tq-group.com>
Tue, 7 Apr 2026 13:06:45 +0000 (15:06 +0200)
committerFabio Estevam <festevam@gmail.com>
Tue, 21 Apr 2026 23:49:39 +0000 (20:49 -0300)
Reduce code duplication by adding a default implementation.

Signed-off-by: Max Merchel <Max.Merchel@ew.tq-group.com>
Signed-off-by: Alexander Feilke <alexander.feilke@ew.tq-group.com>
board/tq/common/Kconfig
board/tq/common/Makefile
board/tq/common/tq_som.c [new file with mode: 0644]
board/tq/common/tq_som.h [new file with mode: 0644]

index a1896929ea36153bc876f0564e73cecab4bd0f74..2fe2ca3007289b64af3dc2a6a9c5d2461bfee798 100644 (file)
@@ -11,3 +11,6 @@ config TQ_COMMON_BB
 
 config TQ_COMMON_SDMMC
        bool
+
+config TQ_COMMON_SOM
+       bool
index ac564a713fd1729dee67a263dc442e6ddc70438f..4af9207da4abffeec7de98d46553c27574fe0475 100644 (file)
@@ -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 (file)
index 0000000..6fb4839
--- /dev/null
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2025-2026 TQ-Systems GmbH <u-boot@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 (file)
index 0000000..0ab01d5
--- /dev/null
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (c) 2025-2026 TQ-Systems GmbH <u-boot@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>
+#include <linux/iopoll.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)
+{
+       u32 val;
+       readl_poll_timeout(address, val, (val & mask) == mask, 1000);
+}
+
+#endif /* __TQ_SOM_H */