[PATCH 1/9] arm: socfpga: agilex5: cleanup TF-A loading

Michael Tretter m.tretter at pengutronix.de
Thu Apr 16 02:48:05 PDT 2026


Use local variables for the bl31 and bl33 address to be able to change
these more easily and consistently.

Print the TF-A memory locations to the logs.

Signed-off-by: Michael Tretter <m.tretter at pengutronix.de>
---
 arch/arm/mach-socfpga/atf.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-socfpga/atf.c b/arch/arm/mach-socfpga/atf.c
index d0f57d95415e..98460472227e 100644
--- a/arch/arm/mach-socfpga/atf.c
+++ b/arch/arm/mach-socfpga/atf.c
@@ -11,23 +11,25 @@
 
 void __noreturn agilex5_load_and_start_image_via_tfa(unsigned long memsize)
 {
-	unsigned long atf_dest = AGILEX5_ATF_BL31_BASE_ADDR;
-	void __noreturn (*bl31)(void) = (void *)atf_dest;
+	void *bl31 = (void *)AGILEX5_ATF_BL31_BASE_ADDR;
+	void *bl33 = (void *)AGILEX5_ATF_BL33_BASE_ADDR;
 	struct fwobj tfa;
 
-	pr_debug("Load TFA\n");
-
-	memcpy((void *)AGILEX5_ATF_BL33_BASE_ADDR, __image_start, barebox_image_size);
+	pr_debug("copy bl33 to %p from %p (%zu bytes)\n",
+		 bl33, __image_start, barebox_image_size);
+	memcpy(bl33, __image_start, barebox_image_size);
 
 	get_builtin_firmware(agilex5_bl31_bin, &tfa);
 
+	pr_debug("copy bl31 to %p from %p (%zu bytes)\n",
+		 bl31, tfa.data, tfa.size);
 	memcpy(bl31, tfa.data, tfa.size);
 
 	asm volatile("msr sp_el2, %0" : :
-		     "r" (AGILEX5_ATF_BL33_BASE_ADDR - 16) :
+		     "r" (bl33 - 16) :
 		     "cc");
 
-	pr_debug("Jumping to @0x%08lx\n", atf_dest);
-	bl31_entry((uintptr_t)bl31, 0, AGILEX5_ATF_BL33_BASE_ADDR, 0);
+	pr_debug("Jump to bl31 0x%p\n", bl31);
+	bl31_entry((uintptr_t)bl31, 0, (uintptr_t)bl33, 0);
 	__builtin_unreachable();
 }

-- 
2.47.3




More information about the barebox mailing list