1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * This file holds USB constants and structures that are needed for 4*4882a593Smuzhiyun * USB device APIs. These are used by the USB device model, which is 5*4882a593Smuzhiyun * defined in chapter 9 of the USB 2.0 specification and in the 6*4882a593Smuzhiyun * Wireless USB 1.0 (spread around). Linux has several APIs in C that 7*4882a593Smuzhiyun * need these: 8*4882a593Smuzhiyun * 9*4882a593Smuzhiyun * - the host side Linux-USB kernel driver API; 10*4882a593Smuzhiyun * - the "usbfs" user space API; and 11*4882a593Smuzhiyun * - the Linux "gadget" device/peripheral side driver API. 12*4882a593Smuzhiyun * 13*4882a593Smuzhiyun * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems 14*4882a593Smuzhiyun * act either as a USB host or as a USB device. That means the host and 15*4882a593Smuzhiyun * device side APIs benefit from working well together. 16*4882a593Smuzhiyun * 17*4882a593Smuzhiyun * There's also "Wireless USB", using low power short range radios for 18*4882a593Smuzhiyun * peripheral interconnection but otherwise building on the USB framework. 19*4882a593Smuzhiyun * 20*4882a593Smuzhiyun * Note all descriptors are declared '__attribute__((packed))' so that: 21*4882a593Smuzhiyun * 22*4882a593Smuzhiyun * [a] they never get padded, either internally (USB spec writers 23*4882a593Smuzhiyun * probably handled that) or externally; 24*4882a593Smuzhiyun * 25*4882a593Smuzhiyun * [b] so that accessing bigger-than-a-bytes fields will never 26*4882a593Smuzhiyun * generate bus errors on any platform, even when the location of 27*4882a593Smuzhiyun * its descriptor inside a bundle isn't "naturally aligned", and 28*4882a593Smuzhiyun * 29*4882a593Smuzhiyun * [c] for consistency, removing all doubt even when it appears to 30*4882a593Smuzhiyun * someone that the two other points are non-issues for that 31*4882a593Smuzhiyun * particular descriptor type. 32*4882a593Smuzhiyun */ 33*4882a593Smuzhiyun #ifndef __LINUX_USB_CH9_H 34*4882a593Smuzhiyun #define __LINUX_USB_CH9_H 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun #include <linux/device.h> 37*4882a593Smuzhiyun #include <uapi/linux/usb/ch9.h> 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun /* USB 3.2 SuperSpeed Plus phy signaling rate generation and lane count */ 40*4882a593Smuzhiyun 41*4882a593Smuzhiyun enum usb_ssp_rate { 42*4882a593Smuzhiyun USB_SSP_GEN_UNKNOWN = 0, 43*4882a593Smuzhiyun USB_SSP_GEN_2x1, 44*4882a593Smuzhiyun USB_SSP_GEN_1x2, 45*4882a593Smuzhiyun USB_SSP_GEN_2x2, 46*4882a593Smuzhiyun }; 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun extern const char *usb_ep_type_string(int ep_type); 49*4882a593Smuzhiyun extern const char *usb_speed_string(enum usb_device_speed speed); 50*4882a593Smuzhiyun extern enum usb_device_speed usb_get_maximum_speed(struct device *dev); 51*4882a593Smuzhiyun extern enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev); 52*4882a593Smuzhiyun extern const char *usb_state_string(enum usb_device_state state); 53*4882a593Smuzhiyun unsigned int usb_decode_interval(const struct usb_endpoint_descriptor *epd, 54*4882a593Smuzhiyun enum usb_device_speed speed); 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun #ifdef CONFIG_TRACING 57*4882a593Smuzhiyun extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, 58*4882a593Smuzhiyun __u8 bRequest, __u16 wValue, __u16 wIndex, 59*4882a593Smuzhiyun __u16 wLength); 60*4882a593Smuzhiyun #endif 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun #endif /* __LINUX_USB_CH9_H */ 63