public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements
@ 2025-01-26 23:48 Jonas Karlman
  2025-01-26 23:48 ` [PATCH 1/5] rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig symbol Jonas Karlman
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman

Use of the Kconfig symbol ROCKCHIP_COMMON_STACK_ADDR is currently
not working well when a SoC needs to use a custom tpl.c and the default
values are only working when DRAM base address is 0x0.

This series changes to not imply TPL_ROCKCHIP_COMMON_BOARD and instead
let each SoC symbol decide. It also adds default values for the two
other used DRAM base addresses, 0x60000000 and 0x40000000. Finally, it
also moves imply of ROCKCHIP_EXTERNAL_TPL under each SoC symbol.

Jonas Karlman (5):
  rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig
    symbol
  rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  rockchip: Move imply ROCKCHIP_COMMON_STACK_ADDR under SoC Kconfig
    symbol
  rockchip: Move imply ROCKCHIP_EXTERNAL_TPL under SoC Kconfig symbol
  rockchip: Add RK3576 support for ROCKCHIP_COMMON_STACK_ADDR

 arch/arm/mach-rockchip/Kconfig        | 67 ++++++++++++++++++++-------
 arch/arm/mach-rockchip/px30/Kconfig   |  3 --
 arch/arm/mach-rockchip/rk3308/Kconfig |  3 --
 arch/arm/mach-rockchip/rk3328/Kconfig |  3 --
 arch/arm/mach-rockchip/rk3399/Kconfig |  3 --
 arch/arm/mach-rockchip/rk3568/Kconfig |  3 --
 arch/arm/mach-rockchip/rk3588/Kconfig |  3 --
 7 files changed, 50 insertions(+), 35 deletions(-)

-- 
2.48.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/5] rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig symbol
  2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
@ 2025-01-26 23:48 ` Jonas Karlman
  2025-01-26 23:48 ` [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman

The Kconfig symbol ROCKCHIP_COMMON_STACK_ADDR currently imply the
TPL_ROCKCHIP_COMMON_BOARD option when TPL=y. This is inconvenient for a
SoC with very limited SRAM to use a custom tpl.c together with the
common stack addresses.

Move any imply TPL_ROCKCHIP_COMMON_BOARD to under the SoC symbol, where
it belongs. Add the missing imply to RK3328 and PX30 use a SoC specific
tpl.c and only expect imply TPL_LIBGENERIC_SUPPORT.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
 arch/arm/mach-rockchip/Kconfig | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 4d3157b2edd3..5aa9e0f1af3b 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -16,6 +16,7 @@ config ROCKCHIP_PX30
 	select DEBUG_UART_BOARD_INIT
 	imply ROCKCHIP_COMMON_BOARD
 	imply SPL_ROCKCHIP_COMMON_BOARD
+	imply TPL_LIBGENERIC_SUPPORT
 	imply ARMV8_CRYPTO
 	imply ARMV8_SET_SMPEN
 	help
@@ -212,6 +213,7 @@ config ROCKCHIP_RK3328
 	imply SPL_ROCKCHIP_COMMON_BOARD
 	imply SPL_SEPARATE_BSS
 	imply SPL_SERIAL
+	imply TPL_ROCKCHIP_COMMON_BOARD
 	imply TPL_SERIAL
 	help
 	  The Rockchip RK3328 is a ARM-based SoC with a quad-core Cortex-A53.
@@ -608,11 +610,10 @@ config ROCKCHIP_COMMON_STACK_ADDR
 	imply SPL_ROCKCHIP_COMMON_BOARD if SPL
 	imply SPL_SYS_MALLOC_F if SPL
 	imply SPL_SYS_MALLOC_SIMPLE if SPL
-	imply TPL_LIBCOMMON_SUPPORT if TPL
-	imply TPL_LIBGENERIC_SUPPORT if TPL
-	imply TPL_ROCKCHIP_COMMON_BOARD if TPL
-	imply TPL_SYS_MALLOC_F if TPL
-	imply TPL_SYS_MALLOC_SIMPLE if TPL
+	imply TPL_LIBCOMMON_SUPPORT if TPL && TPL_ROCKCHIP_COMMON_BOARD
+	imply TPL_LIBGENERIC_SUPPORT if TPL && TPL_ROCKCHIP_COMMON_BOARD
+	imply TPL_SYS_MALLOC_F if TPL && TPL_ROCKCHIP_COMMON_BOARD
+	imply TPL_SYS_MALLOC_SIMPLE if TPL && TPL_ROCKCHIP_COMMON_BOARD
 
 config NR_DRAM_BANKS
 	default 10 if ROCKCHIP_EXTERNAL_TPL
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
  2025-01-26 23:48 ` [PATCH 1/5] rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig symbol Jonas Karlman
@ 2025-01-26 23:48 ` Jonas Karlman
  2025-01-27 18:59   ` Alex Bee
  2025-02-05 17:07   ` Quentin Schulz
  2025-01-26 23:48 ` [PATCH 3/5] rockchip: Move imply ROCKCHIP_COMMON_STACK_ADDR under SoC Kconfig symbol Jonas Karlman
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman

A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
the more common 0x0 DRAM base address used on AArch64 SoCs.

