MLK-19869-1 imx6: Checking serial download booting
authorYe Li <ye.li@nxp.com>
Fri, 17 May 2019 09:36:57 +0000 (02:36 -0700)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 11:28:57 +0000 (04:28 -0700)
We introduce a new arch-specific flag GD_FLG_ARCH_IMX_USB_BOOT to indicate if it is
USB boot. We check the USB PHY PWD bit at early of boot stage then set that flag
in global variable. So any following calling of is_boot_from_usb will return
correct value.

Signed-off-by: Ye Li <ye.li@nxp.com>
arch/arm/include/asm/arch-mx6/imx-regs.h
arch/arm/include/asm/mach-imx/sys_proto.h
arch/arm/mach-imx/mx6/soc.c

index 5aca229..7097625 100644 (file)
@@ -1105,7 +1105,11 @@ struct dbg_monitor_regs {
  * If ROM fail back to USB recover mode, USBPH0_PWD will be clear to use USB
  * If boot from the other mode, USB0_PWD will keep reset value
  */
-#define        is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+#include <stdbool.h>
+bool is_usb_boot(void);
+#define        is_boot_from_usb  is_usb_boot
+#define        is_usbphy_power_on(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
+#define        disconnect_from_pc(void) writel(0x0, OTG_BASE_ADDR + 0x140)
 
 #endif /* __ASSEMBLER__*/
 #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
index 877f04f..4dbad53 100644 (file)
@@ -57,6 +57,9 @@
 #define is_imx8qm() (is_cpu_type(MXC_CPU_IMX8QM))
 #define is_imx8qxp() (is_cpu_type(MXC_CPU_IMX8QXP))
 
+ /* gd->flags reserves high 16 bits for arch-specific flags */
+#define GD_FLG_ARCH_IMX_USB_BOOT               0x80000000       /* Only used for MX6/7, If set, the u-boot is booting from USB serial download */
+
 #ifdef CONFIG_MX6
 #define IMX6_SRC_GPR10_BMODE           BIT(28)
 
index 4538c61..d010f90 100644 (file)
@@ -28,6 +28,8 @@
 #include <fsl_caam.h>
 #endif
 
+DECLARE_GLOBAL_DATA_PTR;
+
 enum ldo_reg {
        LDO_ARM,
        LDO_SOC,
@@ -519,8 +521,19 @@ static void imx_set_pcie_phy_power_down(void)
        }
 }
 
+bool is_usb_boot(void)
+{
+       if (gd->flags & GD_FLG_ARCH_IMX_USB_BOOT)
+               return true;
+
+       return false;
+}
+
 int arch_cpu_init(void)
 {
+       if (is_usbphy_power_on())
+               gd->flags |= GD_FLG_ARCH_IMX_USB_BOOT;
+
        if (!is_mx6sl() && !is_mx6sx()
                && !is_mx6ul() && !is_mx6ull()
                && !is_mx6sll()) {