1 // SPDX-License-Identifier: GPL-2.0+
3 * u_serial.h - interface to USB gadget "serial port"/TTY utilities
5 * Copyright (C) 2008 David Brownell
6 * Copyright (C) 2008 by Nokia Corporation
12 #include <linux/usb/composite.h>
13 #include <linux/usb/cdc.h>
15 #define MAX_U_SERIAL_PORTS 4
17 struct f_serial_opts
{
18 struct usb_function_instance func_inst
;
23 * One non-multiplexed "serial" I/O port ... there can be several of these
24 * on any given USB peripheral device, if it provides enough endpoints.
26 * The "u_serial" utility component exists to do one thing: manage TTY
27 * style I/O using the USB peripheral endpoints listed here, including
28 * hookups to sysfs and /dev for each logical "tty" device.
30 * REVISIT at least ACM could support tiocmget() if needed.
32 * REVISIT someday, allow multiplexing several TTYs over these endpoints.
35 struct usb_function func
;
37 /* port is managed by gserial_{connect,disconnect} */
38 struct gs_port
*ioport
;
43 /* REVISIT avoid this CDC-ACM support harder ... */
44 struct usb_cdc_line_coding port_line_coding
; /* 9600-8-N-1 etc */
46 /* notification callbacks */
47 void (*connect
)(struct gserial
*p
);
48 void (*disconnect
)(struct gserial
*p
);
49 int (*send_break
)(struct gserial
*p
, int duration
);
52 /* utilities to allocate/free request and buffer */
53 struct usb_request
*gs_alloc_req(struct usb_ep
*ep
, unsigned len
, gfp_t flags
);
54 void gs_free_req(struct usb_ep
*, struct usb_request
*req
);
56 /* management of individual TTY ports */
57 int gserial_alloc_line(unsigned char *port_line
);
58 void gserial_free_line(unsigned char port_line
);
60 /* connect/disconnect is handled by individual functions */
61 int gserial_connect(struct gserial
*, u8 port_num
);
62 void gserial_disconnect(struct gserial
*);
64 /* functions are bound to configurations by a config or gadget driver */
65 int gser_bind_config(struct usb_configuration
*c
, u8 port_num
);
66 int obex_bind_config(struct usb_configuration
*c
, u8 port_num
);
68 #endif /* __U_SERIAL_H */