Lines Matching +full:autosuspend +full:- +full:delay +full:- +full:ms

1 /* SPDX-License-Identifier: GPL-2.0 */
14 #include <linux/errno.h> /* for -ENODEV */
15 #include <linux/delay.h> /* for mdelay() */
30 /*-------------------------------------------------------------------------*/
33 * Host-side wrappers for standard USB descriptors ... these are parsed
37 * - devices have one (usually) or more configs;
38 * - configs have one (often) or more interfaces;
39 * - interfaces have one (usually) or more settings;
40 * - each interface setting has zero or (usually) more endpoints.
41 * - a SuperSpeed endpoint has a companion descriptor
45 * Devices may also have class-specific or vendor-specific descriptors.
51 * struct usb_host_endpoint - host-side endpoint descriptor and queue
62 * @streams: number of USB-3 streams allocated on the endpoint
81 /* host-side wrapper for one interface setting's parsed descriptors */
174 * struct usb_interface - what usb device drivers talk to
190 * @ep_devs_created: endpoint child pseudo-devices exist
192 * @needs_remote_wakeup: flag set when the driver requires remote-wakeup
193 * capability during autosuspend.
194 * @needs_altsetting0: flag set when a set-interface request for altsetting 0
196 * @needs_binding: flag set when the driver should be re-probed or unbound
223 * All standards-conformant USB devices that use isochronous endpoints
224 * will use them in non-default settings.
265 return dev_get_drvdata(&intf->dev); in usb_get_intfdata()
270 dev_set_drvdata(&intf->dev, data); in usb_set_intfdata()
289 * 20 ms, but it doesn't give an upper bound. This creates two possible
292 * (a) sometimes an msleep(20) might expire slightly before 20 ms, which causes
295 * (b) Some (many) devices actually need more than 20 ms of resume signalling,
302 * In order to avoid both conditions, we're using a 40 ms resume timeout, which
306 #define USB_RESUME_TIMEOUT 40 /* ms */
309 * struct usb_interface_cache - long-term representation of a device interface
312 * @altsetting: variable-length array of interface structures, one for
320 * providing support for the /sys/kernel/debug/usb/devices pseudo-file.
326 /* variable-length array of alternate settings for this interface,
336 * struct usb_host_config - representation of a device's configuration
355 * for example, a dual-speed device would have separate configurations for
356 * full-speed and high-speed operation. The number of configurations
362 * are supposed to be numbered from 0 to desc.bNumInterfaces-1, but a lot
410 __usb_get_extra_descriptor((ifpoint)->extra, \
411 (ifpoint)->extralen, \
414 /* ----------------------------------------------------------------------- */
435 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
445 * round-robin allocation */
462 unsigned resuming_ports; /* bit array: resuming root-hub ports */
465 struct mon_bus *mon_bus; /* non-null when associated */
466 int monitored; /* non-zero when monitored */
472 /* ----------------------------------------------------------------------- */
490 /* Decrease TRSTRCY to 10ms during device enumeration. */
512 * PEL and SEL are USB 3.0 Link PM latencies for device-initiated LPM exit.
513 * MEL is the USB 3.0 Link PM latency for host-initiated LPM exit.
525 * Maximum exit latency for a device-initiated LPM transition to bring
535 * receive the data packet. Basically, SEL should be the worse-case
549 * struct usb_device - kernel's representation of a USB device
555 * @rx_lanes: number of rx lanes in use, USB 3.2 adds dual-lane support
556 * @tx_lanes: number of tx lanes in use, USB 3.2 adds dual-lane support
584 * FIXME -- complete doc
613 * @u1_params: exit latencies for USB3 U1 LPM state, and hub-initiated timeout.
614 * @u2_params: exit latencies for USB3 U2 LPM state, and hub-initiated timeout.
620 * parent->hub_delay + wHubDelay + tTPTransmissionDelay (40ns)
625 * Usbcore drivers should not set usbdev->state directly. Instead use
716 return to_usb_device(intf->dev.parent); in interface_to_usbdev()
725 * usb_hub_for_each_child - iterate over all child devices on the hub
732 port1 <= hdev->maxchild; \
737 #define usb_lock_device(udev) device_lock(&(udev)->dev)
738 #define usb_unlock_device(udev) device_unlock(&(udev)->dev)
739 #define usb_lock_device_interruptible(udev) device_lock_interruptible(&(udev)->dev)
740 #define usb_trylock_device(udev) device_trylock(&(udev)->dev)
761 /* USB autosuspend and autoresume */
775 pm_runtime_mark_last_busy(&udev->dev); in usb_mark_last_busy()
815 if (udev->speed < USB_SPEED_SUPER || !udev->bos || !udev->bos->ss_cap) in usb_device_supports_ltm()
817 return udev->bos->ss_cap->bmAttributes & USB_LTM_SUPPORT; in usb_device_supports_ltm()
822 return udev && udev->bus && udev->bus->no_sg_constraint; in usb_device_no_sg_constraint()
826 /*-------------------------------------------------------------------------*/
841 /* used these for multi-interface device registration */
846 * usb_interface_claimed - returns true iff an interface is claimed
860 return (iface->dev.driver != NULL); in usb_interface_claimed()
889 * usb_make_path - returns stable device path in the usb tree
900 * reconfigured, by re-cabling a tree of USB devices or by moving USB host
903 * neither does rebooting or re-enumerating. These are more useful identifiers
916 actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name, in usb_make_path()
917 dev->devpath); in usb_make_path()
918 return (actual >= (int)size) ? -1 : actual; in usb_make_path()
921 /*-------------------------------------------------------------------------*/
939 * USB_DEVICE - macro used to describe a specific usb device
951 * USB_DEVICE_VER - describe a specific usb device with a version range
968 * USB_DEVICE_INTERFACE_CLASS - describe a usb device with a specific interface class
984 * USB_DEVICE_INTERFACE_PROTOCOL - describe a usb device with a specific interface protocol
1000 * USB_DEVICE_INTERFACE_NUMBER - describe a usb device with a specific interface number
1016 * USB_DEVICE_INFO - macro used to describe a class of usb devices
1031 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
1046 * USB_DEVICE_AND_INTERFACE_INFO - describe a specific usb device with a class of usb interfaces
1057 * vendor specific bDeviceClass values, but standards-compliant interfaces.
1069 * USB_VENDOR_AND_INTERFACE_INFO - describe a specific usb vendor with a class of usb interfaces
1079 * vendor specific bDeviceClass values, but standards-compliant interfaces.
1089 /* ----------------------------------------------------------------------- */
1110 * struct usbdrv_wrap - wrapper for driver-model structure
1111 * @driver: The driver-model core driver structure.
1112 * @for_devices: Non-zero for device drivers, 0 for interface drivers.
1120 * struct usb_driver - identifies USB interface driver to usbcore
1125 * usb_set_intfdata() to associate driver-specific data with the
1128 * return -ENODEV, if genuine IO errors occurred, an appropriate
1141 * Instead, let the resume or reset-resume routine recover from
1159 * @drvwrap: Driver-model core structure wrapper.
1162 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
1168 * occurs. Device-initiated USB 3.0 link PM will still be allowed.
1216 * struct usb_device_driver - identifies USB device driver to usbcore
1222 * to associate driver-specific data with the device. If unwilling
1231 * @drvwrap: Driver-model core structure wrapper.
1234 * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend
1262 * struct usb_class_driver - identifies a USB driver that wants to use the USB major number
1294 * module_usb_driver() - Helper macro for registering a USB driver
1316 /* ----------------------------------------------------------------------- */
1323 * urb->transfer_flags:
1328 #define URB_ISO_ASAP 0x0002 /* iso-only; use the first unexpired
1330 #define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
1332 #define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
1341 #define URB_DMA_MAP_SINGLE 0x00010000 /* Non-scatter-gather mapping */
1342 #define URB_DMA_MAP_PAGE 0x00020000 /* HCD-unsupported S-G */
1343 #define URB_DMA_MAP_SG 0x00040000 /* HCD-supported S-G */
1344 #define URB_MAP_LOCAL 0x00080000 /* HCD-local-memory mapping */
1346 #define URB_SETUP_MAP_LOCAL 0x00200000 /* HCD-local setup packet */
1347 #define URB_DMA_SG_COMBINED 0x00400000 /* S-G entries were combined */
1370 INIT_LIST_HEAD(&anchor->urb_list); in init_usb_anchor()
1371 init_waitqueue_head(&anchor->wait); in init_usb_anchor()
1372 spin_lock_init(&anchor->lock); in init_usb_anchor()
1378 * struct urb - USB Request Block
1395 * @status: This is read in non-iso completion functions to get the
1398 * each frame is in the fields of the iso_frame-desc.
1423 * @actual_length: This is read in non-iso completion functions, and
1442 * request-specific driver context.
1468 * the device driver is DMA-aware. For example, a device driver might
1523 * transfer was scheduled. Ranges for frame counter values are HC-specific
1541 * unlinked URBs, and status for all non-ISO transfers. It should not
1547 * When the completion callback is invoked for non-isochronous URBs, the
1577 int status; /* (return) non-ISO status */
1599 /* ----------------------------------------------------------------------- */
1602 * usb_fill_control_urb - initializes a control urb
1624 urb->dev = dev; in usb_fill_control_urb()
1625 urb->pipe = pipe; in usb_fill_control_urb()
1626 urb->setup_packet = setup_packet; in usb_fill_control_urb()
1627 urb->transfer_buffer = transfer_buffer; in usb_fill_control_urb()
1628 urb->transfer_buffer_length = buffer_length; in usb_fill_control_urb()
1629 urb->complete = complete_fn; in usb_fill_control_urb()
1630 urb->context = context; in usb_fill_control_urb()
1634 * usb_fill_bulk_urb - macro to help initialize a bulk urb
1654 urb->dev = dev; in usb_fill_bulk_urb()
1655 urb->pipe = pipe; in usb_fill_bulk_urb()
1656 urb->transfer_buffer = transfer_buffer; in usb_fill_bulk_urb()
1657 urb->transfer_buffer_length = buffer_length; in usb_fill_bulk_urb()
1658 urb->complete = complete_fn; in usb_fill_bulk_urb()
1659 urb->context = context; in usb_fill_bulk_urb()
1663 * usb_fill_int_urb - macro to help initialize a interrupt urb
1696 urb->dev = dev; in usb_fill_int_urb()
1697 urb->pipe = pipe; in usb_fill_int_urb()
1698 urb->transfer_buffer = transfer_buffer; in usb_fill_int_urb()
1699 urb->transfer_buffer_length = buffer_length; in usb_fill_int_urb()
1700 urb->complete = complete_fn; in usb_fill_int_urb()
1701 urb->context = context; in usb_fill_int_urb()
1703 if (dev->speed == USB_SPEED_HIGH || dev->speed >= USB_SPEED_SUPER) { in usb_fill_int_urb()
1707 urb->interval = 1 << (interval - 1); in usb_fill_int_urb()
1709 urb->interval = interval; in usb_fill_int_urb()
1712 urb->start_frame = -1; in usb_fill_int_urb()
1743 * usb_urb_dir_in - check if an URB describes an IN transfer
1746 * Return: 1 if @urb describes an IN transfer (device-to-host),
1751 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_IN; in usb_urb_dir_in()
1755 * usb_urb_dir_out - check if an URB describes an OUT transfer
1758 * Return: 1 if @urb describes an OUT transfer (host-to-device),
1763 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; in usb_urb_dir_out()
1790 /*-------------------------------------------------------------------*
1792 *-------------------------------------------------------------------*/
1857 * struct usb_sg_request - support for scatter/gather I/O
1906 /* ----------------------------------------------------------------------- */
1914 * - direction: bit 7 (0 = Host-to-Device [Out],
1915 * 1 = Device-to-Host [In] ...
1917 * - device address: bits 8-14 ... bit positions known to uhci-hcd
1918 * - endpoint: bits 15-18 ... bit positions known to uhci-hcd
1919 * - pipe type: bits 30-31 (00 = isochronous, 01 = interrupt,
1947 return (dev->devnum << 8) | (endpoint << 15); in __create_pipe()
1972 eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out; in usb_pipe_endpoint()
1984 return usb_endpoint_maxp(&ep->desc); in usb_maxpacket()
1992 case -ENOMEM: in usb_translate_errors()
1993 case -ENODEV: in usb_translate_errors()
1994 case -EOPNOTSUPP: in usb_translate_errors()
1997 return -EIO; in usb_translate_errors()