[PATCH 1/2] ARM: i.MX8M: Add support for eCSPI boot

Jonas Rebmann jre at pengutronix.de
Tue Jun 10 08:30:55 PDT 2025


Load and boot barebox via eCSPI when started so via bootrom.

Only tested on i.MX8MP

Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
---
 arch/arm/mach-imx/atf.c       |  4 ++++
 arch/arm/mach-imx/xload-spi.c | 38 ++++++++++++++++++++++++++++++++++++++
 include/mach/imx/xload.h      |  1 +
 3 files changed, 43 insertions(+)

diff --git a/arch/arm/mach-imx/atf.c b/arch/arm/mach-imx/atf.c
index 6dc80cb70054eca2aa70b0cfc989baf2a5b75232..6993e33baa39c87afa15ee7302e574d096fde7a5 100644
--- a/arch/arm/mach-imx/atf.c
+++ b/arch/arm/mach-imx/atf.c
@@ -16,6 +16,7 @@
 #include <soc/fsl/caam.h>
 #include <tee/optee.h>
 #include <mach/imx/ele.h>
+#include <mach/imx/xload.h>
 
 /**
  * imx8m_atf_load_bl31 - Load ATF BL31 blob and transfer control to it
@@ -193,6 +194,9 @@ void imx8mp_load_bl33(void *bl33)
 	case BOOTSOURCE_SPI:
 		imx8mp_qspi_load_image(instance, bl33);
 		break;
+	case BOOTSOURCE_SPI_NOR:
+		imx8m_ecspi_load_image(instance, bl33);
+		break;
 	default:
 		printf("Unhandled bootsource BOOTSOURCE_%d\n", src);
 		hang();
diff --git a/arch/arm/mach-imx/xload-spi.c b/arch/arm/mach-imx/xload-spi.c
index 621e9557be0c54b24eb004deeea85fd5cb9434f4..0bdcce8659f744f54e88aa3a69e1d06f4ab95689 100644
--- a/arch/arm/mach-imx/xload-spi.c
+++ b/arch/arm/mach-imx/xload-spi.c
@@ -4,6 +4,7 @@
 #include <io.h>
 #include <spi/imx-spi.h>
 #include <mach/imx/imx6-regs.h>
+#include <mach/imx/imx8mq-regs.h>
 #include <mach/imx/generic.h>
 #include <bootsource.h>
 #include <asm/sections.h>
@@ -136,3 +137,40 @@ int imx6_spi_start_image(int instance)
 
 	bb();
 }
+
+/**
+ * imx8m_spi_load_image - load an image from SPI NOR
+ * @instance: The SPI controller instance (0..2)
+ * @bl33: The buffer to load the bl33 barebox image to
+ *
+ * This function loads data from SPI NOR flash. This assumes the
+ * SPI controller has already been initialized and the pinctrl / clocks are
+ * configured correctly. This is the case when the ROM has loaded the initial
+ * portion of the boot loader from exactly this controller.
+ *
+ * Return: 0 if successful, negative error code otherwise
+ */
+
+int imx8m_ecspi_load_image(int instance, void *bl33)
+{
+	void *base;
+
+	/* Base Adresses are the same for i.MX8M[QM] */
+	switch (instance) {
+	case 0:
+		base = IOMEM(MX8MQ_ECSPI1_BASE_ADDR);
+		break;
+	case 1:
+		base = IOMEM(MX8MQ_ECSPI2_BASE_ADDR);
+		break;
+	case 2:
+		base = IOMEM(MX8MQ_ECSPI3_BASE_ADDR);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	cspi_2_3_load(base, SZ_8K, bl33, imx_image_size());
+
+	return 0;
+}
diff --git a/include/mach/imx/xload.h b/include/mach/imx/xload.h
index 62b853f585e5a504a853d3da05deecaa1d7b04ad..396c728547614091fc710de50dc1583c6b6e2a68 100644
--- a/include/mach/imx/xload.h
+++ b/include/mach/imx/xload.h
@@ -16,6 +16,7 @@ int imx7_esdhc_start_image(int instance);
 int imx7_nand_start_image(void);
 
 /* Below functions only load and don't start the image */
+int imx8m_ecspi_load_image(int instance, void *bl33);
 int imx8m_esdhc_load_image(int instance, void *bl33);
 int imx8mn_esdhc_load_image(int instance, void *bl33);
 int imx8mp_esdhc_load_image(int instance, void *bl33);

-- 
2.39.5




More information about the barebox mailing list