Skip to content

Commit 451e45d

Browse files
committed
Revert "usb: dwc3: core: Prevent phy suspend during init"
This reverts commit 6d73572. This breaks USB3 on Apple silicon systems and manifests in | phy-apple-atc b03000000.phy: pipehandler lock not acked, this type-c port is probably dead until the next reboot. Revert for now as the ATC phy initialization is due a rewrite. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent a520c6d commit 451e45d

4 files changed

Lines changed: 52 additions & 68 deletions

File tree

drivers/usb/dwc3/core.c

Lines changed: 52 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -104,27 +104,6 @@ static int dwc3_get_dr_mode(struct dwc3 *dwc)
104104
return 0;
105105
}
106106

107-
void dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
108-
{
109-
u32 reg;
110-
111-
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
112-
if (enable && !dwc->dis_u3_susphy_quirk)
113-
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
114-
else
115-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
116-
117-
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
118-
119-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
120-
if (enable && !dwc->dis_u2_susphy_quirk)
121-
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
122-
else
123-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
124-
125-
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
126-
}
127-
128107
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
129108
{
130109
u32 reg;
@@ -628,8 +607,11 @@ static int dwc3_core_ulpi_init(struct dwc3 *dwc)
628607
*/
629608
static int dwc3_phy_setup(struct dwc3 *dwc)
630609
{
610+
unsigned int hw_mode;
631611
u32 reg;
632612

613+
hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
614+
633615
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
634616

635617
/*
@@ -639,16 +621,21 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
639621
reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX;
640622

641623
/*
642-
* Above DWC_usb3.0 1.94a, it is recommended to set
643-
* DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration.
644-
* So default value will be '0' when the core is reset. Application
645-
* needs to set it to '1' after the core initialization is completed.
646-
*
647-
* Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be
648-
* cleared after power-on reset, and it can be set after core
649-
* initialization.
624+
* Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
625+
* to '0' during coreConsultant configuration. So default value
626+
* will be '0' when the core is reset. Application needs to set it
627+
* to '1' after the core initialization is completed.
650628
*/
651-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
629+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
630+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
631+
632+
/*
633+
* For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be cleared after
634+
* power-on reset, and it can be set after core initialization, which is
635+
* after device soft-reset during initialization.
636+
*/
637+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
638+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
652639

653640
if (dwc->u2ss_inp3_quirk)
654641
reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
@@ -674,6 +661,9 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
674661
if (dwc->tx_de_emphasis_quirk)
675662
reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
676663

664+
if (dwc->dis_u3_susphy_quirk)
665+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
666+
677667
if (dwc->dis_del_phy_power_chg_quirk)
678668
reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
679669

@@ -721,15 +711,24 @@ static int dwc3_phy_setup(struct dwc3 *dwc)
721711
}
722712

723713
/*
724-
* Above DWC_usb3.0 1.94a, it is recommended to set
725-
* DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration.
726-
* So default value will be '0' when the core is reset. Application
727-
* needs to set it to '1' after the core initialization is completed.
728-
*
729-
* Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared
730-
* after power-on reset, and it can be set after core initialization.
714+
* Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
715+
* '0' during coreConsultant configuration. So default value will
716+
* be '0' when the core is reset. Application needs to set it to
717+
* '1' after the core initialization is completed.
718+
*/
719+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
720+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
721+
722+
/*
723+
* For DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared after
724+
* power-on reset, and it can be set after core initialization, which is
725+
* after device soft-reset during initialization.
731726
*/
732-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
727+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
728+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
729+
730+
if (dwc->dis_u2_susphy_quirk)
731+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
733732

734733
if (dwc->dis_enblslpm_quirk)
735734
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
@@ -1250,6 +1249,21 @@ static int dwc3_core_init(struct dwc3 *dwc)
12501249
if (ret)
12511250
goto err_exit_phy;
12521251

1252+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD &&
1253+
!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {
1254+
if (!dwc->dis_u3_susphy_quirk) {
1255+
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
1256+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
1257+
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
1258+
}
1259+
1260+
if (!dwc->dis_u2_susphy_quirk) {
1261+
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
1262+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
1263+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
1264+
}
1265+
}
1266+
12531267
dwc3_core_setup_global_control(dwc);
12541268
dwc3_core_num_eps(dwc);
12551269

drivers/usb/dwc3/core.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,6 @@ int dwc3_event_buffers_setup(struct dwc3 *dwc);
15831583
void dwc3_event_buffers_cleanup(struct dwc3 *dwc);
15841584

15851585
int dwc3_core_soft_reset(struct dwc3 *dwc);
1586-
void dwc3_enable_susphy(struct dwc3 *dwc, bool enable);
15871586

15881587
#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
15891588
int dwc3_host_init(struct dwc3 *dwc);

drivers/usb/dwc3/gadget.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,7 +2924,6 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
29242924
dwc3_ep0_out_start(dwc);
29252925

29262926
dwc3_gadget_enable_irq(dwc);
2927-
dwc3_enable_susphy(dwc, true);
29282927

29292928
return 0;
29302929

@@ -4691,7 +4690,6 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
46914690
if (!dwc->gadget)
46924691
return;
46934692

4694-
dwc3_enable_susphy(dwc, false);
46954693
usb_del_gadget(dwc->gadget);
46964694
dwc3_gadget_free_endpoints(dwc);
46974695
usb_put_gadget(dwc->gadget);

drivers/usb/dwc3/host.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@
1010
#include <linux/irq.h>
1111
#include <linux/of.h>
1212
#include <linux/platform_device.h>
13-
#include <linux/usb.h>
14-
#include <linux/usb/hcd.h>
1513

1614
#include "../host/xhci-port.h"
1715
#include "../host/xhci-ext-caps.h"
1816
#include "../host/xhci-caps.h"
19-
#include "../host/xhci-plat.h"
2017
#include "core.h"
2118

2219
#define XHCI_HCSPARAMS1 0x4
@@ -60,24 +57,6 @@ static void dwc3_power_off_all_roothub_ports(struct dwc3 *dwc)
6057
}
6158
}
6259

