@@ -16,8 +16,6 @@
#define SUNXI_BOOTED_FROM_NAND 1
#define SUNXI_BOOTED_FROM_MMC2 2
#define SUNXI_BOOTED_FROM_SPI 3
-#define SUNXI_BOOTED_FROM_MMC0_HIGH 0x10
-#define SUNXI_BOOTED_FROM_MMC2_HIGH 0x12
/*
* Values taken from the F1C200s BootROM stack
@@ -276,6 +276,7 @@ static int sunxi_get_boot_source(void)
uint32_t sunxi_get_boot_device(void)
{
int boot_source = sunxi_get_boot_source();
+ int boot_dev = (boot_source & 0xF); /* Low nibble is device */
/*
* When booting from the SD card or NAND memory, the "eGON.BT0"
@@ -293,16 +294,15 @@ uint32_t sunxi_get_boot_device(void)
* binary over USB. If it is found, it determines where SPL was
* read from.
*/
- switch (boot_source) {
- case SUNXI_INVALID_BOOT_SOURCE:
+ if (boot_source == SUNXI_INVALID_BOOT_SOURCE)
return BOOT_DEVICE_BOARD;
+
+ switch (boot_dev) {
case SUNXI_BOOTED_FROM_MMC0:
- case SUNXI_BOOTED_FROM_MMC0_HIGH:
return BOOT_DEVICE_MMC1;
case SUNXI_BOOTED_FROM_NAND:
return BOOT_DEVICE_NAND;
case SUNXI_BOOTED_FROM_MMC2:
- case SUNXI_BOOTED_FROM_MMC2_HIGH:
return BOOT_DEVICE_MMC2;
case SUNXI_BOOTED_FROM_SPI:
return BOOT_DEVICE_SPI;
@@ -312,6 +312,14 @@ uint32_t sunxi_get_boot_device(void)
return -1; /* Never reached */
}
+uint32_t sunxi_get_boot_position(void)
+{
+ int boot_source = sunxi_get_boot_source();
+ int boot_pos = ((boot_source >> 8) & 0xF); /* High nibble is position */
+
+ return boot_pos;
+}
+
#ifdef CONFIG_SPL_BUILD
uint32_t sunxi_get_spl_size(void)
{
@@ -343,12 +351,8 @@ unsigned long board_spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
sector = max(raw_sect, spl_size / 512);
- switch (sunxi_get_boot_source()) {
- case SUNXI_BOOTED_FROM_MMC0_HIGH:
- case SUNXI_BOOTED_FROM_MMC2_HIGH:
+ if (sunxi_get_boot_position() == 1)
sector += (128 - 8) * 2;
- break;
- }
return sector;
}
While MMC1 and MMC2 each currently have only one upper byte possibility, SPI NAND has quite a few. To solve this, split up the byte handling across two functions in preparation for SPI NAND support. I have not tested this patch to validate that MMC SPL offsets are working. It looks like it should work though. Signed-off-by: John Watts <contact@jookia.org> --- arch/arm/include/asm/arch-sunxi/spl.h | 2 -- arch/arm/mach-sunxi/board.c | 22 +++++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-)