omap1510_udc.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * (C) Copyright 2003
  3. * Gerry Hamel, geh@ti.com, Texas Instruments
  4. *
  5. * Based on
  6. * linux/drivers/usb/device/bi/omap.h
  7. * Register definitions for TI OMAP1510 USB bus interface driver
  8. *
  9. * Author: MontaVista Software, Inc.
  10. * source@mvista.com
  11. *
  12. * 2003 (c) MontaVista Software, Inc. This file is licensed under
  13. * the terms of the GNU General Public License version 2. This program
  14. * is licensed "as is" without any warranty of any kind, whether express
  15. * or implied.
  16. */
  17. #ifndef __USBDCORE_OMAP1510_H__
  18. #define __USBDCORE_OMAP1510_H__
  19. /*
  20. * 13.2 MPU Register Map
  21. */
  22. /* Table 13-1. USB Function Module Registers (endpoint) */
  23. #define UDC_BASE 0xFFFB4000
  24. #define UDC_OFFSET(offset) (UDC_BASE + (offset))
  25. #define UDC_REV UDC_OFFSET(0x0) /* Revision */
  26. #define UDC_EP_NUM UDC_OFFSET(0x4) /* Endpoint selection */
  27. #define UDC_DATA UDC_OFFSET(0x08) /* Data */
  28. #define UDC_CTRL UDC_OFFSET(0x0C) /* Control */
  29. #define UDC_STAT_FLG UDC_OFFSET(0x10) /* Status flag */
  30. #define UDC_RXFSTAT UDC_OFFSET(0x14) /* Receive FIFO status */
  31. #define UDC_SYSCON1 UDC_OFFSET(0x18) /* System configuration 1 */
  32. #define UDC_SYSCON2 UDC_OFFSET(0x1C) /* System configuration 2 */
  33. #define UDC_DEVSTAT UDC_OFFSET(0x20) /* Device status */
  34. #define UDC_SOF UDC_OFFSET(0x24) /* Start of frame */
  35. #define UDC_IRQ_EN UDC_OFFSET(0x28) /* Interrupt enable */
  36. #define UDC_DMA_IRQ_EN UDC_OFFSET(0x2C) /* DMA interrupt enable */
  37. #define UDC_IRQ_SRC UDC_OFFSET(0x30) /* Interrupt source */
  38. #define UDC_EPN_STAT UDC_OFFSET(0x34) /* Endpoint interrupt status */
  39. #define UDC_DMAN_STAT UDC_OFFSET(0x3C) /* DMA endpoint interrupt status */
  40. /* IRQ_EN register fields */
  41. #define UDC_Sof_IE (1 << 7) /* Start-of-frame interrupt enabled */
  42. #define UDC_EPn_RX_IE (1 << 5) /* Receive endpoint interrupt enabled */
  43. #define UDC_EPn_TX_IE (1 << 4) /* Transmit endpoint interrupt enabled */
  44. #define UDC_DS_Chg_IE (1 << 3) /* Device state changed interrupt enabled */
  45. #define UDC_EP0_IE (1 << 0) /* EP0 transaction interrupt enabled */
  46. /* IRQ_SRC register fields */
  47. #define UDC_TXn_Done (1 << 10) /* Transmit DMA channel n done */
  48. #define UDC_RXn_Cnt (1 << 9) /* Receive DMA channel n transactions count */
  49. #define UDC_RXn_EOT (1 << 8) /* Receive DMA channel n end of transfer */
  50. #define UDC_SOF_Flg (1 << 7) /* Start-of-frame interrupt flag */
  51. #define UDC_EPn_RX (1 << 5) /* Endpoint n OUT transaction */
  52. #define UDC_EPn_TX (1 << 4) /* Endpoint n IN transaction */
  53. #define UDC_DS_Chg (1 << 3) /* Device state changed */
  54. #define UDC_Setup (1 << 2) /* Setup transaction */
  55. #define UDC_EP0_RX (1 << 1) /* EP0 OUT transaction */
  56. #define UDC_EP0_TX (1 << 0) /* EP0 IN transaction */
  57. /* DEVSTAT register fields, 14.2.9 */
  58. #define UDC_R_WK_OK (1 << 6) /* Remote wakeup granted */
  59. #define UDC_USB_Reset (1 << 5) /* USB reset signalling is active */
  60. #define UDC_SUS (1 << 4) /* Suspended state */
  61. #define UDC_CFG (1 << 3) /* Configured state */
  62. #define UDC_ADD (1 << 2) /* Addressed state */
  63. #define UDC_DEF (1 << 1) /* Default state */
  64. #define UDC_ATT (1 << 0) /* Attached state */
  65. /* SYSCON1 register fields */
  66. #define UDC_Cfg_Lock (1 << 8) /* Device configuration locked */
  67. #define UDC_Nak_En (1 << 4) /* NAK enable */
  68. #define UDC_Self_Pwr (1 << 2) /* Device is self-powered */
  69. #define UDC_Soff_Dis (1 << 1) /* Shutoff disabled */
  70. #define UDC_Pullup_En (1 << 0) /* External pullup enabled */
  71. /* SYSCON2 register fields */
  72. #define UDC_Rmt_Wkp (1 << 6) /* Remote wakeup */
  73. #define UDC_Stall_Cmd (1 << 5) /* Stall endpoint */
  74. #define UDC_Dev_Cfg (1 << 3) /* Device configured */
  75. #define UDC_Clr_Cfg (1 << 2) /* Clear configured */
  76. /*
  77. * Select and enable endpoints
  78. */
  79. /* Table 13-1. USB Function Module Registers (endpoint configuration) */
  80. #define UDC_EPBASE UDC_OFFSET(0x80) /* Endpoints base address */
  81. #define UDC_EP0 UDC_EPBASE /* Control endpoint configuration */
  82. #define UDC_EP_RX_BASE UDC_OFFSET(0x84) /* Receive endpoints base address */
  83. #define UDC_EP_RX(endpoint) (UDC_EP_RX_BASE + ((endpoint) - 1) * 4)
  84. #define UDC_EP_TX_BASE UDC_OFFSET(0xC4) /* Transmit endpoints base address */
  85. #define UDC_EP_TX(endpoint) (UDC_EP_TX_BASE + ((endpoint) - 1) * 4)
  86. /* EP_NUM register fields */
  87. #define UDC_Setup_Sel (1 << 6) /* Setup FIFO select */
  88. #define UDC_EP_Sel (1 << 5) /* TX/RX FIFO select */
  89. #define UDC_EP_Dir (1 << 4) /* Endpoint direction */
  90. /* CTRL register fields */
  91. #define UDC_Clr_Halt (1 << 7) /* Clear halt endpoint */
  92. #define UDC_Set_Halt (1 << 6) /* Set halt endpoint */
  93. #define UDC_Set_FIFO_En (1 << 2) /* Set FIFO enable */
  94. #define UDC_Clr_EP (1 << 1) /* Clear endpoint */
  95. #define UDC_Reset_EP (1 << 0) /* Reset endpoint */
  96. /* STAT_FLG register fields */
  97. #define UDC_Miss_In (1 << 14)
  98. #define UDC_Data_Flush (1 << 13)
  99. #define UDC_ISO_Err (1 << 12)
  100. #define UDC_ISO_FIFO_Empty (1 << 9)
  101. #define UDC_ISO_FIFO_Full (1 << 8)
  102. #define UDC_EP_Halted (1 << 6)
  103. #define UDC_STALL (1 << 5)
  104. #define UDC_NAK (1 << 4)
  105. #define UDC_ACK (1 << 3)
  106. #define UDC_FIFO_En (1 << 2)
  107. #define UDC_Non_ISO_FIFO_Empty (1 << 1)
  108. #define UDC_Non_ISO_FIFO_Full (1 << 0)
  109. /* EPn_RX register fields */
  110. #define UDC_EPn_RX_Valid (1 << 15) /* valid */
  111. #define UDC_EPn_RX_Db (1 << 14) /* double-buffer */
  112. #define UDC_EPn_RX_Iso (1 << 11) /* isochronous */
  113. /* EPn_TX register fields */
  114. #define UDC_EPn_TX_Valid (1 << 15) /* valid */
  115. #define UDC_EPn_TX_Db (1 << 14) /* double-buffer */
  116. #define UDC_EPn_TX_Iso (1 << 11) /* isochronous */
  117. #define EP0_PACKETSIZE 0x40
  118. /* physical to logical endpoint mapping
  119. * Physical endpoints are an index into device->bus->endpoint_array.
  120. * Logical endpoints are endpoints 0 to 15 IN and OUT as defined in
  121. * the USB specification.
  122. *
  123. * physical ep logical ep direction endpoint_address
  124. * 0 0 IN and OUT 0x00
  125. * 1 to 15 1 to 15 OUT 0x01 to 0x0f
  126. * 16 to 30 1 to 15 IN 0x81 to 0x8f
  127. */
  128. #define PHYS_EP_TO_EP_ADDR(ep) (((ep) < 16) ? (ep) : (((ep) - 15) | 0x80))
  129. #define EP_ADDR_TO_PHYS_EP(a) (((a) & 0x80) ? (((a) & ~0x80) + 15) : (a))
  130. /* MOD_CONF_CTRL_0 bits (FIXME: move to board hardware.h ?) */
  131. #define CONF_MOD_USB_W2FC_VBUS_MODE_R (1 << 17)
  132. /* Other registers (may be) related to USB */
  133. #define CLOCK_CTRL (0xFFFE0830)
  134. #define APLL_CTRL (0xFFFE084C)
  135. #define DPLL_CTRL (0xFFFE083C)
  136. #define SOFT_REQ (0xFFFE0834)
  137. #define STATUS_REQ (0xFFFE0840)
  138. /* FUNC_MUX_CTRL_0 bits related to USB */
  139. #define UDC_VBUS_CTRL (1 << 19)
  140. #define UDC_VBUS_MODE (1 << 18)
  141. /* OMAP Endpoint parameters */
  142. #define EP0_MAX_PACKET_SIZE 64
  143. #define UDC_OUT_ENDPOINT 2
  144. #define UDC_OUT_PACKET_SIZE 64
  145. #define UDC_IN_ENDPOINT 1
  146. #define UDC_IN_PACKET_SIZE 64
  147. #define UDC_INT_ENDPOINT 5
  148. #define UDC_INT_PACKET_SIZE 16
  149. #define UDC_BULK_PACKET_SIZE 16
  150. void udc_irq (void);
  151. /* Flow control */
  152. void udc_set_nak(int epid);
  153. void udc_unset_nak (int epid);
  154. /* Higher level functions for abstracting away from specific device */
  155. int udc_endpoint_write(struct usb_endpoint_instance *endpoint);
  156. int udc_init (void);
  157. void udc_enable(struct usb_device_instance *device);
  158. void udc_disable(void);
  159. void udc_connect(void);
  160. void udc_disconnect(void);
  161. void udc_startup_events(struct usb_device_instance *device);
  162. void udc_setup_ep(struct usb_device_instance *device, unsigned int ep, struct usb_endpoint_instance *endpoint);
  163. #endif