Skip to content

Commit eef91cd

Browse files
committed
phy: apple: atc: Initialize USB2 PHY for host mode during probe
Now that the upstream Type-C PHY code is getting wider testing we got reports of USB devices plugged in during boot or those plugged in for the first time after boot occasionally not working correctly. For yet to determined reasons this issue disappears if the USB2 PHY is brought up for USB host mode once during probe. This could be related to the bootloader (m1n1) initializing the USB-C ports for device mode in our test environment. On the other hand Sven has discovered that MacOS sets dwc3 (but not xhci) up and tears it immediately down during boot even if no device is connected. Reported-by: James Calligeros <jcalligeros99@gmail.com> Reported-by: Sven Peter <sven@kernel.org> Fixes: 8e98ca1 ("phy: apple: Add Apple Type-C PHY") Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 99a157d commit eef91cd

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

drivers/phy/apple/atc.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,12 +1788,8 @@ static int atcphy_configure(struct apple_atcphy *atcphy, enum atcphy_mode mode)
17881788
return 0;
17891789
}
17901790

1791-
static int atcphy_usb2_set_mode(struct phy *phy, enum phy_mode mode, int submode)
1791+
static int _atcphy_usb2_set_mode(struct apple_atcphy *atcphy, enum phy_mode mode)
17921792
{
1793-
struct apple_atcphy *atcphy = phy_get_drvdata(phy);
1794-
1795-
guard(mutex)(&atcphy->lock);
1796-
17971793
switch (mode) {
17981794
case PHY_MODE_USB_HOST:
17991795
set32(atcphy->regs.usb2phy + USB2PHY_SIG, USB2PHY_SIG_HOST);
@@ -1808,6 +1804,15 @@ static int atcphy_usb2_set_mode(struct phy *phy, enum phy_mode mode, int submode
18081804
return 0;
18091805
}
18101806

1807+
static int atcphy_usb2_set_mode(struct phy *phy, enum phy_mode mode, int submode)
1808+
{
1809+
struct apple_atcphy *atcphy = phy_get_drvdata(phy);
1810+
1811+
guard(mutex)(&atcphy->lock);
1812+
1813+
return _atcphy_usb2_set_mode(atcphy, mode);
1814+
}
1815+
18111816
static const struct phy_ops apple_atc_usb2_phy_ops = {
18121817
.owner = THIS_MODULE,
18131818
.set_mode = atcphy_usb2_set_mode,
@@ -2226,6 +2231,14 @@ static int atcphy_probe_finalize(struct apple_atcphy *atcphy)
22262231
/* Reset dwc3 on probe, let dwc3 (consumer) deassert it */
22272232
_atcphy_dwc3_reset_assert(atcphy);
22282233

2234+
/*
2235+
* Bring the USB2 up once in host mode. For not yet understood reasons
2236+
* this avoids not detecting USB devices on the initial cold or hot
2237+
* plug.
2238+
*/
2239+
atcphy_usb2_power_on(atcphy);
2240+
_atcphy_usb2_set_mode(atcphy, PHY_MODE_USB_HOST);
2241+
22292242
/* Reset atcphy to clear any state potentially left by the bootloader */
22302243
atcphy_usb2_power_off(atcphy);
22312244
atcphy_power_off(atcphy);

0 commit comments

Comments
 (0)