logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

gadgetfs.h (2826B)


  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. /*
  3. * Filesystem based user-mode API to USB Gadget controller hardware
  4. *
  5. * Other than ep0 operations, most things are done by read() and write()
  6. * on endpoint files found in one directory. They are configured by
  7. * writing descriptors, and then may be used for normal stream style
  8. * i/o requests. When ep0 is configured, the device can enumerate;
  9. * when it's closed, the device disconnects from usb. Operations on
  10. * ep0 require ioctl() operations.
  11. *
  12. * Configuration and device descriptors get written to /dev/gadget/$CHIP,
  13. * which may then be used to read usb_gadgetfs_event structs. The driver
  14. * may activate endpoints as it handles SET_CONFIGURATION setup events,
  15. * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT
  16. * then performing data transfers by reading or writing.
  17. */
  18. #ifndef __LINUX_USB_GADGETFS_H
  19. #define __LINUX_USB_GADGETFS_H
  20. #include <linux/types.h>
  21. #include <linux/ioctl.h>
  22. #include <linux/usb/ch9.h>
  23. /*
  24. * Events are delivered on the ep0 file descriptor, when the user mode driver
  25. * reads from this file descriptor after writing the descriptors. Don't
  26. * stop polling this descriptor.
  27. */
  28. enum usb_gadgetfs_event_type {
  29. GADGETFS_NOP = 0,
  30. GADGETFS_CONNECT,
  31. GADGETFS_DISCONNECT,
  32. GADGETFS_SETUP,
  33. GADGETFS_SUSPEND,
  34. /* and likely more ! */
  35. };
  36. /* NOTE: this structure must stay the same size and layout on
  37. * both 32-bit and 64-bit kernels.
  38. */
  39. struct usb_gadgetfs_event {
  40. union {
  41. /* NOP, DISCONNECT, SUSPEND: nothing
  42. * ... some hardware can't report disconnection
  43. */
  44. /* CONNECT: just the speed */
  45. enum usb_device_speed speed;
  46. /* SETUP: packet; DATA phase i/o precedes next event
  47. *(setup.bmRequestType & USB_DIR_IN) flags direction
  48. * ... includes SET_CONFIGURATION, SET_INTERFACE
  49. */
  50. struct usb_ctrlrequest setup;
  51. } u;
  52. enum usb_gadgetfs_event_type type;
  53. };
  54. /* The 'g' code is also used by printer and hid gadget ioctl requests.
  55. * Don't add any colliding codes to either driver, and keep
  56. * them in unique ranges (size 0x20 for now).
  57. */
  58. /* endpoint ioctls */
  59. /* IN transfers may be reported to the gadget driver as complete
  60. * when the fifo is loaded, before the host reads the data;
  61. * OUT transfers may be reported to the host's "client" driver as
  62. * complete when they're sitting in the FIFO unread.
  63. * THIS returns how many bytes are "unclaimed" in the endpoint fifo
  64. * (needed for precise fault handling, when the hardware allows it)
  65. */
  66. #define GADGETFS_FIFO_STATUS _IO('g', 1)
  67. /* discards any unclaimed data in the fifo. */
  68. #define GADGETFS_FIFO_FLUSH _IO('g', 2)
  69. /* resets endpoint halt+toggle; used to implement set_interface.
  70. * some hardware (like pxa2xx) can't support this.
  71. */
  72. #define GADGETFS_CLEAR_HALT _IO('g', 3)
  73. #endif /* __LINUX_USB_GADGETFS_H */