From ec5a2b9d59dce5b6e6099766423e9f9acc7ad698 Mon Sep 17 00:00:00 2001 From: Philipp Tomsich Date: Fri, 16 Sep 2016 10:29:04 +0200 Subject: sunxi: Set probing order for SPL via board_boot_order() for sun9i As SPL can probe multiple interfaces, we can let it do the work for FIT images and simply provide the board_boot_order hook. This mechanism is fully implemented for sun9i (i.e. A80) platforms and falls back to the old mechanism of determining a single boot device for older/other platforms for now. Signed-off-by: Philipp Tomsich --- arch/arm/cpu/armv7/sunxi/board.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 1bc71af863..99ec4b7225 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -163,6 +163,53 @@ void s_init(void) #ifdef CONFIG_SPL_BUILD DECLARE_GLOBAL_DATA_PTR; + +/* Override the weak board_boot_order to support SPL probing multiple + * interfaces in a defined order + */ + +static void sun9i_boot_order(u32 *spl_boot_list) +{ + struct sunxi_sysctl_reg *const sysctl = + (struct sunxi_sysctl_reg *)SUNXI_SYSCTL_BASE; + u32 reg = readl(&sysctl->version); + u32 bootsel = (reg >> 8) & 0x3; + + /* + * This checks for the signature and if it is not found returns to + * the FEL code in the BROM to wait and receive the main u-boot + * binary over USB. If it is found, it determines where SPL was + * read from. + */ + spl_boot_list[0] = BOOT_DEVICE_BOARD; + + if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */ + return; + + switch (bootsel) { + case 0b00: /* 'BIOS Disable' setting on A80-Q7 */ + spl_boot_list[0] = BOOT_DEVICE_MMC1; /* microSD card */ + spl_boot_list[1] = BOOT_DEVICE_MMC2; /* eMMC */ + spl_boot_list[2] = BOOT_DEVICE_SPI; + break; + + case 0b10: /* 'Normal BOOT' setting on A80-Q7 */ + default: + spl_boot_list[0] = BOOT_DEVICE_MMC2; /* eMMC */ + spl_boot_list[1] = BOOT_DEVICE_MMC1; + break; + } +} + +void board_boot_order(u32 *spl_boot_list) +{ +#ifdef CONFIG_MACH_SUN9I + sun9i_boot_order(spl_boot_list); +#else + spl_boot_list[0] = spl_boot_device(); +#endif +} + /* The sunxi internal brom will try to loader external bootloader * from mmc0, nand flash, mmc2. */ -- cgit v1.2.3