diff options
author | Tom Rini <trini@konsulko.com> | 2022-07-14 07:18:33 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-07-14 07:18:33 -0400 |
commit | 58f3dc5c4eac9c6050edda6af2e37d20a2f9586d (patch) | |
tree | 78f091f787b36104ea2e2e42fee9b335a7915daa /common/spl | |
parent | 854d6de6107bca044db362612f39691f4f5395ca (diff) | |
parent | dd6bf539e88aff1b8caeeccbe9af59b2191a178b (diff) | |
download | u-boot-58f3dc5c4eac9c6050edda6af2e37d20a2f9586d.zip u-boot-58f3dc5c4eac9c6050edda6af2e37d20a2f9586d.tar.gz u-boot-58f3dc5c4eac9c6050edda6af2e37d20a2f9586d.tar.bz2 |
Merge tag 'mips-pull-2022-07-13' of https://source.denx.de/u-boot/custodians/u-boot-mips
- MIPS: add drivers and board support for Mediatek MT7621 SoC
Diffstat (limited to 'common/spl')
-rw-r--r-- | common/spl/Kconfig | 2 | ||||
-rw-r--r-- | common/spl/spl_legacy.c | 21 | ||||
-rw-r--r-- | common/spl/spl_nand.c | 27 |
3 files changed, 47 insertions, 3 deletions
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 931619c..908d7d1 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -884,7 +884,7 @@ config SPL_NAND_SIMPLE expose the cmd_ctrl() interface. config SPL_NAND_BASE - depends on SPL_NAND_DRIVERS + depends on SPL_NAND_SUPPORT bool "Use Base NAND Driver" help Include nand_base.c in the SPL. diff --git a/common/spl/spl_legacy.c b/common/spl/spl_legacy.c index 2ec7154..ae8731c 100644 --- a/common/spl/spl_legacy.c +++ b/common/spl/spl_legacy.c @@ -88,15 +88,29 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, /* Read header into local struct */ load->read(load, header, sizeof(hdr), &hdr); + /* + * If the payload is compressed, the decompressed data should be + * directly write to its load address. + */ + if (spl_image_get_comp(&hdr) != IH_COMP_NONE) + spl_image->flags |= SPL_COPY_PAYLOAD_ONLY; + ret = spl_parse_image_header(spl_image, bootdev, &hdr); if (ret) return ret; - dataptr = header + sizeof(hdr); - /* Read image */ switch (spl_image_get_comp(&hdr)) { case IH_COMP_NONE: + dataptr = header; + + /* + * Image header will be skipped only if SPL_COPY_PAYLOAD_ONLY + * is set + */ + if (spl_image->flags & SPL_COPY_PAYLOAD_ONLY) + dataptr += sizeof(hdr); + load->read(load, dataptr, spl_image->size, (void *)(unsigned long)spl_image->load_addr); break; @@ -104,6 +118,9 @@ int spl_load_legacy_img(struct spl_image_info *spl_image, case IH_COMP_LZMA: lzma_len = LZMA_LEN; + /* dataptr points to compressed payload */ + dataptr = header + sizeof(hdr); + debug("LZMA: Decompressing %08lx to %08lx\n", dataptr, spl_image->load_addr); src = malloc(spl_image->size); diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c index 82a10ff..7b7579a 100644 --- a/common/spl/spl_nand.c +++ b/common/spl/spl_nand.c @@ -56,6 +56,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; @@ -93,6 +108,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) |