mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 03/12] ARM: i.MX8MP: Add common code to load image and jump to it via TF-A
Date: Thu, 14 Jul 2022 09:27:13 +0200	[thread overview]
Message-ID: <20220714072722.2863571-4-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20220714072722.2863571-1-s.hauer@pengutronix.de>

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@pengutronix.de>
---
 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




  parent reply	other threads:[~2022-07-14  7:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-14  7:27 [PATCH 00/12] imx-usb-loader support for i.MX8MP Sascha Hauer
2022-07-14  7:27 ` [PATCH 01/12] ARM: i.MX8MM: Prepare loading only piggydata in imx-usb-loader Sascha Hauer
2022-07-14  7:27 ` [PATCH 02/12] ARM: i.MX8M: Add romapi support Sascha Hauer
2022-07-14  7:27 ` Sascha Hauer [this message]
2022-07-14  7:27 ` [PATCH 04/12] ARM: i.MX8MP-EVK: Use imx8mp_load_and_start_image_via_tfa() Sascha Hauer
2022-07-14  7:27 ` [PATCH 05/12] imx-usb-loader: Factor out common code to function Sascha Hauer
2022-07-14  7:27 ` [PATCH 06/12] imx-usb-loader: rename mxs functions Sascha Hauer
2022-07-14  7:27 ` [PATCH 07/12] imx-usb-loader: Add i.MX8MP support Sascha Hauer
2022-07-29  9:33   ` Marco Felsch
2022-08-08 12:20     ` Sascha Hauer
2022-07-14  7:27 ` [PATCH 08/12] imx-usb-loader: drop some casting Sascha Hauer
2022-07-14  7:27 ` [PATCH 09/12] imx-usb-loader: Fix first stage length Sascha Hauer
2022-07-14  7:27 ` [PATCH 10/12] imx-usb-loader: simplify read_memory() Sascha Hauer
2022-07-14  7:27 ` [PATCH 11/12] imx-usb-loader: verify correct image length Sascha Hauer
2022-07-14  7:27 ` [PATCH 12/12] imx-usb-loader: drop some unnecessary casting 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=20220714072722.2863571-4-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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