u_serial.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #ifndef __U_SERIAL_H
  12. #define __U_SERIAL_H
  13. #include <linux/usb/composite.h>
  14. #include <linux/usb/cdc.h>
  15. /*
  16. * One non-multiplexed "serial" I/O port ... there can be several of these
  17. * on any given USB peripheral device, if it provides enough endpoints.
  18. *
  19. * The "u_serial" utility component exists to do one thing: manage TTY
  20. * style I/O using the USB peripheral endpoints listed here, including
  21. * hookups to sysfs and /dev for each logical "tty" device.
  22. *
  23. * REVISIT need TTY --> USB event flow too, so ACM can report open/close
  24. * as carrier detect events. Model after ECM. There's more ACM state too.
  25. *
  26. * REVISIT someday, allow multiplexing several TTYs over these endpoints.
  27. */
  28. struct gserial {
  29. struct usb_function func;
  30. /* port is managed by gserial_{connect,disconnect} */
  31. struct gs_port *ioport;
  32. struct usb_ep *in;
  33. struct usb_ep *out;
  34. struct usb_endpoint_descriptor *in_desc;
  35. struct usb_endpoint_descriptor *out_desc;
  36. /* REVISIT avoid this CDC-ACM support harder ... */
  37. struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */
  38. };
  39. /* port setup/teardown is handled by gadget driver */
  40. int gserial_setup(struct usb_gadget *g, unsigned n_ports);
  41. void gserial_cleanup(void);
  42. /* connect/disconnect is handled by individual functions */
  43. int gserial_connect(struct gserial *, u8 port_num);
  44. void gserial_disconnect(struct gserial *);
  45. /* functions are bound to configurations by a config or gadget driver */
  46. int acm_bind_config(struct usb_configuration *c, u8 port_num);
  47. int gser_bind_config(struct usb_configuration *c, u8 port_num);
  48. #endif /* __U_SERIAL_H */