rockchip: rk3576: Add rng, checkboard() and generic board
Subsystems (4)
v2 cover rockchip: rk3576: Add rng, checkboard() and generic board
This is a follow-up series on top of the "Support for the RK3576" series. It adds support for RNG, USB PID, a generic board and printing of the running SoC variant.
Changes in v2:
- Add RNG node by picking a commit from devicetree-rebasing
- Add compatible for RK3576 to RNG driver
- Add default USB_GADGET_PRODUCT_NUM for RK3576
- Add USB OTG nodes to the minimal generic RK3576 board
- Split the checkboard() patch in two
- Split out the ArmSoM Sige5 patch into a separate series
Jonas Karlman (5):
rng: rockchip_rng: Add compatible for RK3576
rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576
board: rockchip: Add minimal generic RK3576 board
rockchip: rk3576: Implement checkboard() to print SoC variant
arm: dts: rockchip: Include OTP in U-Boot pre-reloc phase for RK3576
Nicolas Frattaroli (1):
arm64: dts: rockchip: add RK3576 RNG node
arch/arm/dts/rk3576-generic-u-boot.dtsi | 3 + arch/arm/dts/rk3576-generic.dts | 65 +++++++++++++++++++++ arch/arm/dts/rk3576-u-boot.dtsi | 4 ++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 5 ++ arch/arm/mach-rockchip/rk3576/rk3576.c | 48 +++++++++++++++ configs/generic-rk3576_defconfig | 51 ++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + drivers/rng/rockchip_rng.c | 4 ++ drivers/usb/gadget/Kconfig | 1 + dts/upstream/src/arm64/rockchip/rk3576.dtsi | 8 +++ 10 files changed, 190 insertions(+) create mode 100644 arch/arm/dts/rk3576-generic-u-boot.dtsi create mode 100644 arch/arm/dts/rk3576-generic.dts create mode 100644 arch/arm/mach-rockchip/rk3576/MAINTAINERS create mode 100644 configs/generic-rk3576_defconfig
Signature · 1 line
2.49.0
PATCH v2 1/6 arm64: dts: rockchip: add RK3576 RNG node
From: Nicolas Frattaroli <[email protected]>
The RK3576 has a hardware random number generator IP built into the SoC.
Add it to the SoC's .dtsi, now that there's a binding and driver for it.
[ upstream commit: 5268f3b5d29887480011b44567bcbf0d422cda94 ]
---
v2: New patch
--- dts/upstream/src/arm64/rockchip/rk3576.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)
dts/upstream/src/arm64/rockchip/rk3576.dtsi +8 -0
@@ -1419,6 +1419,14 @@ status = "disabled"; }; + rng: rng@2a410000 { + compatible = "rockchip,rk3576-rng"; + reg = <0x0 0x2a410000 0x0 0x200>; + clocks = <&cru HCLK_TRNG_NS>; + interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>; + resets = <&cru SRST_H_TRNG_NS>; + }; + otp: otp@2a580000 { compatible = "rockchip,rk3576-otp"; reg = <0x0 0x2a580000 0x0 0x400>;
Signature · 1 line
2.49.0
Re: [PATCH v2 1/6] arm64: dts: rockchip: add RK3576 RNG node
Quoted 6 lines · Jonas Karlman
From: Nicolas Frattaroli <[email protected]>
The RK3576 has a hardware random number generator IP built into the SoC.
Add it to the SoC's .dtsi, now that there's a binding and driver for it.
Quoted 8 lines
Signed-off-by Nicolas Frattaroli <[email protected]>Signed-off-by Heiko Stuebner <[email protected]>[ upstream commit:
5268f3b5d29887480011b44567bcbf0d422cda94](cherry picked from commit 25cfcb091747900639f2b5df297d26b3a6ca3989)Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 25 lines
---
v2: New patch--- dts/upstream/src/arm64/rockchip/rk3576.dtsi | 8 ++++++++ 1 file changed, 8 insertions(+)dts/upstream/src/arm64/rockchip/rk3576.dtsi +8
-0@@ -1419,6 +1419,14 @@ status = "disabled"; }; + rng: rng@2a410000 { + compatible = "rockchip,rk3576-rng"; + reg = <0x0 0x2a410000 0x0 0x200>; + clocks = <&cru HCLK_TRNG_NS>; + interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>; + resets = <&cru SRST_H_TRNG_NS>; + }; + otp: otp@2a580000 { compatible = "rockchip,rk3576-otp"; reg = <0x0 0x2a580000 0x0 0x400>;
PATCH v2 2/6 rng: rockchip_rng: Add compatible for RK3576
In reply to Jonas KarlmanThe RK3576 SoC contains a RKRNG block that can be used to generate random numbers using the rockchip_rng driver.
Add compatible for RK3576 to support random numbers:
=> rng list
RNG #0 - rng@2a410000
=> rng
00000000: 36 dd ab 98 ec fb fe d1 cf 36 b3 e1 9b 3d 00 90 6........6...=.. 00000010: f5 84 de 75 6b 27 48 9e 13 62 12 6c 50 ca 47 1a ...uk'H..b.lP.G. 00000020: b3 4d fc 43 c5 b5 2d be 07 27 03 26 bb 69 61 2a .M.C..-..'.&.ia* 00000030: 6f 70 01 83 4e ce 91 7a 5a 6c 7c 00 43 87 3e c5 op..N..zZl|.C.>.
---
v2: New patch
--- drivers/rng/rockchip_rng.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/rng/rockchip_rng.c +4 -0
@@ -393,6 +393,10 @@ static const struct udevice_id rockchip_rng_match[] = { .compatible = "rockchip,rk3588-rng", .data = (ulong)&rk_trngv1_soc_data, }, + { + .compatible = "rockchip,rk3576-rng", + .data = (ulong)&rkrng_soc_data, + }, { .compatible = "rockchip,rkrng", .data = (ulong)&rkrng_soc_data,
Signature · 1 line
2.49.0
Re: [PATCH v2 2/6] rng: rockchip_rng: Add compatible for RK3576
Quoted 14 lines · Jonas Karlman
The RK3576 SoC contains a RKRNG block that can be used to generate random numbers using the
rockchip_rngdriver.Add compatible for RK3576 to support random numbers:
=> rng list RNG #0 - rng@2a410000 => rng 00000000: 36 dd ab 98 ec fb fe d1 cf 36 b3 e1 9b 3d 00 90 6........6...=.. 00000010: f5 84 de 75 6b 27 48 9e 13 62 12 6c 50 ca 47 1a ...uk'H..b.lP.G. 00000020: b3 4d fc 43 c5 b5 2d be 07 27 03 26 bb 69 61 2a .M.C..-..'.&.ia* 00000030: 6f 70 01 83 4e ce 91 7a 5a 6c 7c 00 43 87 3e c5 op..N..zZl|.C.>.
Quoted 1 line
Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 21 lines
---
v2: New patch--- drivers/rng/rockchip_rng.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/rng/rockchip_rng.c +4
-0@@ -393,6 +393,10 @@ static const struct udevice_id rockchip_rng_match[] = { .compatible = "rockchip,rk3588-rng", .data = (ulong)&rk_trngv1_soc_data, }, + { + .compatible = "rockchip,rk3576-rng", + .data = (ulong)&rkrng_soc_data, + }, { .compatible = "rockchip,rkrng", .data = (ulong)&rkrng_soc_data,
PATCH v2 3/6 rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576
In reply to Jonas KarlmanUse 0x350e as the default USB Product ID for Rockchip RK3576, same PID being used by the BootROM when the device is in MASKROM mode.
---
v2: New patch
--- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/Kconfig +1 -0
@@ -86,6 +86,7 @@ config USB_GADGET_PRODUCT_NUM default 0x350a if ROCKCHIP_RK3568 default 0x350b if ROCKCHIP_RK3588 default 0x350c if ROCKCHIP_RK3528 + default 0x350e if ROCKCHIP_RK3576 default 0x0 help Product ID of the USB device emulated, reported to the host device.
Signature · 1 line
2.49.0
Re: [PATCH v2 3/6] rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576
Hi Jonas,
Thank you for the patch.
Quoted 4 lines · Jonas Karlman
Use
0x350eas the default USB Product ID for Rockchip RK3576, same PID being used by the BootROM when the device is in MASKROM mode.Signed-off-by Jonas Karlman <[email protected]>
Quoted 20 lines
---
v2: New patch--- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/usb/gadget/Kconfig +1
-0@@ -86,6 +86,7 @@ config USB_GADGET_PRODUCT_NUM default 0x350a if ROCKCHIP_RK3568 default 0x350b if ROCKCHIP_RK3588 default 0x350c if ROCKCHIP_RK3528 + default 0x350e if ROCKCHIP_RK3576 default 0x0 help Product ID of the USB device emulated, reported to the host device.Signature · 1 line
2.49.0
Re: [PATCH v2 3/6] rockchip: Add default USB_GADGET_PRODUCT_NUM for RK3576
In reply to Jonas KarlmanQuoted 4 lines · Jonas Karlman
Use
0x350eas the default USB Product ID for Rockchip RK3576, same PID being used by the BootROM when the device is in MASKROM mode.Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 18 lines
---
v2: New patch--- drivers/usb/gadget/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/usb/gadget/Kconfig +1
-0@@ -86,6 +86,7 @@ config USB_GADGET_PRODUCT_NUM default 0x350a if ROCKCHIP_RK3568 default 0x350b if ROCKCHIP_RK3588 default 0x350c if ROCKCHIP_RK3528 + default 0x350e if ROCKCHIP_RK3576 default 0x0 help Product ID of the USB device emulated, reported to the host device.
PATCH v2 4/6 board: rockchip: Add minimal generic RK3576 board
In reply to Jonas KarlmanAdd a minimal generic RK3576 board that only have eMMC, SDMMC and USB OTG enabled. This defconfig can be used to boot from eMMC or SD-card on most RK3576 boards that follow reference board design.
eMMC and SD-card boot tested on:
- ArmSoM CM5
- ArmSoM Sige5
- FriendlyElec NanoPi M5
- Luckfox Omni3576
- Toybrick TB-RK3576D
---
v2: Add nodes and Kconfig options for USB OTG
--- arch/arm/dts/rk3576-generic-u-boot.dtsi | 3 ++ arch/arm/dts/rk3576-generic.dts | 65 +++++++++++++++++++++++ arch/arm/mach-rockchip/rk3576/MAINTAINERS | 5 ++ configs/generic-rk3576_defconfig | 51 ++++++++++++++++++ doc/board/rockchip/rockchip.rst | 1 + 5 files changed, 125 insertions(+) create mode 100644 arch/arm/dts/rk3576-generic-u-boot.dtsi create mode 100644 arch/arm/dts/rk3576-generic.dts create mode 100644 arch/arm/mach-rockchip/rk3576/MAINTAINERS create mode 100644 configs/generic-rk3576_defconfig
arch/arm/dts/rk3576-generic-u-boot.dtsi new file +3 -0
@@ -0,0 +1,3 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) + +#include "rk3576-u-boot.dtsi"
arch/arm/dts/rk3576-generic.dts new file +65 -0
65 lines not on this page · raw message
arch/arm/mach-rockchip/rk3576/MAINTAINERS new file +5 -0
@@ -0,0 +1,5 @@ +GENERIC-RK3576 +M: Jonas Karlman <[email protected]> +S: Maintained +F: arch/arm/dts/rk3576-generic* +F: configs/generic-rk3576_defconfig
configs/generic-rk3576_defconfig new file +51 -0
51 lines not on this page · raw message
doc/board/rockchip/rockchip.rst +1 -0
@@ -138,6 +138,7 @@ List of mainline supported Rockchip boards: * rk3576 - Firefly ROC-RK3576-PC (roc-pc-rk3576) + - Generic RK3576 (generic-rk3576) * rk3588 - ArmSoM Sige7 (sige7-rk3588)
Signature · 1 line
2.49.0
PATCH v2 5/6 rockchip: rk3576: Implement checkboard() to print SoC variant
In reply to Jonas KarlmanImplement checkboard() to print current SoC model used by a board when U-Boot proper is running.
U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
Model: Generic RK3576
SoC: RK3576
DRAM: 8 GiB
Information about the SoC model and variant is read from OTP.
--- arch/arm/mach-rockchip/rk3576/rk3576.c | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
arch/arm/mach-rockchip/rk3576/rk3576.c +48 -0
@@ -3,6 +3,10 @@* Copyright (c) 2024 Rockchip Electronics Co., Ltd */ +#define LOG_CATEGORY LOGC_ARCH + +#include <dm.h> +#include <misc.h> #include <asm/armv8/mmu.h> #include <asm/arch-rockchip/bootrom.h> #include <asm/arch-rockchip/hardware.h>
@@ -153,3 +157,47 @@ int arch_cpu_init(void)return 0 ; } + +#define RK3576_OTP_CPU_CODE_OFFSET 0x02 +#define RK3576_OTP_SPECIFICATION_OFFSET 0x08 + +int checkboard (void ) +{ +u8 cpu_code[2 ], specification; +struct udevice *dev; +char suffix[2 ]; +int ret; + +if (!IS_ENABLED (CONFIG_ROCKCHIP_OTP ) || !CONFIG_IS_ENABLED (MISC )) +return 0 ; + + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_DRIVER_GET (rockchip_otp), &dev); +if (ret) { +log_debug ("Could not find otp device, ret=%d\n" , ret); +return 0 ; + } + +/* cpu-code: SoC model, e.g. 0x35 0x76 */ + ret =misc_read (dev,RK3576_OTP_CPU_CODE_OFFSET , cpu_code,2 ); +if (ret <0 ) { +log_debug ("Could not read cpu-code, ret=%d\n" , ret); +return 0 ; + } + +/* specification: SoC variant, e.g. 0xA for RK3576J */ + ret =misc_read (dev,RK3576_OTP_SPECIFICATION_OFFSET , &specification,1 ); +if (ret <0 ) { +log_debug ("Could not read specification, ret=%d\n" , ret); +return 0 ; + } + specification &=0x1f ; + +/* for RK3576J i.e. '@' + 0xA = 'J' */ + suffix[0 ] = specification >1 ?'@' + specification :'\0' ; + suffix[1 ] ='\0' ; + +printf ("SoC: RK%02x%02x%s\n" , cpu_code[0 ], cpu_code[1 ], suffix); + +return 0 ; +}
Signature · 1 line
2.49.0
Re: [PATCH v2 5/6] rockchip: rk3576: Implement checkboard() to print SoC variant
Quoted 5 lines · Jonas Karlman
Implement
checkboard()to print current SoC model used by a board when U-Boot proper is running.U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
Quoted 7 lines
Model: Generic RK3576
SoC: RK3576
DRAM: 8 GiBInformation about the SoC model and variant is read from OTP.
Signed-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 67 lines
--- arch/arm/mach-rockchip/rk3576/rk3576.c | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)arch/arm/mach-rockchip/rk3576/rk3576.c +48
-0@@ -3,6 +3,10 @@* Copyright (c) 2024 Rockchip Electronics Co., Ltd */ +#define LOG_CATEGORY LOGC_ARCH + +#include <dm.h> +#include <misc.h> #include <asm/armv8/mmu.h> #include <asm/arch-rockchip/bootrom.h> #include <asm/arch-rockchip/hardware.h> @@ -153,3 +157,47 @@ int arch_cpu_init(void)return 0 ; } + +#define RK3576_OTP_CPU_CODE_OFFSET 0x02 +#define RK3576_OTP_SPECIFICATION_OFFSET 0x08 + +int checkboard (void ) +{ +u8 cpu_code[2 ], specification; +struct udevice *dev; +char suffix[2 ]; +int ret; + +if (!IS_ENABLED (CONFIG_ROCKCHIP_OTP ) || !CONFIG_IS_ENABLED (MISC )) +return 0 ; + + ret =uclass_get_device_by_driver (UCLASS_MISC , +DM_DRIVER_GET (rockchip_otp), &dev); +if (ret) { +log_debug ("Could not find otp device, ret=%d\n" , ret); +return 0 ; + } + +/* cpu-code: SoC model, e.g. 0x35 0x76 */ + ret =misc_read (dev,RK3576_OTP_CPU_CODE_OFFSET , cpu_code,2 ); +if (ret <0 ) { +log_debug ("Could not read cpu-code, ret=%d\n" , ret); +return 0 ; + } + +/* specification: SoC variant, e.g. 0xA for RK3576J */ + ret =misc_read (dev,RK3576_OTP_SPECIFICATION_OFFSET , &specification,1 ); +if (ret <0 ) { +log_debug ("Could not read specification, ret=%d\n" , ret); +return 0 ; + } + specification &=0x1f ; + +/* for RK3576J i.e. '@' + 0xA = 'J' */ + suffix[0 ] = specification >1 ?'@' + specification :'\0' ; + suffix[1 ] ='\0' ; + +printf ("SoC: RK%02x%02x%s\n" , cpu_code[0 ], cpu_code[1 ], suffix); + +return 0 ; +}
PATCH v2 6/6 arm: dts: rockchip: Include OTP in U-Boot pre-reloc phase for RK3576
In reply to Jonas KarlmanUpdate rk3576-u-boot.dtsi to include OTP in U-Boot pre-reloc phase for checkboard() to be able to read information about the running SoC model and variant from OTP and print it during boot:
U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
Model: Generic RK3576
SoC: RK3576
DRAM: 8 GiB
--- arch/arm/dts/rk3576-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/dts/rk3576-u-boot.dtsi +4 -0
@@ -49,6 +49,10 @@ bootph-all; }; +&otp { + bootph-some-ram; +}; + &pcfg_pull_none { bootph-all; };
Signature · 1 line
2.49.0
Re: [PATCH v2 6/6] arm: dts: rockchip: Include OTP in U-Boot pre-reloc phase for RK3576
Quoted 11 lines · Jonas Karlman
Update
rk3576-u-boot.dtsito include OTP in U-Boot pre-reloc phase forcheckboard()to be able to read information about the running SoC model and variant from OTP and print it during boot:U-Boot 2025.04 (Apr 22 2025 - 20:43:17 +0000)
Model: Generic RK3576
SoC: RK3576
DRAM: 8 GiBSigned-off-by Jonas Karlman <[email protected]>
Thanks,
- Kever
Quoted 19 lines
--- arch/arm/dts/rk3576-u-boot.dtsi | 4 ++++ 1 file changed, 4 insertions(+)arch/arm/dts/rk3576-u-boot.dtsi +4
-0@@ -49,6 +49,10 @@ bootph-all; }; +&otp { + bootph-some-ram; +}; + &pcfg_pull_none { bootph-all; };