Skip to content

Commit cf3f8d0

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 6c15ed1 commit cf3f8d0

4 files changed

Lines changed: 52 additions & 73 deletions

File tree

drivers/usb/dwc3/core.c

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

108-
void dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
109-
{
110-
u32 reg;
111-
int i;
112-
113-
for (i = 0; i < dwc->num_usb3_ports; i++) {
114-
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(i));
115-
if (enable && !dwc->dis_u3_susphy_quirk)
116-
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
117-
else
118-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
119-
120-
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(i), reg);
121-
}
122-
123-
for (i = 0; i < dwc->num_usb2_ports; i++) {
124-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(i));
125-
if (enable && !dwc->dis_u2_susphy_quirk)
126-
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
127-
else
128-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
129-
130-
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(i), reg);
131-
}
132-
}
133-
134108
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
135109
{
136110
u32 reg;
@@ -664,8 +638,11 @@ static int dwc3_core_ulpi_init(struct dwc3 *dwc)
664638

665639
static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
666640
{
641+
unsigned int hw_mode;
667642
u32 reg;
668643

644+
hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
645+
669646
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(index));
670647

671648
/*
@@ -675,16 +652,21 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
675652
reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX;
676653

677654
/*
678-
* Above DWC_usb3.0 1.94a, it is recommended to set
679-
* DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration.
680-
* So default value will be '0' when the core is reset. Application
681-
* needs to set it to '1' after the core initialization is completed.
682-
*
683-
* Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be
684-
* cleared after power-on reset, and it can be set after core
685-
* initialization.
655+
* Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
656+
* to '0' during coreConsultant configuration. So default value
657+
* will be '0' when the core is reset. Application needs to set it
658+
* to '1' after the core initialization is completed.
659+
*/
660+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
661+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
662+
663+
/*
664+
* For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be cleared after
665+
* power-on reset, and it can be set after core initialization, which is
666+
* after device soft-reset during initialization.
686667
*/
687-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
668+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
669+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
688670

689671
if (dwc->u2ss_inp3_quirk)
690672
reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
@@ -710,6 +692,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
710692
if (dwc->tx_de_emphasis_quirk)
711693
reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
712694

695+
if (dwc->dis_u3_susphy_quirk)
696+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
697+
713698
if (dwc->dis_del_phy_power_chg_quirk)
714699
reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
715700

@@ -764,15 +749,24 @@ static int dwc3_hs_phy_setup(struct dwc3 *dwc, int index)
764749
}
765750

766751
/*
767-
* Above DWC_usb3.0 1.94a, it is recommended to set
768-
* DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration.
769-
* So default value will be '0' when the core is reset. Application
770-
* needs to set it to '1' after the core initialization is completed.
771-
*
772-
* Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared
773-
* after power-on reset, and it can be set after core initialization.
752+
* Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
753+
* '0' during coreConsultant configuration. So default value will
754+
* be '0' when the core is reset. Application needs to set it to
755+
* '1' after the core initialization is completed.
756+
*/
757+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
758+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
759+
760+
/*
761+
* For DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared after
762+
* power-on reset, and it can be set after core initialization, which is
763+
* after device soft-reset during initialization.
774764
*/
775-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
765+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
766+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
767+
768+
if (dwc->dis_u2_susphy_quirk)
769+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
776770

777771
if (dwc->dis_enblslpm_quirk)
778772
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
@@ -1371,6 +1365,21 @@ static int dwc3_core_init(struct dwc3 *dwc)
13711365
if (ret)
13721366
goto err_exit_phy;
13731367

1368+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD &&
1369+
!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {
1370+
if (!dwc->dis_u3_susphy_quirk) {
1371+
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
1372+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
1373+
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
1374+
}
1375+
1376+
if (!dwc->dis_u2_susphy_quirk) {
1377+
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
1378+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
1379+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
1380+
}
1381+
}
1382+
13741383
dwc3_core_setup_global_control(dwc);
13751384
dwc3_core_num_eps(dwc);
13761385

drivers/usb/dwc3/core.h

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

16071607
int dwc3_core_soft_reset(struct dwc3 *dwc);
1608-
void dwc3_enable_susphy(struct dwc3 *dwc, bool enable);
16091608

16101609
#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
16111610
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
@@ -2915,7 +2915,6 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
29152915
dwc3_ep0_out_start(dwc);
29162916

29172917
dwc3_gadget_enable_irq(dwc);
2918-
dwc3_enable_susphy(dwc, true);
29192918

29202919
return 0;
29212920

@@ -4682,7 +4681,6 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
46824681
if (!dwc->gadget)
46834682
return;
46844683

4685-
dwc3_enable_susphy(dwc, false);
46864684
usb_del_gadget(dwc->gadget);
46874685
dwc3_gadget_free_endpoints(dwc);
46884686
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
{
@@ -190,11 +169,6 @@ int dwc3_host_init(struct dwc3 *dwc)
190169
}
191170
}
192171

193-
ret = platform_device_add_data(xhci, &dwc3_xhci_plat_quirk,
194-
sizeof(struct xhci_plat_priv));
195-
if (ret)
196-
goto err;
197-
198172
ret = platform_device_add(xhci);
199173
if (ret) {
200174
dev_err(dwc->dev, "failed to register xHCI device\n");
@@ -220,7 +194,6 @@ void dwc3_host_exit(struct dwc3 *dwc)
220194
if (dwc->sys_wakeup)
221195
device_init_wakeup(&dwc->xhci->dev, false);
222196

223-
dwc3_enable_susphy(dwc, false);
224197
platform_device_unregister(dwc->xhci);
225198
dwc->xhci = NULL;
226199
}

0 commit comments

Comments
 (0)