Skip to contentSkip to conversation

board: rockchip: Add Radxa ROCK 4D

PATCH Superseded Jonas Karlman 2 participants 13 messages Aug 1, 2025 – Aug 31, 2025

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover board: rockchip: Add Radxa ROCK 4D

This series add initial support for the Raxda ROCK 4D board, running from SPI flash, booting OS from SD-card and using Ethernet has been tested.

It also adds a helper function to read and translate the new bootsource ids reported by the BootROM of RK3576 to help support booting from SPI flash.

Kconfig options for PCIe, NVMe and USB has been enabled and tested using latest device tree from pending v6.17-rc1, and should automatically start working once the updated device tree finally reach dts/upstream.

Change in v3:
- Add comment about the reset-gpios prop rename in board u-boot.dtsi

This series depends on the "board: rockchip: Add ArmSoM Sige5" [1] and "rockchip: Fix misc USB PHY related issues" [2] series for a clean apply.

[1] https://patchwork.ozlabs.org/cover/2118082/
[2] https://patchwork.ozlabs.org/cover/2114085/

Jon Lin (1):
spi: rockchip_sfc: Support sclk_x2 version

Jonas Karlman (3):
rockchip: spl: Add a read_brom_bootsource_id() helper
rockchip: rk3576: Add SPI Flash boot support
board: rockchip: Add Radxa ROCK 4D

 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi      | 19 ++++++
 arch/arm/dts/rk3576-u-boot.dtsi              | 36 +++++++++++
 arch/arm/include/asm/arch-rockchip/bootrom.h |  2 +
 arch/arm/mach-rockchip/rk3576/MAINTAINERS    |  6 ++
 arch/arm/mach-rockchip/rk3576/rk3576.c       | 23 +++++++
 arch/arm/mach-rockchip/spl.c                 |  7 +-
 configs/rock-4d-rk3576_defconfig             | 68 ++++++++++++++++++++
 doc/board/rockchip/rockchip.rst              |  1 +
 drivers/spi/rockchip_sfc.c                   | 13 +++-
 9 files changed, 173 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi
 create mode 100644 configs/rock-4d-rk3576_defconfig
Signature · 1 line
2.50.1
#1 lore raw

PATCH v2 1/4 spi: rockchip_sfc: Support sclk_x2 version

From: Jon Lin <[email protected]>

SFC after version 8 supports dtr mode, so the IO is the binary output of the controller clock.

---
v2: No change

---
 drivers/spi/rockchip_sfc.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/spi/rockchip_sfc.c +12 -1
index 73738ab26d33..60e74117057a 100644
@@ -108,6 +108,7 @@
 #define  SFC_VER_3			0x3
 #define  SFC_VER_4			0x4
 #define  SFC_VER_5			0x5
+#define  SFC_VER_8			0x8
 
 /* Delay line controller resiter */
 #define SFC_DLL_CTRL0			0x3C
@@ -589,6 +590,16 @@ static int rockchip_sfc_adjust_op_size(struct spi_slave *mem, struct spi_mem_op
 	return 0;
 }
 
