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 <william.wu@rock-chips.com>
Change-Id: I79074d11773486250cd9ab286eb450826649bfcb
This commit is contained in:
William Wu
2021-12-23 15:27:34 +08:00
committed by Tao Huang
parent 3c5901b19d
commit fedba533e2

View File

@@ -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);