回复: [PATCH 5/6] usb: dwc3: gadget: Add delay after software writes DCTL in dwc3_gadget_run_stop()
    Mattijs Korpershoek 
    mkorpershoek at kernel.org
       
    Thu Oct  9 14:38:49 CEST 2025
    
    
  
Hi Alice,
On Thu, Oct 09, 2025 at 10:34, "Alice Guo (OSS)" <alice.guo at oss.nxp.com> wrote:
>> -----邮件原件-----
>> 发件人: Mattijs Korpershoek <mkorpershoek at kernel.org>
>> 发送时间: 2025年9月29日 16:47
>> 收件人: Alice Guo (OSS) <alice.guo at oss.nxp.com>; Stefano Babic
>> <sbabic at nabladev.com>; Fabio Estevam <festevam at gmail.com>; dl-uboot-imx
>> <uboot-imx at nxp.com>; Tom Rini <trini at konsulko.com>; Peng Fan
>> <peng.fan at nxp.com>; Troy Kisky <troy.kisky at boundarydevices.com>; Adrian
>> Alonso <adrian.alonso at nxp.com>; Lukasz Majewski <lukma at denx.de>; Mattijs
>> Korpershoek <mkorpershoek at kernel.org>; Marek Vasut <marex at denx.de>;
>> tharvey at gateworks.com; Alice Guo <alice.guo at nxp.com>
>> 抄送: u-boot at lists.denx.de
>> 主题: Re: [PATCH 5/6] usb: dwc3: gadget: Add delay after software writes DCTL
>> in dwc3_gadget_run_stop()
>> 
>> Hi Alice,
>> 
>> Thank you for the patch.
>> 
>> On Sun, Jul 20, 2025 at 06:13, "Alice Guo (OSS)" <alice.guo at oss.nxp.com>
>> wrote:
>> 
>> > From: Alice Guo <alice.guo at nxp.com>
>> >
>> > When using NXP UUU to download flash.bin to i.MX95 19x19 evk board, it
>> > will get stuck in a loop at sdp_init() without this change.
>> >
>> > Signed-off-by: Alice Guo <alice.guo at nxp.com>
>> 
>> I see that a similar change exist in the Linux kernel:
>> https://lore.kernel.org/all/20220901193625.8727-4-quic_wcheng@quicinc.com
>> /
>> 
>> Please mention this change in the commit message for v2.
>> See the following example:
>> https://lore.kernel.org/all/20250110-dwc2-dev-v4-7-987f4fd6f8b2@pigmoral.te
>> ch/
>> 
>> > ---
>> >  drivers/usb/dwc3/gadget.c | 1 +
>> >  1 file changed, 1 insertion(+)
>> >
>> > diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>> > index 2b01113d54c..6b2b25c7aa5 100644
>> > --- a/drivers/usb/dwc3/gadget.c
>> > +++ b/drivers/usb/dwc3/gadget.c
>> > @@ -1423,6 +1423,7 @@ static int dwc3_gadget_run_stop(struct dwc3 *dwc,
>> int is_on, int suspend)
>> >  	}
>> >
>> >  	dwc3_writel(dwc->regs, DWC3_DCTL, reg);
>> > +	mdelay(2);
>> 
>> Can you elaborate on why 1ms is not enough?
>> 
>
> Apologies for the confusion that I previously replay this email from the wrong email address.
>
> Hi Mattijs,
>
> Apologies for the confusion that I previously replay this email from the wrong email address.
No worries.
>
> This patch I submitted was indeed inspired by the change you mentioned in the Linux kernel. The mdelay(2) value was determined empirically during testing on our development board.
>
> However, after a deeper understanding of the driver, I believe the real root cause is that the USB3 PHY was not properly initialized. When DWC3 is configured to DWC3_DSTS_SUPERSPEED in dwc3_gadget_start(), enumeration fails because the PHY is not ready and cannot complete the electrical and protocol-level handshake required by USB 3.0. The delay acts as a workaround to compensate for the missing hardware initialization or timing issues. Once the PHY driver (phy-imx8mq-usb.c) is added and properly initializes the USB3 PHY, the delay is no longer needed.
>
> The updated changes are included in the patch set titled "Enable USB and ENETC on i.MX943 EVK", specifically in patch 6 and patch 7:
> https://patchwork.ozlabs.org/project/uboot/patch/20250923-usbnetc-v1-6-507cddbe7214@oss.nxp.com/
> https://patchwork.ozlabs.org/project/uboot/patch/20250923-usbnetc-v1-7-507cddbe7214@oss.nxp.com/
>
> Thanks for the feedback!
I see, thanks for taking the time answer me. And glad you could solve
this properly by enabling the PHY driver.
>
> Best regards,
> Alice Guo
    
    
More information about the U-Boot
mailing list