imx_udc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. /*
  2. * Copyright (C) 2010-2012 Freescale Semiconductor, Inc.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in
  11. * the documentation and/or other materials provided with the
  12. * distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  15. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  16. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  17. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  18. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  20. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  21. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  22. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  24. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  25. * SUCH DAMAGE.
  26. */
  27. #ifndef _IMX_UDC_H_
  28. #define _IMX_UDC_H_
  29. #include <usbdevice.h>
  30. #define USB_OTGREGS_BASE (OTG_BASE_ADDR + 0x000)
  31. #define USB_H1REGS_BASE (OTG_BASE_ADDR + 0x200)
  32. #define USB_H2REGS_BASE (OTG_BASE_ADDR + 0x400)
  33. #if (defined CONFIG_MX51 || defined CONFIG_MX50 || defined CONFIG_MX6Q \
  34. || defined CONFIG_MX53 || defined CONFIG_MX6DL || defined CONFIG_MX6SL)
  35. #define USB_H3REGS_BASE (OTG_BASE_ADDR + 0x600)
  36. #define USB_OTHERREGS_BASE (OTG_BASE_ADDR + 0x800)
  37. #else
  38. #define USB_OTHERREGS_BASE (OTG_BASE_ADDR + 0x600)
  39. #endif
  40. #define USBOTG_REG32(offset) (USB_OTGREGS_BASE + (offset))
  41. #define USBOTG_REG16(offset) (USB_OTGREGS_BASE + (offset))
  42. #define USBOTHER_REG(offset) (USB_OTHERREGS_BASE + (offset))
  43. #define USB_ID (OTG_BASE_ADDR + 0x0000)
  44. #define USB_HWGENERAL (OTG_BASE_ADDR + 0x0004)
  45. #define USB_HWHOST (OTG_BASE_ADDR + 0x0008)
  46. #define USB_HWDEVICE (OTG_BASE_ADDR + 0x000C)
  47. #define USB_HWTXBUF (OTG_BASE_ADDR + 0x0010)
  48. #define USB_HWRXBUF (OTG_BASE_ADDR + 0x0014)
  49. #define USB_SBUSCFG (OTG_BASE_ADDR + 0x0090)
  50. #define USB_CAPLENGTH (OTG_BASE_ADDR + 0x0100) /* 8 bit */
  51. #define USB_HCIVERSION (OTG_BASE_ADDR + 0x0102) /* 16 bit */
  52. #define USB_HCSPARAMS (OTG_BASE_ADDR + 0x0104)
  53. #define USB_HCCPARAMS (OTG_BASE_ADDR + 0x0108)
  54. #define USB_DCIVERSION (OTG_BASE_ADDR + 0x0120) /* 16 bit */
  55. #define USB_DCCPARAMS (OTG_BASE_ADDR + 0x0124)
  56. #define USB_USBCMD (OTG_BASE_ADDR + 0x0140)
  57. #define USB_USBSTS (OTG_BASE_ADDR + 0x0144)
  58. #define USB_USBINTR (OTG_BASE_ADDR + 0x0148)
  59. #define USB_FRINDEX (OTG_BASE_ADDR + 0x014C)
  60. #define USB_DEVICEADDR (OTG_BASE_ADDR + 0x0154)
  61. #define USB_ENDPOINTLISTADDR (OTG_BASE_ADDR + 0x0158)
  62. #define USB_BURSTSIZE (OTG_BASE_ADDR + 0x0160)
  63. #define USB_TXFILLTUNING (OTG_BASE_ADDR + 0x0164)
  64. #define USB_ULPI_VIEWPORT (OTG_BASE_ADDR + 0x0170)
  65. #define USB_ENDPTNAK (OTG_BASE_ADDR + 0x0178)
  66. #define USB_ENDPTNAKEN (OTG_BASE_ADDR + 0x017C)
  67. #define USB_PORTSC1 (OTG_BASE_ADDR + 0x0184)
  68. #define USB_OTGSC (OTG_BASE_ADDR + 0x01A4)
  69. #define USB_USBMODE (OTG_BASE_ADDR + 0x01A8)
  70. #define USB_ENDPTSETUPSTAT (OTG_BASE_ADDR + 0x01AC)
  71. #define USB_ENDPTPRIME (OTG_BASE_ADDR + 0x01B0)
  72. #define USB_ENDPTFLUSH (OTG_BASE_ADDR + 0x01B4)
  73. #define USB_ENDPTSTAT (OTG_BASE_ADDR + 0x01B8)
  74. #define USB_ENDPTCOMPLETE (OTG_BASE_ADDR + 0x01BC)
  75. #define USB_ENDPTCTRL(n) (OTG_BASE_ADDR + 0x01C0 + (4 * (n)))
  76. /*
  77. * other regs (not part of ARC core)
  78. */
  79. #define USBCTRL USBOTHER_REG(0x00) /* USB Control register */
  80. #define USB_OTG_MIRROR USBOTHER_REG(0x04) /* USB OTG mirror register */
  81. #define USB_PHY_CTR_FUNC USBOTHER_REG(0x08) /* OTG UTMI PHY Function Control register */
  82. #define USB_PHY_CTR_FUNC2 USBOTHER_REG(0x0c) /* OTG UTMI PHY Function Control register */
  83. #define USB_CTRL_1 USBOTHER_REG(0x10) /* USB Cotrol Register 1*/
  84. #define USBCTRL_HOST2 USBOTHER_REG(0x14) /* USB Cotrol Register 1*/
  85. #define USBCTRL_HOST3 USBOTHER_REG(0x18) /* USB Cotrol Register 1*/
  86. #define USBH1_PHY_CTRL0 USBOTHER_REG(0x1c) /* USB Cotrol Register 1*/
  87. #define USBH1_PHY_CTRL1 USBOTHER_REG(0x20) /* USB Cotrol Register 1*/
  88. #define USB_CLKONOFF_CTRL USBOTHER_REG(0x24) /* USB Clock on/off Control Register */
  89. /* mx6x other regs */
  90. #define USB_OTG_CTRL USBOTHER_REG(0x00) /* USB OTG Control register */
  91. #define USB_H1_CTRL USBOTHER_REG(0x04) /* USB H1 Control register */
  92. #define USB_H2_CTRL USBOTHER_REG(0x08) /* USB H2 Control register */
  93. #define USB_H3_CTRL USBOTHER_REG(0x0c) /* USB H3 Control register */
  94. #define USB_UH2_HSIC_CTRL USBOTHER_REG(0x10) /* USB Host2 HSIC Control Register */
  95. #define USB_UH3_HSIC_CTRL USBOTHER_REG(0x14) /* USB Host3 HSIC Control Register */
  96. #define USB_OTG_PHY_CTRL_0 USBOTHER_REG(0x18) /* OTG UTMI PHY Control 0 Register */
  97. #define USB_H1_PHY_CTRL_0 USBOTHER_REG(0x1c) /* OTG UTMI PHY Control 1 Register */
  98. #define USB_UH2_HSIC_DLL_CFG1 USBOTHER_REG(0x20) /* USB Host2 HSIC DLL Configuration Register 1 */
  99. #define USB_UH2_HSIC_DLL_CFG2 USBOTHER_REG(0x24) /* USB Host2 HSIC DLL Configuration Register 2 */
  100. #define USB_UH2_HSIC_DLL_CFG3 USBOTHER_REG(0x28) /* USB Host2 HSIC DLL Configuration Register 3 */
  101. #define USB_UH3_HSIC_DLL_CFG1 USBOTHER_REG(0x30) /* USB Host3 HSIC DLL Configuration Register 1 */
  102. #define USB_UH3_HSIC_DLL_CFG2 USBOTHER_REG(0x34) /* USB Host3 HSIC DLL Configuration Register 2 */
  103. #define USB_UH3_HSIC_DLL_CFG3 USBOTHER_REG(0x38) /* USB Host3 HSIC DLL Configuration Register 3 */
  104. #define USB_PHY1_CTRL (OTG_BASE_ADDR + 0x80C)
  105. #define USBCMD_RESET 2
  106. #define USBCMD_ATTACH 1
  107. #define USBMODE_DEVICE 2
  108. #define USBMODE_HOST 3
  109. struct ep_queue_head {
  110. volatile unsigned int config;
  111. volatile unsigned int current; /* read-only */
  112. volatile unsigned int next_queue_item;
  113. volatile unsigned int info;
  114. volatile unsigned int page0;
  115. volatile unsigned int page1;
  116. volatile unsigned int page2;
  117. volatile unsigned int page3;
  118. volatile unsigned int page4;
  119. volatile unsigned int reserved_0;
  120. volatile unsigned char setup_data[8];
  121. volatile unsigned int reserved[4];
  122. };
  123. #define CONFIG_MAX_PKT(n) ((n) << 16)
  124. #define CONFIG_ZLT (1 << 29) /* stop on zero-len xfer */
  125. #define CONFIG_IOS (1 << 15) /* IRQ on setup */
  126. struct ep_queue_item {
  127. volatile unsigned int next_item_ptr;
  128. volatile unsigned int info;
  129. volatile unsigned int page0;
  130. volatile unsigned int page1;
  131. volatile unsigned int page2;
  132. volatile unsigned int page3;
  133. volatile unsigned int page4;
  134. unsigned int item_dma;
  135. unsigned int page_vir;
  136. unsigned int page_dma;
  137. struct ep_queue_item *next_item_vir;
  138. volatile unsigned int reserved[5];
  139. };
  140. #define TERMINATE 1
  141. #define INFO_BYTES(n) ((n) << 16)
  142. #define INFO_IOC (1 << 15)
  143. #define INFO_ACTIVE (1 << 7)
  144. #define INFO_HALTED (1 << 6)
  145. #define INFO_BUFFER_ERROR (1 << 5)
  146. #define INFO_TX_ERROR (1 << 3)
  147. /* Device Controller Capability Parameter register */
  148. #define DCCPARAMS_DC 0x00000080
  149. #define DCCPARAMS_DEN_MASK 0x0000001f
  150. /* Frame Index Register Bit Masks */
  151. #define USB_FRINDEX_MASKS (0x3fff)
  152. /* USB CMD Register Bit Masks */
  153. #define USB_CMD_RUN_STOP (0x00000001)
  154. #define USB_CMD_CTRL_RESET (0x00000002)
  155. #define USB_CMD_PERIODIC_SCHEDULE_EN (0x00000010)
  156. #define USB_CMD_ASYNC_SCHEDULE_EN (0x00000020)
  157. #define USB_CMD_INT_AA_DOORBELL (0x00000040)
  158. #define USB_CMD_ASP (0x00000300)
  159. #define USB_CMD_ASYNC_SCH_PARK_EN (0x00000800)
  160. #define USB_CMD_SUTW (0x00002000)
  161. #define USB_CMD_ATDTW (0x00004000)
  162. #define USB_CMD_ITC (0x00FF0000)
  163. /* bit 15,3,2 are frame list size */
  164. #define USB_CMD_FRAME_SIZE_1024 (0x00000000)
  165. #define USB_CMD_FRAME_SIZE_512 (0x00000004)
  166. #define USB_CMD_FRAME_SIZE_256 (0x00000008)
  167. #define USB_CMD_FRAME_SIZE_128 (0x0000000C)
  168. #define USB_CMD_FRAME_SIZE_64 (0x00008000)
  169. #define USB_CMD_FRAME_SIZE_32 (0x00008004)
  170. #define USB_CMD_FRAME_SIZE_16 (0x00008008)
  171. #define USB_CMD_FRAME_SIZE_8 (0x0000800C)
  172. /* bit 9-8 are async schedule park mode count */
  173. #define USB_CMD_ASP_00 (0x00000000)
  174. #define USB_CMD_ASP_01 (0x00000100)
  175. #define USB_CMD_ASP_10 (0x00000200)
  176. #define USB_CMD_ASP_11 (0x00000300)
  177. #define USB_CMD_ASP_BIT_POS (8)
  178. /* bit 23-16 are interrupt threshold control */
  179. #define USB_CMD_ITC_NO_THRESHOLD (0x00000000)
  180. #define USB_CMD_ITC_1_MICRO_FRM (0x00010000)
  181. #define USB_CMD_ITC_2_MICRO_FRM (0x00020000)
  182. #define USB_CMD_ITC_4_MICRO_FRM (0x00040000)
  183. #define USB_CMD_ITC_8_MICRO_FRM (0x00080000)
  184. #define USB_CMD_ITC_16_MICRO_FRM (0x00100000)
  185. #define USB_CMD_ITC_32_MICRO_FRM (0x00200000)
  186. #define USB_CMD_ITC_64_MICRO_FRM (0x00400000)
  187. #define USB_CMD_ITC_BIT_POS (16)
  188. /* USB STS Register Bit Masks */
  189. #define USB_STS_INT (0x00000001)
  190. #define USB_STS_ERR (0x00000002)
  191. #define USB_STS_PORT_CHANGE (0x00000004)
  192. #define USB_STS_FRM_LST_ROLL (0x00000008)
  193. #define USB_STS_SYS_ERR (0x00000010)
  194. #define USB_STS_IAA (0x00000020)
  195. #define USB_STS_RESET (0x00000040)
  196. #define USB_STS_SOF (0x00000080)
  197. #define USB_STS_SUSPEND (0x00000100)
  198. #define USB_STS_HC_HALTED (0x00001000)
  199. #define USB_STS_RCL (0x00002000)
  200. #define USB_STS_PERIODIC_SCHEDULE (0x00004000)
  201. #define USB_STS_ASYNC_SCHEDULE (0x00008000)
  202. /* USB INTR Register Bit Masks */
  203. #define USB_INTR_INT_EN (0x00000001)
  204. #define USB_INTR_ERR_INT_EN (0x00000002)
  205. #define USB_INTR_PTC_DETECT_EN (0x00000004)
  206. #define USB_INTR_FRM_LST_ROLL_EN (0x00000008)
  207. #define USB_INTR_SYS_ERR_EN (0x00000010)
  208. #define USB_INTR_ASYN_ADV_EN (0x00000020)
  209. #define USB_INTR_RESET_EN (0x00000040)
  210. #define USB_INTR_SOF_EN (0x00000080)
  211. #define USB_INTR_DEVICE_SUSPEND (0x00000100)
  212. /* Device Address bit masks */
  213. #define USB_DEVICE_ADDRESS_MASK (0xFE000000)
  214. #define USB_DEVICE_ADDRESS_BIT_POS (25)
  215. /* endpoint list address bit masks */
  216. #define USB_EP_LIST_ADDRESS_MASK (0xfffff800)
  217. /* PORTSCX Register Bit Masks */
  218. #define PORTSCX_CURRENT_CONNECT_STATUS (0x00000001)
  219. #define PORTSCX_CONNECT_STATUS_CHANGE (0x00000002)
  220. #define PORTSCX_PORT_ENABLE (0x00000004)
  221. #define PORTSCX_PORT_EN_DIS_CHANGE (0x00000008)
  222. #define PORTSCX_OVER_CURRENT_ACT (0x00000010)
  223. #define PORTSCX_OVER_CURRENT_CHG (0x00000020)
  224. #define PORTSCX_PORT_FORCE_RESUME (0x00000040)
  225. #define PORTSCX_PORT_SUSPEND (0x00000080)
  226. #define PORTSCX_PORT_RESET (0x00000100)
  227. #define PORTSCX_LINE_STATUS_BITS (0x00000C00)
  228. #define PORTSCX_PORT_POWER (0x00001000)
  229. #define PORTSCX_PORT_INDICTOR_CTRL (0x0000C000)
  230. #define PORTSCX_PORT_TEST_CTRL (0x000F0000)
  231. #define PORTSCX_WAKE_ON_CONNECT_EN (0x00100000)
  232. #define PORTSCX_WAKE_ON_CONNECT_DIS (0x00200000)
  233. #define PORTSCX_WAKE_ON_OVER_CURRENT (0x00400000)
  234. #define PORTSCX_PHY_LOW_POWER_SPD (0x00800000)
  235. #define PORTSCX_PORT_FORCE_FULL_SPEED (0x01000000)
  236. #define PORTSCX_PORT_SPEED_MASK (0x0C000000)
  237. #define PORTSCX_PORT_WIDTH (0x10000000)
  238. #define PORTSCX_PHY_TYPE_SEL (0xC0000000)
  239. /* bit 11-10 are line status */
  240. #define PORTSCX_LINE_STATUS_SE0 (0x00000000)
  241. #define PORTSCX_LINE_STATUS_JSTATE (0x00000400)
  242. #define PORTSCX_LINE_STATUS_KSTATE (0x00000800)
  243. #define PORTSCX_LINE_STATUS_UNDEF (0x00000C00)
  244. #define PORTSCX_LINE_STATUS_BIT_POS (10)
  245. /* bit 15-14 are port indicator control */
  246. #define PORTSCX_PIC_OFF (0x00000000)
  247. #define PORTSCX_PIC_AMBER (0x00004000)
  248. #define PORTSCX_PIC_GREEN (0x00008000)
  249. #define PORTSCX_PIC_UNDEF (0x0000C000)
  250. #define PORTSCX_PIC_BIT_POS (14)
  251. /* bit 19-16 are port test control */
  252. #define PORTSCX_PTC_DISABLE (0x00000000)
  253. #define PORTSCX_PTC_JSTATE (0x00010000)
  254. #define PORTSCX_PTC_KSTATE (0x00020000)
  255. #define PORTSCX_PTC_SEQNAK (0x00030000)
  256. #define PORTSCX_PTC_PACKET (0x00040000)
  257. #define PORTSCX_PTC_FORCE_EN (0x00050000)
  258. #define PORTSCX_PTC_BIT_POS (16)
  259. /* bit 27-26 are port speed */
  260. #define PORTSCX_PORT_SPEED_FULL (0x00000000)
  261. #define PORTSCX_PORT_SPEED_LOW (0x04000000)
  262. #define PORTSCX_PORT_SPEED_HIGH (0x08000000)
  263. #define PORTSCX_PORT_SPEED_UNDEF (0x0C000000)
  264. #define PORTSCX_SPEED_BIT_POS (26)
  265. /* OTGSC Register Bit Masks */
  266. #define OTGSC_B_SESSION_VALID_IRQ_EN (1 << 27)
  267. #define OTGSC_B_SESSION_VALID_IRQ_STS (1 << 19)
  268. #define OTGSC_B_SESSION_VALID (1 << 11)
  269. /* bit 28 is parallel transceiver width for UTMI interface */
  270. #define PORTSCX_PTW (0x10000000)
  271. #define PORTSCX_PTW_8BIT (0x00000000)
  272. #define PORTSCX_PTW_16BIT (0x10000000)
  273. /* bit 31-30 are port transceiver select */
  274. #define PORTSCX_PTS_UTMI (0x00000000)
  275. #define PORTSCX_PTS_ULPI (0x80000000)
  276. #define PORTSCX_PTS_FSLS (0xC0000000)
  277. #define PORTSCX_PTS_BIT_POS (30)
  278. /* USB MODE Register Bit Masks */
  279. #define USB_MODE_CTRL_MODE_IDLE (0x00000000)
  280. #define USB_MODE_CTRL_MODE_DEVICE (0x00000002)
  281. #define USB_MODE_CTRL_MODE_HOST (0x00000003)
  282. #define USB_MODE_CTRL_MODE_MASK 0x00000003
  283. #define USB_MODE_CTRL_MODE_RSV (0x00000001)
  284. #define USB_MODE_ES 0x00000004 /* (big) Endian Sel */
  285. #define USB_MODE_SETUP_LOCK_OFF (0x00000008)
  286. #define USB_MODE_STREAM_DISABLE (0x00000010)
  287. /* Endpoint Flush Register */
  288. #define EPFLUSH_TX_OFFSET (0x00010000)
  289. #define EPFLUSH_RX_OFFSET (0x00000000)
  290. /* Endpoint Setup Status bit masks */
  291. #define EP_SETUP_STATUS_MASK (0x0000003F)
  292. #define EP_SETUP_STATUS_EP0 (0x00000001)
  293. /* ENDPOINTCTRLx Register Bit Masks */
  294. #define EPCTRL_TX_ENABLE (0x00800000)
  295. #define EPCTRL_TX_DATA_TOGGLE_RST (0x00400000) /* Not EP0 */
  296. #define EPCTRL_TX_DATA_TOGGLE_INH (0x00200000) /* Not EP0 */
  297. #define EPCTRL_TX_TYPE (0x000C0000)
  298. #define EPCTRL_TX_DATA_SOURCE (0x00020000) /* Not EP0 */
  299. #define EPCTRL_TX_EP_STALL (0x00010000)
  300. #define EPCTRL_RX_ENABLE (0x00000080)
  301. #define EPCTRL_RX_DATA_TOGGLE_RST (0x00000040) /* Not EP0 */
  302. #define EPCTRL_RX_DATA_TOGGLE_INH (0x00000020) /* Not EP0 */
  303. #define EPCTRL_RX_TYPE (0x0000000C)
  304. #define EPCTRL_RX_DATA_SINK (0x00000002) /* Not EP0 */
  305. #define EPCTRL_RX_EP_STALL (0x00000001)
  306. /* bit 19-18 and 3-2 are endpoint type */
  307. #define EPCTRL_EP_TYPE_CONTROL (0)
  308. #define EPCTRL_EP_TYPE_ISO (1)
  309. #define EPCTRL_EP_TYPE_BULK (2)
  310. #define EPCTRL_EP_TYPE_INTERRUPT (3)
  311. #define EPCTRL_TX_EP_TYPE_SHIFT (18)
  312. #define EPCTRL_RX_EP_TYPE_SHIFT (2)
  313. /* SNOOPn Register Bit Masks */
  314. #define SNOOP_ADDRESS_MASK (0xFFFFF000)
  315. #define SNOOP_SIZE_ZERO (0x00) /* snooping disable */
  316. #define SNOOP_SIZE_4KB (0x0B) /* 4KB snoop size */
  317. #define SNOOP_SIZE_8KB (0x0C)
  318. #define SNOOP_SIZE_16KB (0x0D)
  319. #define SNOOP_SIZE_32KB (0x0E)
  320. #define SNOOP_SIZE_64KB (0x0F)
  321. #define SNOOP_SIZE_128KB (0x10)
  322. #define SNOOP_SIZE_256KB (0x11)
  323. #define SNOOP_SIZE_512KB (0x12)
  324. #define SNOOP_SIZE_1MB (0x13)
  325. #define SNOOP_SIZE_2MB (0x14)
  326. #define SNOOP_SIZE_4MB (0x15)
  327. #define SNOOP_SIZE_8MB (0x16)
  328. #define SNOOP_SIZE_16MB (0x17)
  329. #define SNOOP_SIZE_32MB (0x18)
  330. #define SNOOP_SIZE_64MB (0x19)
  331. #define SNOOP_SIZE_128MB (0x1A)
  332. #define SNOOP_SIZE_256MB (0x1B)
  333. #define SNOOP_SIZE_512MB (0x1C)
  334. #define SNOOP_SIZE_1GB (0x1D)
  335. #define SNOOP_SIZE_2GB (0x1E) /* 2GB snoop size */
  336. /* pri_ctrl Register Bit Masks */
  337. #define PRI_CTRL_PRI_LVL1 (0x0000000C)
  338. #define PRI_CTRL_PRI_LVL0 (0x00000003)
  339. /* si_ctrl Register Bit Masks */
  340. #define SI_CTRL_ERR_DISABLE (0x00000010)
  341. #define SI_CTRL_IDRC_DISABLE (0x00000008)
  342. #define SI_CTRL_RD_SAFE_EN (0x00000004)
  343. #define SI_CTRL_RD_PREFETCH_DISABLE (0x00000002)
  344. #define SI_CTRL_RD_PREFEFETCH_VAL (0x00000001)
  345. /* control Register Bit Masks */
  346. #define USB_CTRL_IOENB (0x00000004)
  347. #define USB_CTRL_ULPI_INT0EN (0x00000001)
  348. #define USB_CTRL_OTG_WUIR (0x80000000)
  349. #define USB_CTRL_OTG_WUIE (0x08000000)
  350. #define USB_CTRL_OTG_VWUE (0x00001000)
  351. #define USB_CTRL_OTG_IWUE (0x00100000)
  352. #define INTR_UE (1 << 0)
  353. #define INTR_UEE (1 << 1)
  354. #define INTR_PCE (1 << 2)
  355. #define INTR_SEE (1 << 4)
  356. #define INTR_URE (1 << 6)
  357. #define INTR_SRE (1 << 7)
  358. #define INTR_SLE (1 << 8)
  359. /* bits used in all the endpoint status registers */
  360. #define EPT_TX(n) (1 << ((n) + 16))
  361. #define EPT_RX(n) (1 << (n))
  362. #define CTRL_TXE (1 << 23)
  363. #define CTRL_TXR (1 << 22)
  364. #define CTRL_TXI (1 << 21)
  365. #define CTRL_TXD (1 << 17)
  366. #define CTRL_TXS (1 << 16)
  367. #define CTRL_RXE (1 << 7)
  368. #define CTRL_RXR (1 << 6)
  369. #define CTRL_RXI (1 << 5)
  370. #define CTRL_RXD (1 << 1)
  371. #define CTRL_RXS (1 << 0)
  372. #define CTRL_TXT_CTRL (0 << 18)
  373. #define CTRL_TXT_ISOCH (1 << 18)
  374. #define CTRL_TXT_BULK (2 << 18)
  375. #define CTRL_TXT_INT (3 << 18)
  376. #define CTRL_RXT_CTRL (0 << 2)
  377. #define CTRL_RXT_ISOCH (1 << 2)
  378. #define CTRL_RXT_BULK (2 << 2)
  379. #define CTRL_RXT_INT (3 << 2)
  380. #define USB_RECV 0
  381. #define USB_SEND 1
  382. #define USB_MAX_CTRL_PAYLOAD 64
  383. /* UDC device defines */
  384. #define EP0_MAX_PACKET_SIZE USB_MAX_CTRL_PAYLOAD
  385. #define UDC_OUT_ENDPOINT 0x02
  386. #define UDC_OUT_PACKET_SIZE USB_MAX_CTRL_PAYLOAD
  387. #define UDC_IN_ENDPOINT 0x03
  388. #define UDC_IN_PACKET_SIZE USB_MAX_CTRL_PAYLOAD
  389. #define UDC_INT_ENDPOINT 0x01
  390. #define UDC_INT_PACKET_SIZE USB_MAX_CTRL_PAYLOAD
  391. #define UDC_BULK_PACKET_SIZE USB_MAX_CTRL_PAYLOAD
  392. /* mx6q's register bit begins*/
  393. /* OTG CTRL - H3 CTRL */
  394. #define UCTRL_OWIR (1 << 31) /* OTG wakeup intr request received */
  395. /* bit 18 - bit 30 is reserved at mx6q */
  396. #define UCTRL_WKUP_VBUS_EN (1 << 17) /* OTG wake-up on VBUS change enable */
  397. #define UCTRL_WKUP_ID_EN (1 << 16) /* OTG wake-up on ID change enable */
  398. #define UCTRL_WKUP_SW (1 << 15) /* OTG Software Wake-up */
  399. #define UCTRL_WKUP_SW_EN (1 << 14) /* OTG Software Wake-up enable */
  400. #define UCTRL_UTMI_ON_CLOCK (1 << 13) /* Force OTG UTMI PHY clock output on even if suspend mode */
  401. #define UCTRL_SUSPENDM (1 << 12) /* Force OTG UTMI PHY Suspend */
  402. #define UCTRL_RESET (1 << 11) /* Force OTG UTMI PHY Reset */
  403. #define UCTRL_OWIE (1 << 10) /* OTG wakeup intr request received */
  404. #define UCTRL_PM (1 << 9) /* OTG Power Mask */
  405. #define UCTRL_OVER_CUR_POL (1 << 8) /* OTG Polarity of Overcurrent */
  406. #define UCTRL_OVER_CUR_DIS (1 << 7) /* Disable OTG Overcurrent Detection */
  407. /* bit 0 - bit 6 is reserved at mx6q */
  408. /* Host2/3 HSIC Ctrl */
  409. #define CLK_VLD (1 << 31) /* Indicating whether HSIC clock is valid */
  410. #define HSIC_EN (1 << 12) /* HSIC enable */
  411. #define HSIC_CLK_ON (1 << 11) /* Force HSIC module 480M clock on,
  412. * even when in Host is in suspend mode
  413. */
  414. /* OTG/HOST1 Phy Ctrl */
  415. #define PHY_UTMI_CLK_VLD (1 << 31) /* Indicating whether OTG UTMI PHY Clock Valida */
  416. int udc_init(void);
  417. void udc_enable(struct usb_device_instance *device);
  418. void udc_disable(void);
  419. void udc_connect(void);
  420. void udc_disconnect(void);
  421. void udc_startup_events(struct usb_device_instance *device);
  422. void udc_setup_ep(struct usb_device_instance *device,
  423. unsigned int ep, struct usb_endpoint_instance *endpoint);
  424. int udc_endpoint_write(struct usb_endpoint_instance *epi);
  425. void udc_irq(void);
  426. void usb_shutdown(void);
  427. void mxc_udc_rxqueue_update(u8 ep, u32 len);
  428. int is_usb_disconnected(void);
  429. void reset_usb_phy1(void);
  430. void set_usboh3_clk(void);
  431. void set_usb_phy1_clk(void);
  432. void enable_usb_phy1_clk(unsigned char enable);
  433. void enable_usboh3_clk(unsigned char enable);
  434. void udc_pins_setting(void);
  435. #ifdef CONFIG_FASTBOOT
  436. #define EP0_OUT_INDEX 0
  437. #define EP0_IN_INDEX 16
  438. #define EP1_OUT_INDEX 1
  439. #define EP1_IN_INDEX 17
  440. #define EP2_OUT_INDEX 2
  441. #define EP2_IN_INDEX 18
  442. #define EP3_OUT_INDEX 3
  443. #define EP3_IN_INDEX 19
  444. #define EP4_OUT_INDEX 4
  445. #define EP4_IN_INDEX 20
  446. #define EP5_OUT_INDEX 5
  447. #define EP5_IN_INDEX 21
  448. #define EP6_OUT_INDEX 6
  449. #define EP6_IN_INDEX 22
  450. #define EP7_OUT_INDEX 7
  451. #define EP7_IN_INDEX 23
  452. #define EP8_OUT_INDEX 8
  453. #define EP8_IN_INDEX 24
  454. #define EP9_OUT_INDEX 9
  455. #define EP9_IN_INDEX 25
  456. #define EP10_OUT_INDEX 10
  457. #define EP10_IN_INDEX 26
  458. #define EP11_OUT_INDEX 11
  459. #define EP11_IN_INDEX 27
  460. #define EP12_OUT_INDEX 12
  461. #define EP12_IN_INDEX 28
  462. #define EP13_OUT_INDEX 13
  463. #define EP13_IN_INDEX 29
  464. #define EP14_OUT_INDEX 14
  465. #define EP14_IN_INDEX 30
  466. #define EP15_OUT_INDEX 15
  467. #define EP15_IN_INDEX 31
  468. #define MAX_PAKET_LEN 512
  469. typedef void (*EP_HANDLER_P)(u32 index, u8 *buf);
  470. int udc_irq_handler(void);
  471. void udc_hal_data_init(void);
  472. void udc_wait_connect(void);
  473. void udc_run(void);
  474. int udc_recv_data(u32 index, u8 *recvbuf, u32 recvlen, EP_HANDLER_P cb);
  475. int udc_send_data(u32 index, u8 *buf, u32 sendlen, EP_HANDLER_P cb);
  476. void udc_qh_dtd_init(u32 index);
  477. void udc_dtd_setup(u32 index, u8 ep_type);
  478. void udc_qh_setup(u32 index, u8 ep_type, u32 max_pkt_len, u32 zlt, u8 mult);
  479. u8 *udc_get_descriptor(u8 type, u8 *plen);
  480. void udc_set_addr(u8 addr);
  481. void udc_set_configure(u8 config);
  482. #endif /* CONFIG_FASTBOOT */
  483. #endif