aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorSarah Sharp <sarah.a.sharp@linux.intel.com>2012-01-06 13:34:31 -0500
committerSarah Sharp <sarah.a.sharp@linux.intel.com>2012-02-14 15:12:24 -0500
commit4296c70a5ec316903ef037ed15f154dd3d354ad7 (patch)
tree9e56518a0470c2884420864dda4717cf4bd2d0cb /drivers/usb
parent3b9b6acd4798aafe9b9f64ccb7e8eb76f27f904a (diff)
USB/xHCI: Enable USB 3.0 hub remote wakeup.
USB 3.0 hubs have a different remote wakeup policy than USB 2.0 hubs. USB 2.0 hubs, once they have remote wakeup enabled, will always send remote wakes when anything changes on a port. However, USB 3.0 hubs have a per-port remote wake up policy that is off by default. The Set Feature remote wake mask can be changed for any port, enabling remote wakeup for a connect, disconnect, or overcurrent event, much like EHCI and xHCI host controller "wake on" port status bits. The bits are cleared to zero on the initial hub power on, or after the hub has been reset. Without this patch, when a USB 3.0 hub gets suspended, it will not send a remote wakeup on device connect or disconnect. This would show up to the user as "dead ports" unless they ran lsusb -v (since newer versions of lsusb use the sysfs files, rather than sending control transfers). Change the hub driver's suspend method to enable remote wake up for disconnect, connect, and overcurrent for all ports on the hub. Modify the xHCI driver's roothub code to handle that request, and set the "wake on" bits in the port status registers accordingly. Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/core/hub.c12
-rw-r--r--drivers/usb/host/xhci-hub.c41
2 files changed, 53 insertions, 0 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 70622d633fda..b3137fa65f2a 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2731,6 +2731,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2731 struct usb_hub *hub = usb_get_intfdata (intf); 2731 struct usb_hub *hub = usb_get_intfdata (intf);
2732 struct usb_device *hdev = hub->hdev; 2732 struct usb_device *hdev = hub->hdev;
2733 unsigned port1; 2733 unsigned port1;
2734 int status;
2734 2735
2735 /* Warn if children aren't already suspended */ 2736 /* Warn if children aren't already suspended */
2736 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 2737 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
@@ -2743,6 +2744,17 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2743 return -EBUSY; 2744 return -EBUSY;
2744 } 2745 }
2745 } 2746 }
2747 if (hub_is_superspeed(hdev) && hdev->do_remote_wakeup) {
2748 /* Enable hub to send remote wakeup for all ports. */
2749 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
2750 status = set_port_feature(hdev,
2751 port1 |
2752 USB_PORT_FEAT_REMOTE_WAKE_CONNECT |
2753 USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT |
2754 USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT,
2755 USB_PORT_FEAT_REMOTE_WAKE_MASK);
2756 }
2757 }
2746 2758
2747 dev_dbg(&intf->dev, "%s\n", __func__); 2759 dev_dbg(&intf->dev, "%s\n", __func__);
2748 2760
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 557b6f32db86..673ad120c43e 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -422,6 +422,32 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,
422 xhci_writel(xhci, temp, port_array[port_id]); 422 xhci_writel(xhci, temp, port_array[port_id]);
423} 423}
424 424
425void xhci_set_remote_wake_mask(struct xhci_hcd *xhci,
426 __le32 __iomem **port_array, int port_id, u16 wake_mask)
427{
428 u32 temp;
429
430 temp = xhci_readl(xhci, port_array[port_id]);
431 temp = xhci_port_state_to_neutral(temp);
432
433 if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_CONNECT)
434 temp |= PORT_WKCONN_E;
435 else
436 temp &= ~PORT_WKCONN_E;
437
438 if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT)
439 temp |= PORT_WKDISC_E;
440 else
441 temp &= ~PORT_WKDISC_E;
442
443 if (wake_mask & USB_PORT_FEAT_REMOTE_WAKE_OVER_CURRENT)
444 temp |= PORT_WKOC_E;
445 else
446 temp &= ~PORT_WKOC_E;
447
448 xhci_writel(xhci, temp, port_array[port_id]);
449}
450
425/* Test and clear port RWC bit */ 451/* Test and clear port RWC bit */
426void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, 452void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array,
427 int port_id, u32 port_bit) 453 int port_id, u32 port_bit)
@@ -448,6 +474,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
448 int slot_id; 474 int slot_id;
449 struct xhci_bus_state *bus_state; 475 struct xhci_bus_state *bus_state;
450 u16 link_state = 0; 476 u16 link_state = 0;
477 u16 wake_mask = 0;
451 478
452 max_ports = xhci_get_ports(hcd, &port_array); 479 max_ports = xhci_get_ports(hcd, &port_array);
453 bus_state = &xhci->bus_state[hcd_index(hcd)]; 480 bus_state = &xhci->bus_state[hcd_index(hcd)];
@@ -593,6 +620,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
593 case SetPortFeature: 620 case SetPortFeature:
594 if (wValue == USB_PORT_FEAT_LINK_STATE) 621 if (wValue == USB_PORT_FEAT_LINK_STATE)
595 link_state = (wIndex & 0xff00) >> 3; 622 link_state = (wIndex & 0xff00) >> 3;
623 if (wValue == USB_PORT_FEAT_REMOTE_WAKE_MASK)
624 wake_mask = wIndex & 0xff00;
596 wIndex &= 0xff; 625 wIndex &= 0xff;
597 if (!wIndex || wIndex > max_ports) 626 if (!wIndex || wIndex > max_ports)
598 goto error; 627 goto error;
@@ -703,6 +732,14 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
703 temp = xhci_readl(xhci, port_array[wIndex]); 732 temp = xhci_readl(xhci, port_array[wIndex]);
704 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp); 733 xhci_dbg(xhci, "set port reset, actual port %d status = 0x%x\n", wIndex, temp);
705 break; 734 break;
735 case USB_PORT_FEAT_REMOTE_WAKE_MASK:
736 xhci_set_remote_wake_mask(xhci, port_array,
737 wIndex, wake_mask);
738 temp = xhci_readl(xhci, port_array[wIndex]);
739 xhci_dbg(xhci, "set port remote wake mask, "
740 "actual port %d status = 0x%x\n",
741 wIndex, temp);
742 break;
706 case USB_PORT_FEAT_BH_PORT_RESET: 743 case USB_PORT_FEAT_BH_PORT_RESET:
707 temp |= PORT_WR; 744 temp |= PORT_WR;
708 xhci_writel(xhci, temp, port_array[wIndex]); 745 xhci_writel(xhci, temp, port_array[wIndex]);
@@ -883,6 +920,10 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
883 t2 |= PORT_LINK_STROBE | XDEV_U3; 920 t2 |= PORT_LINK_STROBE | XDEV_U3;
884 set_bit(port_index, &bus_state->bus_suspended); 921 set_bit(port_index, &bus_state->bus_suspended);
885 } 922 }
923 /* USB core sets remote wake mask for USB 3.0 hubs,
924 * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND
925 * is enabled, so also enable remote wake here.
926 */
886 if (hcd->self.root_hub->do_remote_wakeup) { 927 if (hcd->self.root_hub->do_remote_wakeup) {
887 if (t1 & PORT_CONNECT) { 928 if (t1 & PORT_CONNECT) {
888 t2 |= PORT_WKOC_E | PORT_WKDISC_E; 929 t2 |= PORT_WKOC_E | PORT_WKDISC_E;