isp1760-udc.h 2.2 KB

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