This adds the update handler support to flash barebox flexspi compatible images to the QSPI. Signed-off-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx> --- 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