For new IP version DWC3_REVISION_330A or above, current code only allows dual role if role-switch is used, those IP w/o OTG only removes OTG block but dual role should be capable so don't limit dual role, user may use debugfs or any other way to switch role. Signed-off-by: Li Jun <jun.li@xxxxxxx> --- drivers/usb/dwc3/core.c | 11 ----------- drivers/usb/dwc3/drd.c | 10 +++++++++- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 75ee602..e4e473f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -78,17 +78,6 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc) mode = USB_DR_MODE_HOST; else if (IS_ENABLED(CONFIG_USB_DWC3_GADGET)) mode = USB_DR_MODE_PERIPHERAL; - - /* - * 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 && - (!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; } if (mode != dwc->dr_mode) { diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index a24c6c0..4281e96 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -587,7 +587,7 @@ int dwc3_drd_init(struct dwc3 *dwc) } dwc3_drd_update(dwc); - } else { + } else if (!dwc3_is_usb31(dwc) && dwc->revision < DWC3_REVISION_330A) { dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_OTG); dwc->current_dr_role = DWC3_GCTL_PRTCAP_OTG; @@ -615,6 +615,14 @@ int dwc3_drd_init(struct dwc3 *dwc) dwc3_otg_init(dwc); dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_OTG); + } else { + /* + * DWC_usb3 dwc_usb31, 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 + * default role to be peripheral. + */ + dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE); } return 0; -- 2.7.4