[U-Boot] [PATCH] mx6: invalidate D-cache only when booting from USB

Stefano Babic sbabic at denx.de
Sun May 24 09:24:48 CEST 2015


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é <vincent.stehle at freescale.com>
> Cc: Stefano Babic <sbabic at denx.de>
> Cc: Fabio Estevam <fabio.estevam at freescale.com>
> Cc: Frank Li <Frank.li at freescale.com>
> Cc: Nitin Garg <nitin.garg at 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));
> +}

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
=====================================================================


More information about the U-Boot mailing list