All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active
  2017-09-13 21:29 [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Stefan Agner
@ 2017-09-13 21:28 ` Stefan Agner
  2017-09-13 21:29 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-13 21:28 UTC (permalink / raw)
  To: u-boot

Sorry, the subject should have been v4.

--
Stefan

On 2017-09-13 14:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3: None
> Changes in v2:
> - Move macro to sys_proto.h
> - Renamed from is_boot_from_usb() to is_usbphy_active()
> - Use defines for register offset and field
> - Remove tab after define
> - Remove comment since the actual "magic" is happening and
>   documented at usage side
> 
>  arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h
> b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 14f5d948c9..ba73943260 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -6,3 +6,10 @@
>   */
>  
>  #include <asm/mach-imx/sys_proto.h>
> +
> +#define USBPHY_PWD		0x00000000
> +
> +#define USBPHY_PWD_RXPWDRX	(1 << 20) /* receiver block power down */
> +
> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR +
> USBPHY_PWD) & \
> +				   USBPHY_PWD_RXPWDRX))


On 2017-09-13 14:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3: None
> Changes in v2:
> - Move macro to sys_proto.h
> - Renamed from is_boot_from_usb() to is_usbphy_active()
> - Use defines for register offset and field
> - Remove tab after define
> - Remove comment since the actual "magic" is happening and
>   documented at usage side
> 
>  arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h
> b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 14f5d948c9..ba73943260 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -6,3 +6,10 @@
>   */
>  
>  #include <asm/mach-imx/sys_proto.h>
> +
> +#define USBPHY_PWD		0x00000000
> +
> +#define USBPHY_PWD_RXPWDRX	(1 << 20) /* receiver block power down */
> +
> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR +
> USBPHY_PWD) & \
> +				   USBPHY_PWD_RXPWDRX))

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

* [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active
@ 2017-09-13 21:29 Stefan Agner
  2017-09-13 21:28 ` Stefan Agner
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-13 21:29 UTC (permalink / raw)
  To: u-boot

From: Stefan Agner <stefan.agner@toradex.com>

This macro allows to detect whether the USB PHY is active. This
is helpful to detect if the boot ROM has previously started the
USB serial downloader.

The idea is taken from the mfgtool support in the NXP U-Boot:
http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
---

Changes in v4:
- Rename macro to is_usbotg_phy_active()

Changes in v3: None
Changes in v2:
- Move macro to sys_proto.h
- Renamed from is_boot_from_usb() to is_usbphy_active()
- Use defines for register offset and field
- Remove tab after define
- Remove comment since the actual "magic" is happening and
  documented at usage side

 arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
index 14f5d948c9..ba73943260 100644
--- a/arch/arm/include/asm/arch-mx6/sys_proto.h
+++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
@@ -6,3 +6,10 @@
  */
 
 #include <asm/mach-imx/sys_proto.h>
+
+#define USBPHY_PWD		0x00000000
+
+#define USBPHY_PWD_RXPWDRX	(1 << 20) /* receiver block power down */
+
+#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
+				   USBPHY_PWD_RXPWDRX))
-- 
2.14.1

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-13 21:29 [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Stefan Agner
  2017-09-13 21:28 ` Stefan Agner
@ 2017-09-13 21:29 ` Stefan Agner
  2017-09-14  5:24   ` Eric Nelson
  2017-09-20 13:36   ` Stefano Babic
  2017-09-14  5:23 ` [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Eric Nelson
  2017-09-20 13:36 ` Stefano Babic
  3 siblings, 2 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-13 21:29 UTC (permalink / raw)
  To: u-boot

From: Stefan Agner <stefan.agner@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
---

Changes in v4:
- Rename macro to is_usbotg_phy_active()

Changes in v3:
- Fix spelling and grammar

Changes in v2:
- Add comment that we infer boot ROM behavior from USB PHY state

 arch/arm/mach-imx/spl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..534cc6504d 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,18 @@ u32 spl_boot_device(void)
 	if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
 		return BOOT_DEVICE_BOARD;
 
+	/*
+	 * The above method does not detect that the boot ROM used
+	 * serial downloader in case the boot ROM decided to use the
+	 * serial downloader as a fall back (primary boot source failed).
+	 *
+	 * Infer that the boot ROM used the USB serial downloader by
+	 * checking whether the USB PHY is currently active... This
+	 * assumes that SPL did not (yet) initialize the USB PHY...
+	 */
+	if (is_otgusb_phy_active())
+		return BOOT_DEVICE_BOARD;
+
 	/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
 	switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 	 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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

* [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active
  2017-09-13 21:29 [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Stefan Agner
  2017-09-13 21:28 ` Stefan Agner
  2017-09-13 21:29 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner
@ 2017-09-14  5:23 ` Eric Nelson
  2017-09-14  6:13   ` Stefan Agner
  2017-09-20 13:36 ` Stefano Babic
  3 siblings, 1 reply; 11+ messages in thread
From: Eric Nelson @ 2017-09-14  5:23 UTC (permalink / raw)
  To: u-boot

On 09/13/2017 02:29 PM, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3: None
> Changes in v2:
> - Move macro to sys_proto.h
> - Renamed from is_boot_from_usb() to is_usbphy_active()
> - Use defines for register offset and field
> - Remove tab after define
> - Remove comment since the actual "magic" is happening and
>    documented at usage side
> 
>   arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
> index 14f5d948c9..ba73943260 100644
> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
> @@ -6,3 +6,10 @@
>    */
>   
>   #include <asm/mach-imx/sys_proto.h>

I'd be more worried about these macro names (asking that they also
include "OTG") if they weren't defined in such close proximity to
their only use.

> +
> +#define USBPHY_PWD		0x00000000
> +
> +#define USBPHY_PWD_RXPWDRX	(1 << 20) /* receiver block power down */
> +
> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
> +				   USBPHY_PWD_RXPWDRX))
> 

