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 diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
18 index 82a10ffa63..7b7579a2df 100644
19 --- a/common/spl/spl_nand.c
20 +++ b/common/spl/spl_nand.c
21 @@ -56,6 +56,21 @@ static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
22 return size / load->bl_len;
25 +static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs,
26 + ulong size, void *dst)
30 + debug("%s: offs %lx, size %lx, dst %p\n",
31 + __func__, offs, size, dst);
33 + err = nand_spl_load_image(offs, size, dst);
40 struct mtd_info * __weak nand_get_mtd(void)
43 @@ -93,6 +108,18 @@ static int spl_nand_load_element(struct spl_image_info *spl_image,
45 load.read = spl_nand_fit_read;
46 return spl_load_imx_container(spl_image, &load, offset / bl_len);
47 + } else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) &&
48 + image_get_magic(header) == IH_MAGIC) {
49 + struct spl_load_info load;
51 + debug("Found legacy image\n");
54 + load.filename = NULL;
56 + load.read = spl_nand_legacy_read;
58 + return spl_load_legacy_img(spl_image, bootdev, &load, offset);
60 err = spl_parse_image_header(spl_image, bootdev, header);