isp1760-udc.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * Driver for the NXP ISP1761 device controller
  3. *
  4. * Copyright 2014 Ideas on Board Oy
  5. *
  6. * Contacts:
  7. * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * version 2 as published by the Free Software Foundation.
  12. */
  13. #ifndef _ISP1760_UDC_H_
  14. #define _ISP1760_UDC_H_
  15. #include <linux/ioport.h>
  16. #include <linux/list.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/timer.h>
  19. #include <linux/usb/gadget.h>
  20. struct isp1760_device;
  21. struct isp1760_udc;
  22. enum isp1760_ctrl_state {
  23. ISP1760_CTRL_SETUP, /* Waiting for a SETUP transaction */
  24. ISP1760_CTRL_DATA_IN, /* Setup received, data IN stage */
  25. ISP1760_CTRL_DATA_OUT, /* Setup received, data OUT stage */
  26. ISP1760_CTRL_STATUS, /* 0-length request in status stage */
  27. };
  28. struct isp1760_ep {
  29. struct isp1760_udc *udc;
  30. struct usb_ep ep;
  31. struct list_head queue;
  32. unsigned int addr;
  33. unsigned int maxpacket;
  34. char name[7];
  35. const struct usb_endpoint_descriptor *desc;
  36. bool rx_pending;
  37. bool halted;
  38. bool wedged;
  39. };
  40. /**
  41. * struct isp1760_udc - UDC state information
  42. * irq: IRQ number
  43. * irqname: IRQ name (as passed to request_irq)
  44. * regs: Base address of the UDC registers
  45. * driver: Gadget driver
  46. * gadget: Gadget device
  47. * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
  48. * ep: Array of endpoints
  49. * ep0_state: Control request state for endpoint 0
  50. * ep0_dir: Direction of the current control request
  51. * ep0_length: Length of the current control request
  52. * connected: Tracks gadget driver bus connection state
  53. */
  54. struct isp1760_udc {
  55. #ifdef CONFIG_USB_ISP1761_UDC
  56. struct isp1760_device *isp;
  57. int irq;
  58. char *irqname;
  59. void __iomem *regs;
  60. struct usb_gadget_driver *driver;
  61. struct usb_gadget gadget;
  62. spinlock_t lock;
  63. struct timer_list vbus_timer;
  64. struct isp1760_ep ep[15];
  65. enum isp1760_ctrl_state ep0_state;
  66. u8 ep0_dir;
  67. u16 ep0_length;
  68. bool connected;
  69. unsigned int devstatus;
  70. #endif
  71. };
  72. #ifdef CONFIG_USB_ISP1761_UDC
  73. int isp1760_udc_register(struct isp1760_device *isp, int irq,
  74. unsigned long irqflags);
  75. void isp1760_udc_unregister(struct isp1760_device *isp);
  76. #else
  77. static inline int isp1760_udc_register(struct isp1760_device *isp, int irq,
  78. unsigned long irqflags)
  79. {
  80. return 0;
  81. }
  82. static inline void isp1760_udc_unregister(struct isp1760_device *isp)
  83. {
  84. }
  85. #endif
  86. #endif