sunxi: eMMC: support TOC0 on boot partitions
authorAndre Przywara <andre.przywara@arm.com>
Fri, 25 Nov 2022 01:38:06 +0000 (01:38 +0000)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 23 Jan 2023 01:18:23 +0000 (01:18 +0000)
commit382b8371340e06fa12ad03dc2f8e466c8c715eff
treee74d165b49071d700aca600c5407ff05919be105
parent456093b4a3d3540305cdafa1f25f50a8693539bb
sunxi: eMMC: support TOC0 on boot partitions

To determine whether we have been booted from an eMMC boot partition, we
replay some of the checks that the BROM must have done to successfully
load the SPL. This involves a checksum check, which currently relies on
the SPL being wrapped in an "eGON" header.

If a board has secure boot enabled, the BROM will only accept the "TOC0"
format, which is internally very different, but uses the same
checksumming algorithm. Actually the only difference for calculating the
checksum is that the size of the SPL is stored at a different offset.

Do a header check to determine whether we deal with an eGON or TOC0
format, then set the SPL size accordingly. The rest of the code is
unchanged.

This fixes booting from an eMMC boot partition on devices with secure
boot enabled, like the Remix Mini PC.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
arch/arm/mach-sunxi/board.c