On 04.04.2017 15:54, Mathias Nyman wrote:
From: Guoqing Zhang <[email protected]>

Refactoring port power on/off related code into
a helper function xhci_set_power_on() which can
be reused when enabling test mode.

Signed-off-by: Guoqing Zhang <[email protected]>
Signed-off-by: Mathias Nyman <[email protected]>
---
  drivers/usb/host/xhci-hub.c | 65 ++++++++++++++++++++++++++++++---------------
  1 file changed, 44 insertions(+), 21 deletions(-)

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 3bddeaa..b8ea7c0 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -540,6 +540,48 @@ static int xhci_get_ports(struct usb_hcd *hcd, __le32 
__iomem ***port_array)
        return max_ports;
  }

+static __le32 __iomem *xhci_get_port_io_addr(struct usb_hcd *hcd, int index)
+{
+       __le32 __iomem **port_array;
+
+       xhci_get_ports(hcd, &port_array);
+       return port_array[index];
+}
+
+/*
+ * xhci_set_port_power() must be called with xhci->lock held.
+ * It will release and re-aquire the lock while calling ACPI
+ * method.
+ */
+static void xhci_set_port_power(struct xhci_hcd *xhci, struct usb_hcd *hcd,
+                               u16 index, bool on)
+{
+       __le32 __iomem *addr;
+       u32 temp;
+       unsigned long flags = 0;
+
+       addr = xhci_get_port_io_addr(hcd, index);
+       temp = readl(addr);

We need to mask out the RW1CS bits if we re-read the portsc register here

+       if (on) {
+               /* Power on */
+               writel(temp | PORT_POWER, addr);

otherwise we clear all the Status Change bits and port enable here.

I'll fix it and resubmit for now, maybe it has a chance to get into 4.12 still

-Mathias
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to