Commit f085bd4b authored by Weitao Wango's avatar Weitao Wango Committed by Greg Kroah-Hartman

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarWeitao Wang <WeitaoWang-oc@zhaoxin.com>
Link: https://lore.kernel.org/r/20220324121735.3803-1-WeitaoWang-oc@zhaoxin.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8d084b2e
...@@ -1103,6 +1103,26 @@ static void ehci_remove_device(struct usb_hcd *hcd, struct usb_device *udev) ...@@ -1103,6 +1103,26 @@ static void ehci_remove_device(struct usb_hcd *hcd, struct usb_device *udev)
#ifdef CONFIG_PM #ifdef CONFIG_PM
/* Clear wakeup signal locked in zhaoxin platform when device plug in. */
static void ehci_zx_wakeup_clear(struct ehci_hcd *ehci)
{
u32 __iomem *reg = &ehci->regs->port_status[4];
u32 t1 = ehci_readl(ehci, reg);
t1 &= (u32)~0xf0000;
t1 |= PORT_TEST_FORCE;
ehci_writel(ehci, t1, reg);
t1 = ehci_readl(ehci, reg);
msleep(1);
t1 &= (u32)~0xf0000;
ehci_writel(ehci, t1, reg);
ehci_readl(ehci, reg);
msleep(1);
t1 = ehci_readl(ehci, reg);
ehci_writel(ehci, t1 | PORT_CSC, reg);
ehci_readl(ehci, reg);
}
/* suspend/resume, section 4.3 */ /* suspend/resume, section 4.3 */
/* These routines handle the generic parts of controller suspend/resume */ /* These routines handle the generic parts of controller suspend/resume */
...@@ -1154,6 +1174,9 @@ int ehci_resume(struct usb_hcd *hcd, bool force_reset) ...@@ -1154,6 +1174,9 @@ int ehci_resume(struct usb_hcd *hcd, bool force_reset)
if (ehci->shutdown) if (ehci->shutdown)
return 0; /* Controller is dead */ return 0; /* Controller is dead */
if (ehci->zx_wakeup_clear_needed)
ehci_zx_wakeup_clear(ehci);
/* /*
* If CF is still set and reset isn't forced * If CF is still set and reset isn't forced
* then we maintained suspend power. * then we maintained suspend power.
......
...@@ -231,6 +231,10 @@ static int ehci_pci_setup(struct usb_hcd *hcd) ...@@ -231,6 +231,10 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
ehci->is_aspeed = 1; ehci->is_aspeed = 1;
} }
break; break;
case PCI_VENDOR_ID_ZHAOXIN:
if (pdev->device == 0x3104 && (pdev->revision & 0xf0) == 0x90)
ehci->zx_wakeup_clear_needed = 1;
break;
} }
/* optional debug port, normally in the first BAR */ /* optional debug port, normally in the first BAR */
......
...@@ -220,6 +220,7 @@ struct ehci_hcd { /* one per controller */ ...@@ -220,6 +220,7 @@ struct ehci_hcd { /* one per controller */
unsigned imx28_write_fix:1; /* For Freescale i.MX28 */ unsigned imx28_write_fix:1; /* For Freescale i.MX28 */
unsigned spurious_oc:1; unsigned spurious_oc:1;
unsigned is_aspeed:1; unsigned is_aspeed:1;
unsigned zx_wakeup_clear_needed:1;
/* required for usb32 quirk */ /* required for usb32 quirk */
#define OHCI_CTRL_HCFS (3 << 6) #define OHCI_CTRL_HCFS (3 << 6)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment