usb: dwc3: Add role switch reset quirk for Apple DWC3
authorSven Peter <sven@svenpeter.dev>
Sun, 7 Nov 2021 10:21:20 +0000 (11:21 +0100)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Mar 2022 17:35:23 +0000 (10:35 -0700)
commit1e2d46b135e507d79f3cac802e443b8e558543df
tree70a4df1927499832bf5707638244e8c4e3038159
parent2da2a60c0a23c07daee143c598ad884f4c9e4d9a
usb: dwc3: Add role switch reset quirk for Apple DWC3

As mad as it sounds, the dwc3 controller present on the Apple M1 must be
reset and reinitialized whenever a device is unplugged from the root port.
The only reliable unplug/plug notification available comes from the USB
PD controller through the role-switch infrastructure.

This is required for at least two reasons:

  - The USB2 D+/D- lines are connected through a stateful eUSB2 repeater
    which in turn is controlled by a variant of the TI TPS6598x USB PD
    chip. When the USB PD controller detects a hotplug event it resets
    the eUSB2 repeater. Afterwards, no new device is recognized before
    the DWC3 core and PHY are reset as well.

  - It's possible to completely break the dwc3 controller by switching
    it to device mode and unplugging the cable at just the wrong time.
    Even a CORESOFTRESET is not enough to allow new devices again.
    The only workaround is to trigger a hard reset of the entire
    dwc3 core.

Signed-off-by: Sven Peter <sven@svenpeter.dev>
drivers/usb/dwc3/core.c
drivers/usb/dwc3/core.h
drivers/usb/dwc3/drd.c