Skip to content

Commit 07ad580

Browse files
committed
usb: dwc3: apple: Ignore USB role switches to the current role
Ignore USB role switches if dwc3-apple is already in the desired role. The USB-C port controller on M2 and M1/M2 Pro/Max/Ultra devices receives additional interrupts which result in usb_role_switch_set_role() calls with the current role. Ignore these USB role switches to ensure a consistent state between tipd and dwc3-apple. This matches the behaviour in __dwc3_set_mode() in core.c. This fixes connecting USB2 and USB3 device without DP-altmode on Apple silicon systems with M2 or M1/M2 Pro/Max/Ultra. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent d83af04 commit 07ad580

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/usb/dwc3/dwc3-apple.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,23 @@ static int dwc3_usb_role_switch_set(struct usb_role_switch *sw, enum usb_role ro
339339

340340
guard(mutex)(&appledwc->lock);
341341

342+
/*
343+
* Skip role switches if appledwc is already in the desired state. The
344+
* USB-C port controller on M2 and M1/M2 Pro/Max/Ultra issues additional
345+
* interrupts which result in usb_role_switch_set_role() calls with the
346+
* current role. To ensure a consistent state it seems preferable to
347+
* ignore those calls here instead of suppressing them in tipd.
348+
* This matches the behaviour in __dwc3_set_mode().
349+
*/
350+
if (appledwc->state == DWC3_APPLE_HOST && role == USB_ROLE_HOST)
351+
return 0;
352+
if (appledwc->state == DWC3_APPLE_DEVICE && role == USB_ROLE_DEVICE)
353+
return 0;
354+
if ((appledwc->state == DWC3_APPLE_NO_CABLE ||
355+
appledwc->state == DWC3_APPLE_PROBE_PENDING) &&
356+
role == USB_ROLE_NONE)
357+
return 0;
358+
342359
/*
343360
* We need to tear all of dwc3 down and re-initialize it every time a cable is
344361
* connected or disconnected or when the mode changes. See the documentation for enum

0 commit comments

Comments
 (0)