linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: xhci: avoid VBus glitch during controller reset operation
@ 2019-08-21  3:18 Peter Chen
  2019-08-22 11:08 ` Mathias Nyman
  0 siblings, 1 reply; 6+ messages in thread
From: Peter Chen @ 2019-08-21  3:18 UTC (permalink / raw)
  To: mathias.nyman; +Cc: linux-usb, dl-linux-imx, Peter Chen

According to xHCI 1.1 CH4.19.4 Port Power:
	While Chip Hardware Reset or HCRST is asserted,
       	the value of PP is undefined. If the xHC supports
       	power switches (PPC = ‘1’) then VBus may be deasserted
       	during this time. PP (and VBus) shall be enabled immediately
       	upon exiting the reset condition.

The VBus glitch may cause some USB devices work abnormal, we observe
it at NXP LS1012AFWRY/LS1043ARDB/LX2160AQDS/LS1088ARDB platforms. To
avoid this Vbus glitch, we could set PP as 0 before HCRST, and the PP
will back to 1 after HCRST according to spec.

Reported-by: Ran Wang <ran.wang_1@nxp.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/usb/host/xhci.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 6b34a573c3d9..f5a7b5d63031 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -167,7 +167,8 @@ int xhci_reset(struct xhci_hcd *xhci)
 {
 	u32 command;
 	u32 state;
-	int ret;
+	int ret, i;
+	u32 portsc;
 
 	state = readl(&xhci->op_regs->status);
 
@@ -181,6 +182,18 @@ int xhci_reset(struct xhci_hcd *xhci)
 		return 0;
 	}
 
+	/*
+	 * Keep PORTSC.PP as 0 before HCRST to eliminate
+	 * Vbus glitch, see CH 4.19.4.
+	 */
+	for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) {
+		__le32 __iomem *port_addr = &xhci->op_regs->port_status_base +
+				NUM_PORT_REGS * i;
+		portsc = readl(port_addr);
+		portsc &= ~PORT_POWER;
+		writel(portsc, port_addr);
+	}
+
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC");
 	command = readl(&xhci->op_regs->command);
 	command |= CMD_RESET;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-08-23  3:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-21  3:18 [PATCH 1/1] usb: xhci: avoid VBus glitch during controller reset operation Peter Chen
2019-08-22 11:08 ` Mathias Nyman
2019-08-23  1:01   ` Peter Chen
2019-08-23  1:59     ` Ran Wang
2019-08-23  3:33       ` Peter Chen
2019-08-23  3:52         ` Ran Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).