From: Jonas Rebmann <jre@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Jonas Rebmann <jre@pengutronix.de>
Subject: [PATCH 1/2] ARM: i.MX8M: Add support for eCSPI boot
Date: Tue, 10 Jun 2025 17:30:55 +0200 [thread overview]
Message-ID: <20250610-imx8mp_ecspi-v1-1-d14d1e9d65f3@pengutronix.de> (raw)
In-Reply-To: <20250610-imx8mp_ecspi-v1-0-d14d1e9d65f3@pengutronix.de>
Load and boot barebox via eCSPI when started so via bootrom.
Only tested on i.MX8MP
Signed-off-by: Jonas Rebmann <jre@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
next prev parent reply other threads:[~2025-06-10 18:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 15:30 [PATCH 0/2] Add support for eCSPI boot on i.MX8M Jonas Rebmann
2025-06-10 15:30 ` Jonas Rebmann [this message]
2025-06-11 8:13 ` [PATCH 1/2] ARM: i.MX8M: Add support for eCSPI boot Ahmad Fatoum
2025-06-10 15:30 ` [PATCH 2/2] ARM: i.MX8M: Add bbu " Jonas Rebmann
2025-06-11 7:04 ` [PATCH 0/2] Add support for eCSPI boot on i.MX8M 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=20250610-imx8mp_ecspi-v1-1-d14d1e9d65f3@pengutronix.de \
--to=jre@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/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