+#if CONFIG_IS_ENABLED(CLK)
+static int rockchip_sfc_clk_set_rate(struct rockchip_sfc *sfc, uint speed)
+{
+	if (sfc->version >= SFC_VER_8)
+		return clk_set_rate(&sfc->clk, speed * 2);
+	else
+		return clk_set_rate(&sfc->clk, speed);
+}
+#endif
+
 static int rockchip_sfc_set_speed(struct udevice *bus, uint speed)
 {
 	struct rockchip_sfc *sfc = dev_get_plat(bus);
@@ -600,7 +611,7 @@ static int rockchip_sfc_set_speed(struct udevice *bus, uint speed)
 		return 0;
 
 #if CONFIG_IS_ENABLED(CLK)
-	int ret = clk_set_rate(&sfc->clk, speed);
+	int ret = rockchip_sfc_clk_set_rate(sfc, speed);
 
 	if (ret < 0) {
 		dev_err(sfc->dev, "set_freq=%dHz fail, check if it's the cru support level\n",
Signature · 1 line
2.50.1
#2 lore raw

PATCH v2 2/4 rockchip: spl: Add a read_brom_bootsource_id() helper

In reply to Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for e.g. SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a helper function to read the bootsource id. This helper function will be used to translate the new values to the common BROM_BOOTSOURCE enum values on RK3576.

---
v2: No change

---
 arch/arm/include/asm/arch-rockchip/bootrom.h | 2 ++
 arch/arm/mach-rockchip/spl.c                 | 7 ++++++-
 2 files changed, 8 insertions(+), 1 deletion(-)
arch/arm/include/asm/arch-rockchip/bootrom.h +2 -0
index e736772fda75..b15938c021d6 100644
@@ -64,4 +64,6 @@ extern const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1];
  */
 #define BROM_BOOTSOURCE_ID_ADDR   (CFG_IRAM_BASE + 0x10)
 
+u32 read_brom_bootsource_id(void);
+
 #endif
arch/arm/mach-rockchip/spl.c +6 -1
index f4d29bbdd17e..1ce3a3b05547 100644
@@ -31,6 +31,11 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 __weak const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 };
 
+__weak u32 read_brom_bootsource_id(void)
+{
+	return readl(BROM_BOOTSOURCE_ID_ADDR);
+}
+
 const char *board_spl_was_booted_from(void)
 {
 	static u32 brom_bootsource_id_cache = BROM_BOOTSOURCE_UNKNOWN;
@@ -40,7 +45,7 @@ const char *board_spl_was_booted_from(void)
 	if (brom_bootsource_id_cache != BROM_BOOTSOURCE_UNKNOWN)
 		bootdevice_brom_id = brom_bootsource_id_cache;
 	else
-		bootdevice_brom_id = readl(BROM_BOOTSOURCE_ID_ADDR);
+		bootdevice_brom_id = read_brom_bootsource_id();
 
 	if (bootdevice_brom_id < ARRAY_SIZE(boot_devices))
 		bootdevice_ofpath = boot_devices[bootdevice_brom_id];
Signature · 1 line
2.50.1
#3 lore raw

PATCH v2 3/4 rockchip: rk3576: Add SPI Flash boot support

In reply to Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
 arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
 arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
 2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +36 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
 #include "rockchip-u-boot.dtsi"
 
 / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
 	chosen {
 		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
 	};
@@ -16,6 +21,17 @@
 	};
 };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;
+		};
+	};
+};
+#endif
+
 &cru {
 	bootph-all;
 };
@@ -45,6 +61,16 @@
 	bootph-some-ram;
 };
 
+&fspi0_csn0 {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
+&fspi0_pins {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
 &ioc_grf {
 	bootph-all;
 };
@@ -116,6 +142,16 @@
 	bootph-some-ram;
 };
 
+&sfc0 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
+&sfc1 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
 &sys_grf {
 	bootph-all;
 };
arch/arm/mach-rockchip/rk3576/rk3576.c +23 -0
index a6c2fbdc4840..3d5bdeeeb846 100644
@@ -36,8 +36,17 @@
 #define USB_GRF_BASE		0x2601E000
 #define USB3OTG0_CON1		0x0030
 
+enum {
+	BROM_BOOTSOURCE_FSPI0 = 3,
+	BROM_BOOTSOURCE_FSPI1_M0 = 4,
+	BROM_BOOTSOURCE_FSPI1_M1 = 6,
+};
+
 const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
 	[BROM_BOOTSOURCE_EMMC] = "/soc/mmc@2a330000",
+	[BROM_BOOTSOURCE_FSPI0] = "/soc/spi@2a340000/flash@0",
+	[BROM_BOOTSOURCE_FSPI1_M0] = "/soc/spi@2a300000/flash@0",
+	[BROM_BOOTSOURCE_FSPI1_M1] = "/soc/spi@2a300000/flash@0",
 	[BROM_BOOTSOURCE_SD] = "/soc/mmc@2a310000",
 };
 
@@ -85,6 +94,20 @@ void board_debug_uart_init(void)
 {
 }
 
+u32 read_brom_bootsource_id(void)
+{
+	u32 bootsource_id = readl(BROM_BOOTSOURCE_ID_ADDR);
+
+	if (bootsource_id == 0x23)
+		return BROM_BOOTSOURCE_FSPI1_M1;
+	else if (bootsource_id == 0x81)
+		return BROM_BOOTSOURCE_USB;
+	else if (bootsource_id > BROM_LAST_BOOTSOURCE)
+		log_debug("Unknown bootsource %x\n", bootsource_id);
+
+	return bootsource_id;
+}
+
 #define HP_TIMER_BASE			CONFIG_ROCKCHIP_STIMER_BASE
 #define HP_CTRL_REG			0x04
 #define TIMER_EN			BIT(0)
Signature · 1 line
2.50.1
#4 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

Hi Jonas,

Quoted 6 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).

I would refrain from adding partial support for it then.

Quoted 90 lines

- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
  arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
  arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
  2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +36 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
  #include "rockchip-u-boot.dtsi"
 
  / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
  	};
@@ -16,6 +21,17 @@
  	};
  };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;
+		};
+	};
+};
+#endif
+
  &cru {
  	bootph-all;
  };
@@ -45,6 +61,16 @@
  	bootph-some-ram;
  };
 
+&fspi0_csn0 {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
+&fspi0_pins {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
  &ioc_grf {
  	bootph-all;
  };
@@ -116,6 +142,16 @@
  	bootph-some-ram;
  };
 
+&sfc0 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
+&sfc1 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
  &sys_grf {
  	bootph-all;
  };
arch/arm/mach-rockchip/rk3576/rk3576.c +0 -0
index a6c2fbdc4840..3d5bdeeeb846 100644
@@ -36,8 +36,17 @@
  #define USB_GRF_BASE		0x2601E000
  #define USB3OTG0_CON1		0x0030
 

arch/arm/mach-rockchip/rk3576/rk3576.c line 48

Quoted 10 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +8 -0
+enum {
+	BROM_BOOTSOURCE_FSPI0 = 3,
+	BROM_BOOTSOURCE_FSPI1_M0 = 4,
+	BROM_BOOTSOURCE_FSPI1_M1 = 6,
+};
+
  const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
  	[BROM_BOOTSOURCE_EMMC] = "/soc/mmc@2a330000",
+	[BROM_BOOTSOURCE_FSPI0] = "/soc/spi@2a340000/flash@0",
+	[BROM_BOOTSOURCE_FSPI1_M0] = "/soc/spi@2a300000/flash@0",

This in addition to BROM_BOOTSOURCE_FSPI1_M0 in the enum may mislead the user into believing it is supported whereas we most likely need to do another mapping in read_brom_bootsource_id() below, so I would just not add either to this patch.

Quoted 6 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +1 -0
+	[BROM_BOOTSOURCE_FSPI1_M1] = "/soc/spi@2a300000/flash@0",
  	[BROM_BOOTSOURCE_SD] = "/soc/mmc@2a310000",
  };
 
@@ -85,6 +94,20 @@ void board_debug_uart_init(void)
  {

arch/arm/mach-rockchip/rk3576/rk3576.c void board_debug_uart_init(void) · line 104

Quoted 10 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +8 -0
  }
 
+u32 read_brom_bootsource_id(void)
+{
+	u32 bootsource_id = readl(BROM_BOOTSOURCE_ID_ADDR);
+
+	if (bootsource_id == 0x23)
+		return BROM_BOOTSOURCE_FSPI1_M1;
+	else if (bootsource_id == 0x81)
+		return BROM_BOOTSOURCE_USB;

I believe this differs from what we've done for all other SoCs where we have an entry at the offset bootsource_id in the boot_devices array.

On RK3588 it seems we're doing something similar of defining new BROM_BOOTSOURCE_ values in another enum and using them in the boot_devices array as indices. However, it seems we're using them verbatim instead of doing the mapping like we do here in rk3576.c. The only reason I could think of that is that 0x81 would create a pretty big array for no specific reason. Considering we already have an entry for the exact same scenario with a different number, I feel like it's fair to do the mapping.

It would be nice at least to provide some information on why it's done this way since it differs from what we've done until now. Especially that the enum doesn't match the raw value from the register anymore.

Cheers,
Quentin

#5 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

Hi Quentin,

Quoted 11 lines · Quentin Schulz

Hi Jonas,

Quoted 6 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).

I would refrain from adding partial support for it then.

Sure, I will remove anything related to sfc1 M0 in v3.

Quoted 91 lines
Quoted 91 lines

- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
  arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
  arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
  2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +36 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
  #include "rockchip-u-boot.dtsi"
 
  / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
  	};
@@ -16,6 +21,17 @@
  	};
  };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;
+		};
+	};
+};
+#endif
+
  &cru {
  	bootph-all;
  };
@@ -45,6 +61,16 @@
  	bootph-some-ram;
  };
 
+&fspi0_csn0 {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
+&fspi0_pins {
+	bootph-pre-ram;
+	bootph-some-ram;
+};
+
  &ioc_grf {
  	bootph-all;
  };
@@ -116,6 +142,16 @@
  	bootph-some-ram;
  };
 
