[PATCH 03/12] ARM: i.MX8MP: Add common code to load image and jump to it via TF-A

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add imx8mp_load_and_start_image_via_tfa() to load barebox proper image
and jump to it via TF-A.

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/mach-imx/atf.c | 40 ++++++++++++++++++++++++++++++++++++++++
 include/soc/imx8m.h     |  1 +
 2 files changed, 41 insertions(+)

diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index ad3800519f..d9aaee1bc6 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -6,6 +6,7 @@
 #include <mach/atf.h>
 #include <mach/generic.h>
 #include <mach/xload.h>
+#include <mach/romapi.h>
 #include <soc/imx8m.h>
 #include <soc/fsl/fsl_udc.h>
 
@@ -129,3 +130,42 @@ void imx8mm_load_and_start_image_via_tfa(void)
 
 	/* not reached */
 }
+
+void imx8mp_load_and_start_image_via_tfa(void)
+{
+	size_t bl31_size;
+	const u8 *bl31;
+	enum bootsource src;
+	int instance;
+
+	imx8mp_get_boot_source(&src, &instance);
+	switch (src) {
+	case BOOTSOURCE_MMC:
+		imx8mp_esdhc_load_image(instance, false);
+		break;
+	case BOOTSOURCE_SERIAL:
+		imx8mp_bootrom_load_image();
+		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(imx8mp_bl31_bin, &bl31, &bl31_size);
+
+	imx8mp_atf_load_bl31(bl31, bl31_size);
+
+	/* not reached */
+}
diff --git a/include/soc/imx8m.h b/include/soc/imx8m.h
index 03b9b59b0b..15f7a4c2c0 100644
--- a/include/soc/imx8m.h
+++ b/include/soc/imx8m.h
@@ -4,5 +4,6 @@
 #define __MACH_IMX8M_H__
 
 void imx8mm_load_and_start_image_via_tfa(void);
+void imx8mp_load_and_start_image_via_tfa(void);
 
 #endif
-- 
2.30.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux