From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH v2 08/23] ARM: i.MX8M: Add QSPI image load support
Date: Mon, 13 Mar 2023 14:41:47 +0100 [thread overview]
Message-ID: <20230228-v2023-02-0-topic-flexspi-v2-8-3d33126d2434@pengutronix.de> (raw)
In-Reply-To: <20230228-v2023-02-0-topic-flexspi-v2-0-3d33126d2434@pengutronix.de>
This adds the helper function which can be used to load images from the
QSPI flash.
Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
arch/arm/mach-imx/Makefile | 1 +
arch/arm/mach-imx/xload-qspi.c | 57 ++++++++++++++++++++++++++++++++++++++++++
include/mach/imx/xload.h | 3 +++
3 files changed, 61 insertions(+)
diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 5d70e79b57..f49bbea2b4 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -31,3 +31,4 @@ obj-$(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND) += imx-bbu-external-nand.o
obj-$(CONFIG_RESET_IMX_SRC) += src.o
lwl-y += cpu_init.o
pbl-y += xload-spi.o xload-common.o xload-imx-nand.o xload-gpmi-nand.o
+pbl-y += xload-qspi.o
diff --git a/arch/arm/mach-imx/xload-qspi.c b/arch/arm/mach-imx/xload-qspi.c
new file mode 100644
index 0000000000..6bf5bba5e6
--- /dev/null
+++ b/arch/arm/mach-imx/xload-qspi.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <common.h>
+#include <linux/sizes.h>
+#include <mach/imx/atf.h>
+#include <mach/imx/imx8m-regs.h>
+#include <mach/imx/xload.h>
+
+#define IMX8M_QSPI_MMAP 0x8000000
+
+/* Make use of AHB reads */
+static
+int imx8m_qspi_read(void *dest, size_t len, void *priv)
+{
+ void __iomem *qspi_ahb = priv;
+
+ memcpy(dest, qspi_ahb, len);
+
+ return 0;
+}
+
+/**
+ * imx8mm_qspi_start_image - Load and optionally start an image from the
+ * FlexSPI controller.
+ * @instance: The FlexSPI controller instance
+ * @start: Whether to directly start the loaded image
+ *
+ * This uses imx8m_qspi_load_image() to load an image from QSPI. It is assumed
+ * that the image is the currently running barebox image (This information
+ * is used to calculate the length of the image).
+ * The image is started afterwards.
+ *
+ * Return: If successful, this function does not return (if directly started)
+ * or 0. A negative error code is returned when this function fails.
+ */
+static
+int imx8m_qspi_load_image(int instance, bool start, off_t offset, off_t ivt_offset)
+{
+ void __iomem *qspi_ahb = IOMEM(IMX8M_QSPI_MMAP);
+
+ return imx_load_image(MX8M_DDR_CSD1_BASE_ADDR, MX8M_ATF_BL33_BASE_ADDR,
+ offset, ivt_offset, start, 0,
+ imx8m_qspi_read, qspi_ahb);
+}
+
+int imx8mm_qspi_load_image(int instance, bool start)
+{
+ return imx8m_qspi_load_image(instance, start, 0, SZ_4K);
+}
+
+int imx8mn_qspi_load_image(int instance, bool start)
+{
+ return imx8m_qspi_load_image(instance, start, SZ_4K, 0);
+}
+
+int imx8mp_qspi_load_image(int instance, bool start)
+ __alias(imx8mn_qspi_load_image);
diff --git a/include/mach/imx/xload.h b/include/mach/imx/xload.h
index e9d41adc97..790887c956 100644
--- a/include/mach/imx/xload.h
+++ b/include/mach/imx/xload.h
@@ -16,6 +16,9 @@ int imx7_nand_start_image(void);
int imx8m_esdhc_load_image(int instance, bool start);
int imx8mn_esdhc_load_image(int instance, bool start);
int imx8mp_esdhc_load_image(int instance, bool start);
+int imx8mm_qspi_load_image(int instance, bool start);
+int imx8mn_qspi_load_image(int instance, bool start);
+int imx8mp_qspi_load_image(int instance, bool start);
void imx8mm_load_bl33(void *bl33);
void imx8mn_load_bl33(void *bl33);
--
2.30.2
next prev parent reply other threads:[~2023-03-13 13:43 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-13 13:41 [PATCH v2 00/23] FlexSPI image/boot/update support Marco Felsch
2023-03-13 13:41 ` [PATCH v2 01/23] spi: remove flash_platform_data support Marco Felsch
2023-03-13 13:41 ` [PATCH v2 02/23] bbu: make it possible to check multiple of-compatibles Marco Felsch
2023-04-04 7:04 ` Sascha Hauer
2023-04-04 8:01 ` Marco Felsch
2023-04-04 8:49 ` Sascha Hauer
2023-04-04 9:05 ` Marco Felsch
2023-03-13 13:41 ` [PATCH v2 03/23] ARM: i.MX8MM: add missing IMD_USED_OF image metadata entry Marco Felsch
2023-03-13 13:41 ` [PATCH v2 04/23] ARM: i.MX8MN: add missing IMD_USED_OF image metadata entries Marco Felsch
2023-03-13 13:41 ` [PATCH v2 05/23] mci: imx-esdhc-pbl: fix number of read blocks Marco Felsch
2023-03-13 13:41 ` [PATCH v2 06/23] mci: imx-esdhc-pbl: refactor the esdhc_load_image function Marco Felsch
2023-03-13 13:41 ` [PATCH v2 07/23] mci: imx-esdhc-pbl: move imx_load_image into common xload code Marco Felsch
2023-03-13 13:41 ` Marco Felsch [this message]
2023-03-13 13:41 ` [PATCH v2 09/23] ARM: i.MX bootsource: set QSPI instance Marco Felsch
2023-03-13 13:41 ` [PATCH v2 10/23] ARM: i.MX8MM bootsource: fix QSPI boot source detection Marco Felsch
2023-03-13 13:41 ` [PATCH v2 11/23] ARM: i.MX8M: Add QSPI boot support Marco Felsch
2023-03-13 13:41 ` [PATCH v2 12/23] scripts: imx-image: convert flag variables into bool Marco Felsch
2023-03-13 13:41 ` [PATCH v2 13/23] scripts: imx-image: header_v2: factor out offset parameter Marco Felsch
2023-03-13 13:41 ` [PATCH v2 14/23] scripts: imx-image: header_v2: add header_len parameter Marco Felsch
2023-03-13 13:41 ` [PATCH v2 15/23] scripts: imx-image: add FlexSPI image support Marco Felsch
2023-03-13 13:41 ` [PATCH v2 16/23] filetype: add NXP FlexSPI filetype Marco Felsch
2023-03-13 13:41 ` [PATCH v2 17/23] ARM: i.MX: bbu: rename IMX_INTERNAL_FLAG_ERASE to IMX_BBU_FLAG_ERASE Marco Felsch
2023-03-13 13:41 ` [PATCH v2 18/23] ARM: i.MX: bbu: add filetype offset Marco Felsch
2023-03-13 13:41 ` [PATCH v2 19/23] ARM: i.MX: bbu: add FlexSPI update handler Marco Felsch
2023-03-13 13:41 ` [PATCH v2 20/23] ARM: i.MX8M: enable FlexSPI image support Marco Felsch
2023-03-13 13:42 ` [PATCH v2 21/23] ARM: i.MX8M: add qspi barebox and barebox-environment partitions Marco Felsch
2023-03-13 13:42 ` [PATCH v2 22/23] ARM: i.MX8M: add QSPI update handler Marco Felsch
2023-03-13 13:42 ` [PATCH v2 23/23] Documentation: i.MX8M: add EVK QSPI NOR barebox installation documentation Marco Felsch
2023-03-17 11:11 ` [PATCH v2 00/23] FlexSPI image/boot/update support 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=20230228-v2023-02-0-topic-flexspi-v2-8-3d33126d2434@pengutronix.de \
--to=m.felsch@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