
Add a detection at runtime of the boot from USB on i.MX6, and invalidate the D-cache only in that case.
The USB boot detection method is taken from Freescale u-boot commit 1309b1ed78b3 ("ENGR00315499-8 Auto check if boot from usb").
This repairs u-boot when it is built with CONFIG_SKIP_LOWLEVEL_INIT defined, and is booted from another u-boot, which booted from SD card, for example.
Signed-off-by: Vincent Stehlé vincent.stehle@freescale.com Cc: Stefano Babic sbabic@denx.de Cc: Fabio Estevam fabio.estevam@freescale.com Cc: Frank Li Frank.li@freescale.com Cc: Nitin Garg nitin.garg@freescale.com --- arch/arm/cpu/armv7/mx6/soc.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/cpu/armv7/mx6/soc.c b/arch/arm/cpu/armv7/mx6/soc.c index 21ef9d0..774f078 100644 --- a/arch/arm/cpu/armv7/mx6/soc.c +++ b/arch/arm/cpu/armv7/mx6/soc.c @@ -350,6 +350,18 @@ int board_postclk_init(void) return 0; }
+/* + * Determine if we booted from USB. + * + * We look at the USBPH0_PWD0.RXPWDRX register to determine if the USB + * PHY is powered on or off. If the USB PHY is turned on, we assume that + * the ROM booted us from USB. + */ +static bool is_boot_from_usb(void) +{ + return !(readl(USB_PHY0_BASE_ADDR) & (1<<20)); +} + #ifndef CONFIG_SYS_DCACHE_OFF void enable_caches(void) { @@ -360,7 +372,8 @@ void enable_caches(void) #endif
/* Avoid random hang when download by usb */ - invalidate_dcache_all(); + if (is_boot_from_usb()) + invalidate_dcache_all();
/* Enable D-cache. I-cache is already enabled in start.S */ dcache_enable();