aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb')
-rw-r--r--include/linux/usb/Kbuild1
-rw-r--r--include/linux/usb/gadgetfs.h81
-rw-r--r--include/linux/usb/quirks.h3
-rw-r--r--include/linux/usb/serial.h7
4 files changed, 92 insertions, 0 deletions
diff --git a/include/linux/usb/Kbuild b/include/linux/usb/Kbuild
index 43f160cfe003..6ce42bf9f743 100644
--- a/include/linux/usb/Kbuild
+++ b/include/linux/usb/Kbuild
@@ -1,5 +1,6 @@
1unifdef-y += audio.h 1unifdef-y += audio.h
2unifdef-y += cdc.h 2unifdef-y += cdc.h
3unifdef-y += ch9.h 3unifdef-y += ch9.h
4unifdef-y += gadgetfs.h
4unifdef-y += midi.h 5unifdef-y += midi.h
5 6
diff --git a/include/linux/usb/gadgetfs.h b/include/linux/usb/gadgetfs.h
new file mode 100644
index 000000000000..e8654c338729
--- /dev/null
+++ b/include/linux/usb/gadgetfs.h
@@ -0,0 +1,81 @@
1#ifndef __LINUX_USB_GADGETFS_H
2#define __LINUX_USB_GADGETFS_H
3
4#include <asm/types.h>
5#include <asm/ioctl.h>
6
7#include <linux/usb/ch9.h>
8
9/*
10 * Filesystem based user-mode API to USB Gadget controller hardware
11 *
12 * Other than ep0 operations, most things are done by read() and write()
13 * on endpoint files found in one directory. They are configured by
14 * writing descriptors, and then may be used for normal stream style
15 * i/o requests. When ep0 is configured, the device can enumerate;
16 * when it's closed, the device disconnects from usb. Operations on
17 * ep0 require ioctl() operations.
18 *
19 * Configuration and device descriptors get written to /dev/gadget/$CHIP,
20 * which may then be used to read usb_gadgetfs_event structs. The driver
21 * may activate endpoints as it handles SET_CONFIGURATION setup events,
22 * or earlier; writing endpoint descriptors to /dev/gadget/$ENDPOINT
23 * then performing data transfers by reading or writing.
24 */
25
26/*
27 * Events are delivered on the ep0 file descriptor, when the user mode driver
28 * reads from this file descriptor after writing the descriptors. Don't
29 * stop polling this descriptor.
30 */
31
32enum usb_gadgetfs_event_type {
33 GADGETFS_NOP = 0,
34
35 GADGETFS_CONNECT,
36 GADGETFS_DISCONNECT,
37 GADGETFS_SETUP,
38 GADGETFS_SUSPEND,
39 // and likely more !
40};
41
42/* NOTE: this structure must stay the same size and layout on
43 * both 32-bit and 64-bit kernels.
44 */
45struct usb_gadgetfs_event {
46 union {
47 // NOP, DISCONNECT, SUSPEND: nothing
48 // ... some hardware can't report disconnection
49
50 // CONNECT: just the speed
51 enum usb_device_speed speed;
52
53 // SETUP: packet; DATA phase i/o precedes next event
54 // (setup.bmRequestType & USB_DIR_IN) flags direction
55 // ... includes SET_CONFIGURATION, SET_INTERFACE
56 struct usb_ctrlrequest setup;
57 } u;
58 enum usb_gadgetfs_event_type type;
59};
60
61
62/* endpoint ioctls */
63
64/* IN transfers may be reported to the gadget driver as complete
65 * when the fifo is loaded, before the host reads the data;
66 * OUT transfers may be reported to the host's "client" driver as
67 * complete when they're sitting in the FIFO unread.
68 * THIS returns how many bytes are "unclaimed" in the endpoint fifo
69 * (needed for precise fault handling, when the hardware allows it)
70 */
71#define GADGETFS_FIFO_STATUS _IO('g',1)
72
73/* discards any unclaimed data in the fifo. */
74#define GADGETFS_FIFO_FLUSH _IO('g',2)
75
76/* resets endpoint halt+toggle; used to implement set_interface.
77 * some hardware (like pxa2xx) can't support this.
78 */
79#define GADGETFS_CLEAR_HALT _IO('g',3)
80
81#endif /* __LINUX_USB_GADGETFS_H */
diff --git a/include/linux/usb/quirks.h b/include/linux/usb/quirks.h
index 6bac8faacbc6..8da374caf582 100644
--- a/include/linux/usb/quirks.h
+++ b/include/linux/usb/quirks.h
@@ -9,3 +9,6 @@
9 9
10/* string descriptors must not be fetched using a 255-byte read */ 10/* string descriptors must not be fetched using a 255-byte read */
11#define USB_QUIRK_STRING_FETCH_255 0x00000002 11#define USB_QUIRK_STRING_FETCH_255 0x00000002
12
13/* device can't resume correctly so reset it instead */
14#define USB_QUIRK_RESET_RESUME 0x00000004
diff --git a/include/linux/usb/serial.h b/include/linux/usb/serial.h
index 32acbae28d24..e8b8928232c8 100644
--- a/include/linux/usb/serial.h
+++ b/include/linux/usb/serial.h
@@ -221,6 +221,9 @@ struct usb_serial_driver {
221 int (*port_probe) (struct usb_serial_port *port); 221 int (*port_probe) (struct usb_serial_port *port);
222 int (*port_remove) (struct usb_serial_port *port); 222 int (*port_remove) (struct usb_serial_port *port);
223 223
224 int (*suspend) (struct usb_serial *serial, pm_message_t message);
225 int (*resume) (struct usb_serial *serial);
226
224 /* serial function calls */ 227 /* serial function calls */
225 int (*open) (struct usb_serial_port *port, struct file * filp); 228 int (*open) (struct usb_serial_port *port, struct file * filp);
226 void (*close) (struct usb_serial_port *port, struct file * filp); 229 void (*close) (struct usb_serial_port *port, struct file * filp);
@@ -249,6 +252,9 @@ extern void usb_serial_port_softint(struct usb_serial_port *port);
249extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id); 252extern int usb_serial_probe(struct usb_interface *iface, const struct usb_device_id *id);
250extern void usb_serial_disconnect(struct usb_interface *iface); 253extern void usb_serial_disconnect(struct usb_interface *iface);
251 254
255extern int usb_serial_suspend(struct usb_interface *intf, pm_message_t message);
256extern int usb_serial_resume(struct usb_interface *intf);
257
252extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest); 258extern int ezusb_writememory (struct usb_serial *serial, int address, unsigned char *data, int length, __u8 bRequest);
253extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit); 259extern int ezusb_set_reset (struct usb_serial *serial, unsigned char reset_bit);
254 260
@@ -269,6 +275,7 @@ extern void usb_serial_put(struct usb_serial *serial);
269extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp); 275extern int usb_serial_generic_open (struct usb_serial_port *port, struct file *filp);
270extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count); 276extern int usb_serial_generic_write (struct usb_serial_port *port, const unsigned char *buf, int count);
271extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp); 277extern void usb_serial_generic_close (struct usb_serial_port *port, struct file *filp);
278extern int usb_serial_generic_resume (struct usb_serial *serial);
272extern int usb_serial_generic_write_room (struct usb_serial_port *port); 279extern int usb_serial_generic_write_room (struct usb_serial_port *port);
273extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port); 280extern int usb_serial_generic_chars_in_buffer (struct usb_serial_port *port);
274extern void usb_serial_generic_read_bulk_callback (struct urb *urb); 281extern void usb_serial_generic_read_bulk_callback (struct urb *urb);