efi_loader: refactor switch to non-secure mode
[oweals/u-boot.git] / arch / arm / mach-omap2 / boot-common.c
index 7ae3d8041c48ee61c3c332e79004217537a34936..2db19227b92104c72b166c4bed73ca595275880b 100644 (file)
@@ -1,15 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * boot-common.c
  *
  * Common bootmode functions for omap based boards
  *
  * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <ahci.h>
+#include <environment.h>
 #include <spl.h>
 #include <asm/omap_common.h>
 #include <asm/arch/omap.h>
@@ -64,6 +64,23 @@ void save_omap_boot_params(void)
         */
        if (boot_device == BOOT_DEVICE_QSPI_4)
                boot_device = BOOT_DEVICE_SPI;
+#endif
+#ifdef CONFIG_TI816X
+       /*
+        * On PG2.0 and later TI816x the values we get when booting are not the
+        * same as on PG1.0, which is what the defines are based on.  Update
+        * them as needed.
+        */
+       if (get_cpu_rev() != 1) {
+               if (boot_device == 0x05) {
+                       omap_boot_params->boot_device = BOOT_DEVICE_NAND;
+                       boot_device = BOOT_DEVICE_NAND;
+               }
+               if (boot_device == 0x08) {
+                       omap_boot_params->boot_device = BOOT_DEVICE_MMC1;
+                       boot_device = BOOT_DEVICE_MMC1;
+               }
+       }
 #endif
        /*
         * When booting from peripheral booting, the boot device is not usable
@@ -81,7 +98,7 @@ void save_omap_boot_params(void)
                        sys_boot_device = 1;
                        break;
 #endif
-#if defined(BOOT_DEVICE_USBETH) && !defined(CONFIG_SPL_USBETH_SUPPORT)
+#if defined(BOOT_DEVICE_USBETH) && !defined(CONFIG_SPL_USB_ETHER)
                case BOOT_DEVICE_USBETH:
                        sys_boot_device = 1;
                        break;
@@ -91,7 +108,7 @@ void save_omap_boot_params(void)
                        sys_boot_device = 1;
                        break;
 #endif
-#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU_SUPPORT)
+#if defined(BOOT_DEVICE_DFU) && !defined(CONFIG_SPL_DFU)
                case BOOT_DEVICE_DFU:
                        sys_boot_device = 1;
                        break;
@@ -178,20 +195,14 @@ u32 spl_boot_mode(const u32 boot_device)
 
 void spl_board_init(void)
 {
-       /*
-        * Save the boot parameters passed from romcode.
-        * We cannot delay the saving further than this,
-        * to prevent overwrites.
-        */
-       save_omap_boot_params();
-
+#ifdef CONFIG_SPL_SERIAL_SUPPORT
        /* Prepare console output */
        preloader_console_init();
-
+#endif
 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
        gpmc_init();
 #endif
-#ifdef CONFIG_SPL_I2C_SUPPORT
+#if defined(CONFIG_SPL_I2C_SUPPORT) && !defined(CONFIG_DM_I2C)
        i2c_init(CONFIG_SYS_OMAP24_I2C_SPEED, CONFIG_SYS_OMAP24_I2C_SLAVE);
 #endif
 #if defined(CONFIG_AM33XX) && defined(CONFIG_SPL_MUSB_NEW_SUPPORT)
@@ -205,21 +216,6 @@ void spl_board_init(void)
 #endif
 }
 
-__weak int board_mmc_init(bd_t *bis)
-{
-       switch (spl_boot_device()) {
-       case BOOT_DEVICE_MMC1:
-               omap_mmc_init(0, 0, 0, -1, -1);
-               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;
-       }
-       return 0;
-}
-
 void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
 {
        typedef void __noreturn (*image_entry_noargs_t)(u32 *);
@@ -240,13 +236,3 @@ void arch_preboot_os(void)
        ahci_reset((void __iomem *)DWC_AHSATA_BASE);
 }
 #endif
-
-#if defined(CONFIG_USB_FUNCTION_FASTBOOT) && !defined(CONFIG_ENV_IS_NOWHERE)
-int fb_set_reboot_flag(void)
-{
-       printf("Setting reboot to fastboot flag ...\n");
-       setenv("dofastboot", "1");
-       saveenv();
-       return 0;
-}
-#endif