![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 0002 /* 0003 * Filesystem based user-mode API to USB Gadget controller hardware 0004 * 0005 * Other than ep0 operations, most things are done by read() and write() 0006 * on endpoint files found in one directory. They are configured by 0007 * writing descriptors, and then may be used for normal stream style 0008 * i/o requests. When ep0 is configured, the device can enumerate; 0009 * when it's closed, the device disconnects from usb. Operations on 0010 * ep0 require ioctl() operations. 0011 * 0012 * Configuration and device descriptors get written to /dev/gadget/$CHIP, 0013 * which may then be used to read usb_gadgetfs_event structs. The driver 0014 * may activate endpoints as it handles SET_CONFIGURATION setup events, 0015 * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT 0016 * then performing data transfers by reading or writing. 0017 */ 0018 0019 #ifndef __LINUX_USB_GADGETFS_H 0020 #define __LINUX_USB_GADGETFS_H 0021 0022 #include <linux/types.h> 0023 #include <linux/ioctl.h> 0024 0025 #include <linux/usb/ch9.h> 0026 0027 /* 0028 * Events are delivered on the ep0 file descriptor, when the user mode driver 0029 * reads from this file descriptor after writing the descriptors. Don't 0030 * stop polling this descriptor. 0031 */ 0032 0033 enum usb_gadgetfs_event_type { 0034 GADGETFS_NOP = 0, 0035 0036 GADGETFS_CONNECT, 0037 GADGETFS_DISCONNECT, 0038 GADGETFS_SETUP, 0039 GADGETFS_SUSPEND, 0040 /* and likely more ! */ 0041 }; 0042 0043 /* NOTE: this structure must stay the same size and layout on 0044 * both 32-bit and 64-bit kernels. 0045 */ 0046 struct usb_gadgetfs_event { 0047 union { 0048 /* NOP, DISCONNECT, SUSPEND: nothing 0049 * ... some hardware can't report disconnection 0050 */ 0051 0052 /* CONNECT: just the speed */ 0053 enum usb_device_speed speed; 0054 0055 /* SETUP: packet; DATA phase i/o precedes next event 0056 *(setup.bmRequestType & USB_DIR_IN) flags direction 0057 * ... includes SET_CONFIGURATION, SET_INTERFACE 0058 */ 0059 struct usb_ctrlrequest setup; 0060 } u; 0061 enum usb_gadgetfs_event_type type; 0062 }; 0063 0064 0065 /* The 'g' code is also used by printer gadget ioctl requests. 0066 * Don't add any colliding codes to either driver, and keep 0067 * them in unique ranges (size 0x20 for now). 0068 */ 0069 0070 /* endpoint ioctls */ 0071 0072 /* IN transfers may be reported to the gadget driver as complete 0073 * when the fifo is loaded, before the host reads the data; 0074 * OUT transfers may be reported to the host's "client" driver as 0075 * complete when they're sitting in the FIFO unread. 0076 * THIS returns how many bytes are "unclaimed" in the endpoint fifo 0077 * (needed for precise fault handling, when the hardware allows it) 0078 */ 0079 #define GADGETFS_FIFO_STATUS _IO('g', 1) 0080 0081 /* discards any unclaimed data in the fifo. */ 0082 #define GADGETFS_FIFO_FLUSH _IO('g', 2) 0083 0084 /* resets endpoint halt+toggle; used to implement set_interface. 0085 * some hardware (like pxa2xx) can't support this. 0086 */ 0087 #define GADGETFS_CLEAR_HALT _IO('g', 3) 0088 0089 #endif /* __LINUX_USB_GADGETFS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |