u-boot/arch/arm/mach-sunxi
Andre Przywara b9a2e18533 sunxi: eMMC: Improve automatic boot source detection
When the Allwinner BROM loads the SPL from an eMMC boot partition, it
sets the boot source byte to the same value as when booting from the
user data partition. This prevents us from determining the boot source
to load U-Boot proper from the proper partition for sure.

The generic SPL MMC code already looks at the enabled boot partition
number, to load U-Boot proper from the same partition, but this fails
if there is nothing bootable in this partition, as the BROM then
silently falls back to the user data partition, which the SPL misses.

To learn about the actual boot source anyway, we repeat the algorithm
the BROM used to select the boot partition in the first place:
- Test EXT_CSD[179] to check if an eMMC boot partition is enabled.
- Test EXT_CSD[177] to check for valid MMC interface settings.
- Check if BOOT_ACK is enabled.
- Check the beginning of the first sector for a valid eGON signature.
- Load the whole SPL.
- Recalculate the checksum to verify the SPL is valid.

If one of those steps fails, we bail out and continue loading from the
user data partition. Otherwise we load from the selected boot partition.

Since the boot source is needed twice in the boot process, we cache the
result of this test to avoid doing this costly test multiple times.

This allows the very same image file to be put onto an SD card, into the
eMMC user data partition or into the eMMC boot partition, and safely
loads the whole of U-Boot from there.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2022-04-05 00:08:40 +01:00
..
dram_timings WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
board.c sunxi: eMMC: Improve automatic boot source detection 2022-04-05 00:08:40 +01:00
clock.c mach-sunxi: Add support for SUNIV architecture 2022-02-04 00:09:57 +00:00
clock_sun4i.c sunxi: Clean up inclusions of asm/arch/gpio.h 2021-10-11 10:46:44 +01:00
clock_sun6i.c mach-sunxi: Add support for SUNIV architecture 2022-02-04 00:09:57 +00:00
clock_sun8i_a83t.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
clock_sun9i.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
clock_sun50i_h6.c sunxi: clock: H6: Adjust PLL LDO before clock setup 2022-04-04 23:24:17 +01:00
cpu_info.c mach-sunxi: Add support for SUNIV architecture 2022-02-04 00:09:57 +00:00
dram_helpers.c sunxi: Add F1C100s DRAM initial support 2022-02-04 00:09:57 +00:00
dram_sun4i.c WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
dram_sun6i.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
dram_sun8i_a23.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
dram_sun8i_a33.c WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
dram_sun8i_a83t.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
dram_sun9i.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
dram_sun50i_h6.c sunxi: prcm: Add a few registers 2022-04-04 23:24:17 +01:00
dram_sun50i_h616.c sunxi: prcm: Add a few registers 2022-04-04 23:24:17 +01:00
dram_suniv.c sunxi: Add F1C100s DRAM initial support 2022-02-04 00:09:57 +00:00
dram_sunxi_dw.c sunxi: enable dual rank memory on R40 2021-04-16 01:12:58 +01:00
gtbus_sun9i.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
Kconfig sunxi: Support building a SPL as a TOC0 image 2022-04-04 23:24:17 +01:00
Makefile sunxi: Add F1C100s DRAM initial support 2022-02-04 00:09:57 +00:00
pinmux.c sunxi: gpio: Fix up pointer arithmetic 2022-01-30 01:25:00 +00:00
pmic_bus.c sunxi: pmic_bus: Use the DM PMIC interface when possible 2021-10-12 10:48:37 +01:00
prcm.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
rmr_switch.S sunxi: Introduce common symbol for H6 like SoCs 2021-01-25 21:52:00 +00:00
spl_spi_sunxi.c sunxi: Support SPL in both eGON and TOC0 images 2022-04-04 23:24:17 +01:00
timer.c mach-sunxi: Move timer code to mach folder 2022-02-04 00:09:57 +00:00