+&sfc0 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
+&sfc1 {
+	bootph-some-ram;
+	u-boot,spl-sfc-no-dma;
+};
+
  &sys_grf {
  	bootph-all;
  };
arch/arm/mach-rockchip/rk3576/rk3576.c +0 -0
index a6c2fbdc4840..3d5bdeeeb846 100644
@@ -36,8 +36,17 @@
  #define USB_GRF_BASE		0x2601E000
  #define USB3OTG0_CON1		0x0030
 
Quoted 15 lines

arch/arm/mach-rockchip/rk3576/rk3576.c line 48

Quoted 10 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +8 -0
+enum {
+	BROM_BOOTSOURCE_FSPI0 = 3,
+	BROM_BOOTSOURCE_FSPI1_M0 = 4,
+	BROM_BOOTSOURCE_FSPI1_M1 = 6,
+};
+
  const char * const boot_devices[BROM_LAST_BOOTSOURCE + 1] = {
  	[BROM_BOOTSOURCE_EMMC] = "/soc/mmc@2a330000",
+	[BROM_BOOTSOURCE_FSPI0] = "/soc/spi@2a340000/flash@0",
+	[BROM_BOOTSOURCE_FSPI1_M0] = "/soc/spi@2a300000/flash@0",

This in addition to BROM_BOOTSOURCE_FSPI1_M0 in the enum may mislead the user into believing it is supported whereas we most likely need to do another mapping in read_brom_bootsource_id() below, so I would just not add either to this patch.

You are correct, this will most likely not work as-is, I re-used the SPI NAND value for fspi1 M0, as it may not be used for anything. 6 is the only unused/unknown value, 7 is used for UFS as indicated by vendor tree.

Will drop FSPI1_M0 from v3.

Quoted 30 lines
Quoted 7 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +1 -0
+	[BROM_BOOTSOURCE_FSPI1_M1] = "/soc/spi@2a300000/flash@0",
  	[BROM_BOOTSOURCE_SD] = "/soc/mmc@2a310000",
  };
 
@@ -85,6 +94,20 @@ void board_debug_uart_init(void)
  {

arch/arm/mach-rockchip/rk3576/rk3576.c void board_debug_uart_init(void) · line 104

Quoted 10 lines
arch/arm/mach-rockchip/rk3576/rk3576.c +8 -0
  }
 
+u32 read_brom_bootsource_id(void)
+{
+	u32 bootsource_id = readl(BROM_BOOTSOURCE_ID_ADDR);
+
+	if (bootsource_id == 0x23)
+		return BROM_BOOTSOURCE_FSPI1_M1;
+	else if (bootsource_id == 0x81)
+		return BROM_BOOTSOURCE_USB;

I believe this differs from what we've done for all other SoCs where we have an entry at the offset bootsource_id in the boot_devices array.

On RK3588 it seems we're doing something similar of defining new BROM_BOOTSOURCE_ values in another enum and using them in the boot_devices array as indices. However, it seems we're using them verbatim instead of doing the mapping like we do here in rk3576.c. The only reason I could think of that is that 0x81 would create a pretty big array for no specific reason. Considering we already have an entry for the exact same scenario with a different number, I feel like it's fair to do the mapping.

Quoted 3 lines

It would be nice at least to provide some information on why it's done this way since it differs from what we've done until now. Especially that the enum doesn't match the raw value from the register anymore.

Yes, the table size was the only reason for using a different type re-mapping here, for rk3588 the actual raw values changed meaning so using a new enum worked fine. For rk3576 the values changes completely, and vendor U-Boot does not give any hint, so re-mapping known values seem least intrusive until more details are uncovered.

I will add comment about reson for re-mapping in v3.

Maybe @Kever have some insights in how boot source id is encoded by the boot-rom for rk3576?

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#6 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

In reply to Jonas Karlman

Hi Jonas,

Quoted 37 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
  arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
  arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
  2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +5 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
  #include "rockchip-u-boot.dtsi"
 
  / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
  	};

arch/arm/dts/rk3576-u-boot.dtsi line 29

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +6 -0
@@ -16,6 +21,17 @@
  	};
  };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;

Is this a requirement of the SoC or just a default?

E.g. on my RK3399 I can flash at offset 0 u-boot-rockchip-spi.bin and it'll happily boot. Is it still the same on RK3576 but you preferred to have a similar offset than for eMMC/SD (and/or have space to store a partition table before?)

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 4 lines
arch/arm/dts/rk3576-u-boot.dtsi +4 -0
+		};
+	};
+};
+#endif

