Files
build/patch/kernel/archive/rockchip64-6.16/rk3399-usbc-usb-dwc3-Extend-reset-quirk-support-to-include-role-.patch
hyx0329 6e39531b62 rockchip64-6.16: Partial fix of DP alt mode on some rk3399 boards
The old method carried along with board-pbp-add-dp-alt-mode.patch only
makes typec work in one(normal) orientation. This patch introduces a
proper extcon driver and makes the workaround cleaner, so orientation
switch is working.

Improvements:
- type-c DP on rk3399 works with both orientations
- type-c USB 3.0 on rk3399 works with both orientations, with minor
  issues, see below

Caveats:
- Powered USB-C hubs may be not recognized, and can be worked around by
  loading a gadget driver, or manually toggling the mode once for each
  connection.
- Some dual-role devices(phone, tablet) may be not recognized.

Affected boards:
- TinkerBoard 2/2S
- Pinebook Pro
- NanoPC T4
- Orange Pi 4
- Orange Pi 4 LTS

Tested on tinkerboard 2s. This patch contains other minor fixes for
tinker2's device tree, including adding a missing fan node, adding color
labels to leds.

The 2 patches adding dp support for nanopc t4 and pinebook pro are also
updated accordingly.

The device trees of Orange Pi 4 / 4 LTS are also updated to match the
new implementation.
2025-07-02 12:12:05 +02:00

58 lines
1.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ondrej Jirman <megi@xff.cz>
Date: Sat, 2 Mar 2024 14:33:21 +0100
Subject: usb: dwc3: Extend reset quirk support to include role-switch
Originally my reset quirk patch only supported extcon mode changes
via extcon interface. Support role-switch, too.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/usb/dwc3/drd.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/dwc3/drd.c b/drivers/usb/dwc3/drd.c
index 111111111111..222222222222 100644
--- a/drivers/usb/dwc3/drd.c
+++ b/drivers/usb/dwc3/drd.c
@@ -458,7 +458,7 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw,
enum usb_role role)
{
struct dwc3 *dwc = usb_role_switch_get_drvdata(sw);
- u32 mode;
+ u32 mode = DWC3_GCTL_PRTCAP_DEVICE_DISCONNECTED;
switch (role) {
case USB_ROLE_HOST:
@@ -468,6 +468,8 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw,
mode = DWC3_GCTL_PRTCAP_DEVICE;
break;
default:
+ if (dwc->usb3_phy_reset_quirk)
+ break;
if (dwc->role_switch_default_mode == USB_DR_MODE_HOST)
mode = DWC3_GCTL_PRTCAP_HOST;
else
@@ -487,6 +489,9 @@ static enum usb_role dwc3_usb_role_switch_get(struct usb_role_switch *sw)
spin_lock_irqsave(&dwc->lock, flags);
switch (dwc->current_dr_role) {
+ case DWC3_GCTL_PRTCAP_DEVICE_DISCONNECTED:
+ role = USB_ROLE_NONE;
+ break;
case DWC3_GCTL_PRTCAP_HOST:
role = USB_ROLE_HOST;
break;
@@ -518,6 +523,8 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
} else {
dwc->role_switch_default_mode = USB_DR_MODE_PERIPHERAL;
mode = DWC3_GCTL_PRTCAP_DEVICE;
+ if (dwc->usb3_phy_reset_quirk)
+ mode = DWC3_GCTL_PRTCAP_DEVICE_DISCONNECTED;
}
dwc3_set_mode(dwc, mode);
--
Armbian