Skip to content

Commit 465caa8

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 5387f1f commit 465caa8

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
@@ -105,27 +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-
112-
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
113-
if (enable && !dwc->dis_u3_susphy_quirk)
114-
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
115-
else
116-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
117-
118-
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
119-
120-
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
121-
if (enable && !dwc->dis_u2_susphy_quirk)
122-
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
123-
else
124-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
125-
126-
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
127-
}
128-
129108
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode)
130109
{
131110
u32 reg;
@@ -639,8 +618,11 @@ static int dwc3_core_ulpi_init(struct dwc3 *dwc)
639618

640619
static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
641620
{
621+
unsigned int hw_mode;
642622
u32 reg;
643623

624+
hw_mode = DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);
625+
644626
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(index));
645627

646628
/*
@@ -650,16 +632,21 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
650632
reg &= ~DWC3_GUSB3PIPECTL_UX_EXIT_PX;
651633

652634
/*
653-
* Above DWC_usb3.0 1.94a, it is recommended to set
654-
* DWC3_GUSB3PIPECTL_SUSPHY to '0' during coreConsultant configuration.
655-
* So default value will be '0' when the core is reset. Application
656-
* needs to set it to '1' after the core initialization is completed.
657-
*
658-
* Similarly for DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be
659-
* cleared after power-on reset, and it can be set after core
660-
* initialization.
635+
* Above 1.94a, it is recommended to set DWC3_GUSB3PIPECTL_SUSPHY
636+
* to '0' during coreConsultant configuration. So default value
637+
* will be '0' when the core is reset. Application needs to set it
638+
* to '1' after the core initialization is completed.
639+
*/
640+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
641+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
642+
643+
/*
644+
* For DRD controllers, GUSB3PIPECTL.SUSPENDENABLE must be cleared after
645+
* power-on reset, and it can be set after core initialization, which is
646+
* after device soft-reset during initialization.
661647
*/
662-
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
648+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
649+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
663650

664651
if (dwc->u2ss_inp3_quirk)
665652
reg |= DWC3_GUSB3PIPECTL_U2SSINP3OK;
@@ -685,6 +672,9 @@ static int dwc3_ss_phy_setup(struct dwc3 *dwc, int index)
685672
if (dwc->tx_de_emphasis_quirk)
686673
reg |= DWC3_GUSB3PIPECTL_TX_DEEPH(dwc->tx_de_emphasis);
687674

675+
if (dwc->dis_u3_susphy_quirk)
676+
reg &= ~DWC3_GUSB3PIPECTL_SUSPHY;
677+
688678
if (dwc->dis_del_phy_power_chg_quirk)
689679
reg &= ~DWC3_GUSB3PIPECTL_DEPOCHANGE;
690680

@@ -739,15 +729,24 @@ static int dwc3_hs_phy_setup(struct dwc3 *dwc, int index)
739729
}
740730

741731
/*
742-
* Above DWC_usb3.0 1.94a, it is recommended to set
743-
* DWC3_GUSB2PHYCFG_SUSPHY to '0' during coreConsultant configuration.
744-
* So default value will be '0' when the core is reset. Application
745-
* needs to set it to '1' after the core initialization is completed.
746-
*
747-
* Similarly for DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared
748-
* after power-on reset, and it can be set after core initialization.
732+
* Above 1.94a, it is recommended to set DWC3_GUSB2PHYCFG_SUSPHY to
733+
* '0' during coreConsultant configuration. So default value will
734+
* be '0' when the core is reset. Application needs to set it to
735+
* '1' after the core initialization is completed.
749736
*/
750-
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
737+
if (!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A))
738+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
739+
740+
/*
741+
* For DRD controllers, GUSB2PHYCFG.SUSPHY must be cleared after
742+
* power-on reset, and it can be set after core initialization, which is
743+
* after device soft-reset during initialization.
744+
*/
745+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD)
746+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
747+
748+
if (dwc->dis_u2_susphy_quirk)
749+
reg &= ~DWC3_GUSB2PHYCFG_SUSPHY;
751750

752751
if (dwc->dis_enblslpm_quirk)
753752
reg &= ~DWC3_GUSB2PHYCFG_ENBLSLPM;
@@ -1346,6 +1345,21 @@ static int dwc3_core_init(struct dwc3 *dwc)
13461345
if (ret)
13471346
goto err_exit_phy;
13481347

1348+
if (hw_mode == DWC3_GHWPARAMS0_MODE_DRD &&
1349+
!DWC3_VER_IS_WITHIN(DWC3, ANY, 194A)) {
1350+
if (!dwc->dis_u3_susphy_quirk) {
1351+
reg = dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0));
1352+
reg |= DWC3_GUSB3PIPECTL_SUSPHY;
1353+
dwc3_writel(dwc->regs, DWC3_GUSB3PIPECTL(0), reg);
1354+
}
1355+
1356+
if (!dwc->dis_u2_susphy_quirk) {
1357+
reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYCFG(0));
1358+
reg |= DWC3_GUSB2PHYCFG_SUSPHY;
1359+
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(0), reg);
1360+
}
1361+
}
1362+
13491363
dwc3_core_setup_global_control(dwc);
13501364
dwc3_core_num_eps(dwc);
13511365

drivers/usb/dwc3/core.h

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

15971597
int dwc3_core_soft_reset(struct dwc3 *dwc);
1598-
void dwc3_enable_susphy(struct dwc3 *dwc, bool enable);
15991598

16001599
#if IS_ENABLED(CONFIG_USB_DWC3_HOST) || IS_ENABLED(CONFIG_USB_DWC3_DUAL_ROLE)
16011600
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
@@ -2922,7 +2922,6 @@ static int __dwc3_gadget_start(struct dwc3 *dwc)
29222922
dwc3_ep0_out_start(dwc);
29232923

29242924
dwc3_gadget_enable_irq(dwc);
2925-
dwc3_enable_susphy(dwc, true);
29262925

29272926
return 0;
29282927

@@ -4689,7 +4688,6 @@ void dwc3_gadget_exit(struct dwc3 *dwc)
46894688
if (!dwc->gadget)
46904689
return;
46914690

4692-
dwc3_enable_susphy(dwc, false);
46934691
usb_del_gadget(dwc->gadget);
46944692
dwc3_gadget_free_endpoints(dwc);
46954693
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)