Add default options that should work for these ARMv7 SoCs. Same offsets
as before are used, just below 64 MiB. Hex values have also been padded
to improve alignment.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
 arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index 5aa9e0f1af3b..da20d3233fe3 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
 if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
 
 config CUSTOM_SYS_INIT_SP_ADDR
-	default 0x3f00000
+	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
+	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
 
 config SYS_MALLOC_F_LEN
-	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
+	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_SYS_MALLOC_F_LEN
-	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
+	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config TPL_SYS_MALLOC_F_LEN
-	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
+	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config TEXT_BASE
-	default 0x00200000 if ARM64
+	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
+	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
 
 config SPL_TEXT_BASE
-	default 0x0 if ARM64
+	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
+			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
+			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
+	default 0x00000000
 
 config SPL_HAS_BSS_LINKER_SECTION
 	default y if ARM64
 
 config SPL_BSS_START_ADDR
-	default 0x3f80000
+	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
+	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
 
 config SPL_BSS_MAX_SIZE
-	default 0x8000 if SPL_BSS_START_ADDR = 0x3f80000
+	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
+	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
 
 config SPL_STACK_R
-	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
+	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_STACK_R_ADDR
-	default 0x3e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
+	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_STACK_R_MALLOC_SIMPLE_LEN
-	default 0x200000 if SPL_STACK_R_ADDR = 0x3e00000
+	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
+	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
 
 endif
 endif
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 3/5] rockchip: Move imply ROCKCHIP_COMMON_STACK_ADDR under SoC Kconfig symbol
  2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
  2025-01-26 23:48 ` [PATCH 1/5] rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig symbol Jonas Karlman
  2025-01-26 23:48 ` [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
@ 2025-01-26 23:48 ` Jonas Karlman
  2025-01-26 23:48 ` [PATCH 4/5] rockchip: Move imply ROCKCHIP_EXTERNAL_TPL " Jonas Karlman
  2025-01-26 23:48 ` [PATCH 5/5] rockchip: Add RK3576 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
  4 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman

The ROCKCHIP_COMMON_STACK_ADDR Kconfig option was originally enabled
in the SoC specific Kconfig files to ease during the initial migration
to use common stack addresses.

All boards for the affected SoCs have been migrated to use common stack
addresses. Migrate to use an imply under the SoC symbol instead of
re-define the symbol in each SoC specific Kconfig file.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
 arch/arm/mach-rockchip/Kconfig        | 6 ++++++
 arch/arm/mach-rockchip/px30/Kconfig   | 3 ---
 arch/arm/mach-rockchip/rk3308/Kconfig | 3 ---
 arch/arm/mach-rockchip/rk3328/Kconfig | 3 ---
 arch/arm/mach-rockchip/rk3399/Kconfig | 3 ---
 arch/arm/mach-rockchip/rk3568/Kconfig | 3 ---
 arch/arm/mach-rockchip/rk3588/Kconfig | 3 ---
 7 files changed, 6 insertions(+), 18 deletions(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index da20d3233fe3..a71988485825 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -15,6 +15,7 @@ config ROCKCHIP_PX30
 	select TPL_SERIAL
 	select DEBUG_UART_BOARD_INIT
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply SPL_ROCKCHIP_COMMON_BOARD
 	imply TPL_LIBGENERIC_SUPPORT
 	imply ARMV8_CRYPTO
@@ -176,6 +177,7 @@ config ROCKCHIP_RK3308
 	imply OF_UPSTREAM
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply ROCKCHIP_OTP
 	imply SPL_CLK
 	imply SPL_DM_SEQ_ALIAS
@@ -208,6 +210,7 @@ config ROCKCHIP_RK3328
 	imply OF_UPSTREAM
 	imply PRE_CONSOLE_BUFFER
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply ROCKCHIP_EFUSE
 	imply ROCKCHIP_SDRAM_COMMON
 	imply SPL_ROCKCHIP_COMMON_BOARD
@@ -286,6 +289,7 @@ config ROCKCHIP_RK3399
 	imply PRE_CONSOLE_BUFFER
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply ROCKCHIP_EFUSE
 	imply ROCKCHIP_SDRAM_COMMON
 	imply SPL_DM_SEQ_ALIAS
@@ -335,6 +339,7 @@ config ROCKCHIP_RK3568
 	imply PHY_GIGE if DWC_ETH_QOS_ROCKCHIP
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply ROCKCHIP_OTP
 	imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF
 	imply SPL_MMC_HS200_SUPPORT if SPL_MMC && MMC_HS200_SUPPORT
@@ -368,6 +373,7 @@ config ROCKCHIP_RK3588
 	imply PHY_GIGE if DWC_ETH_QOS_ROCKCHIP
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
+	imply ROCKCHIP_COMMON_STACK_ADDR
 	imply ROCKCHIP_OTP
 	imply SCMI_FIRMWARE
 	imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF
diff --git a/arch/arm/mach-rockchip/px30/Kconfig b/arch/arm/mach-rockchip/px30/Kconfig
index dcf9eb8144b8..2b57b1668942 100644
--- a/arch/arm/mach-rockchip/px30/Kconfig
+++ b/arch/arm/mach-rockchip/px30/Kconfig
@@ -68,9 +68,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "px30"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config SYS_MALLOC_F_LEN
 	default 0x400 if !SPL_SHARES_INIT_SP_ADDR
 
diff --git a/arch/arm/mach-rockchip/rk3308/Kconfig b/arch/arm/mach-rockchip/rk3308/Kconfig
index fac966207a92..06572d545f6e 100644
--- a/arch/arm/mach-rockchip/rk3308/Kconfig
+++ b/arch/arm/mach-rockchip/rk3308/Kconfig
@@ -17,9 +17,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "rk3308"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config TEXT_BASE
 	default 0x00600000
 
diff --git a/arch/arm/mach-rockchip/rk3328/Kconfig b/arch/arm/mach-rockchip/rk3328/Kconfig
index 70770da5fdf2..ec1dae8d413a 100644
--- a/arch/arm/mach-rockchip/rk3328/Kconfig
+++ b/arch/arm/mach-rockchip/rk3328/Kconfig
@@ -21,9 +21,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "rk3328"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config TPL_LDSCRIPT
 	default "arch/arm/mach-rockchip/u-boot-tpl-v8.lds"
 
diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig
index 500cfcd87afd..b2430207ee9d 100644
--- a/arch/arm/mach-rockchip/rk3399/Kconfig
+++ b/arch/arm/mach-rockchip/rk3399/Kconfig
@@ -143,9 +143,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "rk3399"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config TPL_LDSCRIPT
 	default "arch/arm/mach-rockchip/u-boot-tpl-v8.lds"
 
diff --git a/arch/arm/mach-rockchip/rk3568/Kconfig b/arch/arm/mach-rockchip/rk3568/Kconfig
index ce327ed6f9e0..c589fd586993 100644
--- a/arch/arm/mach-rockchip/rk3568/Kconfig
+++ b/arch/arm/mach-rockchip/rk3568/Kconfig
@@ -71,9 +71,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "rk3568"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config TEXT_BASE
 	default 0x00a00000
 
diff --git a/arch/arm/mach-rockchip/rk3588/Kconfig b/arch/arm/mach-rockchip/rk3588/Kconfig
index 155b8f00ca2c..efd192068ad1 100644
--- a/arch/arm/mach-rockchip/rk3588/Kconfig
+++ b/arch/arm/mach-rockchip/rk3588/Kconfig
@@ -420,9 +420,6 @@ config ROCKCHIP_STIMER_BASE
 config SYS_SOC
 	default "rk3588"
 
-config ROCKCHIP_COMMON_STACK_ADDR
-	default y
-
 config TEXT_BASE
 	default 0x00a00000
 
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 4/5] rockchip: Move imply ROCKCHIP_EXTERNAL_TPL under SoC Kconfig symbol
  2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
                   ` (2 preceding siblings ...)
  2025-01-26 23:48 ` [PATCH 3/5] rockchip: Move imply ROCKCHIP_COMMON_STACK_ADDR under SoC Kconfig symbol Jonas Karlman
@ 2025-01-26 23:48 ` Jonas Karlman
  2025-01-26 23:48 ` [PATCH 5/5] rockchip: Add RK3576 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
  4 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman

New Rockchip SoCs will typically require use or an external TPL when
support for the SoC is added to U-Boot.

Move imply ROCKCHIP_EXTERNAL_TPL under SoC Kconfig symbol to remove a
future likelihood of a long "default y if" line.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
 arch/arm/mach-rockchip/Kconfig | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index a71988485825..ef5ad72dd089 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -178,6 +178,7 @@ config ROCKCHIP_RK3308
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
 	imply ROCKCHIP_COMMON_STACK_ADDR
+	imply ROCKCHIP_EXTERNAL_TPL
 	imply ROCKCHIP_OTP
 	imply SPL_CLK
 	imply SPL_DM_SEQ_ALIAS
@@ -340,6 +341,7 @@ config ROCKCHIP_RK3568
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
 	imply ROCKCHIP_COMMON_STACK_ADDR
+	imply ROCKCHIP_EXTERNAL_TPL
 	imply ROCKCHIP_OTP
 	imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF
 	imply SPL_MMC_HS200_SUPPORT if SPL_MMC && MMC_HS200_SUPPORT
@@ -374,6 +376,7 @@ config ROCKCHIP_RK3588
 	imply RNG_ROCKCHIP
 	imply ROCKCHIP_COMMON_BOARD
 	imply ROCKCHIP_COMMON_STACK_ADDR
+	imply ROCKCHIP_EXTERNAL_TPL
 	imply ROCKCHIP_OTP
 	imply SCMI_FIRMWARE
 	imply SPL_ATF_NO_PLATFORM_PARAM if SPL_ATF
@@ -500,7 +503,6 @@ config TPL_ROCKCHIP_COMMON_BOARD
 
 config ROCKCHIP_EXTERNAL_TPL
 	bool "Use external TPL binary"
-	default y if ROCKCHIP_RK3308 || ROCKCHIP_RK3568 || ROCKCHIP_RK3588
 	help
 	  Some Rockchip SoCs require an external TPL to initialize DRAM.
 	  Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 5/5] rockchip: Add RK3576 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
                   ` (3 preceding siblings ...)
  2025-01-26 23:48 ` [PATCH 4/5] rockchip: Move imply ROCKCHIP_EXTERNAL_TPL " Jonas Karlman
@ 2025-01-26 23:48 ` Jonas Karlman
  4 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-01-26 23:48 UTC (permalink / raw)
  To: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot, Jonas Karlman, Heiko Stuebner

The Rockchip RK3576 SoC uses a different DRAM base address, 0x40000000,
compared to prior SoCs.

Add default options that should work when 0x40000000 is used as DRAM
base address. Use same offsets as before, just below 64 MiB.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
Cc: Heiko Stuebner <heiko@sntech.de>
---
 arch/arm/mach-rockchip/Kconfig | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
index ef5ad72dd089..2166807de5ce 100644
--- a/arch/arm/mach-rockchip/Kconfig
+++ b/arch/arm/mach-rockchip/Kconfig
@@ -646,28 +646,34 @@ if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
 
 config CUSTOM_SYS_INIT_SP_ADDR
 	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
+	default 0x43f00000 if SPL_TEXT_BASE = 0x40000000
 	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
 
 config SYS_MALLOC_F_LEN
 	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x43f00000
 	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_SYS_MALLOC_F_LEN
 	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x43f00000
 	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config TPL_SYS_MALLOC_F_LEN
 	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x43f00000
 	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config TEXT_BASE
 	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
+	default 0x40200000 if SPL_TEXT_BASE = 0x40000000
 	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
 
 config SPL_TEXT_BASE
 	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
 			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
 			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
+	default 0x40000000 if ROCKCHIP_RK3576
 	default 0x00000000
 
 config SPL_HAS_BSS_LINKER_SECTION
@@ -675,22 +681,27 @@ config SPL_HAS_BSS_LINKER_SECTION
 
 config SPL_BSS_START_ADDR
 	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
+	default 0x43f80000 if SPL_TEXT_BASE = 0x40000000
 	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
 
 config SPL_BSS_MAX_SIZE
 	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
+	default 0x8000 if SPL_BSS_START_ADDR = 0x43f80000
 	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
 
 config SPL_STACK_R
 	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x43f00000
 	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_STACK_R_ADDR
 	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
+	default 0x43e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x43f00000
 	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
 
 config SPL_STACK_R_MALLOC_SIMPLE_LEN
 	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
+	default 0x200000 if SPL_STACK_R_ADDR = 0x43e00000
 	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
 
 endif
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-26 23:48 ` [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
@ 2025-01-27 18:59   ` Alex Bee
  2025-01-30 21:41     ` Jonas Karlman
  2025-02-05 17:07   ` Quentin Schulz
  1 sibling, 1 reply; 12+ messages in thread
From: Alex Bee @ 2025-01-27 18:59 UTC (permalink / raw)
  To: Jonas Karlman, Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini; +Cc: u-boot

Hi Jonas,

thanks for working on this.  Please see one comment below.

Am 27.01.25 um 00:48 schrieb Jonas Karlman:
> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
> the more common 0x0 DRAM base address used on AArch64 SoCs.
>
> Add default options that should work for these ARMv7 SoCs. Same offsets
> as before are used, just below 64 MiB. Hex values have also been padded
> to improve alignment.
>
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
>   arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>   1 file changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 5aa9e0f1af3b..da20d3233fe3 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>   if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>   
>   config CUSTOM_SYS_INIT_SP_ADDR
> -	default 0x3f00000
> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
>   
>   config SYS_MALLOC_F_LEN
> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config SPL_SYS_MALLOC_F_LEN
> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config TPL_SYS_MALLOC_F_LEN
> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config TEXT_BASE
> -	default 0x00200000 if ARM64
> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>   
>   config SPL_TEXT_BASE
> -	default 0x0 if ARM64
> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \

I'm not sure if adding RK3036 and RK3188 is correct at this point. Both use
SPL (without TPL) currently for DRAM initialization and thus need their
CFG_IRAM_BASE as SPL_TEXT_BASE.

Regards,

Alex

> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
> +	default 0x00000000
>   
>   config SPL_HAS_BSS_LINKER_SECTION
>   	default y if ARM64
>   
>   config SPL_BSS_START_ADDR
> -	default 0x3f80000
> +	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
> +	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
>   
>   config SPL_BSS_MAX_SIZE
> -	default 0x8000 if SPL_BSS_START_ADDR = 0x3f80000
> +	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
> +	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
>   
>   config SPL_STACK_R
> -	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config SPL_STACK_R_ADDR
> -	default 0x3e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config SPL_STACK_R_MALLOC_SIMPLE_LEN
> -	default 0x200000 if SPL_STACK_R_ADDR = 0x3e00000
> +	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
> +	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
>   
>   endif
>   endif

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-27 18:59   ` Alex Bee
@ 2025-01-30 21:41     ` Jonas Karlman
  2025-02-05 19:02       ` Alex Bee
  0 siblings, 1 reply; 12+ messages in thread
From: Jonas Karlman @ 2025-01-30 21:41 UTC (permalink / raw)
  To: Alex Bee; +Cc: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini, u-boot

Hi Alex,

On 2025-01-27 19:59, Alex Bee wrote:
> Hi Jonas,
> 
> thanks for working on this.  Please see one comment below.
> 
> Am 27.01.25 um 00:48 schrieb Jonas Karlman:
>> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
>> the more common 0x0 DRAM base address used on AArch64 SoCs.
>>
>> Add default options that should work for these ARMv7 SoCs. Same offsets
>> as before are used, just below 64 MiB. Hex values have also been padded
>> to improve alignment.
>>
>> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
>> ---
>>   arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>>   1 file changed, 24 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
>> index 5aa9e0f1af3b..da20d3233fe3 100644
>> --- a/arch/arm/mach-rockchip/Kconfig
>> +++ b/arch/arm/mach-rockchip/Kconfig
>> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>>   if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>>   
>>   config CUSTOM_SYS_INIT_SP_ADDR
>> -	default 0x3f00000
>> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
>> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
>>   
>>   config SYS_MALLOC_F_LEN
>> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config SPL_SYS_MALLOC_F_LEN
>> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config TPL_SYS_MALLOC_F_LEN
>> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config TEXT_BASE
>> -	default 0x00200000 if ARM64
>> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
>> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>>   
>>   config SPL_TEXT_BASE
>> -	default 0x0 if ARM64
>> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
>> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
> 
> I'm not sure if adding RK3036 and RK3188 is correct at this point. Both use
> SPL (without TPL) currently for DRAM initialization and thus need their
> CFG_IRAM_BASE as SPL_TEXT_BASE.

I think it should be safe to add these default values here, any value
defined in board defconfig or soc Kconfig will take precedence.

The RK3036 and RK3188 boards use SPL back-to-brom to load U-Boot proper,
if someone wants to move these board to use similar TPL+SPL+FIT this
will prepare for such occasion.

Having them included here also prevents a possible issue in case someone
in the future where to add a select/imply ROCKCHIP_COMMON_STACK_ADDR for
these SoCs, else they may fallback to wrongly use 0x0.

Do you want me to drop them in a v2?

Regards,
Jonas

> 
> Regards,
> 
> Alex
> 
>> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
>> +	default 0x00000000
>>   
>>   config SPL_HAS_BSS_LINKER_SECTION
>>   	default y if ARM64
>>   
>>   config SPL_BSS_START_ADDR
>> -	default 0x3f80000
>> +	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
>> +	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
>>   
>>   config SPL_BSS_MAX_SIZE
>> -	default 0x8000 if SPL_BSS_START_ADDR = 0x3f80000
>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
>>   
>>   config SPL_STACK_R
>> -	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config SPL_STACK_R_ADDR
>> -	default 0x3e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config SPL_STACK_R_MALLOC_SIMPLE_LEN
>> -	default 0x200000 if SPL_STACK_R_ADDR = 0x3e00000
>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
>>   
>>   endif
>>   endif


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-26 23:48 ` [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
  2025-01-27 18:59   ` Alex Bee
@ 2025-02-05 17:07   ` Quentin Schulz
  2025-02-05 18:28     ` Jonas Karlman
  1 sibling, 1 reply; 12+ messages in thread
From: Quentin Schulz @ 2025-02-05 17:07 UTC (permalink / raw)
  To: Jonas Karlman, Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini
  Cc: Alex Bee, u-boot

Hi Jonas,

On 1/27/25 12:48 AM, Jonas Karlman wrote:
> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of

Are there known exceptions? Among the list you provided I see RV1126 is 
missing but is ARMv7-based. Is it an oversight or done on purpose? I 
couldn't quickly find the TRM so no clue.

> the more common 0x0 DRAM base address used on AArch64 SoCs.
> 
> Add default options that should work for these ARMv7 SoCs. Same offsets
> as before are used, just below 64 MiB. Hex values have also been padded
> to improve alignment.
> 
> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
> ---
>   arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>   1 file changed, 24 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
> index 5aa9e0f1af3b..da20d3233fe3 100644
> --- a/arch/arm/mach-rockchip/Kconfig
> +++ b/arch/arm/mach-rockchip/Kconfig
> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>   if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>   
>   config CUSTOM_SYS_INIT_SP_ADDR
> -	default 0x3f00000
> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000

A bit sad we cannot do arithmetic here in Kconfig :(

>   
>   config SYS_MALLOC_F_LEN
> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config SPL_SYS_MALLOC_F_LEN
> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config TPL_SYS_MALLOC_F_LEN
> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>   
>   config TEXT_BASE
> -	default 0x00200000 if ARM64
> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>   
>   config SPL_TEXT_BASE
> -	default 0x0 if ARM64
> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108

If applicable to all ARMv7 SoCs, maybe

if CPU_V7A

would be more future-proof?

Cheers,
Quentin

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-02-05 17:07   ` Quentin Schulz
@ 2025-02-05 18:28     ` Jonas Karlman
  0 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-02-05 18:28 UTC (permalink / raw)
  To: Quentin Schulz
  Cc: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini, Alex Bee,
	u-boot

Hi Quentin,

On 2025-02-05 18:07, Quentin Schulz wrote:
> Hi Jonas,
> 
> On 1/27/25 12:48 AM, Jonas Karlman wrote:
>> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
> 
> Are there known exceptions? Among the list you provided I see RV1126 is 
> missing but is ARMv7-based. Is it an oversight or done on purpose? I 
> couldn't quickly find the TRM so no clue.

The default if tested SoCs below is the only 6 SoCs that seem to use the
0x60000000 base, both in mainline and vendor U-Boot. RV1126, RK3288 and
incoming RK3506 all use 0x0 as base address.

> 
>> the more common 0x0 DRAM base address used on AArch64 SoCs.
>>
>> Add default options that should work for these ARMv7 SoCs. Same offsets
>> as before are used, just below 64 MiB. Hex values have also been padded
>> to improve alignment.
>>
>> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
>> ---
>>   arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>>   1 file changed, 24 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
>> index 5aa9e0f1af3b..da20d3233fe3 100644
>> --- a/arch/arm/mach-rockchip/Kconfig
>> +++ b/arch/arm/mach-rockchip/Kconfig
>> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>>   if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>>   
>>   config CUSTOM_SYS_INIT_SP_ADDR
>> -	default 0x3f00000
>> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
>> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
> 
> A bit sad we cannot do arithmetic here in Kconfig :(

That would have been a really nice feature :-)

> 
>>   
>>   config SYS_MALLOC_F_LEN
>> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config SPL_SYS_MALLOC_F_LEN
>> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config TPL_SYS_MALLOC_F_LEN
>> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>   
>>   config TEXT_BASE
>> -	default 0x00200000 if ARM64
>> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
>> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>>   
>>   config SPL_TEXT_BASE
>> -	default 0x0 if ARM64
>> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
>> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
>> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
> 
> If applicable to all ARMv7 SoCs, maybe
> 
> if CPU_V7A
> 
> would be more future-proof?

Unfortunately that does not seem to be the case, most new RK SoCs seem
to use 0x0 as DRAM base, with RK3576 being the odd one, or possible
start of a new trend.

Following ARMv7 SoCs seem to use 0x0 as DRAM base:
- RK3288
- RK3506
- RV1103B
- RV1106
- RV1126

For the RK3506 I have been playing with recently the OP-TEE (for psci)
is instead placed at start of DRAM and SPL must be put somewhere else,
vendor place it at 63 MiB offset, I decided to put SPL at 0.5 MiB
instead of 0x0, so that could require a few more default lines :-S

Regards,
Jonas

> 
> Cheers,
> Quentin


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-01-30 21:41     ` Jonas Karlman
@ 2025-02-05 19:02       ` Alex Bee
  2025-02-09 17:59         ` Jonas Karlman
  0 siblings, 1 reply; 12+ messages in thread
From: Alex Bee @ 2025-02-05 19:02 UTC (permalink / raw)
  To: Jonas Karlman; +Cc: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini, u-boot

Hi Jonas,

> Hi Alex,
>
> On 2025-01-27 19:59, Alex Bee wrote:
>> Hi Jonas,
>>
>> thanks for working on this.  Please see one comment below.
>>
>> Am 27.01.25 um 00:48 schrieb Jonas Karlman:
>>> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
>>> the more common 0x0 DRAM base address used on AArch64 SoCs.
>>>
>>> Add default options that should work for these ARMv7 SoCs. Same offsets
>>> as before are used, just below 64 MiB. Hex values have also been padded
>>> to improve alignment.
>>>
>>> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
>>> ---
>>>    arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>>>    1 file changed, 24 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
>>> index 5aa9e0f1af3b..da20d3233fe3 100644
>>> --- a/arch/arm/mach-rockchip/Kconfig
>>> +++ b/arch/arm/mach-rockchip/Kconfig
>>> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>>>    if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>>>    
>>>    config CUSTOM_SYS_INIT_SP_ADDR
>>> -	default 0x3f00000
>>> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
>>> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
>>>    
>>>    config SYS_MALLOC_F_LEN
>>> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>    
>>>    config SPL_SYS_MALLOC_F_LEN
>>> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>    
>>>    config TPL_SYS_MALLOC_F_LEN
>>> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>    
>>>    config TEXT_BASE
>>> -	default 0x00200000 if ARM64
>>> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
>>> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>>>    
>>>    config SPL_TEXT_BASE
>>> -	default 0x0 if ARM64
>>> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
>>> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
>> I'm not sure if adding RK3036 and RK3188 is correct at this point. Both use
>> SPL (without TPL) currently for DRAM initialization and thus need their
>> CFG_IRAM_BASE as SPL_TEXT_BASE.
> I think it should be safe to add these default values here, any value
> defined in board defconfig or soc Kconfig will take precedence.
>
> The RK3036 and RK3188 boards use SPL back-to-brom to load U-Boot proper,
> if someone wants to move these board to use similar TPL+SPL+FIT this
> will prepare for such occasion.
>
> Having them included here also prevents a possible issue in case someone
> in the future where to add a select/imply ROCKCHIP_COMMON_STACK_ADDR for
> these SoCs, else they may fallback to wrongly use 0x0.
>
> Do you want me to drop them in a v2?
>
> Regards,
> Jonas
it is currently "safe" as it would of course be overwritten by the
currently existing defconfigs. But if someone dares to use this symbol for
a downstream/new board for either of these two SoCs, things go south.

How about adding some "extra security" by making it
     depends on TPL || ROCKCHIP_EXTERNAL_TPL

As I mentioned off-list: I'm not sure if any of these
XXX_ROCKCHIP_COMMON_BORD belong here: I understand the goal of syncing
configurations for the different SoCs, but I'm not sure if a symbol called
ROCKCHIP_COMMON_STACK_ADDR is the right place for it (plus the
XXX_ROCKCHIP_COMMON_BORD symbols (should) have no dependency on using
ROCKCHIP_COMMON_STACK_ADDR, neither code-wise nor from semantics).

Regards,
Alex

>> Regards,
>>
>> Alex
>>
>>> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
>>> +	default 0x00000000
>>>    
>>>    config SPL_HAS_BSS_LINKER_SECTION
>>>    	default y if ARM64
>>>    
>>>    config SPL_BSS_START_ADDR
>>> -	default 0x3f80000
>>> +	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
>>> +	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
>>>    
>>>    config SPL_BSS_MAX_SIZE
>>> -	default 0x8000 if SPL_BSS_START_ADDR = 0x3f80000
>>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
>>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
>>>    
>>>    config SPL_STACK_R
>>> -	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>    
>>>    config SPL_STACK_R_ADDR
>>> -	default 0x3e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>> +	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>> +	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>    
>>>    config SPL_STACK_R_MALLOC_SIMPLE_LEN
>>> -	default 0x200000 if SPL_STACK_R_ADDR = 0x3e00000
>>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
>>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
>>>    
>>>    endif
>>>    endif

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR
  2025-02-05 19:02       ` Alex Bee
@ 2025-02-09 17:59         ` Jonas Karlman
  0 siblings, 0 replies; 12+ messages in thread
From: Jonas Karlman @ 2025-02-09 17:59 UTC (permalink / raw)
  To: Alex Bee; +Cc: Kever Yang, Simon Glass, Philipp Tomsich, Tom Rini, u-boot

Hi Alex,

On 2025-02-05 20:02, Alex Bee wrote:
> Hi Jonas,
> 
>> Hi Alex,
>>
>> On 2025-01-27 19:59, Alex Bee wrote:
>>> Hi Jonas,
>>>
>>> thanks for working on this.  Please see one comment below.
>>>
>>> Am 27.01.25 um 00:48 schrieb Jonas Karlman:
>>>> A few Rockchip ARMv7 SoCs use 0x60000000 as DRAM base address instead of
>>>> the more common 0x0 DRAM base address used on AArch64 SoCs.
>>>>
>>>> Add default options that should work for these ARMv7 SoCs. Same offsets
>>>> as before are used, just below 64 MiB. Hex values have also been padded
>>>> to improve alignment.
>>>>
>>>> Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
>>>> ---
>>>>    arch/arm/mach-rockchip/Kconfig | 35 +++++++++++++++++++++++-----------
>>>>    1 file changed, 24 insertions(+), 11 deletions(-)
>>>>
>>>> diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig
>>>> index 5aa9e0f1af3b..da20d3233fe3 100644
>>>> --- a/arch/arm/mach-rockchip/Kconfig
>>>> +++ b/arch/arm/mach-rockchip/Kconfig
>>>> @@ -637,40 +637,53 @@ source "arch/arm/mach-rockchip/rv1126/Kconfig"
>>>>    if ROCKCHIP_COMMON_STACK_ADDR && SPL_SHARES_INIT_SP_ADDR
>>>>    
>>>>    config CUSTOM_SYS_INIT_SP_ADDR
>>>> -	default 0x3f00000
>>>> +	default 0x63f00000 if SPL_TEXT_BASE = 0x60000000
>>>> +	default 0x03f00000 if SPL_TEXT_BASE = 0x00000000
>>>>    
>>>>    config SYS_MALLOC_F_LEN
>>>> -	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>>> +	default 0x10000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>>    
>>>>    config SPL_SYS_MALLOC_F_LEN
>>>> -	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>>> +	default 0x8000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>>    
>>>>    config TPL_SYS_MALLOC_F_LEN
>>>> -	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>>> +	default 0x0800 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>>> +	default 0x4000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>>    
>>>>    config TEXT_BASE
>>>> -	default 0x00200000 if ARM64
>>>> +	default 0x60200000 if SPL_TEXT_BASE = 0x60000000
>>>> +	default 0x00200000 if SPL_TEXT_BASE = 0x00000000
>>>>    
>>>>    config SPL_TEXT_BASE
>>>> -	default 0x0 if ARM64
>>>> +	default 0x60000000 if ROCKCHIP_RK3036 || ROCKCHIP_RK3066 || \
>>>> +			      ROCKCHIP_RK3128 || ROCKCHIP_RK3188 || \
>>> I'm not sure if adding RK3036 and RK3188 is correct at this point. Both use
>>> SPL (without TPL) currently for DRAM initialization and thus need their
>>> CFG_IRAM_BASE as SPL_TEXT_BASE.
>> I think it should be safe to add these default values here, any value
>> defined in board defconfig or soc Kconfig will take precedence.
>>
>> The RK3036 and RK3188 boards use SPL back-to-brom to load U-Boot proper,
>> if someone wants to move these board to use similar TPL+SPL+FIT this
>> will prepare for such occasion.
>>
>> Having them included here also prevents a possible issue in case someone
>> in the future where to add a select/imply ROCKCHIP_COMMON_STACK_ADDR for
>> these SoCs, else they may fallback to wrongly use 0x0.
>>
>> Do you want me to drop them in a v2?
>>
>> Regards,
>> Jonas
> it is currently "safe" as it would of course be overwritten by the
> currently existing defconfigs. But if someone dares to use this symbol for
> a downstream/new board for either of these two SoCs, things go south.
> 
> How about adding some "extra security" by making it
>      depends on TPL || ROCKCHIP_EXTERNAL_TPL
> 
> As I mentioned off-list: I'm not sure if any of these
> XXX_ROCKCHIP_COMMON_BORD belong here: I understand the goal of syncing
> configurations for the different SoCs, but I'm not sure if a symbol called
> ROCKCHIP_COMMON_STACK_ADDR is the right place for it (plus the
> XXX_ROCKCHIP_COMMON_BORD symbols (should) have no dependency on using
> ROCKCHIP_COMMON_STACK_ADDR, neither code-wise nor from semantics).

In principle I fully agree, and TPL_ROCKCHIP_COMMON_BOARD was moved away
from being implied in first patch in this series. However, I left the
implied SPL symbol as-is.

Adding the "depends on TPL ..." could be something for a v2.

The original intent of this symbol was to help move boards and SoCs that
use common TPL+SPL to use safer addresses without having to affect all
boards/SoCs all at once.

With this series it should be simple to move the remaining ARMv7 SoCs to
use similar TPL/ROCKCHIP_EXTERNAL_TPL + SPL separation without having
to worry about picking new SPL stack addresses in DRAM.

The Kconfig symbol is hidden from menuconfig so I do not expect end
users to easily break anything by accidentally enabling this symbol.

I was hoping to be able to send a migration series for RK322x this
weekend but unfortunately, I managed to brick the new RK3228A box I
picked up after only a few hours, the box uses an eMCP and I have not
found an exposed mmc clk pin yet, a new box should arrive soon :-)

Regards,
Jonas

> 
> Regards,
> Alex
> 
>>> Regards,
>>>
>>> Alex
>>>
>>>> +			      ROCKCHIP_RK322X || ROCKCHIP_RV1108
>>>> +	default 0x00000000
>>>>    
>>>>    config SPL_HAS_BSS_LINKER_SECTION
>>>>    	default y if ARM64
>>>>    
>>>>    config SPL_BSS_START_ADDR
>>>> -	default 0x3f80000
>>>> +	default 0x63f80000 if SPL_TEXT_BASE = 0x60000000
>>>> +	default 0x03f80000 if SPL_TEXT_BASE = 0x00000000
>>>>    
>>>>    config SPL_BSS_MAX_SIZE
>>>> -	default 0x8000 if SPL_BSS_START_ADDR = 0x3f80000
>>>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x63f80000
>>>> +	default 0x8000 if SPL_BSS_START_ADDR = 0x03f80000
>>>>    
>>>>    config SPL_STACK_R
>>>> -	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>>> +	default y if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>>    
>>>>    config SPL_STACK_R_ADDR
>>>> -	default 0x3e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x3f00000
>>>> +	default 0x63e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x63f00000
>>>> +	default 0x03e00000 if CUSTOM_SYS_INIT_SP_ADDR = 0x03f00000
>>>>    
>>>>    config SPL_STACK_R_MALLOC_SIMPLE_LEN
>>>> -	default 0x200000 if SPL_STACK_R_ADDR = 0x3e00000
>>>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x63e00000
>>>> +	default 0x200000 if SPL_STACK_R_ADDR = 0x03e00000
>>>>    
>>>>    endif
>>>>    endif


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2025-02-09 17:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-26 23:48 [PATCH 0/5] rockchip: ROCKCHIP_COMMON_STACK_ADDR improvements Jonas Karlman
2025-01-26 23:48 ` [PATCH 1/5] rockchip: Move imply TPL_ROCKCHIP_COMMON_BOARD under SoC Kconfig symbol Jonas Karlman
2025-01-26 23:48 ` [PATCH 2/5] rockchip: Improve ARMv7 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman
2025-01-27 18:59   ` Alex Bee
2025-01-30 21:41     ` Jonas Karlman
2025-02-05 19:02       ` Alex Bee
2025-02-09 17:59         ` Jonas Karlman
2025-02-05 17:07   ` Quentin Schulz
2025-02-05 18:28     ` Jonas Karlman
2025-01-26 23:48 ` [PATCH 3/5] rockchip: Move imply ROCKCHIP_COMMON_STACK_ADDR under SoC Kconfig symbol Jonas Karlman
2025-01-26 23:48 ` [PATCH 4/5] rockchip: Move imply ROCKCHIP_EXTERNAL_TPL " Jonas Karlman
2025-01-26 23:48 ` [PATCH 5/5] rockchip: Add RK3576 support for ROCKCHIP_COMMON_STACK_ADDR Jonas Karlman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox