board: rockchip: Add Radxa ROCK 4D
Subsystems (4)
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 mmind/for-next, and should automatically start working once the updated device tree finally reach dts/upstream.
This series depends on the "board: rockchip: Add ArmSoM Sige5" [1] series for a clean apply.
[1] https://patchwork.ozlabs.org/cover/2110236/
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 | 15 +++++ 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, 169 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.49.0
PATCH 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.
--- drivers/spi/rockchip_sfc.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/spi/rockchip_sfc.c +12 -1
@@ -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_opreturn 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.49.0
PATCH 2/4 rockchip: spl: Add a read_brom_bootsource_id() helper
In reply to Jonas KarlmanThe 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.
--- 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
@@ -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
@@ -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.49.0
PATCH 3/4 rockchip: rk3576: Add SPI Flash boot support
In reply to Jonas KarlmanThe 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.
--- 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
@@ -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
@@ -33,8 +33,17 @@#define SGRF_DOMAIN_CON4 0x10#define SGRF_DOMAIN_CON5 0x14 +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" , };
@@ -82,6 +91,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.49.0
PATCH 4/4 board: rockchip: Add Radxa ROCK 4D
In reply to Jonas KarlmanThe 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.
--- arch/arm/dts/rk3576-rock-4d-u-boot.dtsi | 15 +++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 6 ++ configs/rock-4d-rk3576_defconfig | 68 +++++++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 4 files changed, 90 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 +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi" + +&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
@@ -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
@@ -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.49.0
Hi Jonas,
Quoted 31 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
- EthernetROCK 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.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/dts/rk3576-rock-4d-u-boot.dtsi | 15 +++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 6 ++ configs/rock-4d-rk3576_defconfig | 68 +++++++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 4 files changed, 90 insertions(+)create mode 100644
arch/arm/dts/rk3576-rock-4d-u-boot.dtsicreate mode 100644 configs/rock-4d-rk3576_defconfigarch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +0
-0
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 7
Quoted 7 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +7
-0@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi" + +&rgmii_phy0 { + /delete-property/ reset-gpio; + reset-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;
Why?
If the upstream DT is wrong, please fix the upstream DT first and cherry-pick.
If it isn't wrong, then can't we simply patch the PHY subsystem/driver to be able to read reset-gpio too instead?
Cheers,
Quentin
Hi Quentin,
Quoted 44 lines · Quentin Schulz
Hi Jonas,
Quoted 31 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
- EthernetROCK 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.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/dts/rk3576-rock-4d-u-boot.dtsi | 15 +++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 6 ++ configs/rock-4d-rk3576_defconfig | 68 +++++++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 4 files changed, 90 insertions(+)create mode 100644
arch/arm/dts/rk3576-rock-4d-u-boot.dtsicreate mode 100644 configs/rock-4d-rk3576_defconfigarch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +0
-0arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 7
Quoted 7 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +7
-0@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi" + +&rgmii_phy0 { + /delete-property/ reset-gpio; + reset-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;Why?
Quoted 2 lines
If the upstream DT is wrong, please fix the upstream DT first and cherry-pick.
This has already been fixed in upstream DT [1], however it is targeted for v6.17 so not pickable for another 4-6 weeks.
This u-boot.dtsi override fixes it so Ethernet PHY reset can work in U-Boot until the prop-rename fix has fully landed.
[1] https://lore.kernel.org/all/20250704-rk3576-rock4d-phy-handling-fixes-v1-1-1d64130c4139@kernel.org/
Quoted 3 lines
If it isn't wrong, then can't we simply patch the PHY subsystem/driver to be able to read reset-gpio too instead?
reset-gpios is the correct prop, so fixing DT is what should be done.
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
Hi Jonas,
Quoted 47 lines · Jonas Karlman
Hi Quentin,
Quoted 44 lines · Quentin Schulz
Hi Jonas,
Quoted 31 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
- EthernetROCK 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.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/dts/rk3576-rock-4d-u-boot.dtsi | 15 +++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 6 ++ configs/rock-4d-rk3576_defconfig | 68 +++++++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 4 files changed, 90 insertions(+)create mode 100644
arch/arm/dts/rk3576-rock-4d-u-boot.dtsicreate mode 100644 configs/rock-4d-rk3576_defconfigarch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +0
-0arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 7
Quoted 7 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +7
-0@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi" + +&rgmii_phy0 { + /delete-property/ reset-gpio; + reset-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;Why?
Quoted 6 lines
Quoted 2 lines
If the upstream DT is wrong, please fix the upstream DT first and cherry-pick.
This has already been fixed in upstream DT [1], however it is targeted for v6.17 so not pickable for another 4-6 weeks.
Maybe it'll make it in time for 6.16 but I don't see it in Heiko's v6.16-armsoc/dtsfixes so it probably is too late in the cycle :)
Can you add a comment that this can be removed once https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git/commit/?h=v6.17-armsoc/dts64&id=cd803da7c033e376a66793a43ee98e136bc6cc25 is merged into U-Boot DT?
So this part is fine with me now, thanks for the explanation :)
Cheers,
Quentin
Hi Quentin,
Quoted 57 lines · Quentin Schulz
Hi Jonas,
Quoted 47 lines · Jonas Karlman
Hi Quentin,
Quoted 44 lines · Quentin Schulz
Hi Jonas,
Quoted 31 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
- EthernetROCK 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.Signed-off-by Jonas Karlman <[email protected]>--- arch/arm/dts/rk3576-rock-4d-u-boot.dtsi | 15 +++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 6 ++ configs/rock-4d-rk3576_defconfig | 68 +++++++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 4 files changed, 90 insertions(+)create mode 100644
arch/arm/dts/rk3576-rock-4d-u-boot.dtsicreate mode 100644 configs/rock-4d-rk3576_defconfigarch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +0
-0arch/arm/dts/rk3576-rock-4d-u-boot.dtsi line 7
Quoted 7 lines
arch/arm/dts/rk3576-rock-4d-u-boot.dtsi new file +7
-0@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi" + +&rgmii_phy0 { + /delete-property/ reset-gpio; + reset-gpios = <&gpio2 RK_PB5 GPIO_ACTIVE_LOW>;Why?
Quoted 6 lines
Quoted 2 lines
If the upstream DT is wrong, please fix the upstream DT first and cherry-pick.
This has already been fixed in upstream DT [1], however it is targeted for v6.17 so not pickable for another 4-6 weeks.
Quoted 6 lines
Maybe it'll make it in time for 6.16 but I don't see it in Heiko's v6.16-armsoc/dtsfixes so it probably is too late in the cycle :)
Can you add a comment that this can be removed once
https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git/commit/?h=v6.17-armsoc/dts64&id=cd803da7c033e376a66793a43ee98e136bc6cc25
is merged into U-Boot DT?
I will add a comment to the U-Boot DT in a v2.
Regards,
Jonas
Quoted 5 lines
So this part is fine with me now, thanks for the explanation :)
Cheers,
Quentin