pxa25x_udc.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Intel PXA25x on-chip full speed USB device controller
  3. *
  4. * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>, Pengutronix
  5. * Copyright (C) 2003 David Brownell
  6. * Copyright (C) 2012 Lukasz Dalek <luk0104@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. #ifndef __LINUX_USB_GADGET_PXA25X_H
  23. #define __LINUX_USB_GADGET_PXA25X_H
  24. #include <linux/types.h>
  25. #include <asm/arch/regs-usb.h>
  26. /*
  27. * Prefetching support - only ARMv5.
  28. */
  29. #ifdef ARCH_HAS_PREFETCH
  30. static inline void prefetch(const void *ptr)
  31. {
  32. __asm__ __volatile__(
  33. "pld\t%a0"
  34. :
  35. : "p" (ptr)
  36. : "cc");
  37. }
  38. #define prefetchw(ptr) prefetch(ptr)
  39. #endif /* ARCH_HAS_PREFETCH */
  40. /*-------------------------------------------------------------------------*/
  41. #define UDC_REGS ((struct pxa25x_udc_regs *)PXA25X_UDC_BASE)
  42. /*-------------------------------------------------------------------------*/
  43. struct pxa2xx_udc_mach_info {
  44. int (*udc_is_connected)(void); /* do we see host? */
  45. void (*udc_command)(int cmd);
  46. #define PXA2XX_UDC_CMD_CONNECT 0 /* let host see us */
  47. #define PXA2XX_UDC_CMD_DISCONNECT 1 /* so host won't see us */
  48. };
  49. struct pxa25x_udc;
  50. struct pxa25x_ep {
  51. struct usb_ep ep;
  52. struct pxa25x_udc *dev;
  53. const struct usb_endpoint_descriptor *desc;
  54. struct list_head queue;
  55. unsigned long pio_irqs;
  56. unsigned short fifo_size;
  57. u8 bEndpointAddress;
  58. u8 bmAttributes;
  59. unsigned stopped:1;
  60. /* UDCCS = UDC Control/Status for this EP
  61. * UBCR = UDC Byte Count Remaining (contents of OUT fifo)
  62. * UDDR = UDC Endpoint Data Register (the fifo)
  63. * DRCM = DMA Request Channel Map
  64. */
  65. u32 *reg_udccs;
  66. u32 *reg_ubcr;
  67. u32 *reg_uddr;
  68. };
  69. struct pxa25x_request {
  70. struct usb_request req;
  71. struct list_head queue;
  72. };
  73. enum ep0_state {
  74. EP0_IDLE,
  75. EP0_IN_DATA_PHASE,
  76. EP0_OUT_DATA_PHASE,
  77. EP0_END_XFER,
  78. EP0_STALL,
  79. };
  80. #define EP0_FIFO_SIZE 16U
  81. #define BULK_FIFO_SIZE 64U
  82. #define ISO_FIFO_SIZE 256U
  83. #define INT_FIFO_SIZE 8U
  84. struct udc_stats {
  85. struct ep0stats {
  86. unsigned long ops;
  87. unsigned long bytes;
  88. } read, write;
  89. unsigned long irqs;
  90. };
  91. #ifdef CONFIG_USB_PXA25X_SMALL
  92. /* when memory's tight, SMALL config saves code+data. */
  93. #define PXA_UDC_NUM_ENDPOINTS 3
  94. #endif
  95. #ifndef PXA_UDC_NUM_ENDPOINTS
  96. #define PXA_UDC_NUM_ENDPOINTS 16
  97. #endif
  98. struct pxa25x_watchdog {
  99. unsigned running:1;
  100. ulong period;
  101. ulong base;
  102. struct pxa25x_udc *udc;
  103. void (*function)(struct pxa25x_udc *udc);
  104. };
  105. struct pxa25x_udc {
  106. struct usb_gadget gadget;
  107. struct usb_gadget_driver *driver;
  108. struct pxa25x_udc_regs *regs;
  109. enum ep0_state ep0state;
  110. struct udc_stats stats;
  111. unsigned got_irq:1,
  112. pullup:1,
  113. has_cfr:1,
  114. req_pending:1,
  115. req_std:1,
  116. req_config:1,
  117. active:1;
  118. struct clk *clk;
  119. struct pxa2xx_udc_mach_info *mach;
  120. u64 dma_mask;
  121. struct pxa25x_ep ep[PXA_UDC_NUM_ENDPOINTS];
  122. struct pxa25x_watchdog watchdog;
  123. };
  124. /*-------------------------------------------------------------------------*/
  125. static struct pxa25x_udc *the_controller;
  126. /*-------------------------------------------------------------------------*/
  127. #ifndef DEBUG
  128. # define NOISY 0
  129. #endif
  130. #endif /* __LINUX_USB_GADGET_PXA25X_H */