[PATCH v2] arm64: renesas: Make bottom 128 MiB of DRAM available in EL3

Marek Vasut marek.vasut+renesas at mailbox.org
Sat Dec 21 22:46:36 CET 2024


In case U-Boot runs in EL3, which is the highest privilege level on ARM64,
there can be no firmware running that would restrict access to the bottom
128 MiB of DRAM. In fact, it is likely that U-Boot would have to load that
firmware into those bottom 128 MiB of DRAM and start that firmware.

Make those bottom 128 MiB of DRAM available in case U-Boot runs in EL3 to
allow loading the firmware to that area.

Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
---
Cc: Adam Ford <aford173 at gmail.com>
Cc: Biju Das <biju.das.jz at bp.renesas.com>
Cc: Hai Pham <hai.pham.ud at renesas.com>
Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj at bp.renesas.com>
Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
Cc: Simon Glass <sjg at chromium.org>
Cc: Tom Rini <trini at konsulko.com>
Cc: u-boot at lists.denx.de
---
V2: Make this non-Gen4 specific, Gen3 an benefit from this too
---
 board/renesas/rcar-common/common.c | 32 +++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/board/renesas/rcar-common/common.c b/board/renesas/rcar-common/common.c
index 4e35e0151c9..90eb468e4c4 100644
--- a/board/renesas/rcar-common/common.c
+++ b/board/renesas/rcar-common/common.c
@@ -15,6 +15,7 @@
 #include <asm/io.h>
 #include <dm/uclass-internal.h>
 #include <asm/arch/renesas.h>
+#include <asm/system.h>
 #include <linux/libfdt.h>
 
 #ifdef CONFIG_RCAR_64
@@ -23,13 +24,42 @@ DECLARE_GLOBAL_DATA_PTR;
 
 int dram_init(void)
 {
-	return fdtdec_setup_mem_size_base();
+	int ret = fdtdec_setup_mem_size_base();
+
+	if (current_el() == 3 && gd->ram_base == 0x48000000) {
+		/*
+		 * If this U-Boot runs in EL3, make the bottom 128 MiB
+		 * available for loading of follow up firmware blobs.
+		 */
+		gd->ram_base -= 0x8000000;
+		gd->ram_size += 0x8000000;
+	}
+
+	return ret;
 }
 
 int dram_init_banksize(void)
 {
+	int bank;
+
 	fdtdec_setup_memory_banksize();
 
+	if (current_el() != 3)
+		return 0;
+
+	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
+		if (gd->bd->bi_dram[bank].start != 0x48000000)
+			continue;
+
+		/*
+		 * If this U-Boot runs in EL3, make the bottom 128 MiB
+		 * available for loading of follow up firmware blobs.
+		 */
+		gd->bd->bi_dram[bank].start -= 0x8000000;
+		gd->bd->bi_dram[bank].size += 0x8000000;
+		break;
+	}
+
 	return 0;
 }
 
-- 
2.45.2



More information about the U-Boot mailing list