Role Switch Driver on DWC3
Subsystems (2)
Hi,
As per my understanding, role switch interface for DWC3 controller will be called in dwc3_drd_init.
However, dwc3_drd_init is called only if mode is USB_DR_MODE_OTG. However for USB3 V3.3 and above the following code exists.
/*
* DWC_usb31 and DWC_usb3 v3.30a and higher do not support OTG
* mode. If the controller supports DRD but the dr_mode is not
* specified or set to OTG, then set the mode to peripheral. */
if (mode == USB_DR_MODE_OTG &&
dwc->revision >= DWC3_REVISION_330A)
mode = USB_DR_MODE_PERIPHERAL;
}
Hence, in this case role switch interface will never will be called.
Please clear my understanding, and in such case how can i use the role switch driver?
Regards
Nehal Shah
Shah, Nehal-bakulchandra <[email protected]>
Quoted 17 lines · 于2020年7月8日周三 下午7:44写道:
Hi,
As per my understanding, role switch interface for DWC3 controller will be called in
dwc3_drd_init.However,
dwc3_drd_initis called only if mode isUSB_DR_MODE_OTG. However for USB3 V3.3 and above the following code exists./*
* DWC_usb31 and DWC_usb3 v3.30a and higher do not support OTG * mode. If the controller supports DRD but the dr_mode is not * specified or set to OTG, then set the mode to peripheral. */ if (mode == USB_DR_MODE_OTG && dwc->revision >= DWC3_REVISION_330A) mode = USB_DR_MODE_PERIPHERAL; }
Quoted 4 lines
Hence, in this case role switch interface will never will be called.
Please clear my understanding, and in such case how can i use the role switch driver?
This has been changed by below commit:
commit 8bb14308a86970a2321ac7d0e28ea0f1f1e744b0
Author: Thinh Nguyen <[email protected]> Date: Sun Mar 29 17:10:05 2020 -0700
usb: dwc3: core: Use role-switch default dr_mode
If the driver is configured to use DRD role-switch, let the drd code path decide the default dr_mode.
drivers/usb/dwc3/core.c +2 -0
@@ -85,6 +85,8 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)* specified or set to OTG, then set the mode to peripheral. */ if (mode ==USB_DR_MODE_OTG && + (!IS_ENABLED (CONFIG_USB_ROLE_SWITCH ) || + !device_property_read_bool (dwc->dev,"usb-role-switch" )) && dwc->revision >=DWC3_REVISION_330A ) mode =USB_DR_MODE_PERIPHERAL ; }
Quoted 7 lines
Regards
Nehal Shah