mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Tretter <m.tretter@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
	 BAREBOX <barebox@lists.infradead.org>
Cc: Steffen Trumtrar <s.trumtrar@pengutronix.de>,
	 Michael Tretter <m.tretter@pengutronix.de>
Subject: [PATCH 7/9] arm: socfpga: agilex5: read SDRAM limits from firewall
Date: Thu, 16 Apr 2026 11:48:11 +0200	[thread overview]
Message-ID: <20260416-socfpga-agilex5-sdram-v1-7-07556aa7219f@pengutronix.de> (raw)
In-Reply-To: <20260416-socfpga-agilex5-sdram-v1-0-07556aa7219f@pengutronix.de>

The hard-coded membase and memsize are not flexible enough for the
configurable SDRAM setup on Agilex 5.

The SZ_1M offset is the result of reserving some memory for the TF-A.
The offset isn't correct anymore, if the reserved area for the TF-A is
changed.

The memory size may change, if the EMIF is configured with inline ECC,
which reserves 1/8 of the memory for checksums and reduces the usable
SDRAM size. Depending on the EMIF configuration, the same board may or
may not use inline ECC.

Since the PBL in EL3 configures the firewall to consider the reserved
area for the TF-A and the reserved memory for ECC checksums, the PBL in
EL1 may read back the configuration to determine the usable memory for
barebox proper.

Add sanity checks on the base address and size to ensure the firewall is
actually configured.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 arch/arm/boards/arrow-axe5-eagle/lowlevel.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
index 41c1b832a682..4817b3ec2d86 100644
--- a/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
+++ b/arch/arm/boards/arrow-axe5-eagle/lowlevel.c
@@ -21,6 +21,8 @@ extern char __dtb_z_socfpga_agilex5_axe5_eagle_start[];
 static noinline void axe5_eagle_continue(void)
 {
 	void *fdt;
+	phys_addr_t membase;
+	phys_size_t memsize;
 
 	agilex5_clk_init();
 
@@ -68,7 +70,15 @@ static noinline void axe5_eagle_continue(void)
 
 	fdt = __dtb_z_socfpga_agilex5_axe5_eagle_start;
 
-	barebox_arm_entry(SOCFPGA_AGILEX5_DDR_BASE + SZ_1M, SZ_1G - SZ_1M, fdt);
+	membase = agilex5_mpfe_sdram_base();
+	memsize = agilex5_mpfe_sdram_size();
+
+	if (membase < SOCFPGA_AGILEX5_DDR_BASE || memsize == 0) {
+		pr_err("Invalid firewall configuration\n");
+		hang();
+	}
+
+	barebox_arm_entry(membase, memsize, fdt);
 }
 
 ENTRY_FUNCTION_WITHSTACK(start_socfpga_agilex5_axe5_eagle, AXE5_STACKTOP, r0, r1, r2)

-- 
2.47.3




  parent reply	other threads:[~2026-04-16  9:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16  9:48 [PATCH 0/9] arm: socfpga: agilex5: rework low level code Michael Tretter
2026-04-16  9:48 ` [PATCH 1/9] arm: socfpga: agilex5: cleanup TF-A loading Michael Tretter
2026-04-16  9:48 ` [PATCH 2/9] arm: socfgpa: agilex5: remove unused memsize Michael Tretter
2026-04-16  9:48 ` [PATCH 3/9] arm: socfpga: agilex5: configure firewall with base and size Michael Tretter
2026-04-16  9:48 ` [PATCH 4/9] arm: socfpga: agilex5: fix read of memory limit Michael Tretter
2026-04-16  9:48 ` [PATCH 5/9] arm: socfpga: agilex5: fix SDRAM size calculation Michael Tretter
2026-04-16  9:48 ` [PATCH 6/9] arm: socfpga: agilex5: remove unused declarations Michael Tretter
2026-04-16  9:48 ` Michael Tretter [this message]
2026-04-16  9:48 ` [PATCH 8/9] arm: socfpga: agilex5: add agilex5_barebox_entry Michael Tretter
2026-04-16  9:48 ` [PATCH 9/9] arm: socfpga: agilex5: add explicit unreachable after TF-A load Michael Tretter
2026-04-17  8:25 ` [PATCH 0/9] arm: socfpga: agilex5: rework low level code Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260416-socfpga-agilex5-sdram-v1-7-07556aa7219f@pengutronix.de \
    --to=m.tretter@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    --cc=s.trumtrar@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox