1 2#include <asm/types.h> 3#include <asm/ioctl.h> 4 5#include <linux/usb_ch9.h> 6 7/* 8 * Filesystem based user-mode API to USB Gadget controller hardware 9 * 10 * Almost everything can be done with only read and write operations, 11 * on endpoint files found in one directory. They are configured by 12 * writing descriptors, and then may be used for normal stream style 13 * i/o requests. When ep0 is configured, the device can enumerate; 14 * when it's closed, the device disconnects from usb. 15 */ 16 17/* 18 * Events are delivered on the ep0 file descriptor, if the user mode driver 19 * reads from this file descriptor after writing the descriptors. Don't 20 * stop polling this descriptor, if you write that kind of driver. 21 */ 22 23enum usb_gadgetfs_event_type { 24 GADGETFS_NOP = 0, 25 26 GADGETFS_CONNECT, 27 GADGETFS_DISCONNECT, 28 GADGETFS_CONFIGURATION, 29 GADGETFS_SETUP, 30 GADGETFS_SUSPEND, 31 // and likely more ! 32}; 33 34struct usb_gadgetfs_event { 35 enum usb_gadgetfs_event_type type; 36 union { 37 // NOP, DISCONNECT, SUSPEND: nothing 38 39 // CONNECT: just the speed 40 enum usb_device_speed speed; 41 42 // CONFIGURATION: speed, config number 43 struct { 44 enum usb_device_speed speed; 45 __u8 bConfigurationValue; 46 } config; 47 48 // SETUP: packet; DATA phase i/o precedes next event 49 // (setup.bmRequestType & USB_DIR_IN) flags direction 50 struct usb_ctrlrequest setup; 51 } u; 52}; 53 54 55/* endpoint ioctls */ 56 57/* IN transfers may be reported to the gadget driver as complete 58 * when the fifo is loaded, before the host reads the data; 59 * OUT transfers may be reported to the host's "client" driver as 60 * complete when they're sitting in the FIFO unread. 61 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 62 */ 63#define GADGETFS_FIFO_STATUS _IO('g',1) 64 65/* discards any unclaimed data in the fifo. */ 66#define GADGETFS_FIFO_FLUSH _IO('g',2) 67 68/* resets endpoint halt+toggle, as with set_interface */ 69#define GADGETFS_CLEAR_HALT _IO('g',3) 70 71 72