mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 18/21] ARM: i.MX: bbu: add FlexSPI update handler
Date: Thu, 09 Mar 2023 11:40:50 +0100	[thread overview]
Message-ID: <20230228-v2023-02-0-topic-flexspi-v1-18-7b3c3fa295f5@pengutronix.de> (raw)
In-Reply-To: <20230228-v2023-02-0-topic-flexspi-v1-0-7b3c3fa295f5@pengutronix.de>

This adds the update handler support to flash barebox flexspi compatible
images to the QSPI.

Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
---
 arch/arm/mach-imx/imx-bbu-internal.c | 40 ++++++++++++++++++++++++++++++++++++
 include/mach/imx/bbu.h               | 11 ++++++++++
 2 files changed, 51 insertions(+)

diff --git a/arch/arm/mach-imx/imx-bbu-internal.c b/arch/arm/mach-imx/imx-bbu-internal.c
index 066b7c0002..cd7db81cc9 100644
--- a/arch/arm/mach-imx/imx-bbu-internal.c
+++ b/arch/arm/mach-imx/imx-bbu-internal.c
@@ -19,6 +19,7 @@
 #include <environment.h>
 #include <mach/imx/bbu.h>
 #include <mach/imx/generic.h>
+#include <mach/imx/imx-header.h>
 #include <libfile.h>
 
 struct imx_internal_bbu_handler {
@@ -654,3 +655,42 @@ int imx_bbu_external_nor_register_handler(const char *name,
 
 	return __register_handler(imx_handler);
 }
+
+static unsigned long imx_bbu_flash_header_offset_flexspi(void)
+{
+	unsigned int sd_flash_header_gap = SZ_32K;
+
+	if (cpu_is_mx8mm())
+		return sd_flash_header_gap;
+
+	return sd_flash_header_gap + SZ_1K;
+}
+
+static unsigned long imx_bbu_device_offset_flexspi(void)
+{
+	if (cpu_is_mx8mm())
+		return 0;
+
+	return 0x400;
+}
+
+static int
+imx_bbu_internal_flexspi_nor_register_handler(const char *name,
+					      const char *devicefile,
+					      unsigned long flags)
+{
+	struct imx_internal_bbu_handler *imx_handler;
+
+	flags |= IMX_BBU_FLAG_ERASE | IMX_BBU_FLAG_PARTITION_STARTS_AT_HEADER;
+	imx_handler = __init_handler(name, devicefile, flags);
+	imx_handler->target_device_offset = imx_bbu_device_offset_flexspi();
+	imx_handler->flash_header_offset = imx_bbu_flash_header_offset_flexspi();
+	imx_handler->expected_type = filetype_nxp_fspi_image;
+
+	return __register_handler(imx_handler);
+}
+
+int imx8m_bbu_internal_flexspi_nor_register_handler(const char *name,
+						    const char *devicefile,
+						    unsigned long flags)
+	__alias(imx_bbu_internal_flexspi_nor_register_handler);
diff --git a/include/mach/imx/bbu.h b/include/mach/imx/bbu.h
index 34133b587c..451ae15740 100644
--- a/include/mach/imx/bbu.h
+++ b/include/mach/imx/bbu.h
@@ -86,6 +86,10 @@ int imx8m_bbu_internal_mmcboot_register_handler(const char *name, const char *de
 int imx_bbu_external_nor_register_handler(const char *name, const char *devicefile,
 		unsigned long flags);
 
+int imx8m_bbu_internal_flexspi_nor_register_handler(const char *name,
+						    const char *devicefile,
+						    unsigned long flags);
+
 #else
 
 static inline int imx51_bbu_internal_mmc_register_handler(const char *name, const char *devicefile,
@@ -198,6 +202,13 @@ imx7_bbu_internal_spi_i2c_register_handler(const char *name, char *devicefile,
 	return -ENOSYS;
 }
 
+static inline int
+imx8m_bbu_internal_flexspi_nor_register_handler(const char *name, const char *devicefile,
+						unsigned long flags);
+{
+	return -ENOSYS;
+}
+
 #endif
 
 #if defined(CONFIG_BAREBOX_UPDATE_IMX_EXTERNAL_NAND)

-- 
2.30.2




  parent reply	other threads:[~2023-03-09 10:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09 10:40 [PATCH 00/21] FlexSPI image/boot/update support Marco Felsch
2023-03-09 10:40 ` [PATCH 01/21] spi: remove flash_platform_data support Marco Felsch
2023-03-09 10:40 ` [PATCH 02/21] bbu: make it possible to check multiple of-compatibles Marco Felsch
2023-03-09 10:40 ` [PATCH 03/21] ARM: i.MX8MM: add missing IMD_USED_OF image metadata entry Marco Felsch
2023-03-09 10:40 ` [PATCH 04/21] ARM: i.MX8MN: add missing IMD_USED_OF image metadata entries Marco Felsch
2023-03-09 10:40 ` [PATCH 05/21] mci: imx-esdhc-pbl: fix number of read blocks Marco Felsch
2023-03-09 10:40 ` [PATCH 06/21] mci: imx-esdhc-pbl: refactor the esdhc_load_image function Marco Felsch
2023-03-09 10:40 ` [PATCH 07/21] mci: imx-esdhc-pbl: move imx_load_image into common xload code Marco Felsch
2023-03-09 10:40 ` [PATCH 08/21] ARM: i.MX8M: Add QSPI image load support Marco Felsch
2023-03-09 10:40 ` [PATCH 09/21] ARM: i.MX8MM bootsource: fix QSPI boot source detection Marco Felsch
2023-03-09 10:40 ` [PATCH 10/21] ARM: i.MX8M: Add QSPI boot support Marco Felsch
2023-03-09 10:40 ` [PATCH 11/21] scripts: imx-image: convert flag variables into bool Marco Felsch
2023-03-09 10:40 ` [PATCH 12/21] scripts: imx-image: header_v2: factor out offset parameter Marco Felsch
2023-03-09 10:40 ` [PATCH 13/21] scripts: imx-image: header_v2: add header_len parameter Marco Felsch
2023-03-09 10:40 ` [PATCH 14/21] scripts: imx-image: add FlexSPI image support Marco Felsch
2023-03-09 10:40 ` [PATCH 15/21] filetype: add NXP FlexSPI filetype Marco Felsch
2023-03-09 10:40 ` [PATCH 16/21] ARM: i.MX: bbu: rename IMX_INTERNAL_FLAG_ERASE to IMX_BBU_FLAG_ERASE Marco Felsch
2023-03-09 10:40 ` [PATCH 17/21] ARM: i.MX: bbu: add target device offset Marco Felsch
2023-03-09 10:40 ` Marco Felsch [this message]
2023-03-09 10:40 ` [PATCH 19/21] ARM: i.MX8M: enable FlexSPI image support Marco Felsch
2023-03-09 10:40 ` [PATCH 20/21] ARM: i.MX8M: add qspi barebox and barebox-environment partitions Marco Felsch
2023-03-09 10:40 ` [PATCH 21/21] ARM: i.MX8M: add QSPI update handler Marco Felsch
2023-03-09 11:28 ` [PATCH 00/21] FlexSPI image/boot/update support Ahmad Fatoum
2023-03-09 11:41   ` Marco Felsch

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-v1-18-7b3c3fa295f5@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