Merge branch 'master' of git://git.denx.de/u-boot
[platform/kernel/u-boot.git] / arch / arm / cpu / armv7 / sunxi / board.c
index f01846e..4785ac6 100644 (file)
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/gpio.h>
+#include <asm/arch/spl.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/timer.h>
+#include <asm/arch/tzpc.h>
 #include <asm/arch/mmc.h>
 
 #include <linux/compiler.h>
@@ -115,6 +117,10 @@ void s_init(void)
                "orr r0, r0, #1 << 6\n"
                "mcr p15, 0, r0, c1, c0, 1\n");
 #endif
+#if defined CONFIG_MACH_SUN6I
+       /* Enable non-secure access to the RTC */
+       tzpc_init();
+#endif
 
        clock_init();
        timer_init();
@@ -130,7 +136,7 @@ DECLARE_GLOBAL_DATA_PTR;
  */
 u32 spl_boot_device(void)
 {
-       struct mmc *mmc0, *mmc1;
+       __maybe_unused struct mmc *mmc0, *mmc1;
        /*
         * When booting from the SD card or NAND memory, the "eGON.BT0"
         * signature is expected to be found in memory at the address 0x0004
@@ -147,19 +153,22 @@ u32 spl_boot_device(void)
         * binary over USB. If it is found, it determines where SPL was
         * read from.
         */
-       if (readl(4) != 0x4E4F4765 || readl(8) != 0x3054422E) /* eGON.BT0 */
+       if (!is_boot0_magic(SPL_ADDR + 4)) /* eGON.BT0 */
                return BOOT_DEVICE_BOARD;
 
        /* The BROM will try to boot from mmc0 first, so try that first. */
+#ifdef CONFIG_MMC
        mmc_initialize(gd->bd);
        mmc0 = find_mmc_device(0);
        if (sunxi_mmc_has_egon_boot_signature(mmc0))
                return BOOT_DEVICE_MMC1;
+#endif
 
        /* Fallback to booting NAND if enabled. */
        if (IS_ENABLED(CONFIG_SPL_NAND_SUPPORT))
                return BOOT_DEVICE_NAND;
 
+#ifdef CONFIG_MMC
        if (CONFIG_MMC_SUNXI_SLOT_EXTRA == 2) {
                mmc1 = find_mmc_device(1);
                if (sunxi_mmc_has_egon_boot_signature(mmc1)) {
@@ -173,6 +182,7 @@ u32 spl_boot_device(void)
                        return BOOT_DEVICE_MMC2;
                }
        }
+#endif
 
        panic("Could not determine boot source\n");
        return -1;              /* Never reached */
@@ -186,6 +196,7 @@ u32 spl_boot_mode(void)
 
 void board_init_f(ulong dummy)
 {
+       spl_init();
        preloader_console_init();
 
 #ifdef CONFIG_SPL_I2C_SUPPORT
@@ -193,11 +204,6 @@ void board_init_f(ulong dummy)
        i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
 #endif
        sunxi_board_init();
-
-       /* Clear the BSS. */
-       memset(__bss_start, 0, __bss_end - __bss_start);
-
-       board_init_r(NULL, 0);
 }
 #endif