1 From b4e5137067d34a099efd921532ece177560789ca Mon Sep 17 00:00:00 2001
2 From: Weijie Gao <weijie.gao@mediatek.com>
3 Date: Fri, 20 May 2022 11:24:04 +0800
4 Subject: [PATCH 23/25] spl: nand: support loading legacy image with payload
7 Add support to load legacy image with payload compressed. This redirects
8 the boot flow for all legacy images. If the payload is not compressed, the
9 actual behavior will remain unchanged.
11 Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
12 Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
14 common/spl/spl_nand.c | 27 +++++++++++++++++++++++++++
15 1 file changed, 27 insertions(+)
17 --- a/common/spl/spl_nand.c
18 +++ b/common/spl/spl_nand.c
19 @@ -56,6 +56,21 @@ static ulong spl_nand_fit_read(struct sp
20 return size / load->bl_len;
23 +static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs,
24 + ulong size, void *dst)
28 + debug("%s: offs %lx, size %lx, dst %p\n",
29 + __func__, offs, size, dst);
31 + err = nand_spl_load_image(offs, size, dst);
38 struct mtd_info * __weak nand_get_mtd(void)
41 @@ -93,6 +108,18 @@ static int spl_nand_load_element(struct
43 load.read = spl_nand_fit_read;
44 return spl_load_imx_container(spl_image, &load, offset / bl_len);
45 + } else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) &&
46 + image_get_magic(header) == IH_MAGIC) {
47 + struct spl_load_info load;
49 + debug("Found legacy image\n");
52 + load.filename = NULL;
54 + load.read = spl_nand_legacy_read;
56 + return spl_load_legacy_img(spl_image, bootdev, &load, offset);
58 err = spl_parse_image_header(spl_image, bootdev, header);