From 64c0d9e010dabdd0f9fcfd68e6e94e7ba831ea6a Mon Sep 17 00:00:00 2001 From: Vignesh Raghavendra Date: Fri, 22 Sep 2023 19:46:47 +0530 Subject: [PATCH] board: ti: am62x: Avoid overwriting reserve mem for AM62 SIP AM62 SIP has 512MB RAM. But the top of the RAM is reserved for TF-A and OPTEE. U-Boot relocating there would cause overwriting of these reserved regions. Fix this by limit U-Boot to first 256MB of RAM for all boards with 512MB. Signed-off-by: Vignesh Raghavendra --- board/ti/am62x/evm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c index 79c37b696b..3b6f5be472 100644 --- a/board/ti/am62x/evm.c +++ b/board/ti/am62x/evm.c @@ -23,6 +23,8 @@ #include #include +#include + #include "../common/board_detect.h" DECLARE_GLOBAL_DATA_PTR; @@ -86,6 +88,16 @@ int dram_init_banksize(void) return fdtdec_setup_memory_banksize(); } +phys_size_t get_effective_memsize(void) +{ + /* + * Just below 512MB are TF-A and OPTEE reserve regions, thus + * SPL/U-Boot RAM has to start below that. Leave 256MB space for + * all reserved memories. + */ + return gd->ram_size == SZ_512M ? SZ_256M : gd->ram_size; +} + #if defined(CONFIG_SPL_BUILD) static int video_setup(void) {