]> git.sur5r.net Git - u-boot/blobdiff - arch/arm/cpu/armv7/omap-common/boot-common.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[u-boot] / arch / arm / cpu / armv7 / omap-common / boot-common.c
index f2a25dcdc905a5ab2f2737ae3872412d87fdb3be..385310ba1ec95825292f55824710a8e18c087275 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+__weak u32 omap_sys_boot_device(void)
+{
+       return BOOT_DEVICE_NONE;
+}
+
 void save_omap_boot_params(void)
 {
        u32 boot_params = *((u32 *)OMAP_SRAM_SCRATCH_BOOT_PARAMS);
        struct omap_boot_parameters *omap_boot_params;
+       int sys_boot_device = 0;
        u32 boot_device;
        u32 boot_mode;
 
@@ -34,9 +40,10 @@ void save_omap_boot_params(void)
 
        omap_boot_params = (struct omap_boot_parameters *)boot_params;
 
-       /* Boot device */
-
        boot_device = omap_boot_params->boot_device;
+       boot_mode = MMCSD_MODE_UNDEFINED;
+
+       /* Boot device */
 
 #ifdef BOOT_DEVICE_NAND_I2C
        /*
@@ -58,16 +65,55 @@ void save_omap_boot_params(void)
        if (boot_device == BOOT_DEVICE_QSPI_4)
                boot_device = BOOT_DEVICE_SPI;
 #endif
+       /*
+        * When booting from peripheral booting, the boot device is not usable
+        * as-is (unless there is support for it), so the boot device is instead
+        * figured out using the SYS_BOOT pins.
+        */
+       switch (boot_device) {
+#if defined(BOOT_DEVICE_UART) && !defined(CONFIG_SPL_YMODEM_SUPPORT)
+               case BOOT_DEVICE_UART:
+                       sys_boot_device = 1;
+                       break;
+#endif
+#if defined(BOOT_DEVICE_USB) && !defined(CONFIG_SPL_USB_SUPPORT)
+               case BOOT_DEVICE_USB:
+                       sys_boot_device = 1;
+                       break;
+#endif
+#if defined(BOOT_DEVICE_USBETH) && !defined(CONFIG_SPL_USBETH_SUPPORT)
+               case BOOT_DEVICE_USBETH:
+                       sys_boot_device = 1;
+                       break;
+#endif
+#if defined(BOOT_DEVICE_CPGMAC) && !defined(CONFIG_SPL_ETH_SUPPORT)
+               case BOOT_DEVICE_CPGMAC:
+                       sys_boot_device = 1;
+                       break;
+#endif
+#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT)
+               case BOOT_DEVICE_DFU:
+                       sys_boot_device = 1;
+                       break;
+#endif
+       }
+
+       if (sys_boot_device) {
+               boot_device = omap_sys_boot_device();
+
+               /* MMC raw mode will fallback to FS mode. */
+               if ((boot_device >= MMC_BOOT_DEVICES_START) &&
+                   (boot_device <= MMC_BOOT_DEVICES_END))
+                       boot_mode = MMCSD_MODE_RAW;
+       }
 
        gd->arch.omap_boot_device = boot_device;
 
        /* Boot mode */
 
-       boot_mode = MMCSD_MODE_UNDEFINED;
-
+#ifdef CONFIG_OMAP34XX
        if ((boot_device >= MMC_BOOT_DEVICES_START) &&
            (boot_device <= MMC_BOOT_DEVICES_END)) {
-#ifdef CONFIG_OMAP34XX
                switch (boot_device) {
                case BOOT_DEVICE_MMC1:
                        boot_mode = MMCSD_MODE_FS;
@@ -76,7 +122,16 @@ void save_omap_boot_params(void)
                        boot_mode = MMCSD_MODE_RAW;
                        break;
                }
+       }
 #else
+       /*
+        * If the boot device was dynamically changed and doesn't match what
+        * the bootrom initially booted, we cannot use the boot device
+        * descriptor to figure out the boot mode.
+        */
+       if ((boot_device == omap_boot_params->boot_device) &&
+           (boot_device >= MMC_BOOT_DEVICES_START) &&
+           (boot_device <= MMC_BOOT_DEVICES_END)) {
                boot_params = omap_boot_params->boot_device_descriptor;
                if ((boot_params < NON_SECURE_SRAM_START) ||
                    (boot_params > NON_SECURE_SRAM_END))
@@ -92,12 +147,12 @@ void save_omap_boot_params(void)
                if (boot_mode != MMCSD_MODE_FS &&
                    boot_mode != MMCSD_MODE_RAW)
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
-                       boot_mode = MMCSD_MODE_EMMCBOOT
+                       boot_mode = MMCSD_MODE_EMMCBOOT;
 #else
                        boot_mode = MMCSD_MODE_UNDEFINED;
-#endif
 #endif
        }
+#endif
 
        gd->arch.omap_boot_mode = boot_mode;
 
@@ -116,7 +171,7 @@ u32 spl_boot_device(void)
        return gd->arch.omap_boot_device;
 }
 
-u32 spl_boot_mode(void)
+u32 spl_boot_mode(const u32 boot_device)
 {
        return gd->arch.omap_boot_mode;
 }
@@ -150,7 +205,7 @@ void spl_board_init(void)
 #endif
 }
 
-int board_mmc_init(bd_t *bis)
+__weak int board_mmc_init(bd_t *bis)
 {
        switch (spl_boot_device()) {
        case BOOT_DEVICE_MMC1:
@@ -158,6 +213,7 @@ int board_mmc_init(bd_t *bis)
                break;
        case BOOT_DEVICE_MMC2:
        case BOOT_DEVICE_MMC2_2:
+               omap_mmc_init(0, 0, 0, -1, -1);
                omap_mmc_init(1, 0, 0, -1, -1);
                break;
        }