aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h79
1 files changed, 66 insertions, 13 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 73b68d1f2cb0..dea39dc551d4 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -351,10 +351,6 @@ struct usb_bus {
351 int bandwidth_int_reqs; /* number of Interrupt requests */ 351 int bandwidth_int_reqs; /* number of Interrupt requests */
352 int bandwidth_isoc_reqs; /* number of Isoc. requests */ 352 int bandwidth_isoc_reqs; /* number of Isoc. requests */
353 353
354#ifdef CONFIG_USB_DEVICEFS
355 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
356#endif
357
358#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE) 354#if defined(CONFIG_USB_MON) || defined(CONFIG_USB_MON_MODULE)
359 struct mon_bus *mon_bus; /* non-null when associated */ 355 struct mon_bus *mon_bus; /* non-null when associated */
360 int monitored; /* non-zero when monitored */ 356 int monitored; /* non-zero when monitored */
@@ -382,6 +378,45 @@ enum usb_device_removable {
382 USB_DEVICE_FIXED, 378 USB_DEVICE_FIXED,
383}; 379};
384 380
381/*
382 * USB 3.0 Link Power Management (LPM) parameters.
383 *
384 * PEL and SEL are USB 3.0 Link PM latencies for device-initiated LPM exit.
385 * MEL is the USB 3.0 Link PM latency for host-initiated LPM exit.
386 * All three are stored in nanoseconds.
387 */
388struct usb3_lpm_parameters {
389 /*
390 * Maximum exit latency (MEL) for the host to send a packet to the
391 * device (either a Ping for isoc endpoints, or a data packet for
392 * interrupt endpoints), the hubs to decode the packet, and for all hubs
393 * in the path to transition the links to U0.
394 */
395 unsigned int mel;
396 /*
397 * Maximum exit latency for a device-initiated LPM transition to bring
398 * all links into U0. Abbreviated as "PEL" in section 9.4.12 of the USB
399 * 3.0 spec, with no explanation of what "P" stands for. "Path"?
400 */
401 unsigned int pel;
402
403 /*
404 * The System Exit Latency (SEL) includes PEL, and three other
405 * latencies. After a device initiates a U0 transition, it will take
406 * some time from when the device sends the ERDY to when it will finally
407 * receive the data packet. Basically, SEL should be the worse-case
408 * latency from when a device starts initiating a U0 transition to when
409 * it will get data.
410 */
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;
418};
419
385/** 420/**
386 * struct usb_device - kernel's representation of a USB device 421 * struct usb_device - kernel's representation of a USB device
387 * @devnum: device number; address on a USB bus 422 * @devnum: device number; address on a USB bus
@@ -439,6 +474,12 @@ enum usb_device_removable {
439 * specific data for the device. 474 * specific data for the device.
440 * @slot_id: Slot ID assigned by xHCI 475 * @slot_id: Slot ID assigned by xHCI
441 * @removable: Device can be physically removed from this port 476 * @removable: Device can be physically removed from this port
477 * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout.
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.
442 * 483 *
443 * Notes: 484 * Notes:
444 * Usbcore drivers should not set usbdev->state directly. Instead use 485 * Usbcore drivers should not set usbdev->state directly. Instead use
@@ -485,6 +526,7 @@ struct usb_device {
485 unsigned lpm_capable:1; 526 unsigned lpm_capable:1;
486 unsigned usb2_hw_lpm_capable:1; 527 unsigned usb2_hw_lpm_capable:1;
487 unsigned usb2_hw_lpm_enabled:1; 528 unsigned usb2_hw_lpm_enabled:1;
529 unsigned usb3_lpm_enabled:1;
488 int string_langid; 530 int string_langid;
489 531
490 /* static strings from the device */ 532 /* static strings from the device */
@@ -493,12 +535,6 @@ struct usb_device {
493 char *serial; 535 char *serial;
494 536
495 struct list_head filelist; 537 struct list_head filelist;
496#ifdef CONFIG_USB_DEVICE_CLASS
497 struct device *usb_classdev;
498#endif
499#ifdef CONFIG_USB_DEVICEFS
500 struct dentry *usbfs_dentry;
501#endif
502 538
503 int maxchild; 539 int maxchild;
504 struct usb_device **children; 540 struct usb_device **children;
@@ -517,6 +553,10 @@ struct usb_device {
517 struct wusb_dev *wusb_dev; 553 struct wusb_dev *wusb_dev;
518 int slot_id; 554 int slot_id;
519 enum usb_device_removable removable; 555 enum usb_device_removable removable;
556 struct usb3_lpm_parameters u1_params;
557 struct usb3_lpm_parameters u2_params;
558 unsigned lpm_disable_count;
559 unsigned hub_initiated_lpm_disable_count;
520}; 560};
521#define to_usb_device(d) container_of(d, struct usb_device, dev) 561#define to_usb_device(d) container_of(d, struct usb_device, dev)
522 562
@@ -583,6 +623,12 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
583{ } 623{ }
584#endif 624#endif
585 625
626extern int usb_disable_lpm(struct usb_device *udev);
627extern void usb_enable_lpm(struct usb_device *udev);
628/* Same as above, but these functions lock/unlock the bandwidth_mutex. */
629extern int usb_unlocked_disable_lpm(struct usb_device *udev);
630extern void usb_unlocked_enable_lpm(struct usb_device *udev);
631
586/*-------------------------------------------------------------------------*/ 632/*-------------------------------------------------------------------------*/
587 633
588/* for drivers using iso endpoints */ 634/* for drivers using iso endpoints */
@@ -800,6 +846,8 @@ extern ssize_t usb_store_new_id(struct usb_dynids *dynids,
800 struct device_driver *driver, 846 struct device_driver *driver,
801 const char *buf, size_t count); 847 const char *buf, size_t count);
802 848
849extern ssize_t usb_show_dynids(struct usb_dynids *dynids, char *buf);
850
803/** 851/**
804 * struct usbdrv_wrap - wrapper for driver-model structure 852 * struct usbdrv_wrap - wrapper for driver-model structure
805 * @driver: The driver-model core driver structure. 853 * @driver: The driver-model core driver structure.
@@ -850,6 +898,9 @@ struct usbdrv_wrap {
850 * for interfaces bound to this driver. 898 * for interfaces bound to this driver.
851 * @soft_unbind: if set to 1, the USB core will not kill URBs and disable 899 * @soft_unbind: if set to 1, the USB core will not kill URBs and disable
852 * endpoints before calling the driver's disconnect method. 900 * endpoints before calling the driver's disconnect method.
901 * @disable_hub_initiated_lpm: if set to 0, the USB core will not allow hubs
902 * to initiate lower power link state transitions when an idle timeout
903 * occurs. Device-initiated USB 3.0 link PM will still be allowed.
853 * 904 *
854 * USB interface drivers must provide a name, probe() and disconnect() 905 * USB interface drivers must provide a name, probe() and disconnect()
855 * methods, and an id_table. Other driver fields are optional. 906 * methods, and an id_table. Other driver fields are optional.
@@ -890,6 +941,7 @@ struct usb_driver {
890 struct usbdrv_wrap drvwrap; 941 struct usbdrv_wrap drvwrap;
891 unsigned int no_dynamic_id:1; 942 unsigned int no_dynamic_id:1;
892 unsigned int supports_autosuspend:1; 943 unsigned int supports_autosuspend:1;
944 unsigned int disable_hub_initiated_lpm:1;
893 unsigned int soft_unbind:1; 945 unsigned int soft_unbind:1;
894}; 946};
895#define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver) 947#define to_usb_driver(d) container_of(d, struct usb_driver, drvwrap.driver)
@@ -1379,6 +1431,7 @@ extern int usb_unlink_urb(struct urb *urb);
1379extern void usb_kill_urb(struct urb *urb); 1431extern void usb_kill_urb(struct urb *urb);
1380extern void usb_poison_urb(struct urb *urb); 1432extern void usb_poison_urb(struct urb *urb);
1381extern void usb_unpoison_urb(struct urb *urb); 1433extern void usb_unpoison_urb(struct urb *urb);
1434extern void usb_block_urb(struct urb *urb);
1382extern void usb_kill_anchored_urbs(struct usb_anchor *anchor); 1435extern void usb_kill_anchored_urbs(struct usb_anchor *anchor);
1383extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); 1436extern void usb_poison_anchored_urbs(struct usb_anchor *anchor);
1384extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); 1437extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor);
@@ -1391,6 +1444,8 @@ extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor);
1391extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); 1444extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor);
1392extern int usb_anchor_empty(struct usb_anchor *anchor); 1445extern int usb_anchor_empty(struct usb_anchor *anchor);
1393 1446
1447#define usb_unblock_urb usb_unpoison_urb
1448
1394/** 1449/**
1395 * usb_urb_dir_in - check if an URB describes an IN transfer 1450 * usb_urb_dir_in - check if an URB describes an IN transfer
1396 * @urb: URB to be checked 1451 * @urb: URB to be checked
@@ -1627,6 +1682,7 @@ static inline int usb_translate_errors(int error_code)
1627 case 0: 1682 case 0:
1628 case -ENOMEM: 1683 case -ENOMEM:
1629 case -ENODEV: 1684 case -ENODEV:
1685 case -EOPNOTSUPP:
1630 return error_code; 1686 return error_code;
1631 default: 1687 default:
1632 return -EIO; 1688 return -EIO;
@@ -1652,9 +1708,6 @@ do { \
1652} while (0) 1708} while (0)
1653#endif 1709#endif
1654 1710
1655#define err(format, arg...) \
1656 printk(KERN_ERR KBUILD_MODNAME ": " format "\n", ##arg)
1657
1658/* debugfs stuff */ 1711/* debugfs stuff */
1659extern struct dentry *usb_debug_root; 1712extern struct dentry *usb_debug_root;
1660 1713