blob: f06ee9a5db51cf427e2278be8b9e5bbc0c576313 [file] [log] [blame]
David Brownellc1dca562008-06-19 17:51:44 -07001/*
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 Brownell4d5a73d2008-06-19 18:18:40 -070015#include <linux/usb/composite.h>
David Brownellc1dca562008-06-19 17:51:44 -070016#include <linux/usb/cdc.h>
17
Sebastian Andrzej Siewior19b10a82012-12-23 21:10:06 +010018#define MAX_U_SERIAL_PORTS 4
19
David Brownellc1dca562008-06-19 17:51:44 -070020/*
21 * One non-multiplexed "serial" I/O port ... there can be several of these
22 * on any given USB peripheral device, if it provides enough endpoints.
23 *
24 * The "u_serial" utility component exists to do one thing: manage TTY
25 * style I/O using the USB peripheral endpoints listed here, including
26 * hookups to sysfs and /dev for each logical "tty" device.
27 *
David Brownell1f1ba112008-08-06 18:49:57 -070028 * REVISIT at least ACM could support tiocmget() if needed.
David Brownellc1dca562008-06-19 17:51:44 -070029 *
30 * REVISIT someday, allow multiplexing several TTYs over these endpoints.
31 */
32struct gserial {
David Brownell4d5a73d2008-06-19 18:18:40 -070033 struct usb_function func;
David Brownellc1dca562008-06-19 17:51:44 -070034
35 /* port is managed by gserial_{connect,disconnect} */
36 struct gs_port *ioport;
37
38 struct usb_ep *in;
39 struct usb_ep *out;
David Brownellc1dca562008-06-19 17:51:44 -070040
41 /* REVISIT avoid this CDC-ACM support harder ... */
42 struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */
David Brownell1f1ba112008-08-06 18:49:57 -070043
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 Brownellc1dca562008-06-19 17:51:44 -070048};
49
David Brownell1f1ba112008-08-06 18:49:57 -070050/* utilities to allocate/free request and buffer */
51struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags);
52void gs_free_req(struct usb_ep *, struct usb_request *req);
53
Sebastian Andrzej Siewior19b10a82012-12-23 21:10:06 +010054/* management of individual TTY ports */
55int gserial_alloc_line(unsigned char *port_line);
56void gserial_free_line(unsigned char port_line);
David Brownellc1dca562008-06-19 17:51:44 -070057
58/* connect/disconnect is handled by individual functions */
59int gserial_connect(struct gserial *, u8 port_num);
60void gserial_disconnect(struct gserial *);
61
David Brownell4d5a73d2008-06-19 18:18:40 -070062/* functions are bound to configurations by a config or gadget driver */
63int acm_bind_config(struct usb_configuration *c, u8 port_num);
David Brownell61d8bae2008-06-19 18:18:50 -070064int gser_bind_config(struct usb_configuration *c, u8 port_num);
Felipe Balbi30867752008-08-18 17:39:30 -070065int obex_bind_config(struct usb_configuration *c, u8 port_num);
David Brownell4d5a73d2008-06-19 18:18:40 -070066
David Brownellc1dca562008-06-19 17:51:44 -070067#endif /* __U_SERIAL_H */