]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sunxi: SPL SPI: Allow larger SPL
authorAndre Przywara <andre.przywara@arm.com>
Mon, 5 Jul 2021 23:04:43 +0000 (00:04 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 25 Oct 2021 13:48:58 +0000 (14:48 +0100)
The more recent Allwinner SoCs BootROMs can actually load SPL images
larger than 32KB. We use this on the H616 to fit the extra code needed
for the PMIC into the image, and have provisions in board.c to respect
that larger SPL size when booting from MMC.

However the sunxi SPL SPI loader has a hardcoded load offset of 32KB,
which will fail on the H616.

To fix this, use the same algorithm we use for MMC: if the SPL size is
smaller than 32KB, we use 32KB, otherwise we expect the U-Boot payload
directly after the SPL code.

This prepares for SPI booting with larger SPLs like on the H616.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
arch/arm/mach-sunxi/spl_spi_sunxi.c

index 15e86cbac8f4ab88f71fca6c89feacdbe5b3451d..3499c4cc5f88c73aa0648a24333c2d8bf9c43589 100644 (file)
@@ -7,6 +7,7 @@
 #include <image.h>
 #include <log.h>
 #include <spl.h>
+#include <asm/arch/spl.h>
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <linux/bitops.h>
@@ -326,10 +327,13 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
        int ret = 0;
        struct image_header *header;
        header = (struct image_header *)(CONFIG_SYS_TEXT_BASE);
+       int load_offset = readl(SPL_ADDR + 0x10);
+
+       load_offset = max(load_offset, CONFIG_SYS_SPI_U_BOOT_OFFS);
 
        spi0_init();
 
-       spi0_read_data((void *)header, CONFIG_SYS_SPI_U_BOOT_OFFS, 0x40);
+       spi0_read_data((void *)header, load_offset, 0x40);
 
         if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) &&
                image_get_magic(header) == FDT_MAGIC) {
@@ -342,14 +346,14 @@ static int spl_spi_load_image(struct spl_image_info *spl_image,
                load.bl_len = 1;
                load.read = spi_load_read;
                ret = spl_load_simple_fit(spl_image, &load,
-                                         CONFIG_SYS_SPI_U_BOOT_OFFS, header);
+                                         load_offset, header);
        } else {
                ret = spl_parse_image_header(spl_image, header);
                if (ret)
                        return ret;
 
                spi0_read_data((void *)spl_image->load_addr,
-                              CONFIG_SYS_SPI_U_BOOT_OFFS, spl_image->size);
+                              load_offset, spl_image->size);
        }
 
        spi0_deinit();