Otherwise,

Reviewed-by: Eric Nelson <eric@nelint.com>

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-13 21:29 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner
@ 2017-09-14  5:24   ` Eric Nelson
  2017-09-18 15:05     ` Stefano Babic
  2017-09-20 13:36   ` Stefano Babic
  1 sibling, 1 reply; 11+ messages in thread
From: Eric Nelson @ 2017-09-14  5:24 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

Thanks for this patch.

On 09/13/2017 02:29 PM, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> The current mechanism using SCR/GPR registers work well when
> the serial downloader boot mode has been selected explicitly
> (either via boot mode pins or using bmode command). However,
> in case the system entered boot ROM due to unbootable primary
> boot devices (e.g. empty eMMC), the SPL fails to detect that
> it has been downloaded through serial loader and tries to
> continue booting from eMMC:
>    Trying to boot from MMC1
>    mmc_load_image_raw_sector: mmc block read error
>    SPL: failed to boot from all boot devices
>    ### ERROR ### Please RESET the board ###
> 
> The only known way to reliably detect USB serial downloader
> is by checking the USB PHY receiver block power state...
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> 
> Changes in v4:
> - Rename macro to is_usbotg_phy_active()
> 
> Changes in v3:
> - Fix spelling and grammar
> 
> Changes in v2:
> - Add comment that we infer boot ROM behavior from USB PHY state
> 
>   arch/arm/mach-imx/spl.c | 12 ++++++++++++
>   1 file changed, 12 insertions(+)
> 
> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
> index 258578ac25..534cc6504d 100644
> --- a/arch/arm/mach-imx/spl.c
> +++ b/arch/arm/mach-imx/spl.c
> @@ -31,6 +31,18 @@ u32 spl_boot_device(void)
>   	if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>   		return BOOT_DEVICE_BOARD;
>   
> +	/*
> +	 * The above method does not detect that the boot ROM used
> +	 * serial downloader in case the boot ROM decided to use the
> +	 * serial downloader as a fall back (primary boot source failed).
> +	 *
> +	 * Infer that the boot ROM used the USB serial downloader by
> +	 * checking whether the USB PHY is currently active... This
> +	 * assumes that SPL did not (yet) initialize the USB PHY...
> +	 */
> +	if (is_otgusb_phy_active())
> +		return BOOT_DEVICE_BOARD;
> +
>   	/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>   	switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>   	 /* EIM: See 8.5.1, Table 8-9 */
> 

Reviewed-by: Eric Nelson <eric@nelint.com>

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

* [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active
  2017-09-14  5:23 ` [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Eric Nelson
@ 2017-09-14  6:13   ` Stefan Agner
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-14  6:13 UTC (permalink / raw)
  To: u-boot

On 2017-09-13 22:23, Eric Nelson wrote:
> On 09/13/2017 02:29 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.agner@toradex.com>
>>
>> This macro allows to detect whether the USB PHY is active. This
>> is helpful to detect if the boot ROM has previously started the
>> USB serial downloader.
>>
>> The idea is taken from the mfgtool support in the NXP U-Boot:
>> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
>>
>> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
>> ---
>>
>> Changes in v4:
>> - Rename macro to is_usbotg_phy_active()
>>
>> Changes in v3: None
>> Changes in v2:
>> - Move macro to sys_proto.h
>> - Renamed from is_boot_from_usb() to is_usbphy_active()
>> - Use defines for register offset and field
>> - Remove tab after define
>> - Remove comment since the actual "magic" is happening and
>>    documented at usage side
>>
>>   arch/arm/include/asm/arch-mx6/sys_proto.h | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/arch-mx6/sys_proto.h b/arch/arm/include/asm/arch-mx6/sys_proto.h
>> index 14f5d948c9..ba73943260 100644
>> --- a/arch/arm/include/asm/arch-mx6/sys_proto.h
>> +++ b/arch/arm/include/asm/arch-mx6/sys_proto.h
>> @@ -6,3 +6,10 @@
>>    */
>>     #include <asm/mach-imx/sys_proto.h>
> 
> I'd be more worried about these macro names (asking that they also
> include "OTG") if they weren't defined in such close proximity to
> their only use.
> 

The registers for the host and otg phy are the same, one might reuse
them for host...

>> +
>> +#define USBPHY_PWD		0x00000000
>> +
>> +#define USBPHY_PWD_RXPWDRX	(1 << 20) /* receiver block power down */
>> +
>> +#define is_usbotg_phy_active(void) (!(readl(USB_PHY0_BASE_ADDR + USBPHY_PWD) & \
>> +				   USBPHY_PWD_RXPWDRX))
>>

In contrast, this function define is really OTG phy specific since we
use PHY0.

> 
> Otherwise,
> 
> Reviewed-by: Eric Nelson <eric@nelint.com>

Thx!

--
Stefan

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-14  5:24   ` Eric Nelson
@ 2017-09-18 15:05     ` Stefano Babic
  2017-09-18 15:09       ` Stefan Agner
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Babic @ 2017-09-18 15:05 UTC (permalink / raw)
  To: u-boot

Hi Stefan,

On 14/09/2017 07:24, Eric Nelson wrote:
> Hi Stefan,
> 
> Thanks for this patch.
> 
> On 09/13/2017 02:29 PM, Stefan Agner wrote:
>> From: Stefan Agner <stefan.agner@toradex.com>
>>
>> The current mechanism using SCR/GPR registers work well when
>> the serial downloader boot mode has been selected explicitly
>> (either via boot mode pins or using bmode command). However,
>> in case the system entered boot ROM due to unbootable primary
>> boot devices (e.g. empty eMMC), the SPL fails to detect that
>> it has been downloaded through serial loader and tries to
>> continue booting from eMMC:
>>    Trying to boot from MMC1
>>    mmc_load_image_raw_sector: mmc block read error
>>    SPL: failed to boot from all boot devices
>>    ### ERROR ### Please RESET the board ###
>>
>> The only known way to reliably detect USB serial downloader
>> is by checking the USB PHY receiver block power state...
>>
>> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
>> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
>> ---
>>
>> Changes in v4:
>> - Rename macro to is_usbotg_phy_active()
>>
>> Changes in v3:
>> - Fix spelling and grammar
>>
>> Changes in v2:
>> - Add comment that we infer boot ROM behavior from USB PHY state
>>
>>   arch/arm/mach-imx/spl.c | 12 ++++++++++++
>>   1 file changed, 12 insertions(+)
>>
>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>> index 258578ac25..534cc6504d 100644
>> --- a/arch/arm/mach-imx/spl.c
>> +++ b/arch/arm/mach-imx/spl.c
>> @@ -31,6 +31,18 @@ u32 spl_boot_device(void)
>>       if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>           return BOOT_DEVICE_BOARD;
>>   +    /*
>> +     * The above method does not detect that the boot ROM used
>> +     * serial downloader in case the boot ROM decided to use the
>> +     * serial downloader as a fall back (primary boot source failed).
>> +     *
>> +     * Infer that the boot ROM used the USB serial downloader by
>> +     * checking whether the USB PHY is currently active... This
>> +     * assumes that SPL did not (yet) initialize the USB PHY...
>> +     */
>> +    if (is_otgusb_phy_active())

This is "otgusb", but in sys_proto.h is "usbotg".

Can I fix it myself as "usbotg" by merging ?

Best regards,
Stefano

>> +        return BOOT_DEVICE_BOARD;
>> +
>>       /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>>       switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>>        /* EIM: See 8.5.1, Table 8-9 */
>>
> 
> Reviewed-by: Eric Nelson <eric@nelint.com>


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

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-18 15:05     ` Stefano Babic
@ 2017-09-18 15:09       ` Stefan Agner
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-18 15:09 UTC (permalink / raw)
  To: u-boot



On September 18, 2017 8:05:43 AM PDT, Stefano Babic <sbabic@denx.de> wrote:
>Hi Stefan,
>
>On 14/09/2017 07:24, Eric Nelson wrote:
>> Hi Stefan,
>> 
>> Thanks for this patch.
>> 
>> On 09/13/2017 02:29 PM, Stefan Agner wrote:
>>> From: Stefan Agner <stefan.agner@toradex.com>
>>>
>>> The current mechanism using SCR/GPR registers work well when
>>> the serial downloader boot mode has been selected explicitly
>>> (either via boot mode pins or using bmode command). However,
>>> in case the system entered boot ROM due to unbootable primary
>>> boot devices (e.g. empty eMMC), the SPL fails to detect that
>>> it has been downloaded through serial loader and tries to
>>> continue booting from eMMC:
>>>    Trying to boot from MMC1
>>>    mmc_load_image_raw_sector: mmc block read error
>>>    SPL: failed to boot from all boot devices
>>>    ### ERROR ### Please RESET the board ###
>>>
>>> The only known way to reliably detect USB serial downloader
>>> is by checking the USB PHY receiver block power state...
>>>
>>> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
>>> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
>>> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
>>> ---
>>>
>>> Changes in v4:
>>> - Rename macro to is_usbotg_phy_active()
>>>
>>> Changes in v3:
>>> - Fix spelling and grammar
>>>
>>> Changes in v2:
>>> - Add comment that we infer boot ROM behavior from USB PHY state
>>>
>>>   arch/arm/mach-imx/spl.c | 12 ++++++++++++
>>>   1 file changed, 12 insertions(+)
>>>
>>> diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
>>> index 258578ac25..534cc6504d 100644
>>> --- a/arch/arm/mach-imx/spl.c
>>> +++ b/arch/arm/mach-imx/spl.c
>>> @@ -31,6 +31,18 @@ u32 spl_boot_device(void)
>>>       if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
>>>           return BOOT_DEVICE_BOARD;
>>>   +    /*
>>> +     * The above method does not detect that the boot ROM used
>>> +     * serial downloader in case the boot ROM decided to use the
>>> +     * serial downloader as a fall back (primary boot source
>failed).
>>> +     *
>>> +     * Infer that the boot ROM used the USB serial downloader by
>>> +     * checking whether the USB PHY is currently active... This
>>> +     * assumes that SPL did not (yet) initialize the USB PHY...
>>> +     */
>>> +    if (is_otgusb_phy_active())
>
>This is "otgusb", but in sys_proto.h is "usbotg".
>
>Can I fix it myself as "usbotg" by merging ?

Good point, wonder why I did not notice, I usually build it again. Sure go ahead.

--
Stefan

>
>Best regards,
>Stefano
>
>>> +        return BOOT_DEVICE_BOARD;
>>> +
>>>       /* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
>>>       switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
>>>        /* EIM: See 8.5.1, Table 8-9 */
>>>
>> 
>> Reviewed-by: Eric Nelson <eric@nelint.com>

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

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

* [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active
  2017-09-13 21:29 [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Stefan Agner
                   ` (2 preceding siblings ...)
  2017-09-14  5:23 ` [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Eric Nelson
@ 2017-09-20 13:36 ` Stefano Babic
  3 siblings, 0 replies; 11+ messages in thread
From: Stefano Babic @ 2017-09-20 13:36 UTC (permalink / raw)
  To: u-boot

On 13/09/2017 23:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> This macro allows to detect whether the USB PHY is active. This
> is helpful to detect if the boot ROM has previously started the
> USB serial downloader.
> 
> The idea is taken from the mfgtool support in the NXP U-Boot:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/commit/?h=imx_v2016.03_4.1.15_2.0.0_ga&id=a352ed3c5184b95c4c9f7468f5fbb5f43de5e412
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---

Applied to u-boot-imx, thanks !

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

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-13 21:29 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner
  2017-09-14  5:24   ` Eric Nelson
@ 2017-09-20 13:36   ` Stefano Babic
  1 sibling, 0 replies; 11+ messages in thread
From: Stefano Babic @ 2017-09-20 13:36 UTC (permalink / raw)
  To: u-boot

On 13/09/2017 23:29, Stefan Agner wrote:
> From: Stefan Agner <stefan.agner@toradex.com>
> 
> The current mechanism using SCR/GPR registers work well when
> the serial downloader boot mode has been selected explicitly
> (either via boot mode pins or using bmode command). However,
> in case the system entered boot ROM due to unbootable primary
> boot devices (e.g. empty eMMC), the SPL fails to detect that
> it has been downloaded through serial loader and tries to
> continue booting from eMMC:
>   Trying to boot from MMC1
>   mmc_load_image_raw_sector: mmc block read error
>   SPL: failed to boot from all boot devices
>   ### ERROR ### Please RESET the board ###
> 
> The only known way to reliably detect USB serial downloader
> is by checking the USB PHY receiver block power state...
> 
> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
> Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---


Applied to u-boot-imx, thanks !

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

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

* [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably
  2017-09-12 23:54 Stefan Agner
@ 2017-09-12 23:54 ` Stefan Agner
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Agner @ 2017-09-12 23:54 UTC (permalink / raw)
  To: u-boot

From: Stefan Agner <stefan.agner@toradex.com>

The current mechanism using SCR/GPR registers work well when
the serial downloader boot mode has been selected explicitly
(either via boot mode pins or using bmode command). However,
in case the system entered boot ROM due to unbootable primary
boot devices (e.g. empty eMMC), the SPL fails to detect that
it has been downloaded through serial loader and tries to
continue booting from eMMC:
  Trying to boot from MMC1
  mmc_load_image_raw_sector: mmc block read error
  SPL: failed to boot from all boot devices
  ### ERROR ### Please RESET the board ###

The only known way to reliably detect USB serial downloader
is by checking the USB PHY receiver block power state...

Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
Tested-by: Fabio Estevam <fabio.estevam@nxp.com>
---

Changes in v3:
- Fix spelling and grammar

Changes in v2:
- Add comment that we infer boot ROM behavior from USB PHY state

 arch/arm/mach-imx/spl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/arch/arm/mach-imx/spl.c b/arch/arm/mach-imx/spl.c
index 258578ac25..522ab9f260 100644
--- a/arch/arm/mach-imx/spl.c
+++ b/arch/arm/mach-imx/spl.c
@@ -31,6 +31,18 @@ u32 spl_boot_device(void)
 	if (((bmode >> 24) & 0x03) == 0x01) /* Serial Downloader */
 		return BOOT_DEVICE_BOARD;
 
+	/*
+	 * The above method does not detect that the boot ROM used
+	 * serial downloader in case the boot ROM decided to use the
+	 * serial downloader as a fall back (primary boot source failed).
+	 *
+	 * Infer that the boot ROM used the USB serial downloader by
+	 * checking whether the USB PHY is currently active... This
+	 * assumes that SPL did not (yet) initialize the USB PHY...
+	 */
+	if (is_usbphy_active())
+		return BOOT_DEVICE_BOARD;
+
 	/* BOOT_CFG1[7:4] - see IMX6DQRM Table 8-8 */
 	switch ((reg & IMX6_BMODE_MASK) >> IMX6_BMODE_SHIFT) {
 	 /* EIM: See 8.5.1, Table 8-9 */
-- 
2.14.1

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

end of thread, other threads:[~2017-09-20 13:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 21:29 [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Stefan Agner
2017-09-13 21:28 ` Stefan Agner
2017-09-13 21:29 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner
2017-09-14  5:24   ` Eric Nelson
2017-09-18 15:05     ` Stefano Babic
2017-09-18 15:09       ` Stefan Agner
2017-09-20 13:36   ` Stefano Babic
2017-09-14  5:23 ` [U-Boot] [PATCH v3 1/2] imx: add macro to detect whether USB PHY is active Eric Nelson
2017-09-14  6:13   ` Stefan Agner
2017-09-20 13:36 ` Stefano Babic
  -- strict thread matches above, loose matches on Subject: below --
2017-09-12 23:54 Stefan Agner
2017-09-12 23:54 ` [U-Boot] [PATCH v3 2/2] imx_common: detect USB serial downloader reliably Stefan Agner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.