Skip to contentSkip to conversation

rockchip: sdram: fix dram_init_banksize

PATCH New Alex Bee 2 participants 3 messages Jul 14, 2020 – Jul 18, 2020

Subsystems (3)
lore
Share & tools
lore

Alex Bee

author
#0 lore raw

PATCH 1/1 rockchip: sdram: fix dram_init_banksize

Currently 2.5 GB is calculated as DRAM size for a 1 GB RK322x board if CONFIG_SPL_OPTEE is set. This is troublesome when booting a linux kernel since this size will be injected in FDT of the kernel.

gd->bd->bi_dram[0].start (which is basically CONFIG_SYS_SDRAM_BASE) must not be taken into consideration for calculation of second bank size, since this offset is already included in calculation of "top".

After applying this patch 992 MB (1024 MB - 32 MB reserved for optee-os) is correctly calculated and has also been verified on 2 GB boards.

---
 arch/arm/mach-rockchip/sdram.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/sdram.c +2 -4
index 24fe6cc8f0..4c637b7767 100644
@@ -56,16 +56,14 @@ int dram_init_banksize(void)
 					- CONFIG_SYS_SDRAM_BASE;
 		gd->bd->bi_dram[1].start = tos_parameter->tee_mem.phy_addr +
 					tos_parameter->tee_mem.size;
-		gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start
-					+ top - gd->bd->bi_dram[1].start;
+		gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start;
 	} else {
 		gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
 		gd->bd->bi_dram[0].size = 0x8400000;
 		/* Reserve 32M for OPTEE with TA */
 		gd->bd->bi_dram[1].start = CONFIG_SYS_SDRAM_BASE
 					+ gd->bd->bi_dram[0].size + 0x2000000;
-		gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start
-					+ top - gd->bd->bi_dram[1].start;
+		gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start;
 	}
 #else
 	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/1 rockchip: sdram: fix dram_init_banksize

Hi Alex,

Tanks for your fix.

Quoted 8 lines · Alex Bee

Currently 2.5 GB is calculated as DRAM size for a 1 GB RK322x board if CONFIG_SPL_OPTEE is set. This is troublesome when booting a linux kernel since this size will be injected in FDT of the kernel.

gd->bd->bi_dram[0].start (which is basically CONFIG_SYS_SDRAM_BASE) must not be taken into consideration for calculation of second bank size, since this offset is already included in calculation of "top".

Quoted 5 lines

After applying this patch 992 MB (1024 MB - 32 MB reserved for optee-os) is correctly calculated and has also been verified on 2 GB boards.

Thanks,
- Kever

Quoted 27 lines
---
  arch/arm/mach-rockchip/sdram.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
arch/arm/mach-rockchip/sdram.c +2 -4
index 24fe6cc8f0..4c637b7767 100644
@@ -56,16 +56,14 @@ int dram_init_banksize(void)
  					- CONFIG_SYS_SDRAM_BASE;
  		gd->bd->bi_dram[1].start = tos_parameter->tee_mem.phy_addr +
  					tos_parameter->tee_mem.size;
-		gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start
-					+ top - gd->bd->bi_dram[1].start;
+		gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start;
  	} else {
  		gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
  		gd->bd->bi_dram[0].size = 0x8400000;
  		/* Reserve 32M for OPTEE with TA */
  		gd->bd->bi_dram[1].start = CONFIG_SYS_SDRAM_BASE
  					+ gd->bd->bi_dram[0].size + 0x2000000;
-		gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start
-					+ top - gd->bd->bi_dram[1].start;
+		gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start;
  	}
  #else
  	gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;
#2 lore raw

PATCH 1/1 rockchip: sdram: fix dram_init_banksize

Quoted 13 lines · Kever Yang

Hi Alex,

Tanks for your fix.

Quoted 8 lines · Alex Bee

Currently 2.5 GB is calculated as DRAM size for a 1 GB RK322x board if CONFIG_SPL_OPTEE is set. This is troublesome when booting a linux kernel since this size will be injected in FDT of the kernel.

gd->bd->bi_dram[0].start (which is basically CONFIG_SYS_SDRAM_BASE) must not be taken into consideration for calculation of second bank size, since this offset is already included in calculation of "top".

Quoted 6 lines
Quoted 5 lines

After applying this patch 992 MB (1024 MB - 32 MB reserved for optee-os) is correctly calculated and has also been verified on 2 GB boards.

Applied to u-boot-rockchip master for this patch set, thanks.

Quoted 35 lines

Thanks,
- Kever

Quoted 28 lines

---
? arch/arm/mach-rockchip/sdram.c | 6 ++----
? 1 file changed, 2 insertions(+), 4 deletions(-)

arch/arm/mach-rockchip/sdram.c +0 -0
index 24fe6cc8f0..4c637b7767 100644
@@ -56,16 +56,14 @@ int dram_init_banksize(void)
 ????????????????????? - CONFIG_SYS_SDRAM_BASE;

????????? gd->bd->bi_dram[1].start = tos_parameter->tee_mem.phy_addr + ????????????????????? tos_parameter->tee_mem.size;
-??????? gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start -??????????????????? + top - gd->bd->bi_dram[1].start; +??????? gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start; ????? } else {
????????? gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; ????????? gd->bd->bi_dram[0].size = 0x8400000;
????????? /* Reserve 32M for OPTEE with TA */
????????? gd->bd->bi_dram[1].start = CONFIG_SYS_SDRAM_BASE ????????????????????? + gd->bd->bi_dram[0].size + 0x2000000; -??????? gd->bd->bi_dram[1].size = gd->bd->bi_dram[0].start -??????????????????? + top - gd->bd->bi_dram[1].start; +??????? gd->bd->bi_dram[1].size = top - gd->bd->bi_dram[1].start; ????? }
? #else
????? gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE;