]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rockchip: sdram: fix dram_init_banksize
authorAlex Bee <knaerzche@gmail.com>
Tue, 14 Jul 2020 23:03:31 +0000 (01:03 +0200)
committerKever Yang <kever.yang@rock-chips.com>
Wed, 22 Jul 2020 12:22:52 +0000 (20:22 +0800)
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.

Signed-off-by: Alex Bee <knaerzche@gmail.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
arch/arm/mach-rockchip/sdram.c

index 24fe6cc8f0cacb3c4d8fe79430417a70f1d93a00..4c637b7767354f56289cb5404e27a32f762b15fd 100644 (file)
@@ -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;