diff mbox series

[v5,23/25] spl: nand: support loading legacy image with payload compressed

Message ID bb225396a3d492ac065ec97eca1f6c724bf739e4.1652667687.git.weijie.gao@mediatek.com
State Superseded
Delegated to: Daniel Schwierzeck
Headers show
Series Add support for MediaTek MT7621 SoC - v5 | expand

Commit Message

Weijie Gao (高惟杰) May 16, 2022, 2:44 a.m. UTC
Add support to load legacy image with payload compressed. This redirects
the boot flow for all legacy images. If the payload is not compresses, the
actual behavior will remain unchanged.

Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
---
v5 changes: none
v4 changes: new
---
 common/spl/spl_nand.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

Comments

Daniel Schwierzeck May 17, 2022, 10:02 p.m. UTC | #1
On 16.05.22 04:44, Weijie Gao wrote:
> Add support to load legacy image with payload compressed. This redirects
> the boot flow for all legacy images. If the payload is not compresses, the

s/compresses/compressed/

> actual behavior will remain unchanged.
> 
> Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> ---
> v5 changes: none
> v4 changes: new
> ---
>   common/spl/spl_nand.c | 27 +++++++++++++++++++++++++++
>   1 file changed, 27 insertions(+)
> 

Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Weijie Gao (高惟杰) May 18, 2022, 2:01 a.m. UTC | #2
On Wed, 2022-05-18 at 00:02 +0200, Daniel Schwierzeck wrote:
> 
> On 16.05.22 04:44, Weijie Gao wrote:
> > Add support to load legacy image with payload compressed. This
> > redirects
> > the boot flow for all legacy images. If the payload is not
> > compresses, the
> 
> s/compresses/compressed/

I'll correct this in next patch series.

> 
> > actual behavior will remain unchanged.
> > 
> > Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
> > ---
> > v5 changes: none
> > v4 changes: new
> > ---
> >   common/spl/spl_nand.c | 27 +++++++++++++++++++++++++++
> >   1 file changed, 27 insertions(+)
> > 
> 
> Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
>
diff mbox series

Patch

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index fc61b447a5..3f3007a35d 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -59,6 +59,21 @@  static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
 	return size / load->bl_len;
 }
 
+static ulong spl_nand_legacy_read(struct spl_load_info *load, ulong offs,
+				  ulong size, void *dst)
+{
+	int err;
+
+	debug("%s: offs %lx, size %lx, dst %p\n",
+	      __func__, offs, size, dst);
+
+	err = nand_spl_load_image(offs, size, dst);
+	if (err)
+		return 0;
+
+	return size;
+}
+
 struct mtd_info * __weak nand_get_mtd(void)
 {
 	return NULL;
@@ -96,6 +111,18 @@  static int spl_nand_load_element(struct spl_image_info *spl_image,
 		load.bl_len = bl_len;
 		load.read = spl_nand_fit_read;
 		return spl_load_imx_container(spl_image, &load, offset / bl_len);
+	} else if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_FORMAT) &&
+		   image_get_magic(header) == IH_MAGIC) {
+		struct spl_load_info load;
+
+		debug("Found legacy image\n");
+		load.dev = NULL;
+		load.priv = NULL;
+		load.filename = NULL;
+		load.bl_len = 1;
+		load.read = spl_nand_legacy_read;
+
+		return spl_load_legacy_img(spl_image, bootdev, &load, offset);
 	} else {
 		err = spl_parse_image_header(spl_image, bootdev, header);
 		if (err)