[PATCH 2/2] ARM: i.MX: Add bootm handler for i.MX flash header v3 images

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds support for chainloading barebox images in the i.MX flash
header v3 format as found on i.MX9 and some i.MX8 SoCs,

Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---
 arch/arm/mach-imx/Makefile       |  2 +-
 arch/arm/mach-imx/imx-v3-image.c | 50 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile
index 22ea48a833..23f51fc660 100644
--- a/arch/arm/mach-imx/Makefile
+++ b/arch/arm/mach-imx/Makefile
@@ -19,7 +19,7 @@ obj-$(CONFIG_ARCH_IMX7) += imx7.o
 obj-$(CONFIG_ARCH_VF610) += vf610.o
 obj-pbl-$(CONFIG_ARCH_IMX8M) += imx8m.o
 obj-pbl-$(CONFIG_ARCH_IMX_SCRATCHMEM) += scratch.o
-obj-$(CONFIG_ARCH_IMX9) += imx9.o
+obj-$(CONFIG_ARCH_IMX9) += imx9.o imx-v3-image.o
 lwl-$(CONFIG_ARCH_IMX_ATF) += atf.o
 obj-pbl-$(CONFIG_ARCH_IMX8M) += tzasc.o
 obj-pbl-$(CONFIG_ARCH_IMX_ROMAPI) += romapi.o
diff --git a/arch/arm/mach-imx/imx-v3-image.c b/arch/arm/mach-imx/imx-v3-image.c
new file mode 100644
index 0000000000..e5df5fdb81
--- /dev/null
+++ b/arch/arm/mach-imx/imx-v3-image.c
@@ -0,0 +1,50 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <common.h>
+#include <bootm.h>
+#include <memory.h>
+#include <init.h>
+#include <soc/imx9/flash_header.h>
+
+static int do_bootm_imx_image_v3(struct image_data *data)
+{
+	void (*bb)(void);
+	resource_size_t start, end;
+	struct flash_header_v3 *hdr;
+	u32 offset;
+	int ret;
+
+	ret = memory_bank_first_find_space(&start, &end);
+	if (ret)
+		return ret;
+
+	ret = bootm_load_os(data, start);
+	if (ret)
+		return ret;
+
+	hdr = (void *)start;
+	offset = hdr->img[0].offset;
+
+	if (data->verbose)
+		printf("Loaded barebox image to 0x%08llx\n", start);
+
+	shutdown_barebox();
+
+	bb = (void *)start + offset;
+
+	bb();
+
+	return -EIO;
+}
+
+static struct image_handler imx_image_v3_handler = {
+	.name = "",
+	.bootm = do_bootm_imx_image_v3,
+	.filetype = filetype_imx_image_v3,
+};
+
+static int imx_register_image_v3_handler(void)
+{
+	return register_image_handler(&imx_image_v3_handler);
+}
+late_initcall(imx_register_image_v3_handler);

-- 
2.39.5





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux