rockchip: Enable use of OP-TEE for RK3506
Subsystems (3)
cover rockchip: Enable use of OP-TEE for RK3506
Vendor OP-TEE blob provides PSCI that is used to enable CPU cores on RK3506. The OP-TEE blob is expected to be loaded and executed from 0x1000 and uses memory in the 0-1 MiB area of DRAM.
This series add initial support for loading OP-TEE firmware on RK3506 and to reserve the first 1 MiB of DRAM for OP-TEE use.
Use ROCKCHIP_SPL_RESERVE_IRAM to pad beginning of SPL to avoid OP-TEE blob to overlap with SPL. In future, using a different load address for SPL in idblock v2 header could likely avoid this padding. However, we currently does not have a way to configure what load addresses should be written to the idblock header. The padding approach has been used in the past and seem to work good enough for now.
This series does not have any direct dependencies, however other RK3506 related patches may be needed to fully support devicetree/boards that have been submitted to Linux [1][2]. A branch that includes board support and other related patches can be found at [3].
[1] https://patch.msgid.link/[email protected]/
[2] https://patch.msgid.link/[email protected]/
[3] https://git.u-boot-project.org/u-boot/contributors/kwiboo/u-boot/-/commits/rk3506
Jonas Karlman (3):
rockchip: spl: Fix use of ROCKCHIP_SPL_RESERVE_IRAM on ARMv7
rockchip: sdram: Allow reserving a region at start of DRAM on ARMv7
rockchip: rk3506: Enable use of SPL_OPTEE_IMAGE
arch/arm/include/asm/arch-rockchip/boot0.h | 10 +++++----- arch/arm/mach-rockchip/Kconfig | 4 ++++ arch/arm/mach-rockchip/sdram.c | 5 ++++- include/configs/rk3506_common.h | 1 + 4 files changed, 14 insertions(+), 6 deletions(-)
Signature · 1 line
2.56.1
PATCH 1/3 rockchip: spl: Fix use of ROCKCHIP_SPL_RESERVE_IRAM on ARMv7
Traditionally the SPL image is loaded to start of DRAM on Rockchip platform. However, vendor OP-TEE or TF-A blobs for a few newer RK SoCs, i.e. RK3506 and RV1126B, are expected to be loaded at or close to start of DRAM, something that would overlap SPL.
The IDBlock v2 format used on these SoCs can instruct BootROM to load an image to a specific load address. However, mkimage currently lacks support to configure a non-default load address for the SPL image.
The Kconfig option ROCKCHIP_SPL_RESERVE_IRAM can be used to create enough free space at beginning of DRAM for OP-TEE/TF-A to safely be loaded without overwriting SPL. However, this is not working on ARMv7.
Users of ROCKCHIP_SPL_RESERVE_IRAM started to be removed with the commit 5ce94c74a6b5 ("rockchip: rk3399: defconfig: no need to reserve IRAM for SPL") in v2020.01-rc2, and since the commit 49f8131e5594 ("rockchip:
rk3399-gru: Use TPL with common bss and stack addresses") in v2025.04-rc1 there is no more users of this Kconfig option.
Move the .space statement prior to the _start label to fix use of the ROCKCHIP_SPL_RESERVE_IRAM Kconfig option on ARMv7.
--- arch/arm/include/asm/arch-rockchip/boot0.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-rockchip/boot0.h +5 -5
@@ -44,6 +44,11 @@ entry_counter: b reset#endif +#if !defined(CONFIG_TPL_BUILD ) && defined(CONFIG_XPL_BUILD ) && \ + (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM >0 ) + .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for TF-A/OP-TEE */ +#endif +#if !defined(CONFIG_ARM64 )/* * For armv7, the addr '_start' will used as vector start address
@@ -53,8 +58,3 @@ entry_counter: _start: ARM_VECTORS#endif - -#if !defined(CONFIG_TPL_BUILD ) && defined(CONFIG_XPL_BUILD ) && \ - (CONFIG_ROCKCHIP_SPL_RESERVE_IRAM >0 ) - .space CONFIG_ROCKCHIP_SPL_RESERVE_IRAM /* space for the ATF data */ -#endif
Signature · 1 line
2.56.1
PATCH 2/3 rockchip: sdram: Allow reserving a region at start of DRAM on ARMv7
In reply to Jonas KarlmanVendor OP-TEE blob provides PSCI that is used to enable CPU cores on RK3506. The OP-TEE blob is expected to be loaded and executed from 0x1000 and uses memory in the 0-1 MiB area of DRAM.
Allow ARMv7 SoCs to reserve a region at start of DRAM by specifying a size using CFG_SYS_SDRAM_RESERVE. When defined, start the first DRAM bank after the reserved region similar to how the first 2 MiB of DRAM is typically reserved for use of TF-A on Aarch64 SoCs.
--- arch/arm/mach-rockchip/sdram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/sdram.c +4 -1
@@ -330,7 +330,7 @@ int dram_init_banksize(void) gd->dram[0 ].size = ram_top - gd->dram[0 ].start; }#else -#ifdef CONFIG_SPL_OPTEE_IMAGE +#if defined(CONFIG_SPL_OPTEE_IMAGE ) && !defined(CFG_SYS_SDRAM_RESERVE )struct tos_parameter_t *tos_parameter; tos_parameter = (struct tos_parameter_t *)(CFG_SYS_SDRAM_BASE +
@@ -353,6 +353,9 @@ int dram_init_banksize(void) }#else gd->dram[0 ].start =CFG_SYS_SDRAM_BASE ; +#ifdef CFG_SYS_SDRAM_RESERVE + gd->dram[0 ].start +=CFG_SYS_SDRAM_RESERVE ; +#endif gd->dram[0 ].size = top - gd->dram[0 ].start;#endif #endif
Signature · 1 line
2.56.1
PATCH 3/3 rockchip: rk3506: Enable use of SPL_OPTEE_IMAGE
In reply to Jonas KarlmanVendor OP-TEE blob provides PSCI that is used to enable CPU cores on RK3506. The OP-TEE blob is expected to be loaded and executed from 0x1000 and uses memory in the 0-1 MiB area of DRAM.
Add initial support for loading OP-TEE firmware on RK3506. Reserve the first 1 MiB of DRAM for OP-TEE and use ROCKCHIP_SPL_RESERVE_IRAM to add padding to the start of SPL text area to allow loading OP-TEE to 0x1000.
--- arch/arm/mach-rockchip/Kconfig | 4 ++++ include/configs/rk3506_common.h | 1 + 2 files changed, 5 insertions(+)
arch/arm/mach-rockchip/Kconfig +4 -0
@@ -332,6 +332,7 @@ config ROCKCHIP_RK3506 select BOARD_LATE_INIT select DM_REGULATOR_FIXED select DM_RESET + imply ARM_SMCCC if SPL_OPTEE_IMAGE imply BOOTSTD_FULL imply DM_RNG imply ENV_RELOC_GD_ENV_ADDR
@@ -352,6 +353,7 @@ config ROCKCHIP_RK3506 imply SPL_FIT_SIGNATURE imply SPL_LOAD_FIT imply SPL_OF_CONTROL + imply SPL_OPTEE_IMAGE if SPL_FIT imply SPL_PINCTRL imply SPL_RAM imply SPL_REGMAP
@@ -359,6 +361,7 @@ config ROCKCHIP_RK3506 imply SPL_SYSCON imply SYS_ARCH_TIMER imply SYSRESET + imply SYSRESET_PSCI if SPL_OPTEE_IMAGE help The Rockchip RK3506 is a ARM-based SoC with a tri-core Cortex-A7.
@@ -679,6 +682,7 @@ config ROCKCHIP_STIMER_BASE config ROCKCHIP_SPL_RESERVE_IRAM hex "Size of IRAM reserved in SPL" + default 0x40000 if ROCKCHIP_RK3506 && SPL_OPTEE_IMAGE default 0x0 help SPL may need reserve memory for firmware loaded by SPL, whose load
include/configs/rk3506_common.h +1 -0
@@ -11,6 +11,7 @@#define CFG_IRAM_BASE 0xfff80000#define CFG_SYS_SDRAM_BASE 0 +#define CFG_SYS_SDRAM_RESERVE SZ_1M#define SDRAM_MAX_SIZE 0xc0000000#ifndef ROCKCHIP_DEVICE_SETTINGS
Signature · 1 line
2.56.1