aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Liu2024-04-23 15:22:10 +0800
committerTom Rini2024-05-03 12:22:59 -0600
commitb3c0b94f2e3872959ba29c450059221bb3697588 (patch)
tree267e1b390625eed1da784a832fd547aa1cfe7a22
parente7c3948ec51d6dd2d31525c8207b5e8ccceb496a (diff)
board: arbel: Limit the dram effective size to bank0 maximal size
For 4GB dram size, the dram is divided into 2 banks and the address space of these 2 banks are not concatenated. Limit the gd->ram_top to not exceed bank0 top to prevent accessing invalid memory region. Signed-off-by: Jim Liu <JJLIU0@nuvoton.com>
-rw-r--r--board/nuvoton/arbel_evb/arbel_evb.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/board/nuvoton/arbel_evb/arbel_evb.c b/board/nuvoton/arbel_evb/arbel_evb.c
index 8fc56c18397..53c931c3c24 100644
--- a/board/nuvoton/arbel_evb/arbel_evb.c
+++ b/board/nuvoton/arbel_evb/arbel_evb.c
@@ -27,6 +27,15 @@ int board_init(void)
return 0;
}
+phys_size_t get_effective_memsize(void)
+{
+ /* Use bank0 only */
+ if (gd->ram_size > DRAM_2GB_SIZE)
+ return DRAM_2GB_SIZE;
+
+ return gd->ram_size;
+}
+
int dram_init(void)
{
struct npcm_gcr *gcr = (struct npcm_gcr *)NPCM_GCR_BA;
@@ -70,21 +79,16 @@ int dram_init_banksize(void)
gd->bd->bi_dram[1].start = DRAM_4GB_SIZE;
gd->bd->bi_dram[1].size = DRAM_2GB_SIZE -
(DRAM_4GB_SIZE - DRAM_4GB_ECC_SIZE);
- /* use bank0 only */
- gd->ram_size = DRAM_2GB_SIZE;
break;
case DRAM_4GB_SIZE:
gd->bd->bi_dram[0].size = DRAM_2GB_SIZE;
gd->bd->bi_dram[1].start = DRAM_4GB_SIZE;
gd->bd->bi_dram[1].size = DRAM_2GB_SIZE;
- /* use bank0 only */
- gd->ram_size = DRAM_2GB_SIZE;
break;
default:
gd->bd->bi_dram[0].size = DRAM_1GB_SIZE;
gd->bd->bi_dram[1].start = 0;
gd->bd->bi_dram[1].size = 0;
- gd->ram_size = DRAM_1GB_SIZE;
break;
}