usb: dwc2: fix waiting time for host only mode

The current code uses 50ms sleep to wait for host only
mode, the delay time is not enough for some Rockchip
platforms (e.g RK3036G EVB1).

Test on RK3036G EVB1, the dwc2 host only controller reg
GOTGCTL.ConIDSts = 1'b1 (device mode) if only wait for
50ms. And the host fails to detect usb2 device with the
following error log:

usb usb2-port1: connect-debounce failed

This patch checks the GOTGCTL.ConIDSts for host only
mode and increases the maximum waiting time to 200ms.

Signed-off-by: William Wu <william.wu@rock-chips.com>
Change-Id: Ie28299934aba09907ea08f5fd3b34bf2fb35822e
This commit is contained in:
William Wu
2022-12-06 14:45:54 +08:00
committed by Tao Huang
parent 7a22993077
commit ee7c3ab6b5

View File

@@ -656,14 +656,24 @@ static void dwc2_clear_force_mode(struct dwc2_hsotg *hsotg)
*/
void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg)
{
u32 count = 0;
switch (hsotg->dr_mode) {
case USB_DR_MODE_HOST:
/*
* NOTE: This is required for some rockchip soc based
* platforms on their host-only dwc2.
*/
if (!dwc2_hw_is_otg(hsotg))
msleep(50);
if (!dwc2_hw_is_otg(hsotg)) {
while (dwc2_readl(hsotg, GOTGCTL) & GOTGCTL_CONID_B) {
msleep(20);
if (++count > 10)
break;
}
if (count > 10)
dev_err(hsotg->dev,
"Waiting for Host Mode timed out");
}
break;
case USB_DR_MODE_PERIPHERAL: