[U-Boot] [PATCH v1 1/2] imx: add macro to detect whether USB has been initialized

Eric Nelson eric at nelint.com
Tue Sep 5 13:45:10 UTC 2017


Hi Stefan,

On 09/04/2017 09:50 PM, Stefan Agner wrote:
> On 2017-09-04 19:57, Eric Nelson wrote:
>> On 09/04/2017 06:21 PM, Stefan Agner wrote:

<snip>

>>> +
>>> +/*
>>> + * If ROM fell back to USB recover mode, USBPH0_PWD will be clear to use USB
>>> + * If boot from the other mode, USB0_PWD will keep reset value
>>> + */
>>> +#define	is_boot_from_usb(void) (!(readl(USB_PHY0_BASE_ADDR) & (1<<20)))
>>> +
>>>    #endif /* __ASSEMBLER__*/
>>>    #endif /* __ASM_ARCH_MX6_IMX_REGS_H__ */
>>>
>> If I'm reading your comment correctly, the RXPWDRX bit will be set (the
>> PHY will be powered down) unless it was enabled by the Boot ROM.
>>
>> Won't this also be clear if you've run 'usb start' under U-Boot?
> 
> Yes, this only works before a USB initialization...
> 

Based on this, I'd recommend changing the macro name to something
like "is_udc_active" to reflect it's true meaning.

> This should be fine for the use case I have in mind (see patch 2).
> 
> Note this idea is borrowed from NXP downstream and seems to work here:
> http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/tree/arch/arm/include/asm/arch-mx7/imx-regs.h?h=imx_v2016.03_4.1.15_2.0.0_ga#n1204
> 

Understood.

Using this detection mechanism in SPL (where there isn't another path
for initializing the UDC) makes sense.

Regards,


Eric


More information about the U-Boot mailing list