pxa25x_udc.h 3.1 KB

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