mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sohaib Mohamed <sohaib.amhmd@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 Ahmad Fatoum <a.fatoum@pengutronix.de>,
	 Sohaib Mohamed <sohaib.amhmd@gmail.com>,
	 BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 01/14] ARM: rockchip: Add initial RK3562 SoC support
Date: Fri, 16 Jan 2026 20:40:35 +0100	[thread overview]
Message-ID: <20260116-barebox-kickpi-v1-1-d11fbccd527a@gmail.com> (raw)
In-Reply-To: <20260116-barebox-kickpi-v1-0-d11fbccd527a@gmail.com>

Add basic RK3562 support including ATF integration, low-level init,
debug UART configuration, and bootrom integration.

Co-developed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
---
 arch/arm/mach-rockchip/Kconfig      |  4 ++++
 arch/arm/mach-rockchip/Makefile     |  1 +
 arch/arm/mach-rockchip/atf.c        | 38 +++++++++++++++++++++++++++++++++++++
 arch/arm/mach-rockchip/dmc.c        | 33 ++++++++++++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3562.c     | 20 +++++++++++++++++++
 arch/arm/mach-rockchip/rockchip.c   |  4 ++++
 common/Kconfig.debug_ll             |  9 +++++++++
 firmware/Makefile                   |  2 ++
 include/mach/rockchip/atf.h         |  6 ++++++
 include/mach/rockchip/debug_ll.h    |  6 ++++++
 include/mach/rockchip/dmc.h         |  1 +
 include/mach/rockchip/rk3562-regs.h | 21 ++++++++++++++++++++
 include/mach/rockchip/rockchip.h    | 10 ++++++++++
 13 files changed, 155 insertions(+)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 6f6e43101c..a91e7db72d 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -27,6 +27,10 @@ config ARCH_ROCKCHIP_V8
 	select CPU_V8
 	select ARM_ATF
 
+config ARCH_RK3562
+	bool
+	select ARCH_ROCKCHIP_V8
+
 config ARCH_RK3568
 	bool
 	select ARCH_ROCKCHIP_V8
diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index 40454d0284..9e2ef82221 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -4,6 +4,7 @@ obj-y += rockchip.o bootrom.o
 pbl-$(CONFIG_ARCH_ROCKCHIP_ATF) += atf.o
 obj-$(CONFIG_ARCH_RK3188) += rk3188.o
 obj-$(CONFIG_ARCH_RK3288) += rk3288.o
+obj-pbl-$(CONFIG_ARCH_RK3562) += rk3562.o
 obj-pbl-$(CONFIG_ARCH_RK3568) += rk3568.o
 obj-pbl-$(CONFIG_ARCH_RK3576) += rk3576.o
 obj-pbl-$(CONFIG_ARCH_RK3588) += rk3588.o
diff --git a/arch/arm/mach-rockchip/atf.c b/arch/arm/mach-rockchip/atf.c
index c4ed84aae6..55d9918f3e 100644
--- a/arch/arm/mach-rockchip/atf.c
+++ b/arch/arm/mach-rockchip/atf.c
@@ -11,6 +11,7 @@
 #include <mach/rockchip/dmc.h>
 #include <mach/rockchip/rockchip.h>
 #include <mach/rockchip/bootrom.h>
+#include <mach/rockchip/rk3562-regs.h>
 #include <mach/rockchip/rk3568-regs.h>
 #include <mach/rockchip/rk3576-regs.h>
 #include <mach/rockchip/rk3588-regs.h>
@@ -132,6 +133,43 @@ static uintptr_t rk_load_optee(uintptr_t bl32, const void *bl32_image,
 		   SOC##_BAREBOX_LOAD_ADDRESS, (uintptr_t)fdt);                 \
 } while (0)                                                                     \
 
+void rk3562_atf_load_bl31(void *fdt)
+{
+	rockchip_atf_load_bl31(RK3562, rk3562_bl31_bin, rk3562_bl32_bin, fdt);
+}
+
+void __noreturn rk3562_barebox_entry(void *fdt)
+{
+	unsigned long membase, endmem;
+
+	membase = RK3562_DRAM_BOTTOM;
+	endmem = rk3562_ram0_size();
+
+	rk_scratch = (void *)arm_mem_scratch(endmem);
+
+	if (current_el() == 3) {
+		rk3562_lowlevel_init();
+		rockchip_store_bootrom_iram(IOMEM(RK3562_IRAM_BASE));
+
+		/*
+		 * The downstream TF-A doesn't cope with our device tree when
+		 * CONFIG_OF_OVERLAY_LIVE is enabled, supposedly because it is
+		 * too big for some reason. Otherwise it doesn't have any visible
+		 * effect if we pass a device tree or not, except that the TF-A
+		 * fills in the ethernet MAC address into the device tree.
+		 * The upstream TF-A doesn't use the device tree at all.
+		 *
+		 * Pass NULL for now until we have a good reason to pass a real
+		 * device tree.
+		 */
+		rk3562_atf_load_bl31(NULL);
+		/* not reached when CONFIG_ARCH_ROCKCHIP_ATF */
+	}
+
+	optee_set_membase(rk_scratch_get_optee_hdr());
+	barebox_arm_entry(membase, endmem - membase, fdt);
+}
+
 void rk3568_atf_load_bl31(void *fdt)
 {
 	rockchip_atf_load_bl31(RK3568, rk3568_bl31_bin, rk3568_bl32_bin, fdt);
diff --git a/arch/arm/mach-rockchip/dmc.c b/arch/arm/mach-rockchip/dmc.c
index 3cb17b9694..4c0b9c3975 100644
--- a/arch/arm/mach-rockchip/dmc.c
+++ b/arch/arm/mach-rockchip/dmc.c
@@ -16,12 +16,16 @@
 #include <mach/rockchip/dmc.h>
 #include <mach/rockchip/atf.h>
 #include <mach/rockchip/rk3399-regs.h>
+#include <mach/rockchip/rk3562-regs.h>
 #include <mach/rockchip/rk3568-regs.h>
 #include <mach/rockchip/rk3576-regs.h>
 
 #define RK3399_PMUGRF_OS_REG2		0x308
 #define RK3399_PMUGRF_OS_REG3		0x30C
 
+#define RK3562_PMUGRF_OS_REG2           0x208
+#define RK3562_PMUGRF_OS_REG3           0x20c
+
 #define RK3568_PMUGRF_OS_REG2           0x208
 #define RK3568_PMUGRF_OS_REG3           0x20c
 
@@ -29,6 +33,7 @@
 #define RK3576_PMUGRF_OS_REG3           0x20c
 
 #define RK3399_INT_REG_START		0xf0000000
+#define RK3562_INT_REG_START		RK3399_INT_REG_START
 #define RK3568_INT_REG_START		RK3399_INT_REG_START
 #define RK3576_INT_REG_START		0x10000000
 #define RK3588_INT_REG_START		RK3399_INT_REG_START
@@ -155,6 +160,23 @@ resource_size_t rk3399_ram0_size(void)
 	return size;
 }
 
