public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB
@ 2015-05-22 14:52 Vincent Stehlé
  2015-05-22 15:15 ` Li Frank
  2015-05-24  7:24 ` Stefano Babic
  0 siblings, 2 replies; 6+ messages in thread
From: Vincent Stehlé @ 2015-05-22 14:52 UTC (permalink / raw)
  To: u-boot

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();
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-05-26 17:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-22 14:52 [U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB Vincent Stehlé
2015-05-22 15:15 ` Li Frank
2015-05-22 15:37   ` Vincent Stehlé
2015-05-24  7:24 ` Stefano Babic
2015-05-26 15:16   ` Vincent
2015-05-26 17:08     ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox