Re: [PATCH 0/4] usb: dwc2: Add USB DRD support on CV1800 Series SoC
From: Inochi Amaoto
Date: Wed Nov 18 2026 - 06:36:41 EST
On Fri, Nov 13, 2026 at 03:23:05PM +0800, Chen-Yu Yeh wrote:
> On Tue, Nov 10, 2026 at 03:06:21PM +0800, Inochi Amaoto wrote:
> > The current DRD implementation of DRD will cause a interrupt flow on
> > CV1800 Series SoC. It has two reasons:
> > 1. The DRD does not sync the phy mode when change the controller mode,
> > it is a violation of the DRD as it does not rely on a OTG phy.
> > 2. The CV1800 is entered with a Session End Detected interrupt, but the
> > DRD code has no change on it, so the controller will enter the
> > interrupt storm.
>
> Thanks, fixing this in dwc2 makes sense to me. I am dropping my PHY
> series [1].
>
> I tested patches 1-3 on a Milk-V Duo 256M (SG2002), on top of
> f66469d9905b, with this on the board DTS:
>
> &usb {
> dr_mode = "otg";
> usb-role-switch;
> role-switch-default-mode = "peripheral";
> status = "okay";
> };
>
> R=/sys/class/usb_role/4340000.usb-role-switch below.
>
> Bare board on a PC, after booting:
>
> # echo device > $R/role
> # devmem 0x03000048 32
> 0x000003C0
> # cat /sys/class/udc/*/state
> configured
>
> PC$ lsusb | grep 0525
> Bus 003 Device 012: ID 0525:a4a2 Netchip Technology, Inc. Linux-USB Ethernet/RNDIS Gadget
>
> # echo host > $R/role
> # devmem 0x04340000 32 (GOTGCTL)
> 0x002C00FC
> # devmem 0x04340004 32 (GOTGINT)
> 0x00000000
>
> The interrupt count did not move over one second in host mode, so no
> storm. Switching back to device gave "configured" again, and "none"
> went back to device. I did one host/device round on each of two boots.
>
> On the USB & Ethernet IO board, with a USB stick plugged in:
>
> # echo host > $R/role
> [ 136.556790] hub 1-1:1.0: 4 ports detected
> [ 136.837392] usb 1-1.1: new high-speed USB device number 3 using dwc2
> [ 139.174764] sda: sda1 sda2 sda3 sda4
>
> GINTMSK 0xF300081E, HPRT0 0x00001005
>
> Tested-by: Chen-Yu Yeh <chenyou910331@xxxxxxxxx> # Milk-V Duo 256M
>
> > Note: This patches set does not resolve all the problems, as
> > usb_add_hcd() will override the role set by dwc2, but I am not
> > sure whether it should change skip_phy_initialization of hcd.
> > So I kept it as it is and users still needs to set the role
> > in the userspace as "role-switch-default-mode" in devicetree
> > takes no effect.
>
> I see the same at boot, and the "set mode" print in the PHY driver
> shows the order:
>
> [ 1.777738] phy phy-3000000.syscon:phy@48.0: set mode 6
> [ 1.778979] phy phy-3000000.syscon:phy@48.0: set mode 5
> [ 1.779005] phy phy-3000000.syscon:phy@48.0: set mode 1
>
> That is PHY_MODE_USB_DEVICE from dwc2_drd_init(), then HOST_SS (not
> supported by the PHY) and HOST from usb_add_hcd(). The PHY ends up in
> host (0x03000048 = 0x142) while the controller is still in device mode
> (GINTSTS = 0x04000020). On the bare board the UDC stays "not attached"
> and the PC sees nothing. On the IO board the hub does not show up
> either. So until a role is written, the port does not work in either
> mode. This was the same on all three boots.
>
> I am happy to test the next versions on the Duo 256M, in both device
> and host mode, and send a Tested-by.
>
If there are no other bug in this patch. There should be no new
version. The device probe problem is not a very big one. And I have
no idea about these thing. Since my time is tight, you are free to
send the fix for the device mode.
> Once your series is merged, would you like me to send the DTS change
> for the Duo 256M, or would you prefer to do it yourself?
>
> [1] https://lore.kernel.org/all/avLC68zOj8WKuslb@inochi.infowork/
>
> Regards,
> Chen-Yu
It depends, if you accept setting this to host, I can add them
at once. (Note: once set, no change will be accepted).
Regards,
Inochi