[PATCH 0/2] Fix sdram size detection on RK3568

DRAM initialization blobs for rk356x from vendor encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format.
This series adds support for decoding basic information from this new version 3 format. It also adds support for adding a second dram bank of any usable memory beyond the 4GB mark.
With these patches my Radxa ROCK 3 Model A 2GB correctly report 2GB of DRAM, instead of 4GB, and my 8GB board can make full use of its memory.
Jonas Karlman (2): rockchip: sdram: add basic support for sdram reg info version 3 rockchip: sdram: add dram bank with usable memory beyond 4GB
arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 21 ++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-)

Add a second dram bank of usable memory beyond the blob of space for peripheral near 4GB. Any memory that exists beyond the 4GB mark is added to the second bank.
Signed-off-by: Jonas Karlman jonas@kwiboo.se --- arch/arm/mach-rockchip/sdram.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index 7c12112799..2007064f0a 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -37,13 +37,19 @@ struct tos_parameter_t {
int dram_init_banksize(void) { - size_t top = min((unsigned long)(gd->ram_size + CONFIG_SYS_SDRAM_BASE), - (unsigned long)(gd->ram_top)); + size_t ram_top = (unsigned long)(gd->ram_size + CONFIG_SYS_SDRAM_BASE); + size_t top = min((unsigned long)ram_top, (unsigned long)(gd->ram_top));
#ifdef CONFIG_ARM64 /* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0].start = 0x200000; gd->bd->bi_dram[0].size = top - gd->bd->bi_dram[0].start; + + /* Add usable memory beyond the blob of space for peripheral near 4GB */ + 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 #ifdef CONFIG_SPL_OPTEE_IMAGE struct tos_parameter_t *tos_parameter; @@ -181,7 +187,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) * 2. update board_get_usable_ram_top() and dram_init_banksize() * to reserve memory for peripheral space after previous update. */ - if (size_mb > (SDRAM_MAX_SIZE >> 20)) + if (!IS_ENABLED(CONFIG_ARM64) && size_mb > (SDRAM_MAX_SIZE >> 20)) size_mb = (SDRAM_MAX_SIZE >> 20);
return (size_t)size_mb << 20;

Newer DRAM initialization blobs from vendor can encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format.
Add basic support for detecting the version 3 format and decoding the high bits used for ddrtype.
This fixes decode of sdram size on my RK3568 boards that have LPDDR4X.
Details on the new format was deciphered from vendor u-boot commit [1].
[1] https://github.com/rockchip-linux/u-boot/commit/c69667e0e2bf4290ab1f408fcde5...
Signed-off-by: Jonas Karlman jonas@kwiboo.se --- arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 9 +++++-- 2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h b/arch/arm/include/asm/arch-rockchip/sdram.h index cf2a7b7d10..4fb45ac5c7 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram.h +++ b/arch/arm/include/asm/arch-rockchip/sdram.h @@ -8,10 +8,13 @@
enum { DDR4 = 0, - DDR3 = 0x3, - LPDDR2 = 0x5, - LPDDR3 = 0x6, - LPDDR4 = 0x7, + DDR3 = 3, + LPDDR2 = 5, + LPDDR3 = 6, + LPDDR4 = 7, + LPDDR4X = 8, + LPDDR5 = 9, + DDR5 = 10, UNUSED = 0xFF };
@@ -21,16 +24,16 @@ enum { * [30] row_3_4_ch0 * [29:28] chinfo * [27] rank_ch1 - * [26:25] col_ch1 + * [26:25] cs0_col_ch1 * [24] bk_ch1 * [23:22] low bits of cs0_row_ch1 * [21:20] low bits of cs1_row_ch1 * [19:18] bw_ch1 - * [17:16] dbw_ch1; - * [15:13] ddrtype + * [17:16] dbw_ch1 + * [15:13] low bits of ddrtype * [12] channelnum - * [11] rank_ch0 - * [10:9] col_ch0, + * [11] low bit of rank_ch0 + * [10:9] cs0_col_ch0 * [8] bk_ch0 * [7:6] low bits of cs0_row_ch0 * [5:4] low bits of cs1_row_ch0 @@ -61,6 +64,11 @@ enum {
/* * sys_reg3 bitfield struct + * [31:28] version + * [16] cs3_delta_row + * [15] cs2_delta_row + * [14] high bit of rank_ch0 + * [13:12] high bits of ddrtype * [7] high bit of cs0_row_ch1 * [6] high bit of cs1_row_ch1 * [5] high bit of cs0_row_ch0 @@ -70,6 +78,8 @@ enum { */ #define SYS_REG_VERSION_SHIFT 28 #define SYS_REG_VERSION_MASK 0xf +#define SYS_REG_EXTEND_DDRTYPE_SHIFT 12 +#define SYS_REG_EXTEND_DDRTYPE_MASK 3 #define SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) (5 + (ch) * 2) #define SYS_REG_EXTEND_CS0_ROW_MASK 1 #define SYS_REG_EXTEND_CS1_ROW_SHIFT(ch) (4 + (ch) * 2) diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index 12f1d7ee56..7c12112799 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -88,9 +88,15 @@ size_t rockchip_sdram_size(phys_addr_t reg) u32 sys_reg3 = readl(reg + 4); u32 ch_num = 1 + ((sys_reg2 >> SYS_REG_NUM_CH_SHIFT) & SYS_REG_NUM_CH_MASK); + u32 version = (sys_reg3 >> SYS_REG_VERSION_SHIFT) & + SYS_REG_VERSION_MASK;
dram_type = (sys_reg2 >> SYS_REG_DDRTYPE_SHIFT) & SYS_REG_DDRTYPE_MASK; + if (version >= 3) + dram_type |= ((sys_reg3 >> SYS_REG_EXTEND_DDRTYPE_SHIFT) & + SYS_REG_EXTEND_DDRTYPE_MASK) << 3; debug("%s %x %x\n", __func__, (u32)reg, sys_reg2); + debug("%s %x %x\n", __func__, (u32)reg + 4, sys_reg3); for (ch = 0; ch < ch_num; ch++) { rank = 1 + (sys_reg2 >> SYS_REG_RANK_SHIFT(ch) & SYS_REG_RANK_MASK); @@ -98,8 +104,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) SYS_REG_COL_MASK); cs1_col = cs0_col; bk = 3 - ((sys_reg2 >> SYS_REG_BK_SHIFT(ch)) & SYS_REG_BK_MASK); - if ((sys_reg3 >> SYS_REG_VERSION_SHIFT & - SYS_REG_VERSION_MASK) == 0x2) { + if (version >= 2) { cs1_col = 9 + (sys_reg3 >> SYS_REG_CS1_COL_SHIFT(ch) & SYS_REG_CS1_COL_MASK); if (((sys_reg3 >> SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) &

DRAM initialization blobs for rk356x and rk3588 from vendor encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format. RK3588 blob also encode information on sdram channel 3+4 in sys_reg4+5 using the same format.
This series adds support for decoding basic information from this new version 3 format. It also adds support for adding a second dram bank with any usable memory beyond the 4GB mark.
With these patches my Radxa ROCK 3 Model A 2GB correctly report 2GB of DRAM, instead of 4GB, and my 8GB board can make full use of its memory. My Radxa ROCK 5 Model B 8GB also correctly report and can make full use of its 8GB of DRAM with these patches.
Changes in v2: - Change CONFIG_SYS_SDRAM_BASE to CFG_SYS_SDRAM_BASE - Added a note on RK3588 blobs use of sys_reg4+5 to cover letter
Jonas Karlman (2): rockchip: sdram: add basic support for sdram reg info version 3 rockchip: sdram: add dram bank with usable memory beyond 4GB
arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 21 ++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-)

Newer DRAM initialization blobs from vendor can encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format.
Add basic support for detecting the version 3 format and decoding the high bits used for ddrtype.
This fixes decode of sdram size on my RK3568 boards that have LPDDR4X.
Details on the new format was deciphered from vendor u-boot commit [1].
[1] https://github.com/rockchip-linux/u-boot/commit/c69667e0e2bf4290ab1f408fcde5...
Signed-off-by: Jonas Karlman jonas@kwiboo.se --- v2: - No change
arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 9 +++++-- 2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h b/arch/arm/include/asm/arch-rockchip/sdram.h index cf2a7b7d105f..4fb45ac5c76e 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram.h +++ b/arch/arm/include/asm/arch-rockchip/sdram.h @@ -8,10 +8,13 @@
enum { DDR4 = 0, - DDR3 = 0x3, - LPDDR2 = 0x5, - LPDDR3 = 0x6, - LPDDR4 = 0x7, + DDR3 = 3, + LPDDR2 = 5, + LPDDR3 = 6, + LPDDR4 = 7, + LPDDR4X = 8, + LPDDR5 = 9, + DDR5 = 10, UNUSED = 0xFF };
@@ -21,16 +24,16 @@ enum { * [30] row_3_4_ch0 * [29:28] chinfo * [27] rank_ch1 - * [26:25] col_ch1 + * [26:25] cs0_col_ch1 * [24] bk_ch1 * [23:22] low bits of cs0_row_ch1 * [21:20] low bits of cs1_row_ch1 * [19:18] bw_ch1 - * [17:16] dbw_ch1; - * [15:13] ddrtype + * [17:16] dbw_ch1 + * [15:13] low bits of ddrtype * [12] channelnum - * [11] rank_ch0 - * [10:9] col_ch0, + * [11] low bit of rank_ch0 + * [10:9] cs0_col_ch0 * [8] bk_ch0 * [7:6] low bits of cs0_row_ch0 * [5:4] low bits of cs1_row_ch0 @@ -61,6 +64,11 @@ enum {
/* * sys_reg3 bitfield struct + * [31:28] version + * [16] cs3_delta_row + * [15] cs2_delta_row + * [14] high bit of rank_ch0 + * [13:12] high bits of ddrtype * [7] high bit of cs0_row_ch1 * [6] high bit of cs1_row_ch1 * [5] high bit of cs0_row_ch0 @@ -70,6 +78,8 @@ enum { */ #define SYS_REG_VERSION_SHIFT 28 #define SYS_REG_VERSION_MASK 0xf +#define SYS_REG_EXTEND_DDRTYPE_SHIFT 12 +#define SYS_REG_EXTEND_DDRTYPE_MASK 3 #define SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) (5 + (ch) * 2) #define SYS_REG_EXTEND_CS0_ROW_MASK 1 #define SYS_REG_EXTEND_CS1_ROW_SHIFT(ch) (4 + (ch) * 2) diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index e086c47f3c00..91951e4b8ccf 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -88,9 +88,15 @@ size_t rockchip_sdram_size(phys_addr_t reg) u32 sys_reg3 = readl(reg + 4); u32 ch_num = 1 + ((sys_reg2 >> SYS_REG_NUM_CH_SHIFT) & SYS_REG_NUM_CH_MASK); + u32 version = (sys_reg3 >> SYS_REG_VERSION_SHIFT) & + SYS_REG_VERSION_MASK;
dram_type = (sys_reg2 >> SYS_REG_DDRTYPE_SHIFT) & SYS_REG_DDRTYPE_MASK; + if (version >= 3) + dram_type |= ((sys_reg3 >> SYS_REG_EXTEND_DDRTYPE_SHIFT) & + SYS_REG_EXTEND_DDRTYPE_MASK) << 3; debug("%s %x %x\n", __func__, (u32)reg, sys_reg2); + debug("%s %x %x\n", __func__, (u32)reg + 4, sys_reg3); for (ch = 0; ch < ch_num; ch++) { rank = 1 + (sys_reg2 >> SYS_REG_RANK_SHIFT(ch) & SYS_REG_RANK_MASK); @@ -98,8 +104,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) SYS_REG_COL_MASK); cs1_col = cs0_col; bk = 3 - ((sys_reg2 >> SYS_REG_BK_SHIFT(ch)) & SYS_REG_BK_MASK); - if ((sys_reg3 >> SYS_REG_VERSION_SHIFT & - SYS_REG_VERSION_MASK) == 0x2) { + if (version >= 2) { cs1_col = 9 + (sys_reg3 >> SYS_REG_CS1_COL_SHIFT(ch) & SYS_REG_CS1_COL_MASK); if (((sys_reg3 >> SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) &

On 2023/2/8 01:27, Jonas Karlman wrote:
Newer DRAM initialization blobs from vendor can encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format.
Add basic support for detecting the version 3 format and decoding the high bits used for ddrtype.
This fixes decode of sdram size on my RK3568 boards that have LPDDR4X.
Details on the new format was deciphered from vendor u-boot commit [1].
[1] https://github.com/rockchip-linux/u-boot/commit/c69667e0e2bf4290ab1f408fcde5...
Signed-off-by: Jonas Karlman jonas@kwiboo.se
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
v2:
No change
arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 9 +++++-- 2 files changed, 26 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/arch-rockchip/sdram.h b/arch/arm/include/asm/arch-rockchip/sdram.h index cf2a7b7d105f..4fb45ac5c76e 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram.h +++ b/arch/arm/include/asm/arch-rockchip/sdram.h @@ -8,10 +8,13 @@
enum { DDR4 = 0,
- DDR3 = 0x3,
- LPDDR2 = 0x5,
- LPDDR3 = 0x6,
- LPDDR4 = 0x7,
- DDR3 = 3,
- LPDDR2 = 5,
- LPDDR3 = 6,
- LPDDR4 = 7,
- LPDDR4X = 8,
- LPDDR5 = 9,
- DDR5 = 10, UNUSED = 0xFF };
@@ -21,16 +24,16 @@ enum {
- [30] row_3_4_ch0
- [29:28] chinfo
- [27] rank_ch1
- [26:25] col_ch1
- [26:25] cs0_col_ch1
- [24] bk_ch1
- [23:22] low bits of cs0_row_ch1
- [21:20] low bits of cs1_row_ch1
- [19:18] bw_ch1
- [17:16] dbw_ch1;
- [15:13] ddrtype
- [17:16] dbw_ch1
- [15:13] low bits of ddrtype
- [12] channelnum
- [11] rank_ch0
- [10:9] col_ch0,
- [11] low bit of rank_ch0
- [10:9] cs0_col_ch0
- [8] bk_ch0
- [7:6] low bits of cs0_row_ch0
- [5:4] low bits of cs1_row_ch0
@@ -61,6 +64,11 @@ enum {
/*
- sys_reg3 bitfield struct
- [31:28] version
- [16] cs3_delta_row
- [15] cs2_delta_row
- [14] high bit of rank_ch0
- [13:12] high bits of ddrtype
- [7] high bit of cs0_row_ch1
- [6] high bit of cs1_row_ch1
- [5] high bit of cs0_row_ch0
@@ -70,6 +78,8 @@ enum { */ #define SYS_REG_VERSION_SHIFT 28 #define SYS_REG_VERSION_MASK 0xf +#define SYS_REG_EXTEND_DDRTYPE_SHIFT 12 +#define SYS_REG_EXTEND_DDRTYPE_MASK 3 #define SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) (5 + (ch) * 2) #define SYS_REG_EXTEND_CS0_ROW_MASK 1 #define SYS_REG_EXTEND_CS1_ROW_SHIFT(ch) (4 + (ch) * 2) diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index e086c47f3c00..91951e4b8ccf 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -88,9 +88,15 @@ size_t rockchip_sdram_size(phys_addr_t reg) u32 sys_reg3 = readl(reg + 4); u32 ch_num = 1 + ((sys_reg2 >> SYS_REG_NUM_CH_SHIFT) & SYS_REG_NUM_CH_MASK);
u32 version = (sys_reg3 >> SYS_REG_VERSION_SHIFT) &
SYS_REG_VERSION_MASK;
dram_type = (sys_reg2 >> SYS_REG_DDRTYPE_SHIFT) & SYS_REG_DDRTYPE_MASK;
if (version >= 3)
dram_type |= ((sys_reg3 >> SYS_REG_EXTEND_DDRTYPE_SHIFT) &
SYS_REG_EXTEND_DDRTYPE_MASK) << 3;
debug("%s %x %x\n", __func__, (u32)reg, sys_reg2);
debug("%s %x %x\n", __func__, (u32)reg + 4, sys_reg3); for (ch = 0; ch < ch_num; ch++) { rank = 1 + (sys_reg2 >> SYS_REG_RANK_SHIFT(ch) & SYS_REG_RANK_MASK);
@@ -98,8 +104,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) SYS_REG_COL_MASK); cs1_col = cs0_col; bk = 3 - ((sys_reg2 >> SYS_REG_BK_SHIFT(ch)) & SYS_REG_BK_MASK);
if ((sys_reg3 >> SYS_REG_VERSION_SHIFT &
SYS_REG_VERSION_MASK) == 0x2) {
if (version >= 2) { cs1_col = 9 + (sys_reg3 >> SYS_REG_CS1_COL_SHIFT(ch) & SYS_REG_CS1_COL_MASK); if (((sys_reg3 >> SYS_REG_EXTEND_CS0_ROW_SHIFT(ch) &

Add a second dram bank of usable memory beyond the blob of space for peripheral near 4GB. Any memory that exists beyond the 4GB mark is added to the second bank.
Signed-off-by: Jonas Karlman jonas@kwiboo.se --- v2: - Change CONFIG_SYS_SDRAM_BASE to CFG_SYS_SDRAM_BASE
arch/arm/mach-rockchip/sdram.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index 91951e4b8ccf..1d17a740ade9 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -37,13 +37,19 @@ struct tos_parameter_t {
int dram_init_banksize(void) { - size_t top = min((unsigned long)(gd->ram_size + CFG_SYS_SDRAM_BASE), - (unsigned long)(gd->ram_top)); + size_t ram_top = (unsigned long)(gd->ram_size + CFG_SYS_SDRAM_BASE); + size_t top = min((unsigned long)ram_top, (unsigned long)(gd->ram_top));
#ifdef CONFIG_ARM64 /* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0].start = 0x200000; gd->bd->bi_dram[0].size = top - gd->bd->bi_dram[0].start; + + /* Add usable memory beyond the blob of space for peripheral near 4GB */ + 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 #ifdef CONFIG_SPL_OPTEE_IMAGE struct tos_parameter_t *tos_parameter; @@ -181,7 +187,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) * 2. update board_get_usable_ram_top() and dram_init_banksize() * to reserve memory for peripheral space after previous update. */ - if (size_mb > (SDRAM_MAX_SIZE >> 20)) + if (!IS_ENABLED(CONFIG_ARM64) && size_mb > (SDRAM_MAX_SIZE >> 20)) size_mb = (SDRAM_MAX_SIZE >> 20);
return (size_t)size_mb << 20;

On 2023/2/8 01:27, Jonas Karlman wrote:
Add a second dram bank of usable memory beyond the blob of space for peripheral near 4GB. Any memory that exists beyond the 4GB mark is added to the second bank.
Signed-off-by: Jonas Karlman jonas@kwiboo.se
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
v2:
Change CONFIG_SYS_SDRAM_BASE to CFG_SYS_SDRAM_BASE
arch/arm/mach-rockchip/sdram.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-rockchip/sdram.c b/arch/arm/mach-rockchip/sdram.c index 91951e4b8ccf..1d17a740ade9 100644 --- a/arch/arm/mach-rockchip/sdram.c +++ b/arch/arm/mach-rockchip/sdram.c @@ -37,13 +37,19 @@ struct tos_parameter_t {
int dram_init_banksize(void) {
- size_t top = min((unsigned long)(gd->ram_size + CFG_SYS_SDRAM_BASE),
(unsigned long)(gd->ram_top));
size_t ram_top = (unsigned long)(gd->ram_size + CFG_SYS_SDRAM_BASE);
size_t top = min((unsigned long)ram_top, (unsigned long)(gd->ram_top));
#ifdef CONFIG_ARM64 /* Reserve 0x200000 for ATF bl31 */ gd->bd->bi_dram[0].start = 0x200000; gd->bd->bi_dram[0].size = top - gd->bd->bi_dram[0].start;
/* Add usable memory beyond the blob of space for peripheral near 4GB */
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 #ifdef CONFIG_SPL_OPTEE_IMAGE struct tos_parameter_t *tos_parameter;
@@ -181,7 +187,7 @@ size_t rockchip_sdram_size(phys_addr_t reg) * 2. update board_get_usable_ram_top() and dram_init_banksize() * to reserve memory for peripheral space after previous update. */
- if (size_mb > (SDRAM_MAX_SIZE >> 20))
if (!IS_ENABLED(CONFIG_ARM64) && size_mb > (SDRAM_MAX_SIZE >> 20)) size_mb = (SDRAM_MAX_SIZE >> 20);
return (size_t)size_mb << 20;

On 2/7/23 19:27, Jonas Karlman wrote:
DRAM initialization blobs for rk356x and rk3588 from vendor encode sdram info in a new version 3 format. The new format makes use of more bits in sys_reg3 compared to the version 2 format. RK3588 blob also encode information on sdram channel 3+4 in sys_reg4+5 using the same format.
This series adds support for decoding basic information from this new version 3 format. It also adds support for adding a second dram bank with any usable memory beyond the 4GB mark.
With these patches my Radxa ROCK 3 Model A 2GB correctly report 2GB of DRAM, instead of 4GB, and my 8GB board can make full use of its memory. My Radxa ROCK 5 Model B 8GB also correctly report and can make full use of its 8GB of DRAM with these patches.
Changes in v2:
- Change CONFIG_SYS_SDRAM_BASE to CFG_SYS_SDRAM_BASE
- Added a note on RK3588 blobs use of sys_reg4+5 to cover letter
Jonas Karlman (2): rockchip: sdram: add basic support for sdram reg info version 3 rockchip: sdram: add dram bank with usable memory beyond 4GB
arch/arm/include/asm/arch-rockchip/sdram.h | 28 +++++++++++++++------- arch/arm/mach-rockchip/sdram.c | 21 ++++++++++++---- 2 files changed, 35 insertions(+), 14 deletions(-)
Tested-by: Eugen Hristev eugen.hristev@collabora.com
Thanks !
participants (3)
-
Eugen Hristev
-
Jonas Karlman
-
Kever Yang