[PATCH 2/9] ARM: i.MX8M: imx8mn-evk: use generic imx8mn_load_and_start_image_via_tfa
Ahmad Fatoum
a.fatoum at pengutronix.de
Fri Aug 5 05:54:06 PDT 2022
Like already done for i.MX8MM and i.MX8MP, we can considerably reduce
i.MX8MN board code duplication by moving the TF-A loading and jumping
code into common helpers.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/arm/boards/nxp-imx8mn-evk/lowlevel.c | 31 +------------------
arch/arm/mach-imx/atf.c | 36 +++++++++++++++++++++++
arch/arm/mach-imx/include/mach/xload.h | 1 +
3 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/arch/arm/boards/nxp-imx8mn-evk/lowlevel.c b/arch/arm/boards/nxp-imx8mn-evk/lowlevel.c
index 9e44d343b7ed..ddc6e4fd2b29 100644
--- a/arch/arm/boards/nxp-imx8mn-evk/lowlevel.c
+++ b/arch/arm/boards/nxp-imx8mn-evk/lowlevel.c
@@ -132,11 +132,7 @@ extern struct dram_timing_info imx8mn_evk_ddr4_timing, imx8mn_evk_lpddr4_timing;
static void start_atf(void)
{
struct dram_timing_info *dram_timing = &imx8mn_evk_lpddr4_timing;
- size_t bl31_size;
- const u8 *bl31;
- enum bootsource src;
void *i2c;
- int instance;
int ret;
/*
@@ -163,32 +159,7 @@ static void start_atf(void)
imx8mn_ddr_init(dram_timing, dram_timing->dram_type);
- imx8mn_get_boot_source(&src, &instance);
- switch (src) {
- case BOOTSOURCE_MMC:
- imx8mn_esdhc_load_image(instance, false);
- break;
- default:
- printf("Unhandled bootsource BOOTSOURCE_%d\n", src);
- hang();
- }
-
- /*
- * On completion the TF-A will jump to MX8M_ATF_BL33_BASE_ADDR
- * in EL2. Copy the image there, but replace the PBL part of
- * that image with ourselves. On a high assurance boot only the
- * currently running code is validated and contains the checksum
- * for the piggy data, so we need to ensure that we are running
- * the same code in DRAM.
- */
- memcpy((void *)MX8M_ATF_BL33_BASE_ADDR,
- __image_start, barebox_pbl_size);
-
- get_builtin_firmware(imx8mn_bl31_bin, &bl31, &bl31_size);
-
- imx8mn_atf_load_bl31(bl31, bl31_size);
-
- /* not reached */
+ imx8mn_load_and_start_image_via_tfa();
}
/*
diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index 8fc523d3de61..bb9e04c9746b 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -168,3 +168,39 @@ void imx8mp_load_and_start_image_via_tfa(void)
/* not reached */
}
+
+void imx8mn_load_and_start_image_via_tfa(void)
+{
+ size_t bl31_size;
+ const u8 *bl31;
+ enum bootsource src;
+ int instance;
+
+ imx8mn_get_boot_source(&src, &instance);
+ switch (src) {
+ case BOOTSOURCE_MMC:
+ imx8mn_esdhc_load_image(instance, false);
+ break;
+ default:
+ printf("Unhandled bootsource BOOTSOURCE_%d\n", src);
+ hang();
+ }
+
+
+ /*
+ * On completion the TF-A will jump to MX8M_ATF_BL33_BASE_ADDR
+ * in EL2. Copy the image there, but replace the PBL part of
+ * that image with ourselves. On a high assurance boot only the
+ * currently running code is validated and contains the checksum
+ * for the piggy data, so we need to ensure that we are running
+ * the same code in DRAM.
+ */
+ memcpy((void *)MX8M_ATF_BL33_BASE_ADDR,
+ __image_start, barebox_pbl_size);
+
+ get_builtin_firmware(imx8mn_bl31_bin, &bl31, &bl31_size);
+
+ imx8mn_atf_load_bl31(bl31, bl31_size);
+
+ /* not reached */
+}
diff --git a/arch/arm/mach-imx/include/mach/xload.h b/arch/arm/mach-imx/include/mach/xload.h
index cfc52a94879d..3090c9c83bd7 100644
--- a/arch/arm/mach-imx/include/mach/xload.h
+++ b/arch/arm/mach-imx/include/mach/xload.h
@@ -14,6 +14,7 @@ int imx8mn_esdhc_load_image(int instance, bool start);
int imx8mp_esdhc_load_image(int instance, bool start);
void imx8mm_load_and_start_image_via_tfa(void);
+void imx8mn_load_and_start_image_via_tfa(void);
void imx8mp_load_and_start_image_via_tfa(void);
int imx_image_size(void);
--
2.30.2
More information about the barebox
mailing list