summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYe Li <ye.li@nxp.com>2018-10-10 01:16:13 -0700
committerYe Li <ye.li@nxp.com>2018-10-10 02:00:44 -0700
commita3457bfd99930007644fbd6f1ad89764ce836e5d (patch)
tree61d6e5ecdde18a0a2ed7adcb908f74c7c10a003d
parenta176f9de5446787a9c4fd85bbef73db88ec9075b (diff)
MLK-19869-1 imx6: improve the is_boot_from_usb implementation
Currently the is_boot_from_usb is checking the USB PHY Powerdown bit. This way has a defect that if we run any usb function in u-boot the checking will always return true. This patch improves the way to avoid such problem above. A new arch-specific flag is added to indicate if it is USB boot. We check the USB PHY PWD bit at early of boot stage then set that flag. So any following calling of is_boot_from_usb will return correct value. Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit 0efb6ecdb9a40fdbccc3fd7ce69eb31cd82c9ab8)
-rw-r--r--arch/arm/include/asm/arch-mx6/imx-regs.h8
-rw-r--r--arch/arm/mach-imx/mx6/soc.c13
2 files changed, 20 insertions, 1 deletions
diff --git a/arch/arm/include/asm/arch-mx6/imx-regs.h b/arch/arm/include/asm/arch-mx6/imx-regs.h
index 00bad47ac9..897639c3d1 100644
--- a/arch/arm/include/asm/arch-mx6/imx-regs.h
+++ b/arch/arm/include/asm/arch-mx6/imx-regs.h
@@ -1102,11 +1102,17 @@ struct dbg_monitor_regs {
u32 version[4]; /* Version */
};
+ /* gd->flags reserves high 16 bits for arch-specific flags */
+#define GD_FLG_ARCH_MX6_USB_BOOT 0x80000000 /* If set, the u-boot is booting from USB serial download */
+
/*
* 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__*/
diff --git a/arch/arm/mach-imx/mx6/soc.c b/arch/arm/mach-imx/mx6/soc.c
index 8950bcaffd..0cdd27c301 100644
--- a/arch/arm/mach-imx/mx6/soc.c
+++ b/arch/arm/mach-imx/mx6/soc.c
@@ -29,6 +29,8 @@
#include <fsl_caam.h>
#endif
+DECLARE_GLOBAL_DATA_PTR;
+
enum ldo_reg {
LDO_ARM,
LDO_SOC,
@@ -520,8 +522,19 @@ static void imx_set_pcie_phy_power_down(void)
}
}
+bool is_usb_boot(void)
+{
+ if (gd->flags & GD_FLG_ARCH_MX6_USB_BOOT)
+ return true;
+
+ return false;
+}
+
int arch_cpu_init(void)
{
+ if (is_usbphy_power_on())
+ gd->flags |= GD_FLG_ARCH_MX6_USB_BOOT;
+
if (!is_mx6sl() && !is_mx6sx()
&& !is_mx6ul() && !is_mx6ull()
&& !is_mx6sll()) {