[PATCH 1/5] usb: xhci: add quirk flag for broken PED bits

From: Roger Quadros
Date: Fri Mar 18 2016 - 08:35:44 EST


From: Felipe Balbi <balbi@xxxxxxxxxx>

Some devices from Texas Instruments suffer from
a silicon bug where Port Enabled/Disabled bit
should not be used to silence an erroneous device.

The bug is so that if port is disabled with PED
bit, an IRQ for device removal (or attachment)
will never fire.

Just for the sake of completeness, the actual
problem lies with SNPS USB IP and this affects
all known versions up to 3.00a. A separate
patch will be added to dwc3 to enabled this
quirk flag if version is <= 3.00a.

Signed-off-by: Felipe Balbi <balbi@xxxxxxxxxx>
Signed-off-by: Sekhar Nori <nsekhar@xxxxxx>
Signed-off-by: Roger Quadros <rogerq@xxxxxx>
---
drivers/usb/host/xhci-hub.c | 6 ++++++
drivers/usb/host/xhci.h | 2 ++
2 files changed, 8 insertions(+)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index d61fcc4..1649a21 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -455,6 +455,12 @@ static void xhci_disable_port(struct usb_hcd *hcd, struct xhci_hcd *xhci,
return;
}

+ if (xhci->quirks & XHCI_BROKEN_PORT_PE) {
+ xhci_dbg(xhci, "Broken Port Enabled/Disabled, ignoring "
+ "port disable request.\n");
+ return;
+ }
+
/* Write 1 to disable the port */
writel(port_status | PORT_PE, addr);
port_status = readl(addr);
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index e293e09..371a64f 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -1641,6 +1641,8 @@ struct xhci_hcd {
#define XHCI_PME_STUCK_QUIRK (1 << 20)
#define XHCI_MTK_HOST (1 << 21)
#define XHCI_SSIC_PORT_UNUSED (1 << 22)
+/* For controller with a broken Port Disable implementation */
+#define XHCI_BROKEN_PORT_PE (1 << 23)
unsigned int num_active_eps;
unsigned int limit_active_eps;
/* There are two roothubs to keep track of bus suspend info for */
--
2.5.0