aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/linux/usb.h21
-rw-r--r--include/linux/usb/ch11.h2
-rw-r--r--include/linux/usb/ch9.h45
-rw-r--r--include/linux/usb/hcd.h9
4 files changed, 75 insertions, 2 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 22e7b53123ef..40439dfd81a7 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -409,6 +409,12 @@ struct usb3_lpm_parameters {
409 * it will get data. 409 * it will get data.
410 */ 410 */
411 unsigned int sel; 411 unsigned int sel;
412 /*
413 * The idle timeout value that is currently programmed into the parent
414 * hub for this device. When the timer counts to zero, the parent hub
415 * will initiate an LPM transition to either U1 or U2.
416 */
417 int timeout;
412}; 418};
413 419
414/** 420/**
@@ -468,8 +474,12 @@ struct usb3_lpm_parameters {
468 * specific data for the device. 474 * specific data for the device.
469 * @slot_id: Slot ID assigned by xHCI 475 * @slot_id: Slot ID assigned by xHCI
470 * @removable: Device can be physically removed from this port 476 * @removable: Device can be physically removed from this port
471 * @u1_params: exit latencies for U1 (USB 3.0 LPM). 477 * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout.
472 * @u2_params: exit latencies for U2 (USB 3.0 LPM). 478 * @u2_params: exit latencies for USB3 U2 LPM state, and hub-initiated timeout.
479 * @lpm_disable_count: Ref count used by usb_disable_lpm() and usb_enable_lpm()
480 * to keep track of the number of functions that require USB 3.0 Link Power
481 * Management to be disabled for this usb_device. This count should only
482 * be manipulated by those functions, with the bandwidth_mutex is held.
473 * 483 *
474 * Notes: 484 * Notes:
475 * Usbcore drivers should not set usbdev->state directly. Instead use 485 * Usbcore drivers should not set usbdev->state directly. Instead use
@@ -544,6 +554,7 @@ struct usb_device {
544 enum usb_device_removable removable; 554 enum usb_device_removable removable;
545 struct usb3_lpm_parameters u1_params; 555 struct usb3_lpm_parameters u1_params;
546 struct usb3_lpm_parameters u2_params; 556 struct usb3_lpm_parameters u2_params;
557 unsigned lpm_disable_count;
547}; 558};
548#define to_usb_device(d) container_of(d, struct usb_device, dev) 559#define to_usb_device(d) container_of(d, struct usb_device, dev)
549 560
@@ -579,6 +590,12 @@ extern void usb_autopm_put_interface_async(struct usb_interface *intf);
579extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); 590extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf);
580extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); 591extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
581 592
593extern int usb_disable_lpm(struct usb_device *udev);
594extern void usb_enable_lpm(struct usb_device *udev);
595/* Same as above, but these functions lock/unlock the bandwidth_mutex. */
596extern int usb_unlocked_disable_lpm(struct usb_device *udev);
597extern void usb_unlocked_enable_lpm(struct usb_device *udev);
598
582static inline void usb_mark_last_busy(struct usb_device *udev) 599static inline void usb_mark_last_busy(struct usb_device *udev)
583{ 600{
584 pm_runtime_mark_last_busy(&udev->dev); 601 pm_runtime_mark_last_busy(&udev->dev);
diff --git a/include/linux/usb/ch11.h b/include/linux/usb/ch11.h
index f1d26b6067f1..b6c2863b2c94 100644
--- a/include/linux/usb/ch11.h
+++ b/include/linux/usb/ch11.h
@@ -76,6 +76,8 @@
76#define USB_PORT_FEAT_C_BH_PORT_RESET 29 76#define USB_PORT_FEAT_C_BH_PORT_RESET 29
77#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30 77#define USB_PORT_FEAT_FORCE_LINKPM_ACCEPT 30
78 78
79#define USB_PORT_LPM_TIMEOUT(p) (((p) & 0xff) << 8)
80
79/* USB 3.0 hub remote wake mask bits, see table 10-14 */ 81/* USB 3.0 hub remote wake mask bits, see table 10-14 */
80#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8) 82#define USB_PORT_FEAT_REMOTE_WAKE_CONNECT (1 << 8)
81#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9) 83#define USB_PORT_FEAT_REMOTE_WAKE_DISCONNECT (1 << 9)
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index e785d85b617f..43bce9da7a4d 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -935,6 +935,51 @@ enum usb_device_state {
935 */ 935 */
936}; 936};
937 937
938enum usb3_link_state {
939 USB3_LPM_U0 = 0,
940 USB3_LPM_U1,
941 USB3_LPM_U2,
942 USB3_LPM_U3
943};
944
945/*
946 * A U1 timeout of 0x0 means the parent hub will reject any transitions to U1.
947 * 0xff means the parent hub will accept transitions to U1, but will not
948 * initiate a transition.
949 *
950 * A U1 timeout of 0x1 to 0x7F also causes the hub to initiate a transition to
951 * U1 after that many microseconds. Timeouts of 0x80 to 0xFE are reserved
952 * values.
953 *
954 * A U2 timeout of 0x0 means the parent hub will reject any transitions to U2.
955 * 0xff means the parent hub will accept transitions to U2, but will not
956 * initiate a transition.
957 *
958 * A U2 timeout of 0x1 to 0xFE also causes the hub to initiate a transition to
959 * U2 after N*256 microseconds. Therefore a U2 timeout value of 0x1 means a U2
960 * idle timer of 256 microseconds, 0x2 means 512 microseconds, 0xFE means
961 * 65.024ms.
962 */
963#define USB3_LPM_DISABLED 0x0
964#define USB3_LPM_U1_MAX_TIMEOUT 0x7F
965#define USB3_LPM_U2_MAX_TIMEOUT 0xFE
966#define USB3_LPM_DEVICE_INITIATED 0xFF
967
968struct usb_set_sel_req {
969 __u8 u1_sel;
970 __u8 u1_pel;
971 __le16 u2_sel;
972 __le16 u2_pel;
973} __attribute__ ((packed));
974
975/*
976 * The Set System Exit Latency control transfer provides one byte each for
977 * U1 SEL and U1 PEL, so the max exit latency is 0xFF. U2 SEL and U2 PEL each
978 * are two bytes long.
979 */
980#define USB3_LPM_MAX_U1_SEL_PEL 0xFF
981#define USB3_LPM_MAX_U2_SEL_PEL 0xFFFF
982
938/*-------------------------------------------------------------------------*/ 983/*-------------------------------------------------------------------------*/
939 984
940/* 985/*
diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h
index bbb946437070..7f855d50cdf5 100644
--- a/include/linux/usb/hcd.h
+++ b/include/linux/usb/hcd.h
@@ -344,6 +344,15 @@ struct hc_driver {
344 */ 344 */
345 int (*update_device)(struct usb_hcd *, struct usb_device *); 345 int (*update_device)(struct usb_hcd *, struct usb_device *);
346 int (*set_usb2_hw_lpm)(struct usb_hcd *, struct usb_device *, int); 346 int (*set_usb2_hw_lpm)(struct usb_hcd *, struct usb_device *, int);
347 /* USB 3.0 Link Power Management */
348 /* Returns the USB3 hub-encoded value for the U1/U2 timeout. */
349 int (*enable_usb3_lpm_timeout)(struct usb_hcd *,
350 struct usb_device *, enum usb3_link_state state);
351 /* The xHCI host controller can still fail the command to
352 * disable the LPM timeouts, so this can return an error code.
353 */
354 int (*disable_usb3_lpm_timeout)(struct usb_hcd *,
355 struct usb_device *, enum usb3_link_state state);
347}; 356};
348 357
349extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb); 358extern int usb_hcd_link_urb_to_ep(struct usb_hcd *hcd, struct urb *urb);