usb: dwc3: allow dual role switch by defautl for new IP w/o OTG
Subsystems (2)
PATCH 1/1 usb: dwc3: allow dual role switch by defautl for new IP w/o OTG
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.
--- drivers/usb/dwc3/core.c | 11 ----------- drivers/usb/dwc3/drd.c | 10 +++++++++- 2 files changed, 9 insertions(+), 12 deletions(-)
drivers/usb/dwc3/core.c +0 -11
@@ -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) {
drivers/usb/dwc3/drd.c +9 -1
@@ -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 ;
Signature · 1 line
2.7.4
Hi,
Quoted 4 lines · Li Jun
For new IP version
DWC3_REVISION_330Aor 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.
then you need to compile your kernel with support for Dual Role. This patch is the wrong way to go.
Signature · 1 line
balbi
Hi,
Quoted 12 lines
-----Original Message-----
From: Felipe Balbi <[email protected]> On Behalf Of Felipe Balbi
Sent: 2020年5月14日 18:51
To: Jun Li <[email protected]>
Cc: [email protected]; [email protected]; Peter Chen <[email protected]>; dl-linux-imx <[email protected]>
Subject: Re: [PATCH] usb: dwc3: allow dual role switch by defautl for new IP w/o OTGHi,
Quoted 8 lines
Quoted 4 lines · Li Jun
For new IP version
DWC3_REVISION_330Aor 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.then you need to compile your kernel with support for Dual Role. This patch is the wrong way to go.
I am not sure I catch your point.
For dwc3, the change intention is to make the port to be still dual role( don't force dwc->dr_mode to be USB_DR_MODE_PERIPHERAL, but still keep it to be USB_DR_MODE_OTG) in this case. so need compile the kernel with CONFIG_USB_DWC3_DUAL_ROLE enabled is reasonable.
Li Jun
Quoted 3 lines
--
balbi