63-
static void dwc3_xhci_plat_start(struct usb_hcd *hcd)
64-
{
65-
struct platform_device *pdev;
66-
struct dwc3 *dwc;
67-
68-
if (!usb_hcd_is_primary_hcd(hcd))
69-
return;
70-
71-
pdev = to_platform_device(hcd->self.controller);
72-
dwc = dev_get_drvdata(pdev->dev.parent);
73-
74-
dwc3_enable_susphy(dwc, true);
75-
}
76-
77-
static const struct xhci_plat_priv dwc3_xhci_plat_quirk = {
78-
.plat_start = dwc3_xhci_plat_start,
79-
};
80-
8160
static void dwc3_host_fill_xhci_irq_res(struct dwc3 *dwc,
8261
int irq, char *name)
8362
{
@@ -188,11 +167,6 @@ int dwc3_host_init(struct dwc3 *dwc)
188167
}
189168
}
190169

191-
ret = platform_device_add_data(xhci, &dwc3_xhci_plat_quirk,
192-
sizeof(struct xhci_plat_priv));
193-
if (ret)
194-
goto err;
195-
196170
ret = platform_device_add(xhci);
197171
if (ret) {
198172
dev_err(dwc->dev, "failed to register xHCI device\n");
@@ -218,7 +192,6 @@ void dwc3_host_exit(struct dwc3 *dwc)
218192
if (dwc->sys_wakeup)
219193
device_init_wakeup(&dwc->xhci->dev, false);
220194

221-
dwc3_enable_susphy(dwc, false);
222195
platform_device_unregister(dwc->xhci);
223196
dwc->xhci = NULL;
224197
}

0 commit comments

Comments
 (0)