
Instead of trying to boot from SPI NAND then SPI NOR in series, select one based on the current boot device.
Signed-off-by: John Watts contact@jookia.org --- arch/arm/include/asm/arch-sunxi/spl.h | 1 + arch/arm/mach-sunxi/board.c | 5 ++++- arch/arm/mach-sunxi/spl_spi_sunxi.c | 28 ++++++++++++++++++---------- 3 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h index 92be936d56..a9b7c0daca 100644 --- a/arch/arm/include/asm/arch-sunxi/spl.h +++ b/arch/arm/include/asm/arch-sunxi/spl.h @@ -16,6 +16,7 @@ #define SUNXI_BOOTED_FROM_NAND 1 #define SUNXI_BOOTED_FROM_MMC2 2 #define SUNXI_BOOTED_FROM_SPI 3 +#define SUNXI_BOOTED_FROM_SPINAND 4
/* * Values taken from the F1C200s BootROM stack diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c index 7f4ee92991..e374b75ac2 100644 --- a/arch/arm/mach-sunxi/board.c +++ b/arch/arm/mach-sunxi/board.c @@ -222,11 +222,12 @@ static int suniv_get_boot_source(void) switch (brom_call) { case SUNIV_BOOTED_FROM_MMC0: return SUNXI_BOOTED_FROM_MMC0; - case SUNIV_BOOTED_FROM_SPI: case SUNIV_BOOTED_FROM_NAND: return SUNXI_BOOTED_FROM_SPI; case SUNIV_BOOTED_FROM_MMC1: return SUNXI_BOOTED_FROM_MMC2; + case SUNIV_BOOTED_FROM_SPI: + return SUNXI_BOOTED_FROM_SPINAND; } /* If we get here something went wrong try to boot from FEL.*/ printf("Unknown boot source from BROM: 0x%x\n", brom_call); @@ -306,6 +307,8 @@ uint32_t sunxi_get_boot_device(void) return BOOT_DEVICE_MMC2; case SUNXI_BOOTED_FROM_SPI: return BOOT_DEVICE_SPI; + case SUNXI_BOOTED_FROM_SPINAND: + return BOOT_DEVICE_SPINAND; }
panic("Unknown boot source %d\n", boot_source); diff --git a/arch/arm/mach-sunxi/spl_spi_sunxi.c b/arch/arm/mach-sunxi/spl_spi_sunxi.c index 7ecde2b753..46db2900ca 100644 --- a/arch/arm/mach-sunxi/spl_spi_sunxi.c +++ b/arch/arm/mach-sunxi/spl_spi_sunxi.c @@ -494,28 +494,36 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, int ret = 0; uint32_t load_offset = sunxi_get_spl_size(); struct spl_load_info load; + bool allow_raw = false;
load_offset = max_t(uint32_t, load_offset, CONFIG_SYS_SPI_U_BOOT_OFFS);
spi0_init();
+ switch (bootdev->boot_device) { #if defined(CONFIG_SPL_SPI_SUNXI_NAND) - spi0_nand_reset(); - load.read = spi_load_read_nand; - spl_set_bl_len(&load, 1); - ret = spl_spi_try_load(spl_image, bootdev, &load, load_offset, false); - if (!ret) - goto out; + case BOOT_DEVICE_SPINAND: + spi0_nand_reset(); + load.read = spi_load_read_nand; + spl_set_bl_len(&load, 1); + break; #endif + case BOOT_DEVICE_SPI: + load.read = spi_load_read_nor; + spl_set_bl_len(&load, 1); + allow_raw = true; + break; + }
- spl_set_bl_len(&load, 1); - load.read = spi_load_read_nor; - ret = spl_spi_try_load(spl_image, bootdev, &load, load_offset, true); + ret = spl_spi_try_load(spl_image, bootdev, &load, load_offset, allow_raw);
-out: spi0_deinit();
return ret; } /* Use priorty 0 to override the default if it happens to be linked in */ SPL_LOAD_IMAGE_METHOD("sunxi SPI", 0, BOOT_DEVICE_SPI, spl_spi_load_image); + +#if IS_ENABLED(CONFIG_SPL_SPI_SUNXI_NAND) +SPL_LOAD_IMAGE_METHOD("sunxi SPI NAND", 0, BOOT_DEVICE_SPINAND, spl_spi_load_image); +#endif