SPDX: Convert all of our single license tags to Linux Kernel style
[platform/kernel/u-boot.git] / arch / arm / mach-imx / spl.c
index 6c16872..a20b30d 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2014 Gateworks Corporation
  * Copyright (C) 2011-2012 Freescale Semiconductor, Inc.
  *
  * Author: Tim Harvey <tharvey@gateworks.com>
- *
- * SPDX-License-Identifier:     GPL-2.0+
  */
 
 #include <common.h>
@@ -97,10 +96,33 @@ u32 spl_boot_device(void)
        return BOOT_DEVICE_NONE;
 }
 
-#elif defined(CONFIG_MX7)
-/* Translate iMX7 boot device to the SPL boot device enumeration */
+#elif defined(CONFIG_MX7) || defined(CONFIG_MX8M)
+/* Translate iMX7/MX8M boot device to the SPL boot device enumeration */
 u32 spl_boot_device(void)
 {
+#if defined(CONFIG_MX7)
+       unsigned int bmode = readl(&src_base->sbmr2);
+
+       /*
+        * Check for BMODE if serial downloader is enabled
+        * BOOT_MODE - see IMX7DRM Table 6-24
+        */
+       if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
+               return BOOT_DEVICE_BOARD;
+
+       /*
+        * The above method does not detect that the boot ROM used
+        * serial downloader in case the boot ROM decided to use the
+        * serial downloader as a fall back (primary boot source failed).
+        *
+        * Infer that the boot ROM used the USB serial downloader by
+        * checking whether the USB PHY is currently active... This
+        * assumes that SPL did not (yet) initialize the USB PHY...
+        */
+       if (is_boot_from_usb())
+               return BOOT_DEVICE_BOARD;
+#endif
+
        enum boot_device boot_device_spl = get_boot_device();
 
        switch (boot_device_spl) {
@@ -115,11 +137,13 @@ u32 spl_boot_device(void)
                return BOOT_DEVICE_NAND;
        case SPI_NOR_BOOT:
                return BOOT_DEVICE_SPI;
+       case USB_BOOT:
+               return BOOT_DEVICE_USB;
        default:
                return BOOT_DEVICE_NONE;
        }
 }
-#endif /* CONFIG_MX6 || CONFIG_MX7 */
+#endif /* CONFIG_MX6 || CONFIG_MX7 || CONFIG_MX8M */
 
 #ifdef CONFIG_SPL_USB_GADGET_SUPPORT
 int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)