u_serial.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 at least ACM could support tiocmget() if needed.
  24. *
  25. * REVISIT someday, allow multiplexing several TTYs over these endpoints.
  26. */
  27. struct gserial {
  28. struct usb_function func;
  29. /* port is managed by gserial_{connect,disconnect} */
  30. struct gs_port *ioport;
  31. struct usb_ep *in;
  32. struct usb_ep *out;
  33. struct usb_endpoint_descriptor *in_desc;
  34. struct usb_endpoint_descriptor *out_desc;
  35. /* REVISIT avoid this CDC-ACM support harder ... */
  36. struct usb_cdc_line_coding port_line_coding; /* 9600-8-N-1 etc */
  37. /* notification callbacks */
  38. void (*connect)(struct gserial *p);
  39. void (*disconnect)(struct gserial *p);
  40. int (*send_break)(struct gserial *p, int duration);
  41. };
  42. /* utilities to allocate/free request and buffer */
  43. struct usb_request *gs_alloc_req(struct usb_ep *ep, unsigned len, gfp_t flags);
  44. void gs_free_req(struct usb_ep *, struct usb_request *req);
  45. /* port setup/teardown is handled by gadget driver */
  46. int gserial_setup(struct usb_gadget *g, unsigned n_ports);
  47. void gserial_cleanup(void);
  48. /* connect/disconnect is handled by individual functions */
  49. int gserial_connect(struct gserial *, u8 port_num);
  50. void gserial_disconnect(struct gserial *);
  51. /* functions are bound to configurations by a config or gadget driver */
  52. int acm_bind_config(struct usb_configuration *c, u8 port_num);
  53. int gser_bind_config(struct usb_configuration *c, u8 port_num);
  54. int obex_bind_config(struct usb_configuration *c, u8 port_num);
  55. #endif /* __U_SERIAL_H */