Merge branch 'master' of https://gitlab.denx.de/u-boot/custodians/u-boot-sunxi
[oweals/u-boot.git] / arch / arm / mach-mvebu / spl.c
index 50b24f5760b71bbea7ce76d43fed17568a2574ae..a99bf166fd85109ce14edd53440bfcf323cf61f3 100644 (file)
@@ -7,6 +7,7 @@
 #include <dm.h>
 #include <debug_uart.h>
 #include <fdtdec.h>
+#include <hang.h>
 #include <spl.h>
 #include <asm/io.h>
 #include <asm/arch/cpu.h>
@@ -25,17 +26,18 @@ static u32 get_boot_device(void)
        val = readl(CONFIG_BOOTROM_ERR_REG);
        boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
        debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-#if defined(CONFIG_ARMADA_38X)
+       if (boot_device == BOOTROM_ERR_MODE_UART)
+               return BOOT_DEVICE_UART;
+
+#ifdef CONFIG_ARMADA_38X
        /*
-        * If the bootrom error register contains any else than zeros
-        * in the first 8 bits it's an error condition. And in that case
-        * try to boot from UART.
+        * If the bootrom error code contains any other than zeros it's an
+        * error condition and the bootROM has fallen back to UART boot
         */
+       boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
        if (boot_device)
-#else
-       if (boot_device == BOOTROM_ERR_MODE_UART)
-#endif
                return BOOT_DEVICE_UART;
+#endif
 
        /*
         * Now check the SAR register for the strapped boot-device
@@ -58,6 +60,11 @@ static u32 get_boot_device(void)
        case BOOT_FROM_UART_ALT:
 #endif
                return BOOT_DEVICE_UART;
+#ifdef BOOT_FROM_SATA
+       case BOOT_FROM_SATA:
+       case BOOT_FROM_SATA_ALT:
+               return BOOT_DEVICE_SATA;
+#endif
        case BOOT_FROM_SPI:
        default:
                return BOOT_DEVICE_SPI;
@@ -92,15 +99,21 @@ void board_init_f(ulong dummy)
         */
 #endif
 
+       /*
+        * Use special translation offset for SPL. This needs to be
+        * configured *before* spl_init() is called as this function
+        * calls dm_init() which calls the bind functions of the
+        * device drivers. Here the base address needs to be configured
+        * (translated) correctly.
+        */
+       gd->translation_offset = 0xd0000000 - 0xf1000000;
+
        ret = spl_init();
        if (ret) {
                debug("spl_init() failed: %d\n", ret);
                hang();
        }
 
-       /* Use special translation offset for SPL */
-       dm_set_translation_offset(0xd0000000 - 0xf1000000);
-
        preloader_console_init();
 
        timer_init();
@@ -114,6 +127,9 @@ void board_init_f(ulong dummy)
        ddr3_init();
 #endif
 
+       /* Initialize Auto Voltage Scaling */
+       mv_avs_init();
+
        /*
         * Return to the BootROM to continue the Marvell xmodem
         * UART boot protocol. As initiated by the kwboot tool.