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 3/9] arm: socfpga: agilex5: configure firewall with base and size
Date: Thu, 16 Apr 2026 11:48:07 +0200	[thread overview]
Message-ID: <20260416-socfpga-agilex5-sdram-v1-3-07556aa7219f@pengutronix.de> (raw)
In-Reply-To: <20260416-socfpga-agilex5-sdram-v1-0-07556aa7219f@pengutronix.de>

The firewall configuration internally uses the DDR base address and
reserves some space for the TF-A. Pass the base address of the region 0
as a parameter to make it more visible.

Since base is now the base of region 0 instead of the DDR base, the
passed size must now be the size of region 0 instead of the full DDR
size.

Signed-off-by: Michael Tretter <m.tretter@pengutronix.de>
---
 arch/arm/mach-socfpga/agilex5-sdram.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/arch/arm/mach-socfpga/agilex5-sdram.c b/arch/arm/mach-socfpga/agilex5-sdram.c
index 4e7994985d26..4d95c7b64306 100644
--- a/arch/arm/mach-socfpga/agilex5-sdram.c
+++ b/arch/arm/mach-socfpga/agilex5-sdram.c
@@ -179,20 +179,14 @@ static bool ddr_ecc_dbe_status(void)
 	return false;
 }
 
-static void sdram_set_firewall(phys_size_t hw_size)
+static void sdram_set_firewall(phys_addr_t base, phys_size_t size)
 {
-	phys_size_t value;
+	phys_addr_t limit = base + size - 1;
 	u32 lower, upper;
 
-	value = SOCFPGA_AGILEX5_DDR_BASE;
-	/* Keep first 1MB of SDRAM memory region as secure region when
-	 * using ATF flow, where the ATF code is located.
-	 */
-	value += SZ_1M;
-
 	/* Setting non-secure MPU region base and base extended */
-	lower = lower_32_bits(value);
-	upper = upper_32_bits(value);
+	lower = lower_32_bits(base);
+	upper = upper_32_bits(base);
 	FW_MPU_DDR_SCR_WRITEL(lower, FW_MPU_DDR_SCR_MPUREGION0ADDR_BASE);
 	FW_MPU_DDR_SCR_WRITEL(upper & 0xff, FW_MPU_DDR_SCR_MPUREGION0ADDR_BASEEXT);
 	FW_F2SDRAM_DDR_SCR_WRITEL(lower, FW_F2SDRAM_DDR_SCR_REGION0ADDR_BASE);
@@ -203,11 +197,8 @@ static void sdram_set_firewall(phys_size_t hw_size)
 	FW_MPU_DDR_SCR_WRITEL(upper & 0xff, FW_MPU_DDR_SCR_NONMPUREGION0ADDR_BASEEXT);
 
 	/* Setting non-secure MPU limit and limit extended */
-	value = SOCFPGA_AGILEX5_DDR_BASE + hw_size - 1;
-
-	lower = lower_32_bits(value);
-	upper = upper_32_bits(value);
-
+	lower = lower_32_bits(limit);
+	upper = upper_32_bits(limit);
 	FW_MPU_DDR_SCR_WRITEL(lower, FW_MPU_DDR_SCR_MPUREGION0ADDR_LIMIT);
 	FW_MPU_DDR_SCR_WRITEL(upper & 0xff, FW_MPU_DDR_SCR_MPUREGION0ADDR_LIMITEXT);
 
@@ -327,7 +318,11 @@ int agilex5_ddr_init_full(void)
 		hw_size -= hw_size / 8;
 	pr_debug("%s: %lld MiB\n", io96b_ctrl.ddr_type, hw_size / SZ_1M);
 
-	sdram_set_firewall(hw_size);
+	/*
+	 * Keep first 1MB of SDRAM memory region as secure region when
+	 * using ATF flow, where the ATF code is located.
+	 */
+	sdram_set_firewall(SOCFPGA_AGILEX5_DDR_BASE + SZ_1M, hw_size - SZ_1M);
 
 	/* Firewall setting for MPFE CSR */
 	/* IO96B0_reg */

-- 
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 ` Michael Tretter [this message]
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 ` [PATCH 7/9] arm: socfpga: agilex5: read SDRAM limits from firewall Michael Tretter
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-3-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