armbian-build/patch/kernel/archive/rockchip-6.18/patches.armbian/general-dwc2-fix-wait-time.patch
Igor Pecovnik ae085455e3 dwc2: explicitly force host mode for USB_DR_MODE_HOST
- Add dwc2_force_mode(hsotg, true) call in USB_DR_MODE_HOST case
- Ensures proper host mode initialization for Rockchip platforms
- Applies to both 6.18 and 6.19 kernel patches
2026-03-04 21:44:10 +01:00

61 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Wu <william.wu@rock-chips.com>
Date: Tue, 6 Dec 2022 14:45:54 +0800
Subject: 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
---
drivers/usb/dwc2/core.c | 14 ++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/dwc2/core.c b/drivers/usb/dwc2/core.c
index 111111111111..222222222222 100644
--- a/drivers/usb/dwc2/core.c
+++ b/drivers/usb/dwc2/core.c
@@ -579,14 +579,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:
dwc2_force_mode(hsotg, true);
/*
* 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:
--
Armbian