ch9.h 2.3 KB

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