David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 1 | /* |
| 2 | * u_serial.h - interface to USB gadget "serial port"/TTY utilities |
| 3 | * |
| 4 | * Copyright (C) 2008 David Brownell |
| 5 | * Copyright (C) 2008 by Nokia Corporation |
| 6 | * |
| 7 | * This software is distributed under the terms of the GNU General |
| 8 | * Public License ("GPL") as published by the Free Software Foundation, |
| 9 | * either version 2 of that License or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #ifndef __U_SERIAL_H |
| 13 | #define __U_SERIAL_H |
| 14 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 15 | #include <linux/usb/composite.h> |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 16 | #include <linux/usb/cdc.h> |
| 17 | |
| 18 | /* |
| 19 | * One non-multiplexed "serial" I/O port ... there can be several of these |
| 20 | * on any given USB peripheral device, if it provides enough endpoints. |
| 21 | * |
| 22 | * The "u_serial" utility component exists to do one thing: manage TTY |
| 23 | * style I/O using the USB peripheral endpoints listed here, including |
| 24 | * hookups to sysfs and /dev for each logical "tty" device. |
| 25 | * |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 26 | * REVISIT at least ACM could support tiocmget() if needed. |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 27 | * |
| 28 | * REVISIT someday, allow multiplexing several TTYs over these endpoints. |
| 29 | */ |
| 30 | struct gserial { |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 31 | struct usb_function func; |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 32 | |
| 33 | /* port is managed by gserial_{connect,disconnect} */ |
| 34 | struct gs_port *ioport; |
| 35 | |
| 36 | struct usb_ep *in; |
| 37 | struct usb_ep *out; |
| 38 | struct usb_endpoint_descriptor *in_desc; |
| 39 | struct usb_endpoint_descriptor *out_desc; |
| 40 | |
| 41 | /* REVISIT avoid this CDC-ACM support harder ... */ |
| 42 | struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */ |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 43 | |
| 44 | /* notification callbacks */ |
| 45 | void (*connect)(struct gserial *p); |
| 46 | void (*disconnect)(struct gserial *p); |
| 47 | int (*send_break)(struct gserial *p, int duration); |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 48 | }; |
| 49 | |
David Brownell | 1f1ba11 | 2008-08-06 18:49:57 -0700 | [diff] [blame] | 50 | /* utilities to allocate/free request and buffer */ |
| 51 | struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags); |
| 52 | void gs_free_req(struct usb_ep *, struct usb_request *req); |
| 53 | |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 54 | /* port setup/teardown is handled by gadget driver */ |
| 55 | int gserial_setup(struct usb_gadget *g, unsigned n_ports); |
| 56 | void gserial_cleanup(void); |
| 57 | |
| 58 | /* connect/disconnect is handled by individual functions */ |
| 59 | int gserial_connect(struct gserial *, u8 port_num); |
| 60 | void gserial_disconnect(struct gserial *); |
| 61 | |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 62 | /* functions are bound to configurations by a config or gadget driver */ |
| 63 | int acm_bind_config(struct usb_configuration *c, u8 port_num); |
David Brownell | 61d8bae | 2008-06-19 18:18:50 -0700 | [diff] [blame] | 64 | int gser_bind_config(struct usb_configuration *c, u8 port_num); |
Felipe Balbi | 3086775 | 2008-08-18 17:39:30 -0700 | [diff] [blame] | 65 | int obex_bind_config(struct usb_configuration *c, u8 port_num); |
David Brownell | 4d5a73d | 2008-06-19 18:18:40 -0700 | [diff] [blame] | 66 | |
David Brownell | c1dca56 | 2008-06-19 17:51:44 -0700 | [diff] [blame] | 67 | #endif /* __U_SERIAL_H */ |