rockchip: sdram: Fix issues observed on RK3576
Subsystems (3)
v2 cover rockchip: sdram: Fix issues observed on RK3576
Most Rockchip AArch64 SoCs have start of DRAM at 0x0. However, the RK3576 instead has start of DRAM at 0x40000000 and can extend continuous beyond the 4 GiB mark.
This series fixes issues observed on a Rockchip RK3576 board testing Heiko's RK3576 series [1].
Changes in v2:
- Drop duplicate patch
- Add patch to limit gd->ram_top to max 4G
- Add patch to assign gd->ram_base in SPL
- Collect r-b tag
[1] https://patchwork.ozlabs.org/cover/2013854/
Jonas Karlman (3):
rockchip: sdram: Allow the first bank to extend beyond 4 GiB
rockchip: sdram: Limit usable ram_top to max 4G
rockchip: sdram: Ensure ram_base is correct in SPL
arch/arm/mach-rockchip/sdram.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.48.1
PATCH v2 1/3 rockchip: sdram: Allow the first bank to extend beyond 4 GiB
Allow the first bank to extend beyond 4 GiB when the blob of space for peripheral is located before start of DRAM, e.g. when start of DRAM is 0x40000000 and continue beyond the 4 GiB mark.
---
v2: Collect r-b tag
--- arch/arm/mach-rockchip/sdram.c | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-rockchip/sdram.c +2 -0
@@ -310,6 +310,8 @@ int dram_init_banksize(void)if (ram_top >SZ_4G && top <SZ_4G ) { gd->bd->bi_dram[1 ].start =SZ_4G ; gd->bd->bi_dram[1 ].size = ram_top - gd->bd->bi_dram[1 ].start; + }else if (ram_top >SZ_4G && top ==SZ_4G ) { + gd->bd->bi_dram[0 ].size = ram_top - gd->bd->bi_dram[0 ].start; }#else #ifdef CONFIG_SPL_OPTEE_IMAGE
Signature · 1 line
2.48.1
PATCH v2 2/3 rockchip: sdram: Limit usable ram_top to max 4G
In reply to Jonas KarlmanU-Boot only works correctly when it uses RAM below the 4G address boundary on Rockchip SoCs. Limit usable gd->ram_top to max 4G.
---
v2: New patch
--- arch/arm/mach-rockchip/sdram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm/mach-rockchip/sdram.c +4 -1
@@ -488,7 +488,10 @@ int dram_init(void)phys_addr_t board_get_usable_ram_top (phys_size_t total_size) { -unsigned long top =CFG_SYS_SDRAM_BASE +SDRAM_MAX_SIZE ; +unsigned long top; + +/* Make sure U-Boot only uses the space below the 4G address boundary */ + top =min_t (ulong,CFG_SYS_SDRAM_BASE +SDRAM_MAX_SIZE , (ulong )SZ_4G );return (gd->ram_top > top) ? top : gd->ram_top; }
Signature · 1 line
2.48.1
PATCH v2 3/3 rockchip: sdram: Ensure ram_base is correct in SPL
In reply to Jonas KarlmanMost Rockchip SoCs use 0x0 as DRAM base address, however some SoCs use 0x60000000 and RK3576 use 0x40000000 as DRAM base address.
CFG_SYS_SDRAM_BASE is defined with correct address for each SoC and U-Boot proper use this to set correct gd->ram_base in setup_dest_addr().
SPL never assign any value to gd->ram_base and instead use the default, 0x0. Set correct gd->ram_base in dram_init() to ensure its correctness in SPL.
---
v2: New patch
--- arch/arm/mach-rockchip/sdram.c | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-rockchip/sdram.c +1 -0
@@ -479,6 +479,7 @@ int dram_init(void)debug ("Cannot get DRAM size: %d\n" , ret);return ret; } + gd->ram_base = ram.base; gd->ram_size = ram.size;debug ("SDRAM base=%lx, size=%lx\n" , (unsigned long )ram.base, (unsigned long )ram.size);
Signature · 1 line
2.48.1