Re: [RFC/PATCH 1/2] usb: dwc3: disable for USB_ROLE_NONE
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Date: 2025-07-12 00:12:02
Also in:
linux-phy, linux-rockchip, linux-usb, lkml
On Thu, Jul 10, 2025, John Keeping wrote:
When the phy is acting as a Type C mux, it may need to reset when the cable direction changes. But this should not happen while DWC3 is trying to use the USB connection. In this case, there must be a connection manager to notify the phy of the orientation change and tcpm_mux_set() ensures this happens before DWC3's role switch is informed of a change. It should not be possible to go directly from device->device or host->host with a change in orientation without transitioning through the "none" role as the cable is unplugged. So ensuring that DWC3 always
The controller is either host or device mode. It's odd to use "none" to indicate connection.
informs the phy of the new mode whenever a plug is detected should be sufficient for the phy to safely reset itself at a time that is safe for DWC3.
Couldn't the phy do this as it detects connection/disconnection. It seems what you need is a full controller initialization upon new connection on orientation change, and you're using role_switch selecting "none" to do so. I'm not sure if role-switch has the right interface to do so. Perhaps we can introduce one? I don't think we should change the behavior of the current flow and apply that to all other platforms. Thanks, Thinh
Lifting the special-case for desired_dr_mode==0 in __dwc3_set_mode() is sufficient to allow using the unset mode for USB_ROLE_NONE. The handling already disables the old mode and then simply does not enable a new one. If an external device is notifying USB role switches, then it is not necessary to set the default role when USB_ROLE_NONE is passed.