blob: dadc507f2e5a92ad1c3dcc74156b07e826ff3707 [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
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 Brownell1f1ba112008-08-06 18:49:57 -070026 * REVISIT at least ACM could support tiocmget() if needed.
David Brownellc1dca562008-06-19 17:51:44 -070027 *
28 * REVISIT someday, allow multiplexing several TTYs over these endpoints.
29 */
30struct gserial {
David Brownell4d5a73d2008-06-19 18:18:40 -070031 struct usb_function func;
David Brownellc1dca562008-06-19 17:51:44 -070032
33 /* port is managed by gserial_{connect,disconnect} */
34 struct gs_port *ioport;
35
36 struct usb_ep *in;
37 struct usb_ep *out;
David Brownellc1dca562008-06-19 17:51:44 -070038
39 /* REVISIT avoid this CDC-ACM support harder ... */
40 struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070041 u16 serial_state;
42
43 /* control signal callbacks*/
44 unsigned int (*get_dtr)(struct gserial *p);
45 unsigned int (*get_rts)(struct gserial *p);
David Brownell1f1ba112008-08-06 18:49:57 -070046
47 /* notification callbacks */
48 void (*connect)(struct gserial *p);
49 void (*disconnect)(struct gserial *p);
50 int (*send_break)(struct gserial *p, int duration);
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051 unsigned int (*send_carrier_detect)(struct gserial *p, unsigned int);
52 unsigned int (*send_ring_indicator)(struct gserial *p, unsigned int);
53 int (*send_modem_ctrl_bits)(struct gserial *p, int ctrl_bits);
54
55 /* notification changes to modem */
Hemant Kumarf60c0252011-11-03 12:37:07 -070056 void (*notify_modem)(void *gser, u8 portno, int ctrl_bits);
David Brownellc1dca562008-06-19 17:51:44 -070057};
58
David Brownell1f1ba112008-08-06 18:49:57 -070059/* utilities to allocate/free request and buffer */
60struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags);
61void gs_free_req(struct usb_ep *, struct usb_request *req);
62
David Brownellc1dca562008-06-19 17:51:44 -070063/* port setup/teardown is handled by gadget driver */
64int gserial_setup(struct usb_gadget *g, unsigned n_ports);
65void gserial_cleanup(void);
66
67/* connect/disconnect is handled by individual functions */
68int gserial_connect(struct gserial *, u8 port_num);
69void gserial_disconnect(struct gserial *);
70
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070071/* sdio related functions */
72int gsdio_setup(struct usb_gadget *g, unsigned n_ports);
73int gsdio_connect(struct gserial *, u8 port_num);
74void gsdio_disconnect(struct gserial *, u8 portno);
75
76int gsmd_setup(struct usb_gadget *g, unsigned n_ports);
77int gsmd_connect(struct gserial *, u8 port_num);
78void gsmd_disconnect(struct gserial *, u8 portno);
79
David Brownell4d5a73d2008-06-19 18:18:40 -070080/* functions are bound to configurations by a config or gadget driver */
81int acm_bind_config(struct usb_configuration *c, u8 port_num);
David Brownell61d8bae2008-06-19 18:18:50 -070082int gser_bind_config(struct usb_configuration *c, u8 port_num);
Felipe Balbi30867752008-08-18 17:39:30 -070083int obex_bind_config(struct usb_configuration *c, u8 port_num);
David Brownell4d5a73d2008-06-19 18:18:40 -070084
David Brownellc1dca562008-06-19 17:51:44 -070085#endif /* __U_SERIAL_H */