From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Babic Date: Sun, 24 May 2015 09:24:48 +0200 Subject: [U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB In-Reply-To: <1432306377-29169-1-git-send-email-vincent.stehle@freescale.com> References: <1432306377-29169-1-git-send-email-vincent.stehle@freescale.com> Message-ID: <55617CC0.5090004@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Vincent, On 22/05/2015 16:52, Vincent Stehl? wrote: > 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. Please help me to find the use case. I searched in all i.MX6 boards in mainline, but none of them is setting CONFIG_SKIP_LOWLEVEL_INIT. Can you tell me on which board there is this issue ? > > Signed-off-by: Vincent Stehl? > Cc: Stefano Babic > Cc: Fabio Estevam > Cc: Frank Li > Cc: Nitin Garg > --- > 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)); > +} This looks like a hack. I understand this can work in your case, but can we set as general case ? You check power for PHY0, but what about if a board is using PHY1 ? Anyway, is it not possible to get the boot storage from the SRC ? > + > #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(); I cannot understand well this. The correct implementation seems correct to me. And if you have issues booting with USB, why are you changing the behavior in all other cases *except* booting from USB, where you rely on the current implementation invalidating the cache ? Best regards, Stefano Babic -- ===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================