+resource_size_t rk3562_ram0_size(void)
+{
+	void __iomem *pmugrf = IOMEM(RK3562_PMUGRF_BASE);
+	u32 sys_reg2, sys_reg3;
+	resource_size_t size;
+
+	sys_reg2 = readl(pmugrf + RK3562_PMUGRF_OS_REG2);
+	sys_reg3 = readl(pmugrf + RK3562_PMUGRF_OS_REG3);
+
+	size = rockchip_sdram_size(sys_reg2, sys_reg3);
+	size = min_t(resource_size_t, RK3562_INT_REG_START, size);
+
+	pr_debug("%s() = %llu\n", __func__, (u64)size);
+
+	return size;
+}
+
 resource_size_t rk3568_ram0_size(void)
 {
 	void __iomem *pmugrf = IOMEM(RK3568_PMUGRF_BASE);
@@ -314,6 +336,13 @@ static const struct rockchip_dmc_drvdata rk3399_drvdata = {
 	.membase = RK3399_DRAM_BOTTOM,
 };
 
+static const struct rockchip_dmc_drvdata rk3562_drvdata = {
+	.os_reg2 = RK3562_PMUGRF_OS_REG2,
+	.os_reg3 = RK3562_PMUGRF_OS_REG3,
+	.internal_registers_start = RK3562_INT_REG_START,
+	.membase = RK3562_DRAM_BOTTOM,
+};
+
 static const struct rockchip_dmc_drvdata rk3568_drvdata = {
 	.os_reg2 = RK3568_PMUGRF_OS_REG2,
 	.os_reg3 = RK3568_PMUGRF_OS_REG3,
@@ -342,6 +371,10 @@ static struct of_device_id rockchip_dmc_dt_ids[] = {
 		.compatible = "rockchip,rk3399-dmc",
 		.data = &rk3399_drvdata,
 	},
+	{
+		.compatible = "rockchip,rk3562-dmc",
+		.data = &rk3562_drvdata,
+	},
 	{
 		.compatible = "rockchip,rk3568-dmc",
 		.data = &rk3568_drvdata,
diff --git a/arch/arm/mach-rockchip/rk3562.c b/arch/arm/mach-rockchip/rk3562.c
new file mode 100644
index 0000000000..9ab5b82695
--- /dev/null
+++ b/arch/arm/mach-rockchip/rk3562.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier:     GPL-2.0+
+#include <common.h>
+#include <io.h>
+#include <bootsource.h>
+#include <mach/rockchip/rk3562-regs.h>
+#include <mach/rockchip/rockchip.h>
+#include <asm/barebox-arm-head.h>
+#include <mach/rockchip/bootrom.h>
+
+void rk3562_lowlevel_init(void)
+{
+	arm_cpu_lowlevel_init();
+}
+
+int rk3562_init(void)
+{
+	rockchip_parse_bootrom_iram(rockchip_scratch_space()->iram);
+
+	return 0;
+}
diff --git a/arch/arm/mach-rockchip/rockchip.c b/arch/arm/mach-rockchip/rockchip.c
index 0828f0fa72..ce1c06ff38 100644
--- a/arch/arm/mach-rockchip/rockchip.c
+++ b/arch/arm/mach-rockchip/rockchip.c
@@ -17,6 +17,8 @@ int rockchip_soc(void)
 		__rockchip_soc = 3188;
 	else if (of_machine_is_compatible("rockchip,rk3288"))
 		__rockchip_soc = 3288;
+	else if (of_machine_is_compatible("rockchip,rk3562"))
+		__rockchip_soc = 3562;
 	else if (of_machine_is_compatible("rockchip,rk3566"))
 		__rockchip_soc = 3566;
 	else if (of_machine_is_compatible("rockchip,rk3568"))
@@ -49,6 +51,8 @@ static int rockchip_init(void)
 		return rk3188_init();
 	case 3288:
 		return rk3288_init();
+	case 3562:
+		return rk3562_init();
 	case 3566:
 		return rk3568_init();
 	case 3568:
diff --git a/common/Kconfig.debug_ll b/common/Kconfig.debug_ll
index a08d29859d..75d500862b 100644
--- a/common/Kconfig.debug_ll
+++ b/common/Kconfig.debug_ll
@@ -198,6 +198,14 @@ config DEBUG_ROCKCHIP_RK3288_UART
 	  Say Y here if you want kernel low-level debugging support
 	  on RK3288.
 
+config DEBUG_ROCKCHIP_RK3562_UART
+	bool "RK3562 Debug UART"
+	depends on ARCH_RK3562
+	select DEBUG_ROCKCHIP_UART
+	help
+	  Say Y here if you want kernel low-level debugging support
+	  on RK3562.
+
 config DEBUG_ROCKCHIP_RK3568_UART
 	bool "RK3568 Debug UART"
 	depends on ARCH_RK3568
@@ -430,6 +438,7 @@ config DEBUG_OMAP_UART_PORT
 config DEBUG_ROCKCHIP_UART_PORT
 	int "RK3xxx UART debug port" if DEBUG_ROCKCHIP_RK3188_UART || \
 				DEBUG_ROCKCHIP_RK3288_UART || \
+				DEBUG_ROCKCHIP_RK3562_UART || \
 				DEBUG_ROCKCHIP_RK3568_UART || \
 				DEBUG_ROCKCHIP_RK3576_UART || \
 				DEBUG_ROCKCHIP_RK3588_UART || \
diff --git a/firmware/Makefile b/firmware/Makefile
index 163055554d..f0204a8bf6 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -28,12 +28,14 @@ fw-external-$(CONFIG_FIRMWARE_IMX8MP_OPTEE) += imx8mp-bl32.bin
 fw-external-$(CONFIG_FIRMWARE_IMX93_OPTEE) += imx93-bl32.bin \
 					      mx93a1-ahab-container.img
 fw-external-$(CONFIG_FIRMWARE_IMX93_OPTEE_A0) += mx93a0-ahab-container.img
+pbl-firmware-$(CONFIG_ARCH_RK3562) += rk3562-bl31.bin
 pbl-firmware-$(CONFIG_ARCH_RK3568) += rk3568-bl31.bin
 pbl-firmware-$(CONFIG_ARCH_RK3576) += rk3576-bl31.bin
 pbl-firmware-$(CONFIG_ARCH_RK3588) += rk3588-bl31.bin
 ifeq ($(CONFIG_ARCH_ROCKCHIP_OPTEE),y)
 # We install BL31 & BL32 while already running in DRAM,
 # so fw-external is not needed
+pbl-firmware-$(CONFIG_ARCH_RK3562) += rk3562-bl32.bin
 pbl-firmware-$(CONFIG_ARCH_RK3568) += rk3568-bl32.bin
 pbl-firmware-$(CONFIG_ARCH_RK3576) += rk3576-bl32.bin
 pbl-firmware-$(CONFIG_ARCH_RK3588) += rk3588-bl32.bin
diff --git a/include/mach/rockchip/atf.h b/include/mach/rockchip/atf.h
index 8fc2a4bebe..b8627a3598 100644
--- a/include/mach/rockchip/atf.h
+++ b/include/mach/rockchip/atf.h
@@ -5,6 +5,7 @@
 
 /* First usable DRAM address. Lower mem is used for ATF and OP-TEE */
 #define RK3399_DRAM_BOTTOM		0xa00000
+#define RK3562_DRAM_BOTTOM		0xa00000
 #define RK3568_DRAM_BOTTOM		0xa00000
 #define RK3576_DRAM_BOTTOM		0x40a00000
 #define RK3588_DRAM_BOTTOM		0xa00000
@@ -19,6 +20,7 @@
  * The values are taken from rkbin/RKTRUST/RK3*.ini: [BL32_OPTION] ADDR
  */
 #define RK3399_OPTEE_LOAD_ADDRESS	0x8400000
+#define RK3562_OPTEE_LOAD_ADDRESS	0x8400000
 #define RK3568_OPTEE_LOAD_ADDRESS	0x8400000
 #define RK3576_OPTEE_LOAD_ADDRESS	0x8400000
 #define RK3588_OPTEE_LOAD_ADDRESS	0x8400000
@@ -35,22 +37,26 @@
  * OP-TEE jumps to after initialization.
  */
 #define RK3399_BAREBOX_LOAD_ADDRESS	(RK3399_DRAM_BOTTOM + 1024*1024)
+#define RK3562_BAREBOX_LOAD_ADDRESS	(RK3562_DRAM_BOTTOM + 1024*1024)
 #define RK3568_BAREBOX_LOAD_ADDRESS	(RK3568_DRAM_BOTTOM + 1024*1024)
 #define RK3576_BAREBOX_LOAD_ADDRESS	(RK3576_DRAM_BOTTOM + 1024*1024)
 #define RK3588_BAREBOX_LOAD_ADDRESS	(RK3588_DRAM_BOTTOM + 1024*1024)
 
 #ifndef __ASSEMBLY__
 #ifdef CONFIG_ARCH_ROCKCHIP_ATF
+void rk3562_atf_load_bl31(void *fdt);
 void rk3568_atf_load_bl31(void *fdt);
 void rk3576_atf_load_bl31(void *fdt);
 void rk3588_atf_load_bl31(void *fdt);
 #else
+static inline void rk3562_atf_load_bl31(void *fdt) { }
 static inline void rk3568_atf_load_bl31(void *fdt) { }
 static inline void rk3576_atf_load_bl31(void *fdt) { }
 static inline void rk3588_atf_load_bl31(void *fdt) { }
 #endif
 #endif
 
+void __noreturn rk3562_barebox_entry(void *fdt);
 void __noreturn rk3568_barebox_entry(void *fdt);
 void __noreturn rk3576_barebox_entry(void *fdt);
 void __noreturn rk3588_barebox_entry(void *fdt);
diff --git a/include/mach/rockchip/debug_ll.h b/include/mach/rockchip/debug_ll.h
index a51c2cda0b..941d1505e5 100644
--- a/include/mach/rockchip/debug_ll.h
+++ b/include/mach/rockchip/debug_ll.h
@@ -7,6 +7,7 @@
 #include <io.h>
 #include <mach/rockchip/rk3188-regs.h>
 #include <mach/rockchip/rk3288-regs.h>
+#include <mach/rockchip/rk3562-regs.h>
 #include <mach/rockchip/rk3568-regs.h>
 #include <mach/rockchip/rk3576-regs.h>
 #include <mach/rockchip/rk3588-regs.h>
@@ -24,6 +25,11 @@
 #define RK_DEBUG_UART_CLOCK	24000000
 #define RK_DEBUG_SOC		RK3288
 
+#elif defined CONFIG_DEBUG_ROCKCHIP_RK3562_UART
+
+#define RK_DEBUG_UART_CLOCK	24000000
+#define RK_DEBUG_SOC		RK3562
+
 #elif defined CONFIG_DEBUG_ROCKCHIP_RK3568_UART
 
 #define RK_DEBUG_UART_CLOCK	24000000
diff --git a/include/mach/rockchip/dmc.h b/include/mach/rockchip/dmc.h
index a379ba3294..ddcf989a30 100644
--- a/include/mach/rockchip/dmc.h
+++ b/include/mach/rockchip/dmc.h
@@ -84,6 +84,7 @@ enum {
 #define SYS_REG_CS1_COL_MASK			3
 
 resource_size_t rk3399_ram0_size(void);
+resource_size_t rk3562_ram0_size(void);
 resource_size_t rk3568_ram0_size(void);
 resource_size_t rk3576_ram0_size(void);
 resource_size_t rk3588_ram0_size(void);
diff --git a/include/mach/rockchip/rk3562-regs.h b/include/mach/rockchip/rk3562-regs.h
new file mode 100644
index 0000000000..e0a06e6427
--- /dev/null
+++ b/include/mach/rockchip/rk3562-regs.h
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __MACH_RK3562_REGS_H
+#define __MACH_RK3562_REGS_H
+
+/* UART */
+#define RK3562_UART0_BASE	0xff210000
+#define RK3562_UART1_BASE	0xff670000
+#define RK3562_UART2_BASE	0xff680000
+#define RK3562_UART3_BASE	0xff690000
+#define RK3562_UART4_BASE	0xff6a0000
+#define RK3562_UART5_BASE	0xff6b0000
+#define RK3562_UART6_BASE	0xff6c0000
+#define RK3562_UART7_BASE	0xff6d0000
+#define RK3562_UART8_BASE	0xff6e0000
+#define RK3562_UART9_BASE	0xff6f0000
+
+#define RK3562_IRAM_BASE	0xfe480000
+#define RK3562_PMUGRF_BASE	0xff010000
+
+#endif /* __MACH_RK3562_REGS_H */
diff --git a/include/mach/rockchip/rockchip.h b/include/mach/rockchip/rockchip.h
index bb9597cb01..bf115b5576 100644
--- a/include/mach/rockchip/rockchip.h
+++ b/include/mach/rockchip/rockchip.h
@@ -23,6 +23,15 @@ static inline int rk3288_init(void)
 }
 #endif
 
+#ifdef CONFIG_ARCH_RK3562
+int rk3562_init(void);
+#else
+static inline int rk3562_init(void)
+{
+	return -ENOTSUPP;
+}
+#endif
+
 #ifdef CONFIG_ARCH_RK3568
 int rk3568_init(void);
 #define PMU_GRF		0xfdc20000
@@ -53,6 +62,7 @@ static inline int rk3588_init(void)
 }
 #endif
 
+void rk3562_lowlevel_init(void);
 void rk3568_lowlevel_init(void);
 void rk3576_lowlevel_init(void);
 void rk3588_lowlevel_init(void);

-- 
2.43.0




  reply	other threads:[~2026-01-16 19:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16 19:40 [PATCH 00/14] Initial support for Rockchip RK3562 Sohaib Mohamed
2026-01-16 19:40 ` Sohaib Mohamed [this message]
2026-01-16 19:40 ` [PATCH 02/14] clk: rockchip: add RK3562 clock and reset driver support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 03/14] pinctrl: rockchip: sync driver with Linux Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 04/14] ARM: boards: Rockchip: add RK3562-EVB2 support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 05/14] ARM: boards: Rockchip: Add device tree for kickpi k3 board Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 06/14] ARM: rockchip: Add RK3562 KickPi K3 board support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 07/14] pmdomain: rockchip: Add RK3562 power domain support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 08/14] aiodev: rockchip_saradc: Add RK3562 support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 09/14] phy: rockchip-inno-usb2: Add support for RK3562 PHY Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 10/14] rockchip-rng: Add RK3562 support Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 11/14] mci: sdhci: rockchip-dwcmshc: " Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 12/14] nvmem: rockchip-otp: " Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 13/14] phy: rockchip: inno-dsidphy: " Sohaib Mohamed
2026-01-16 19:40 ` [PATCH 14/14] phy: rockchip: naneng-combphy: " Sohaib Mohamed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260116-barebox-kickpi-v1-1-d11fbccd527a@gmail.com \
    --to=sohaib.amhmd@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox