From fedba533e2af44f5aec0dd12a97f52008ce9c291 Mon Sep 17 00:00:00 2001 From: William Wu Date: Thu, 23 Dec 2021 15:27:34 +0800 Subject: [PATCH] usb: dwc3: drd: fix device mode for rockchip platform On some Rockchip platforms (e.g RK3588 EVB2), the USB interface is Type-A USB 3.0 with vbus always on. In this case, the USB PHY may fail to send extcon notifier to dwc3, and the desired_role_sw_mode is uninitialized. So we need to initialize the desired_role_sw_mode which depends on the id status during dwc3 probe. Signed-off-by: William Wu Change-Id: I79074d11773486250cd9ab286eb450826649bfcb --- drivers/usb/dwc3/drd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c index f50255a71770..43340ea7be53 100644 --- a/drivers/usb/dwc3/drd.c +++ b/drivers/usb/dwc3/drd.c @@ -420,6 +420,12 @@ static void dwc3_drd_update(struct dwc3 *dwc) id = extcon_get_state(dwc->edev, EXTCON_USB_HOST); if (id < 0) id = 0; + +#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI) + dwc->desired_role_sw_mode = (id ? USB_DR_MODE_HOST : + USB_DR_MODE_PERIPHERAL); +#endif + dwc3_set_mode(dwc, id ? DWC3_GCTL_PRTCAP_HOST : DWC3_GCTL_PRTCAP_DEVICE);