rockchip: Miscellaneous updates for RK3506
Subsystems (3)
v2 cover rockchip: Miscellaneous updates for RK3506
This series includes miscellaneous updates for RK3506, such as:
- imply OF_UPSTREAM at SoC level
- updated default load addresses to support limited memory SoC variants
- changes to use FIELD_PREP_WM16 macro where appropriate
- print type of RK3506Gx variant during boot
The patches in this series do not really have any dependencies on each other and can be applied independently from each other.
Changes in v2:
- Drop saradc related patch, no longer needed after rk3528 fix
- Drop clk related patches, expanded and moved to a new series
- Add patch to identify RK3506Gx variants, similar to DRAM init blob
- Update memory layout to divide memory between kernel and ramdisk more equally on 64 MiB DRAM boards
- Collect r-b tags
Link to v1: https://patch.msgid.link/[email protected]/
A copy of this and other RK3506 related series and patches can be found at [1], including board targets for upstream submitted boards [2][3].
[1] https://git.u-boot-project.org/u-boot/contributors/kwiboo/u-boot/-/commits/rk3506
[2] https://patch.msgid.link/[email protected]/
[3] https://patch.msgid.link/[email protected]/
Jonas Karlman (4):
rockchip: rk3506: Imply OF_UPSTREAM
rockchip: rk3506: Update ENV_MEM_LAYOUT_SETTINGS
rockchip: rk3506: Use FIELD_PREP_WM16 macro
rockchip: rk3506: Identify RK3506Gx SoC variants
arch/arm/mach-rockchip/Kconfig | 1 + arch/arm/mach-rockchip/rk3506/rk3506.c | 31 ++++++++++++++++++++------ include/configs/rk3506_common.h | 24 +++++++++++++------- 3 files changed, 41 insertions(+), 15 deletions(-)
Signature · 1 line
2.56.1
PATCH v2 1/4 rockchip: rk3506: Imply OF_UPSTREAM
The Rockchip platform typically require new board targets to use OF_UPSTREAM and board device trees from dts/upstream.
Imply OF_UPSTREAM at SoC level for RK3506.
---
Changes in v2:
- Collect r-b tags
--- arch/arm/mach-rockchip/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/Kconfig +1 -0
@@ -341,6 +341,7 @@ config ROCKCHIP_RK3506 imply MISC_INIT_R imply OF_LIBFDT_OVERLAY imply OF_LIVE + imply OF_UPSTREAM imply RNG_ROCKCHIP imply ROCKCHIP_COMMON_BOARD imply ROCKCHIP_COMMON_STACK_ADDR
Signature · 1 line
2.56.1
PATCH v2 2/4 rockchip: rk3506: Update ENV_MEM_LAYOUT_SETTINGS
In reply to Jonas KarlmanThe RK3506G1 has 64 MiB integrated DDR2, the RK3506G2 has 128 MiB integrated DDR3 and the RK3506B support external memory up to 1 GiB.
Current memory layout cause issues loading a ramdisk on RK3506G1 boards due to the default load address used reach beyond end of DRAM.
U-Boot is relocated near end of memory and will typically relocate fdt and ramdisk as close to end of the free memory as possible. Linux will relocate a compressed kernel to make room for the decompressed kernel. For a successful boot there typically need to be enough space in memory
for: U-Boot, compressed and decompressed kernel fdt and ramdisk.
Change the default load addresses to work on SoC variants with limited memory, keep all default addresses in the 0-64 MiB range with the possibility for use of a larger ramdisk on boards with more memory.
old new
scriptaddr 5 MiB 1.5 MiB
pxefile_addr_r 6 MiB 1 MiB
kernel_addr_r 32.5 MiB 4 MiB
fdt_addr_r 30.5 MiB 2 MiB
fdtoverlay_addr_r 31.5 MiB 3 MiB
ramdisk_addr_r 96 MiB 32 MiB
---
Changes in v2:
- Drop kernel_comp variables, they are unused on ARMv7
- Reduce size of fdt/fdtoverlay regions to 1 MiB each (from 2 MiB)
- Move kernel to 4 MiB (from 8 MiB)
- Move ramdisk to 32 MiB (from 48 Mib)
- Update commit message
--- include/configs/rk3506_common.h | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
include/configs/rk3506_common.h +16 -8
@@ -17,17 +17,25 @@#define ROCKCHIP_DEVICE_SETTINGS #endif +/* +* RK3506G1/RK3506G2 has 64/128 MiB integrated memory +* RK3506B support external memory up to 1 GiB +* +* Memory layout considerations: +* - Keep script/pxefile/fdt/fdtoverlay before kernel and ramdisk +* to allow for a larger ramdisk on boards with more memory +* - Keep kernel load address as close to start of DRAM as possible +* - Keep first 1-2 MiB of DRAM reserved for OPTEE-OS or TF-A use +*/ #define ENV_MEM_LAYOUT_SETTINGS \ - "scriptaddr=0x00500000\0" \ + "scriptaddr=0x00180000\0" \ "script_offset_f=0xffe000\0" \ "script_size_f=0x2000\0" \ - "pxefile_addr_r=0x00600000\0" \ - "kernel_addr_r=0x02080000\0" \ - "kernel_comp_addr_r=0x08000000\0" \ - "fdt_addr_r=0x01e00000\0" \ - "fdtoverlay_addr_r=0x01f00000\0" \ - "ramdisk_addr_r=0x06000000\0" \ - "kernel_comp_size=0x2000000\0" + "pxefile_addr_r=0x00100000\0" \ + "kernel_addr_r=0x00400000\0" \ + "fdt_addr_r=0x00200000\0" \ + "fdtoverlay_addr_r=0x00300000\0" \ + "ramdisk_addr_r=0x02000000\0"#define CFG_EXTRA_ENV_SETTINGS \ "fdtfile=" CONFIG_DEFAULT_FDT_FILE "\0" \
Signature · 1 line
2.56.1
PATCH v2 3/4 rockchip: rk3506: Use FIELD_PREP_WM16 macro
In reply to Jonas KarlmanChange to use writel() together with the FIELD_PREP_WM16() macro instead of using the rk_clrreg() macro or custom write-enable bit handling.
No change in behavior is expected due to this code style change.
---
Changes in v2:
- Use FIELD_GET() for TIMER_EN check
- Collect r-b tags
--- arch/arm/mach-rockchip/rk3506/rk3506.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/rk3506/rk3506.c +5 -4
@@ -6,7 +6,8 @@#include <dm.h> #include <misc.h> #include <asm/arch-rockchip/bootrom.h> -#include <asm/arch-rockchip/hardware.h> +#include <asm/io.h> +#include <linux/hw_bitfield.h> #define SGRF_BASE 0xff210000
@@ -32,7 +33,7 @@ int arch_cpu_init(void)return 0 ;/* Select non-secure OTPC */ -rk_clrreg (SGRF_BASE +0x100 ,BIT (1 )); +writel (FIELD_PREP_WM16 (BIT (1 ),0 ),SGRF_BASE +0x0100 );/* Set the sdmmc/emmc to access ddr memory */ val =readl (FIREWALL_DDR_BASE +FW_DDR_MST1_REG );
@@ -71,13 +72,13 @@ void rockchip_stimer_init(void)return ; reg =readl (HP_TIMER_BASE +HP_CTRL_REG ); -if (reg &TIMER_EN ) +if (FIELD_GET (TIMER_EN , reg))return ; asmvolatile ("mcr p15, 0, %0, c14, c0, 0" : :"r" (CONFIG_COUNTER_FREQUENCY ));writel (0xffffffff ,HP_TIMER_BASE +HP_LOAD_COUNT0_REG );writel (0xffffffff ,HP_TIMER_BASE +HP_LOAD_COUNT1_REG ); -writel ((TIMER_EN <<16 ) |TIMER_EN ,HP_TIMER_BASE +HP_CTRL_REG ); +writel (FIELD_PREP_WM16 (TIMER_EN ,1 ),HP_TIMER_BASE +HP_CTRL_REG ); }#define RK3506_OTP_CPU_CODE_OFFSET 0x02
Signature · 1 line
2.56.1
PATCH v2 4/4 rockchip: rk3506: Identify RK3506Gx SoC variants
In reply to Jonas KarlmanOTP data at offset 0x36 and 0x37 can be used to help identify G-variants of the RK3506 SoC.
Override the specification normally read from offset 0x08 with data from offset 0x36 when available to identify G-variants of the SoC.
Model: Luckfox Lyra Plus
SoC: RK3506G2
DRAM: 128 MiB (total 127 MiB)
---
Changes in v2:
- New patch
--- arch/arm/mach-rockchip/rk3506/rk3506.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
arch/arm/mach-rockchip/rk3506/rk3506.c +19 -3
@@ -83,12 +83,13 @@ void rockchip_stimer_init(void)#define RK3506_OTP_CPU_CODE_OFFSET 0x02#define RK3506_OTP_SPECIFICATION_OFFSET 0x08 +#define RK3506_OTP_VARIANT_OFFSET 0x36int checkboard (void ) { -u8 cpu_code[2 ], specification; +u8 cpu_code[2 ], specification, package, variant[2 ];struct udevice *dev; -char suffix[2 ]; +char suffix[3 ];int ret;if (!IS_ENABLED (CONFIG_ROCKCHIP_OTP ) || !CONFIG_IS_ENABLED (MISC ))
@@ -114,11 +115,26 @@ int checkboard(void)log_debug ("Could not read specification, ret=%d\n" , ret);return 0 ; } + package =0 ; specification &=0x1f ; +/* variant: used to identify RK3506G SoC variant */ + ret =misc_read (dev,RK3506_OTP_VARIANT_OFFSET , variant,2 ); +if (ret <0 ) { +log_debug ("Could not read variant, ret=%d\n" , ret); +return 0 ; + } +if (variant[0 ] &0x1f ) { + specification = variant[0 ] &0x1f ; +/* package: likely SoC variant revision, 0x2 for RK3506G2 */ + package = variant[1 ] &0x7 ; + } +/* for RK3506J i.e. '@' + 0xA = 'J' */ suffix[0 ] = specification >1 ?'@' + specification :'\0' ; - suffix[1 ] ='\0' ; +/* for RK3506G2 i.e. '0' + 0x2 = '2' */ + suffix[1 ] = package >0 ?'0' + package :'\0' ; + suffix[2 ] ='\0' ;printf ("SoC: RK%02x%02x%s\n" , cpu_code[0 ], cpu_code[1 ], suffix);
Signature · 1 line
2.56.1