summaryrefslogtreecommitdiff
path: root/board/sunxi/board.c
diff options
context:
space:
mode:
authorKlaus Goger <klaus.goger@theobroma-systems.com>2015-07-26 11:07:42 +0200
committerPhilipp Tomsich <philipp.tomsich@theobroma-systems.com>2017-03-09 01:40:01 +0100
commit67cc056fe30cd7b11491426a05d925214d1d7c43 (patch)
tree33092e4f7f9083d10064a6c0f7ced80affc50756 /board/sunxi/board.c
parent3b4b97a21b539ee78e2bd39ca52a5456076ef5e3 (diff)
ARM: sun6i: select mmc order based on VER_REG
selecting the mmc boot device based on mmc content can fail if the device is booted from eMMC and there is a SD-card with u-boot plugged in. On sun6i we can ѕelect the correct boot device based on the hardware configuration pins in BOOT_SEL. We only want to do this if UBOOT_SEL is not active since this overrides the BOOT_SEL settings to SD card. Signed-off-by: Klaus Goger <klaus.goger@theobroma-systems.com> Signed-off-by: Jakob Unterwurzacher <jakob.unterwurzacher@theobroma-systems.com>
Diffstat (limited to 'board/sunxi/board.c')
-rw-r--r--board/sunxi/board.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index dd00aaa75f..96dd288a7d 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -387,6 +387,7 @@ int board_mmc_init(bd_t *bis)
{
__maybe_unused struct mmc *mmc0, *mmc1;
__maybe_unused char buf[512];
+ __maybe_unused u32 val;
mmc_pinmux_setup(CONFIG_MMC_SUNXI_SLOT);
mmc0 = sunxi_mmc_init(CONFIG_MMC_SUNXI_SLOT);
@@ -401,6 +402,39 @@ int board_mmc_init(bd_t *bis)
#endif
#if !defined(CONFIG_SPL_BUILD) && CONFIG_MMC_SUNXI_SLOT_EXTRA == 2
+#if CONFIG_MACH_SUN6I
+ /*
+ * the bootdevice is shown in VER_REG in the system controller
+ * if U_boot is set then the ROM trys to boot from mmc0 regardless
+ * of the BOOT_SEL pins.
+ */
+ val = readl(0x1c00024);
+ if ((val & (1<<10))) /* check UBOOT_SEL */
+ {
+ switch((val & (3<<8))>>8) /* check BOOT_SEL pins */
+ {
+ case 0x0: /* SPI0 boot */
+ break;
+ case 0x1: /* eMMC2 boot */
+ /* Check if there is a boot loader on eMMC2
+ * If not we want to fall back to SD card */
+ if (mmc_init(mmc1) == 0 &&
+ mmc1->block_dev.block_read(1, 16, 1, buf) == 1) {
+ buf[12] = 0;
+ if (strcmp(&buf[4], "eGON.BT0") == 0) {
+ /* Boot loader found, swap to make eMMC the first device */
+ mmc0->block_dev.dev = 1;
+ mmc1->block_dev.dev = 0;
+ }
+ }
+ break;
+ case 0x2: /* SDC2 boot */
+ break;
+ case 0x3: /* NAND Flash boot */
+ break;
+ }
+ }
+#else
/*
* On systems with an emmc (mmc2), figure out if we are booting from
* the emmc and if we are make it "mmc dev 0" so that boot.scr, etc.
@@ -413,6 +447,7 @@ int board_mmc_init(bd_t *bis)
mmc1->block_dev.devnum = 0;
}
#endif
+#endif
return 0;
}