[PATCH 2/4] ARM: i.MX93: add destination argument to imx93_romapi_load_image()

Sascha Hauer s.hauer at pengutronix.de
Wed Oct 30 04:30:37 PDT 2024


Pass the destination address to imx93_romapi_load_image() rather
than hardcoding the destination to MX93_ATF_BL33_BASE_ADDR.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/boards/tqma93xx/lowlevel.c |  1 -
 arch/arm/mach-imx/atf.c             |  2 ++
 arch/arm/mach-imx/romapi.c          | 11 +++++------
 include/mach/imx/romapi.h           |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/arm/boards/tqma93xx/lowlevel.c b/arch/arm/boards/tqma93xx/lowlevel.c
index 14733d52a3..cc5101a1a3 100644
--- a/arch/arm/boards/tqma93xx/lowlevel.c
+++ b/arch/arm/boards/tqma93xx/lowlevel.c
@@ -81,7 +81,6 @@ static noinline void tqma93xx_continue(void)
 			break;
 		}
 
-		imx93_romapi_load_image();
 		imx93_load_and_start_image_via_tfa();
 	}
 
diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index 8b80460268..f4ba07bf06 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -395,6 +395,8 @@ void __noreturn imx93_load_and_start_image_via_tfa(void)
 	imx_set_cpu_type(IMX_CPU_IMX93);
 	imx93_init_scratch_space(true);
 
+	imx93_romapi_load_image(bl33);
+
 	/*
 	 * On completion the TF-A will jump to MX93_ATF_BL33_BASE_ADDR
 	 * in EL2. Copy the image there, but replace the PBL part of
diff --git a/arch/arm/mach-imx/romapi.c b/arch/arm/mach-imx/romapi.c
index 0f1555abad..155e706437 100644
--- a/arch/arm/mach-imx/romapi.c
+++ b/arch/arm/mach-imx/romapi.c
@@ -173,13 +173,12 @@ static int imx_romapi_boot_device_seekable(struct rom_api *rom_api)
 	return seekable;
 }
 
-int imx93_romapi_load_image(void)
+int imx93_romapi_load_image(void *adr)
 {
 	struct rom_api *rom_api = (void *)0x1980;
 	int ret;
 	int seekable;
 	uint32_t offset, image_offset;
-	void *bl33 = (void *)MX93_ATF_BL33_BASE_ADDR;
 	struct flash_header_v3 *fh;
 
 	OPTIMIZER_HIDE_VAR(rom_api);
@@ -190,7 +189,7 @@ int imx93_romapi_load_image(void)
 
 	if (!seekable) {
 		int align_size = ALIGN(barebox_pbl_size, 1024) - barebox_pbl_size;
-		void *pbl_size_aligned = bl33 + ALIGN(barebox_pbl_size, 1024);
+		void *pbl_size_aligned = adr + ALIGN(barebox_pbl_size, 1024);
 
 		/*
 		 * The USB protocol uploads in chunks of 1024 bytes. This means
@@ -209,11 +208,11 @@ int imx93_romapi_load_image(void)
 
 	pr_debug("%s: IVT offset on boot device: 0x%08x\n", __func__, offset);
 
-	ret = imx_romapi_load_seekable(rom_api, bl33, offset, 4096);
+	ret = imx_romapi_load_seekable(rom_api, adr, offset, 4096);
 	if (ret)
 		return ret;
 
-	fh = bl33;
+	fh = adr;
 
 	if (fh->tag != 0x87) {
 		pr_err("Invalid IVT header: 0x%02x, expected 0x87\n", fh->tag);
@@ -228,7 +227,7 @@ int imx93_romapi_load_image(void)
 	 * We assume the first image in the first container is the barebox image,
 	 * which is what the imx9image call in images/Makefile.imx generates.
 	 */
-	ret = imx_romapi_load_seekable(rom_api, bl33, offset + image_offset, barebox_image_size);
+	ret = imx_romapi_load_seekable(rom_api, adr, offset + image_offset, barebox_image_size);
 	if (ret)
 		return ret;
 
diff --git a/include/mach/imx/romapi.h b/include/mach/imx/romapi.h
index e26b98097d..9967a2a4c3 100644
--- a/include/mach/imx/romapi.h
+++ b/include/mach/imx/romapi.h
@@ -38,7 +38,7 @@ enum boot_dev_type_e {
 /* Below functions only load and don't start the image */
 int imx8mp_romapi_load_image(void *bl33);
 int imx8mn_romapi_load_image(void *bl33);
-int imx93_romapi_load_image(void);
+int imx93_romapi_load_image(void *adr);
 
 /* only call after DRAM has been configured */
 void imx8m_save_bootrom_log(void);

-- 
2.39.5




More information about the barebox mailing list