Not a blocker for this patch but I think it would make sense to invert the logic globally now so that we don't need to have to do this for every new Rockchip SoC we'll support.

Have -T rksd in rockchip-u-boot.dtsi and all SoCs that have an SPI controller and do not override this property would have -T rkspi set in their SoC DTSI, e.g. rk3399-u-boot.dtsi would now get

+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+ simple-bin-spi {
+ mkimage {
+ args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
+ };
+ };
+};
+#endif

Cheers,
Quentin

#7 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

Hi Quentin,

Quoted 52 lines · Quentin Schulz

Hi Jonas,

Quoted 37 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
  arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
  arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
  2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +5 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
  #include "rockchip-u-boot.dtsi"
 
  / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
  	chosen {
  		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
  	};

arch/arm/dts/rk3576-u-boot.dtsi line 29

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +6 -0
@@ -16,6 +21,17 @@
  	};
  };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;

Is this a requirement of the SoC or just a default?

Quoted 4 lines

E.g. on my RK3399 I can flash at offset 0 u-boot-rockchip-spi.bin and it'll happily boot. Is it still the same on RK3576 but you preferred to have a similar offset than for eMMC/SD (and/or have space to store a partition table before?)

Not sure if I ever tested using offset 0 for rk3576, will do before v3.

If I remember correctly the rk356x/rk3588 (and/or others SoCs) would not boot when using offset 0, so I probably only tested the 32 KiB offset that is known working for other rk35xx SoCs. And on RK3326 (probably also PX30) a 64 KiB offset resulted in working boot from SPI flash.

Quoted 14 lines

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 5 lines
arch/arm/dts/rk3576-u-boot.dtsi +4 -0
+		};
+	};
+};
+#endif

Not a blocker for this patch but I think it would make sense to invert the logic globally now so that we don't need to have to do this for every new Rockchip SoC we'll support.

Have -T rksd in rockchip-u-boot.dtsi and all SoCs that have an SPI controller and do not override this property would have -T rkspi set in their SoC DTSI, e.g. rk3399-u-boot.dtsi would now get

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +9 -0
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
+		};
+	};
+};
+#endif

I fully agree, there is now a minority using the special rkspi format so a flip to have rksd (and possible also the 32 KiB offset) in rockchip-u-boot.dtsi is a very good idea for a future series.

From a quick grep maybe only rk3288 and rk3399 may need this special rkspi format? Probably also some older SoCs, not sure we really support building working SPI flash images for such older SoCs anyway.

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#8 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

Hi Jonas,

Quoted 60 lines · Jonas Karlman

Hi Quentin,

Quoted 52 lines · Quentin Schulz

Hi Jonas,

Quoted 37 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
   arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
   arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
   2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +5 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
   #include "rockchip-u-boot.dtsi"
 
   / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
   	chosen {
   		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
   	};

arch/arm/dts/rk3576-u-boot.dtsi line 29

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +6 -0
@@ -16,6 +21,17 @@
   	};
   };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;

Is this a requirement of the SoC or just a default?

Quoted 4 lines

E.g. on my RK3399 I can flash at offset 0 u-boot-rockchip-spi.bin and it'll happily boot. Is it still the same on RK3576 but you preferred to have a similar offset than for eMMC/SD (and/or have space to store a partition table before?)

Quoted 4 lines

Not sure if I ever tested using offset 0 for rk3576, will do before v3.

If I remember correctly the rk356x/rk3588 (and/or others SoCs) would not boot when using offset 0, so I probably only tested the 32 KiB offset

Possibly, I only own one board with a bootable SPI, my old RK3399 Puma so that's about the sample size I can get :)

Quoted 3 lines

that is known working for other rk35xx SoCs. And on RK3326 (probably also PX30) a 64 KiB offset resulted in working boot from SPI flash.

IIRC, I mistakenly flashed on 32KiB offset for RK3399 as well and it booted (the SPL, then it broke because it's so much space constrained on RK3399 Puma that I cannot afford the 32KiB offset).

I guess this could also be something we could have as default. If you want a different offset, then you can update it in your board -u-boot.dtsi (or have a Kconfig symbol, but IIRC we don't have one for MMC so why have one for SPI only?).

Quoted 28 lines
Quoted 14 lines

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 5 lines
arch/arm/dts/rk3576-u-boot.dtsi +4 -0
+		};
+	};
+};
+#endif

Not a blocker for this patch but I think it would make sense to invert the logic globally now so that we don't need to have to do this for every new Rockchip SoC we'll support.

Have -T rksd in rockchip-u-boot.dtsi and all SoCs that have an SPI controller and do not override this property would have -T rkspi set in their SoC DTSI, e.g. rk3399-u-boot.dtsi would now get

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +9 -0
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
+		};
+	};
+};
+#endif

I fully agree, there is now a minority using the special rkspi format so a flip to have rksd (and possible also the 32 KiB offset) in rockchip-u-boot.dtsi is a very good idea for a future series.

Quoted 4 lines

From a quick grep maybe only rk3288 and rk3399 may need this special
rkspi format? Probably also some older SoCs, not sure we really support building working SPI flash images for such older SoCs anyway.

What we can start with is doing a flip which results in the exact same binary before and after the flip. Then whichever SoC doesn't actually need the rkspi trick can disable it on the SoC level I guess in a later patch?

Cheers,
Quentin

#9 lore raw

Re: [PATCH v2 3/4] rockchip: rk3576: Add SPI Flash boot support

Hi Quentin,

Quoted 71 lines · Quentin Schulz

Hi Jonas,

Quoted 60 lines · Jonas Karlman

Hi Quentin,

Quoted 52 lines · Quentin Schulz

Hi Jonas,

Quoted 37 lines · Jonas Karlman

The bootsource ids reported by BootROM of RK3576 for SPI NOR and USB differs slightly compared to prior SoCs:

- Booting from sfc0 (ROCK 4D) report the normal bootsource id 0x3.
- Booting from sfc1 M1 (NanoPi M5) report a new bootsource id 0x23.
- Booting from sfc1 M0 has not been tested (no board using this config).
- Booting from USB report a new bootsource id 0x81.

Add a RK3576 specific read_brom_bootsource_id() function to help decode the new bootsource id values and the required boot_devices mapping of sfc0 and sfc1 to help support booting from SPI flash on RK3576.

---
v2: No change

---
   arch/arm/dts/rk3576-u-boot.dtsi        | 36 ++++++++++++++++++++++++++
   arch/arm/mach-rockchip/rk3576/rk3576.c | 23 ++++++++++++++++
   2 files changed, 59 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +5 -0
index fb5a107f47d9..c7ed09e03eec 100644
@@ -6,6 +6,11 @@
   #include "rockchip-u-boot.dtsi"
 
   / {
+	aliases {
+		spi5 = &sfc0;
+		spi6 = &sfc1;
+	};
+
   	chosen {
   		u-boot,spl-boot-order = "same-as-spl", &sdmmc, &sdhci;
   	};

arch/arm/dts/rk3576-u-boot.dtsi line 29

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +6 -0
@@ -16,6 +21,17 @@
   	};
   };
 
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+			offset = <0x8000>;

Is this a requirement of the SoC or just a default?

Quoted 4 lines

E.g. on my RK3399 I can flash at offset 0 u-boot-rockchip-spi.bin and it'll happily boot. Is it still the same on RK3576 but you preferred to have a similar offset than for eMMC/SD (and/or have space to store a partition table before?)

Quoted 4 lines

Not sure if I ever tested using offset 0 for rk3576, will do before v3.

If I remember correctly the rk356x/rk3588 (and/or others SoCs) would not boot when using offset 0, so I probably only tested the 32 KiB offset

Possibly, I only own one board with a bootable SPI, my old RK3399 Puma so that's about the sample size I can get :)

Quoted 7 lines
Quoted 3 lines

that is known working for other rk35xx SoCs. And on RK3326 (probably also PX30) a 64 KiB offset resulted in working boot from SPI flash.

IIRC, I mistakenly flashed on 32KiB offset for RK3399 as well and it booted (the SPL, then it broke because it's so much space constrained on RK3399 Puma that I cannot afford the 32KiB offset).

I did a quick test of using offset 0 of SPI flash on ROCK 4D and it booted fine, will however keep the 32 KiB offset in v3 to use consistent offset with the other RK35xx SoCs/boards.

Quoted 5 lines

I guess this could also be something we could have as default. If you want a different offset, then you can update it in your board -u-boot.dtsi (or have a Kconfig symbol, but IIRC we don't have one for MMC so why have one for SPI only?).

Agree, possible adding use of a Kconfig symbol for offsets could be something for a future follow-up series.

Quoted 34 lines
Quoted 29 lines
Quoted 15 lines

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 6 lines
arch/arm/dts/rk3576-u-boot.dtsi +4 -0
+		};
+	};
+};
+#endif

