Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * This file holds USB constants and structures that are needed for
0004  * USB device APIs.  These are used by the USB device model, which is
0005  * defined in chapter 9 of the USB 2.0 specification and in the
0006  * Wireless USB 1.0 (spread around).  Linux has several APIs in C that
0007  * need these:
0008  *
0009  * - the host side Linux-USB kernel driver API;
0010  * - the "usbfs" user space API; and
0011  * - the Linux "gadget" device/peripheral side driver API.
0012  *
0013  * USB 2.0 adds an additional "On The Go" (OTG) mode, which lets systems
0014  * act either as a USB host or as a USB device.  That means the host and
0015  * device side APIs benefit from working well together.
0016  *
0017  * There's also "Wireless USB", using low power short range radios for
0018  * peripheral interconnection but otherwise building on the USB framework.
0019  *
0020  * Note all descriptors are declared '__attribute__((packed))' so that:
0021  *
0022  * [a] they never get padded, either internally (USB spec writers
0023  *     probably handled that) or externally;
0024  *
0025  * [b] so that accessing bigger-than-a-bytes fields will never
0026  *     generate bus errors on any platform, even when the location of
0027  *     its descriptor inside a bundle isn't "naturally aligned", and
0028  *
0029  * [c] for consistency, removing all doubt even when it appears to
0030  *     someone that the two other points are non-issues for that
0031  *     particular descriptor type.
0032  */
0033 #ifndef __LINUX_USB_CH9_H
0034 #define __LINUX_USB_CH9_H
0035 
0036 #include <uapi/linux/usb/ch9.h>
0037 
0038 /* USB 3.2 SuperSpeed Plus phy signaling rate generation and lane count */
0039 
0040 enum usb_ssp_rate {
0041     USB_SSP_GEN_UNKNOWN = 0,
0042     USB_SSP_GEN_2x1,
0043     USB_SSP_GEN_1x2,
0044     USB_SSP_GEN_2x2,
0045 };
0046 
0047 struct device;
0048 
0049 extern const char *usb_ep_type_string(int ep_type);
0050 extern const char *usb_speed_string(enum usb_device_speed speed);
0051 extern enum usb_device_speed usb_get_maximum_speed(struct device *dev);
0052 extern enum usb_ssp_rate usb_get_maximum_ssp_rate(struct device *dev);
0053 extern const char *usb_state_string(enum usb_device_state state);
0054 unsigned int usb_decode_interval(const struct usb_endpoint_descriptor *epd,
0055                  enum usb_device_speed speed);
0056 
0057 #ifdef CONFIG_TRACING
0058 extern const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType,
0059                    __u8 bRequest, __u16 wValue, __u16 wIndex,
0060                    __u16 wLength);
0061 #endif
0062 
0063 #endif /* __LINUX_USB_CH9_H */