Skip to content

Commit f085bd4

Browse files
Weitao Wangogregkh
authored andcommitted
USB: Fix ehci infinite suspend-resume loop issue in zhaoxin
In zhaoxin platform, some ehci projects will latch a wakeup signal internal when plug in a device on port during system S0. This wakeup signal will turn on when ehci runtime suspend, which will trigger a system control interrupt that will resume ehci back to D0. As no device connect, ehci will be set to runtime suspend and turn on the internal latched wakeup signal again. It will cause a suspend-resume loop and generate system control interrupt continuously. Fixed this issue by clear wakeup signal latched in ehci internal when ehci resume callback is called. Acked-by: Alan Stern <[email protected]> Signed-off-by: Weitao Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8d084b2 commit f085bd4

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

drivers/usb/host/ehci-hcd.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,26 @@ static void ehci_remove_device(struct usb_hcd *hcd, struct usb_device *udev)
11031103

11041104
#ifdef CONFIG_PM
11051105

1106+
/* Clear wakeup signal locked in zhaoxin platform when device plug in. */
1107+
static void ehci_zx_wakeup_clear(struct ehci_hcd *ehci)
1108+
{
1109+
u32 __iomem *reg = &ehci->regs->port_status[4];
1110+
u32 t1 = ehci_readl(ehci, reg);
1111+
1112+
t1 &= (u32)~0xf0000;
1113+
t1 |= PORT_TEST_FORCE;
1114+
ehci_writel(ehci, t1, reg);
1115+
t1 = ehci_readl(ehci, reg);
1116+
msleep(1);
1117+
t1 &= (u32)~0xf0000;
1118+
ehci_writel(ehci, t1, reg);
1119+
ehci_readl(ehci, reg);
1120+
msleep(1);
1121+
t1 = ehci_readl(ehci, reg);
1122+
ehci_writel(ehci, t1 | PORT_CSC, reg);
1123+
ehci_readl(ehci, reg);
1124+
}
1125+
11061126
/* suspend/resume, section 4.3 */
11071127

11081128
/* These routines handle the generic parts of controller suspend/resume */
@@ -1154,6 +1174,9 @@ int ehci_resume(struct usb_hcd *hcd, bool force_reset)
11541174
if (ehci->shutdown)
11551175
return 0; /* Controller is dead */
11561176

1177+
if (ehci->zx_wakeup_clear_needed)
1178+
ehci_zx_wakeup_clear(ehci);
1179+
11571180
/*
11581181
* If CF is still set and reset isn't forced
11591182
* then we maintained suspend power.

drivers/usb/host/ehci-pci.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
231231
ehci->is_aspeed = 1;
232232
}
233233
break;
234+
case PCI_VENDOR_ID_ZHAOXIN:
235+
if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x90)
236+
ehci->zx_wakeup_clear_needed = 1;
237+
break;
234238
}
235239

236240
/* optional debug port, normally in the first BAR */

drivers/usb/host/ehci.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ struct ehci_hcd { /* one per controller */
220220
unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
221221
unsigned spurious_oc:1;
222222
unsigned is_aspeed:1;
223+
unsigned zx_wakeup_clear_needed:1;
223224

224225
/* required for usb32 quirk */
225226
#define OHCI_CTRL_HCFS (3 << 6)

0 commit comments

Comments
 (0)