Not a blocker for this patch but I think it would make sense to invert the logic globally now so that we don't need to have to do this for every new Rockchip SoC we'll support.

Have -T rksd in rockchip-u-boot.dtsi and all SoCs that have an SPI controller and do not override this property would have -T rkspi set in their SoC DTSI, e.g. rk3399-u-boot.dtsi would now get

arch/arm/dts/rk3576-u-boot.dtsi line 33

Quoted 9 lines
arch/arm/dts/rk3576-u-boot.dtsi +9 -0
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE
+&binman {
+	simple-bin-spi {
+		mkimage {
+			args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
+		};
+	};
+};
+#endif

I fully agree, there is now a minority using the special rkspi format so a flip to have rksd (and possible also the 32 KiB offset) in rockchip-u-boot.dtsi is a very good idea for a future series.

Quoted 4 lines

From a quick grep maybe only rk3288 and rk3399 may need this special
rkspi format? Probably also some older SoCs, not sure we really support building working SPI flash images for such older SoCs anyway.

Quoted 4 lines

What we can start with is doing a flip which results in the exact same binary before and after the flip. Then whichever SoC doesn't actually need the rkspi trick can disable it on the SoC level I guess in a later patch?

I think this make sense, and something for a future series :-)

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#10 lore raw

PATCH v2 4/4 board: rockchip: Add Radxa ROCK 4D

In reply to Jonas Karlman

The Radxa ROCK 4D is a compact single-board computer (SBC) featuring numerous top-tier functions, features, and expansion options.

Equipped with the Rockchip RK3576 or RK3576J SoC, the ROCK 4D boasts an octa-core CPU (4x Cortex-A72 + 4x Cortex-A53), Mali-G52 GPU, and a powerful 6 TOPS NPU, making it ideal for AI and multimedia tasks.

Features tested on a Radxa ROCK 4D v1.112:
- SPI Flash boot
- Ethernet

ROCK 4D boards with SPI Flash is configured to boot from FSPI0->UFS->USB, or directly from USB when the MASKROM button is pressed, booting directly from SD-card is not possible on these boards.

---
v2: Add comment about the reset-gpios prop rename

---
 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi   | 19 +++++++
 arch/arm/mach-rockchip/rk3576/MAINTAINERS |  6 ++
 configs/rock-4d-rk3576_defconfig          | 68 +++++++++++++++++++++++
 doc/board/rockchip/rockchip.rst           |  1 +
 4 files changed, 94 insertions(+)
 create mode 100644 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi
 create mode 100644 configs/rock-4d-rk3576_defconfig
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +19 -0
new file mode 100644
index 000000000000..2e882c3cf786
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3576-u-boot.dtsi"
+
+/* U-Boot only look for the reset-gpios prop, rename the prop until the Linux
+ * commit cd803da7c033 ("arm64: dts: rockchip: fix PHY handling for ROCK 4D")
+ * lands in dts/upstream to ensure Ethernet can work in U-Boot.
+ */
+&rgmii_phy0 {
+	/delete-property/ reset-gpio;
+	reset-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;
+};
+
+&sfc0 {
+	flash@0 {
+		bootph-pre-ram;
+		bootph-some-ram;
+	};
+};
arch/arm/mach-rockchip/rk3576/MAINTAINERS +6 -0
index 94ef74d429f9..54c75f451f0f 100644
@@ -4,6 +4,12 @@ S:	Maintained
 F:	arch/arm/dts/rk3576-generic*
 F:	configs/generic-rk3576_defconfig
 
+ROCK-4D-RK3576
+M:	Jonas Karlman <[email protected]>
+S:	Maintained
+F:	arch/arm/dts/rk3576-rock-4d*
+F:	configs/rock-4d-rk3576_defconfig
+
 SIGE5-RK3576
 M:	Jonas Karlman <[email protected]>
 S:	Maintained
configs/rock-4d-rk3576_defconfig new file +68 -0

68 lines not on this page · raw message

doc/board/rockchip/rockchip.rst +1 -0
index dec07bd3477a..843987f2fa5b 100644
@@ -137,6 +137,7 @@ List of mainline supported Rockchip boards:
      - ArmSoM Sige5 (sige5-rk3576)
      - Firefly ROC-RK3576-PC (roc-pc-rk3576)
      - Generic RK3576 (generic-rk3576)
+     - Radxa ROCK 4D (rock-4d-rk3576)
 
 * rk3588
      - ArmSoM Sige7 (sige7-rk3588)
Signature · 1 line
2.50.1
#11 lore raw

Hi Jonas,

Quoted 33 lines · Jonas Karlman

The Radxa ROCK 4D is a compact single-board computer (SBC) featuring numerous top-tier functions, features, and expansion options.

Equipped with the Rockchip RK3576 or RK3576J SoC, the ROCK 4D boasts an octa-core CPU (4x Cortex-A72 + 4x Cortex-A53), Mali-G52 GPU, and a powerful 6 TOPS NPU, making it ideal for AI and multimedia tasks.

Features tested on a Radxa ROCK 4D v1.112:
- SPI Flash boot
- Ethernet

ROCK 4D boards with SPI Flash is configured to boot from FSPI0->UFS->USB, or directly from USB when the MASKROM button is pressed, booting directly from SD-card is not possible on these boards.

---
v2: Add comment about the reset-gpios prop rename

---
  arch/arm/dts/rk3576-rock-4d-u-boot.dtsi   | 19 +++++++
  arch/arm/mach-rockchip/rk3576/MAINTAINERS |  6 ++
  configs/rock-4d-rk3576_defconfig          | 68 +++++++++++++++++++++++
  doc/board/rockchip/rockchip.rst           |  1 +
  4 files changed, 94 insertions(+)

create mode 100644 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi create mode 100644 configs/rock-4d-rk3576_defconfig

arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +0 -0
new file mode 100644
index 000000000000..2e882c3cf786

arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 8

Quoted 8 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +8 -0
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3576-u-boot.dtsi"
+
+/* U-Boot only look for the reset-gpios prop, rename the prop until the Linux
+ * commit cd803da7c033 ("arm64: dts: rockchip: fix PHY handling for ROCK 4D")
+ * lands in dts/upstream to ensure Ethernet can work in U-Boot.
+ */

This commit landed in v6.17-rc1. I assume it's just a matter of hours/days before it reaches devicetree-rebasing git repo so that you can simply cherry-pick it into U-Boot with tools/update-subtree.sh :)

Cheers,
Quentin

#12 lore raw

Hi Quentin,

Quoted 40 lines · Quentin Schulz

Hi Jonas,

Quoted 37 lines · Jonas Karlman

The Radxa ROCK 4D is a compact single-board computer (SBC) featuring numerous top-tier functions, features, and expansion options.

Equipped with the Rockchip RK3576 or RK3576J SoC, the ROCK 4D boasts an octa-core CPU (4x Cortex-A72 + 4x Cortex-A53), Mali-G52 GPU, and a powerful 6 TOPS NPU, making it ideal for AI and multimedia tasks.

Features tested on a Radxa ROCK 4D v1.112:
- SPI Flash boot
- Ethernet

ROCK 4D boards with SPI Flash is configured to boot from FSPI0->UFS->USB, or directly from USB when the MASKROM button is pressed, booting directly from SD-card is not possible on these boards.

---
v2: Add comment about the reset-gpios prop rename

---
  arch/arm/dts/rk3576-rock-4d-u-boot.dtsi   | 19 +++++++
  arch/arm/mach-rockchip/rk3576/MAINTAINERS |  6 ++
  configs/rock-4d-rk3576_defconfig          | 68 +++++++++++++++++++++++
  doc/board/rockchip/rockchip.rst           |  1 +
  4 files changed, 94 insertions(+)

create mode 100644 arch/arm/dts/rk3576-rock-4d-u-boot.dtsi create mode 100644 configs/rock-4d-rk3576_defconfig

arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +4 -0
new file mode 100644
index 000000000000..2e882c3cf786
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3576-u-boot.dtsi"
+
Quoted 8 lines

arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 8

Quoted 4 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +4 -0
+/* U-Boot only look for the reset-gpios prop, rename the prop until the Linux
+ * commit cd803da7c033 ("arm64: dts: rockchip: fix PHY handling for ROCK 4D")
+ * lands in dts/upstream to ensure Ethernet can work in U-Boot.
+ */

This commit landed in v6.17-rc1. I assume it's just a matter of hours/days before it reaches devicetree-rebasing git repo so that you can simply cherry-pick it into U-Boot with tools/update-subtree.sh :)

Correct, v6.17-rc1-dts has now been pushed to devicetree-rebasing so I will pick the DT fix for v3. May also have to add a clk patch for v3 due to use of an U-Boot unsupported clock-id in mentioned DT fix.

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin