pxa25x_udc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Intel PXA25x on-chip full speed USB device controller
  4. *
  5. * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  6. * Copyright (C) 2003 David Brownell
  7. * Copyright (C) 2012 Lukasz Dalek <luk0104@gmail.com>
  8. */
  9. #ifndef __LINUX_USB_GADGET_PXA25X_H
  10. #define __LINUX_USB_GADGET_PXA25X_H
  11. #include <linux/types.h>
  12. #include <asm/arch/regs-usb.h>
  13. /*
  14. * Prefetching support - only ARMv5.
  15. */
  16. #ifdef ARCH_HAS_PREFETCH
  17. static inline void prefetch(const void *ptr)
  18. {
  19. __asm__ __volatile__(
  20. "pld\t%a0"
  21. :
  22. : "p" (ptr)
  23. : "cc");
  24. }
  25. #define prefetchw(ptr) prefetch(ptr)
  26. #endif /* ARCH_HAS_PREFETCH */
  27. /*-------------------------------------------------------------------------*/
  28. #define UDC_REGS ((struct pxa25x_udc_regs *)PXA25X_UDC_BASE)
  29. /*-------------------------------------------------------------------------*/
  30. struct pxa2xx_udc_mach_info {
  31. int (*udc_is_connected)(void); /* do we see host? */
  32. void (*udc_command)(int cmd);
  33. #define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */
  34. #define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */
  35. };
  36. struct pxa25x_udc;
  37. struct pxa25x_ep {
  38. struct usb_ep ep;
  39. struct pxa25x_udc *dev;
  40. const struct usb_endpoint_descriptor *desc;
  41. struct list_head queue;
  42. unsigned long pio_irqs;
  43. unsigned short fifo_size;
  44. u8 bEndpointAddress;
  45. u8 bmAttributes;
  46. unsigned stopped:1;
  47. /* UDCCS = UDC Control/Status for this EP
  48. * UBCR = UDC Byte Count Remaining (contents of OUT fifo)
  49. * UDDR = UDC Endpoint Data Register (the fifo)
  50. * DRCM = DMA Request Channel Map
  51. */
  52. u32 *reg_udccs;
  53. u32 *reg_ubcr;
  54. u32 *reg_uddr;
  55. };
  56. struct pxa25x_request {
  57. struct usb_request req;
  58. struct list_head queue;
  59. };
  60. enum ep0_state {
  61. EP0_IDLE,
  62. EP0_IN_DATA_PHASE,
  63. EP0_OUT_DATA_PHASE,
  64. EP0_END_XFER,
  65. EP0_STALL,
  66. };
  67. #define EP0_FIFO_SIZE 16U
  68. #define BULK_FIFO_SIZE 64U
  69. #define ISO_FIFO_SIZE 256U
  70. #define INT_FIFO_SIZE 8U
  71. struct udc_stats {
  72. struct ep0stats {
  73. unsigned long ops;
  74. unsigned long bytes;
  75. } read, write;
  76. unsigned long irqs;
  77. };
  78. #ifdef CONFIG_USB_PXA25X_SMALL
  79. /* when memory's tight, SMALL config saves code+data. */
  80. #define PXA_UDC_NUM_ENDPOINTS 3
  81. #endif
  82. #ifndef PXA_UDC_NUM_ENDPOINTS
  83. #define PXA_UDC_NUM_ENDPOINTS 16
  84. #endif
  85. struct pxa25x_watchdog {
  86. unsigned running:1;
  87. ulong period;
  88. ulong base;
  89. struct pxa25x_udc *udc;
  90. void (*function)(struct pxa25x_udc *udc);
  91. };
  92. struct pxa25x_udc {
  93. struct usb_gadget gadget;
  94. struct usb_gadget_driver *driver;
  95. struct pxa25x_udc_regs *regs;
  96. enum ep0_state ep0state;
  97. struct udc_stats stats;
  98. unsigned got_irq:1,
  99. pullup:1,
  100. has_cfr:1,
  101. req_pending:1,
  102. req_std:1,
  103. req_config:1,
  104. active:1;
  105. struct clk *clk;
  106. struct pxa2xx_udc_mach_info *mach;
  107. u64 dma_mask;
  108. struct pxa25x_ep ep[PXA_UDC_NUM_ENDPOINTS];
  109. struct pxa25x_watchdog watchdog;
  110. };
  111. /*-------------------------------------------------------------------------*/
  112. static struct pxa25x_udc *the_controller;
  113. /*-------------------------------------------------------------------------*/
  114. #ifndef DEBUG
  115. # define NOISY 0
  116. #endif
  117. #endif /* __LINUX_USB_GADGET_PXA25X_H */