Skip to contentSkip to conversation

usb: mtu3: fix USB 3.0 dual-role-switch from device to host

PATCH In review Macpaul Lin 2 participants 2 messages Apr 19, 2022 – Apr 20, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: mtu3: fix USB 3.0 dual-role-switch from device to host

Issue description:
When an OTG port has been switched to device role and then switch back to host role again, the USB 3.0 Host (XHCI) will not be able to detect "plug in event of a connected USB 2.0/1.0 ((Highspeed and Fullspeed) devices until system reboot.

Root cause and Solution:
There is a condition checking flag "ssusb->otg_switch.is_u3_drd" in toggle_opstate(). At the end of role switch procedure, toggle_opstate() will be called to set DC_SESSION and SOFT_CONN bit. If "is_u3_drd" was set and switched the role to USB host 3.0, bit DC_SESSION and SOFT_CONN will be skipped hence caused the port cannot detect connected USB 2.0 (Highspeed and Fullspeed) devices. Simply remove the condition check to solve this issue.

Fixes d0ed062a8b75 ("usb: mtu3: dual-role mode support")
---
 drivers/usb/mtu3/mtu3_dr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/mtu3/mtu3_dr.c +2 -4
index ec6ec621838b..b820724c56e4 100644
@@ -21,10 +21,8 @@ static inline struct ssusb_mtk *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)
 
 static void toggle_opstate(struct ssusb_mtk *ssusb)
 {
-	if (!ssusb->otg_switch.is_u3_drd) {
-		mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
-		mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
-	}
+	mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
+	mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
 }
 
 /* only port0 supports dual-role mode */
Signature · 1 line
2.18.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 49 lines · Macpaul Lin

Issue description:
When an OTG port has been switched to device role and then switch
back
to host role again, the USB 3.0 Host (XHCI) will not be able to
detect
"plug in event of a connected USB 2.0/1.0 ((Highspeed and
Fullspeed)
devices until system reboot.

Root cause and Solution:
There is a condition checking flag "ssusb->otg_switch.is_u3_drd" in toggle_opstate(). At the end of role switch procedure,
toggle_opstate()
will be called to set DC_SESSION and SOFT_CONN bit. If "is_u3_drd"
was
set and switched the role to USB host 3.0, bit DC_SESSION and
SOFT_CONN
will be skipped hence caused the port cannot detect connected USB
2.0
(Highspeed and Fullspeed) devices. Simply remove the condition
check to
solve this issue.

Fixes d0ed062a8b75 ("usb: mtu3: dual-role mode support")
---
 drivers/usb/mtu3/mtu3_dr.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/usb/mtu3/mtu3_dr.c +2 -4
index ec6ec621838b..b820724c56e4 100644
@@ -21,10 +21,8 @@ static inline struct ssusb_mtk
 *otg_sx_to_ssusb(struct otg_switch_mtk *otg_sx)
 
 static void toggle_opstate(struct ssusb_mtk *ssusb)
 {
-	if (!ssusb->otg_switch.is_u3_drd) {
-		mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL,
 DC_SESSION);
-		mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT,
 SOFT_CONN);
-	}
+	mtu3_setbits(ssusb->mac_base, U3D_DEVICE_CONTROL, DC_SESSION);
+	mtu3_setbits(ssusb->mac_base, U3D_POWER_MANAGEMENT, SOFT_CONN);
Quoted 2 lines

}

Thanks

Quoted 1 line

/* only port0 supports dual-role mode */