usb_hc_ohci.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. /****************************************************************************
  2. * include/nuttx/usb/ohci.h
  3. *
  4. * Licensed to the Apache Software Foundation (ASF) under one or more
  5. * contributor license agreements. See the NOTICE file distributed with
  6. * this work for additional information regarding copyright ownership. The
  7. * ASF licenses this file to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance with the
  9. * License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. * License for the specific language governing permissions and limitations
  17. * under the License.
  18. *
  19. ****************************************************************************/
  20. #ifndef __INCLUDE_NUTTX_USB_OHCI_H
  21. #define __INCLUDE_NUTTX_USB_OHCI_H
  22. /****************************************************************************
  23. * Included Files
  24. ****************************************************************************/
  25. #include <stdint.h>
  26. /****************************************************************************
  27. * Pre-processor Definitions
  28. ****************************************************************************/
  29. /* Register offsets *********************************************************/
  30. /* Control and status registers (section 7.1) */
  31. #define OHCI_HCIREV_OFFSET 0x0000 /* HcRevision: Version of HCI specification */
  32. #define OHCI_CTRL_OFFSET 0x0004 /* HcControl: HC control */
  33. #define OHCI_CMDST_OFFSET 0x0008 /* HcCommandStatus: HC command status */
  34. #define OHCI_INTST_OFFSET 0x000c /* HcInterruptStatus: HC interrupt status */
  35. #define OHCI_INTEN_OFFSET 0x0010 /* HcInterruptEnable: HC interrupt enable */
  36. #define OHCI_INTDIS_OFFSET 0x0014 /* HcInterruptDisable: HC interrupt disable */
  37. /* Memory pointer registers (section 7.2) */
  38. #define OHCI_HCCA_OFFSET 0x0018 /* HcHCCA: HC communication area */
  39. #define OHCI_PERED_OFFSET 0x001c /* HcPeriodCurrentED: Current isoc or int endpoint desc */
  40. #define OHCI_CTRLHEADED_OFFSET 0x0020 /* HcControlHeadED: First EP desc in the control list */
  41. #define OHCI_CTRLED_OFFSET 0x0024 /* HcControlCurrentED: Current EP desc in the control list */
  42. #define OHCI_BULKHEADED_OFFSET 0x0028 /* HcBulkHeadED: First EP desc in the bulk list */
  43. #define OHCI_BULKED_OFFSET 0x002c /* HcBulkCurrentED: Current EP desc in the bulk list */
  44. #define OHCI_DONEHEAD_OFFSET 0x0030 /* HcDoneHead: Last transfer desc added to DONE queue */
  45. /* Frame counter registers (section 7.3) */
  46. #define OHCI_FMINT_OFFSET 0x0034 /* HcFmInterval: Bit time interval that would not cause overrun */
  47. #define OHCI_FMREM_OFFSET 0x0038 /* HcFmRemaining: Bit time remaining in current frame */
  48. #define OHCI_FMNO_OFFSET 0x003c /* HcFmNumber: Frame number counter */
  49. #define OHCI_PERSTART_OFFSET 0x0040 /* HcPeriodicStart: Time to start processing periodic list */
  50. /* Root hub registers (section 7.4) */
  51. #define OHCI_LSTHRES_OFFSET 0x0044 /* HcLSThreshold: Commit to transfer threshold */
  52. #define OHCI_RHDESCA_OFFSET 0x0048 /* HcRhDescriptorA: Describes root hub (part A) */
  53. #define OHCI_RHDESCB_OFFSET 0x004c /* HcRhDescriptorB: Describes root hub (part B) */
  54. #define OHCI_RHSTATUS_OFFSET 0x0050 /* HcRhStatus: Root hub status */
  55. #define OHCI_MAX_RHPORT 15 /* Maximum number of OHCI root hub ports */
  56. #define OHCI_RHPORTST_OFFSET(n) (0x0054 + (((n) - 1) << 2))
  57. #define OHCI_RHPORTST1_OFFSET 0x0054 /* HcRhPort1Status: Root hub port status 1 */
  58. #define OHCI_RHPORTST2_OFFSET 0x0058 /* HcRhPort2Status: Root hub port status 2 */
  59. #define OHCI_RHPORTST3_OFFSET 0x005c /* HcRhPort3Status: Root hub port status 3 */
  60. #define OHCI_RHPORTST4_OFFSET 0x0060 /* HcRhPort4Status: Root hub port status 4 */
  61. #define OHCI_RHPORTST5_OFFSET 0x0064 /* HcRhPort5Status: Root hub port status 5 */
  62. #define OHCI_RHPORTST6_OFFSET 0x0068 /* HcRhPort6Status: Root hub port status 6 */
  63. #define OHCI_RHPORTST7_OFFSET 0x006c /* HcRhPort7Status: Root hub port status 7 */
  64. #define OHCI_RHPORTST8_OFFSET 0x0070 /* HcRhPort8Status: Root hub port status 8 */
  65. #define OHCI_RHPORTST9_OFFSET 0x0074 /* HcRhPort9Status: Root hub port status 9 */
  66. #define OHCI_RHPORTST10_OFFSET 0x0078 /* HcRhPort10Status: Root hub port status 10 */
  67. #define OHCI_RHPORTST11_OFFSET 0x007c /* HcRhPort11Status: Root hub port status 11 */
  68. #define OHCI_RHPORTST12_OFFSET 0x0080 /* HcRhPort12Status: Root hub port status 12 */
  69. #define OHCI_RHPORTST13_OFFSET 0x0084 /* HcRhPort13Status: Root hub port status 13 */
  70. #define OHCI_RHPORTST14_OFFSET 0x0088 /* HcRhPort14Status: Root hub port status 14 */
  71. #define OHCI_RHPORTST15_OFFSET 0x008c /* HcRhPort15Status: Root hub port status 15 */
  72. /* Register bit definitions *************************************************/
  73. /* HcRevision: Version of HCI specification (7.1.1) */
  74. #define OHCI_HCIREV_SHIFT (0) /* Bits 0-7: HCI spec version (BCD) */
  75. #define OHCI_HCIREV_MASK (0xff << OHCI_HCIREV_SHIFT)
  76. /* HcControl: HC control (7.1.2) */
  77. #define OHCI_CTRL_CBSR (3 << 0) /* Bit 0: Control/bulk service ratio */
  78. #define OHCI_CTRL_PLE (1 << 2) /* Bit 1: Periodic list enable */
  79. #define OHCI_CTRL_IE (1 << 3) /* Bit 2: Isochronous enable */
  80. #define OHCI_CTRL_CLE (1 << 4) /* Bit 3: Control list enable */
  81. #define OHCI_CTRL_BLE (1 << 5) /* Bit 4: Bulk list enable */
  82. #define OHCI_CTRL_HCFS_SHIFT (6) /* Bits 6-7: Host controller functional state */
  83. #define OHCI_CTRL_HCFS_MASK (3 << OHCI_CTRL_HCFS_SHIFT)
  84. # define OHCI_CTRL_HCFS_RESET (0 << OHCI_CTRL_HCFS_SHIFT)
  85. # define OHCI_CTRL_HCFS_RESUME (1 << OHCI_CTRL_HCFS_SHIFT)
  86. # define OHCI_CTRL_HCFS_OPER (2 << OHCI_CTRL_HCFS_SHIFT)
  87. # define OHCI_CTRL_HCFS_SUSPEND (3 << OHCI_CTRL_HCFS_SHIFT)
  88. #define OHCI_CTRL_IR (1 << 8) /* Bit 8: Interrupt routing */
  89. #define OHCI_CTRL_RWC (1 << 9) /* Bit 9: Remote wakeup connected */
  90. #define OHCI_CTRL_RWE (1 << 10) /* Bit 10: Remote wakeup enable */
  91. /* Bits 11-31: Reserved */
  92. /* HcCommandStatus: HC command status (7.1.3) */
  93. #define OHCI_CMDST_HCR (1 << 0) /* Bit 0: Host controller reset */
  94. #define OHCI_CMDST_CLF (1 << 1) /* Bit 1: Control list filled */
  95. #define OHCI_CMDST_BLF (1 << 2) /* Bit 2: Bulk list filled */
  96. #define OHCI_CMDST_OCR (1 << 3) /* Bit 3: Ownership change request */
  97. /* Bits 4-15: Reserved */
  98. #define OHCI_CMDST_SOC (3 << 16) /* Bit 16: Scheduling overrun count */
  99. /* Bits 17-31: Reserved */
  100. /* HcInterruptStatus: HC interrupt status (7.1.4),
  101. * HcInterruptEnable: HC interrupt enable (7.1.5), and
  102. * HcInterruptDisable: HC interrupt disable (7.1.6)
  103. */
  104. #define OHCI_INT_SO (1 << 0) /* Bit 0: Scheduling overrun */
  105. #define OHCI_INT_WDH (1 << 1) /* Bit 1: Writeback done head */
  106. #define OHCI_INT_SF (1 << 2) /* Bit 2: Start of frame */
  107. #define OHCI_INT_RD (1 << 3) /* Bit 3: Resume detected */
  108. #define OHCI_INT_UE (1 << 4) /* Bit 4: Unrecoverable error */
  109. #define OHCI_INT_FNO (1 << 5) /* Bit 5: Frame number overflow */
  110. #define OHCI_INT_RHSC (1 << 6) /* Bit 6: Root hub status change */
  111. /* Bits 7-29: Reserved */
  112. #define OHCI_INT_OC (1 << 30) /* Bit 30: Ownership change */
  113. #define OHCI_INT_MIE (1 << 31) /* Bit 31: Master interrupt enable
  114. * (Enable/disable only) */
  115. /* HcHCCA: HC communication area (7.2.1):
  116. *
  117. * 32-bits aligned to 256 byte boundary.
  118. */
  119. /* HcPeriodCurrentED: Current isoc or int endpoint desc (7.2.2),
  120. * HcControlHeadED: First EP desc in the control list (7.2.3),
  121. * HcControlCurrentED: Current EP desc in the control list (7.2.4),
  122. * HcBulkHeadED: First EP desc in the bulk list (7.2.5),
  123. * HcBulkCurrentED: Current EP desc in the bulk list (7.2.6), and
  124. * HcDoneHead: Last transfer desc added to DONE queue (7.2.7):
  125. *
  126. * All 32-bits aligned to an 8-byte boundary
  127. */
  128. /* HcFmInterval: Bit time interval that would not cause overrun (7.3.1) */
  129. #define OHCI_FMINT_FI_SHIFT (0) /* Bits 0-13: Frame interval */
  130. #define OHCI_FMINT_FI_MASK (0x3fff << OHCI_FMINT_FI_SHIFT)
  131. /* Bits 14-15: Reserved */
  132. #define OHCI_FMINT_FSMPS_SHIFT (16) /* Bits 16-30: FS largest packet data */
  133. #define OHCI_FMINT_FSMPS_MASK (0x7fff << OHCI_FMINT_FSMPS_SHIFT)
  134. #define OHCI_FMINT_FIT (1 << 31) /* Bit 31: Frame interval toggle */
  135. /* HcFmRemaining: Bit time remaining in current frame (7.3.2) */
  136. #define OHCI_FMREM_FR_SHIFT (0) /* Bits 0-13: Frame remaining */
  137. #define OHCI_FMREM_FR_MASK (0x3fff << OHCI_FMREM_FR_SHIFT)
  138. /* Bits 16-30: Reserved */
  139. #define OHCI_FMINT_FRT (1 << 31) /* Bit 31: Frame remaining toggle */
  140. /* HcFmNumber: Frame number counter (7.3.3) */
  141. #define OHCI_FMNO_FI_SHIFT (0) /* Bits 0-15: Frame number */
  142. #define OHCI_FMNO_FI_MASK (0xffff << OHCI_FMINT_FI_SHIFT)
  143. /* Bits 16-31: Reserved */
  144. /* HcPeriodicStart: Time to start processing periodic list (7.3.4) */
  145. #define OHCI_PERSTART_SHIFT (0) /* Bits 0-13: Periodic start */
  146. #define OHCI_PERSTART_MASK (0x3fff << OHCI_PERSTART_SHIFT)
  147. /* Bits 14-31: Reserved */
  148. /* HcLSThreshold: Commit to transfer threshold (7.3.5) */
  149. #define OHCI_LSTHRES_SHIFT (0) /* Bits 0-11: LS threshold */
  150. #define OHCI_LSTHRES_MASK (0x0fff << OHCI_PERSTART_SHIFT)
  151. /* Bits 12-31: Reserved */
  152. /* HcRhDescriptorN: Describes root hub (part A) (7.4.1) */
  153. #define OHCI_RHDESCA_NDP_SHIFT (0) /* Bits 0-7: Number downstream ports */
  154. #define OHCI_RHDESCA_NDP_MASK (0xff << OHCI_RHDESCA_NDP_SHIFT)
  155. #define OHCI_RHDESCA_PSM (1 << 8) /* Bit 8: Power switching mode */
  156. #define OHCI_RHDESCA_NPS (1 << 9) /* Bit 9: No power switching */
  157. #define OHCI_RHDESCA_DT (1 << 10) /* Bit 10: Device type */
  158. #define OHCI_RHDESCA_OCPM (1 << 11) /* Bit 11: Over current protection mode */
  159. #define OHCI_RHDESCA_NOCP (1 << 12) /* Bit 12: No over current protection */
  160. /* Bits 13-23: Reserved */
  161. #define OHCI_RHDESCA_POTPGT_SHIFT (24) /* Bits 24-31: Power on to power good time */
  162. #define OHCI_RHDESCA_POTPGT_MASK (0xff << OHCI_RHDESCA_POTPGT_SHIFT)
  163. /* HcRhDescriptorB: Describes root hub (part B) (7.4.2) */
  164. #define OHCI_RHDESCB_DR_SHIFT (0) /* Bits 0-15: Device removable */
  165. #define OHCI_RHDESCB_DR_MASK (0xffff << OHCI_RHDESCB_DR_SHIFT)
  166. # define OHCI_RHDESCB_ATTACHED(n) (1 << (OHCI_RHDESCB_DR_SHIFT+(n)))
  167. #define OHCI_RHDESCB_PPCM_SHIFT (16) /* Bits 16-31: Port power control mask */
  168. #define OHCI_RHDESCB_PPCM_MASK (0xffff << OHCI_RHDESCB_PPCM_SHIFT)
  169. # define OHCI_RHDESCB_POWERED(n) (1 << (OHCI_RHDESCB_DR_SHIFT+(n)))
  170. /* HcRhStatus: Root hub status (7.4.3) */
  171. #define OHCI_RHSTATUS_LPS (1 << 0) /* Bit 0: Local power status (read)*/
  172. #define OHCI_RHSTATUS_CGP (1 << 0) /* Bit 0: Clear global power (write)*/
  173. #define OHCI_RHSTATUS_OCI (1 << 1) /* Bit 1: Over current indicator */
  174. /* Bits 2-14: Reserved */
  175. #define OHCI_RHSTATUS_DRWE (1 << 15) /* Bit 15: Device remote wakeup enable */
  176. #define OHCI_RHSTATUS_LPSC (1 << 16) /* Bit 16: Local power status change (read) */
  177. #define OHCI_RHSTATUS_SGP (1 << 16) /* Bit 16: Set global power (write) */
  178. #define OHCI_RHSTATUS_OCIC (1 << 17) /* Bit 17: Overcurrent indicator change */
  179. /* Bits 18-30: Reserved */
  180. #define OHCI_RHSTATUS_CRWE (1 << 31) /* Bit 31: Clear remote wakeup enable */
  181. /* HcRhPortStatus: Root hub port status (7.4.4) */
  182. #define OHCI_RHPORTST_CCS (1 << 0) /* Bit 0: Current connect status */
  183. #define OHCI_RHPORTST_PES (1 << 1) /* Bit 1: Port enable status */
  184. #define OHCI_RHPORTST_PSS (1 << 2) /* Bit 2: Port suspend status */
  185. #define OHCI_RHPORTST_POCI (1 << 3) /* Bit 3: Port over current indicator */
  186. #define OHCI_RHPORTST_PRS (1 << 4) /* Bit 4: Port reset status */
  187. /* Bits 5-7: Reserved */
  188. #define OHCI_RHPORTST_PPS (1 << 8) /* Bit 8: Port power status */
  189. #define OHCI_RHPORTST_LSDA (1 << 9) /* Bit 9: Low speed device attached */
  190. /* Bits 10-15: Reserved */
  191. #define OHCI_RHPORTST_CSC (1 << 16) /* Bit 16: Connect status change */
  192. #define OHCI_RHPORTST_PESC (1 << 17) /* Bit 17: Port enable status change */
  193. #define OHCI_RHPORTST_PSSC (1 << 18) /* Bit 18: Port suspend status change */
  194. #define OHCI_RHPORTST_OCIC (1 << 19) /* Bit 19: Port over current indicator change */
  195. #define OHCI_RHPORTST_PRSC (1 << 20) /* Bit 20: Port reset status change */
  196. /* Bits 21-31: Reserved */
  197. /* Transfer Descriptors *****************************************************/
  198. /* Endpoint Descriptor Offsets (4.2.1) */
  199. #define ED_CONTROL_OFFSET (0x00) /* ED status/control bits */
  200. #define ED_TAILP_OFFSET (0x04) /* TD Queue Tail Pointer (TailP) */
  201. #define ED_HEADP_OFFSET (0x08) /* TD Queue Head Pointer (HeadP) */
  202. #define ED_NEXTED_OFFSET (0x0c) /* Next Endpoint Descriptor (NextED) */
  203. /* Endpoint Descriptor Bit Definitions (4.2.2) */
  204. #define ED_CONTROL_FA_SHIFT (0) /* Bits 0-6: Function Address */
  205. #define ED_CONTROL_FA_MASK (0x7f << ED_CONTROL_FA_SHIFT)
  206. #define ED_CONTROL_EN_SHIFT (7) /* Bits 7-10: Endpoint number */
  207. #define ED_CONTROL_EN_MASK (15 << ED_CONTROL_EN_SHIFT)
  208. #define ED_CONTROL_D_SHIFT (11) /* Bits 11-12: Direction */
  209. #define ED_CONTROL_D_MASK (3 << ED_CONTROL_D_SHIFT)
  210. # define ED_CONTROL_D_TD1 (0 << ED_CONTROL_D_SHIFT) /* Get direction from TD */
  211. # define ED_CONTROL_D_OUT (1 << ED_CONTROL_D_SHIFT) /* OUT */
  212. # define ED_CONTROL_D_IN (2 << ED_CONTROL_D_SHIFT) /* IN */
  213. # define ED_CONTROL_D_TD2 (3 << ED_CONTROL_D_SHIFT) /* Get direction from TD */
  214. #define ED_CONTROL_S (1 << 13) /* Bit 13: Speed (low) */
  215. #define ED_CONTROL_K (1 << 14) /* Bit 14: Skip */
  216. #define ED_CONTROL_F (1 << 15) /* Bit 15: Format (isochronous) */
  217. #define ED_CONTROL_MPS_SHIFT (16) /* Bits 16-26: Maximum packet size */
  218. #define ED_CONTROL_MPS_MASK (0x7ff << ED_CONTROL_MPS_SHIFT)
  219. #define ED_HEADP_ADDR_SHIFT (0)
  220. #define ED_HEADP_ADDR_MASK 0xfffffff0
  221. #define ED_HEADP_H (1 << 0) /* Bit 0: Halted */
  222. #define ED_HEADP_C (1 << 1) /* Bit 1: Toggle carry */
  223. /* General Transfer Descriptor Offsets (4.3.1) */
  224. #define GTD_STATUS_OFFSET (0x00) /* TD status bits */
  225. #define GTD_CBP_OFFSET (0x04) /* Current Buffer Pointer (CBP) */
  226. #define GTD_NEXTTD_OFFSET (0x08) /* Next TD (NextTD) */
  227. #define GTD_BE_OFFSET (0x0c) /* Buffer End (BE) */
  228. /* General Transfer Descriptor Bit Definitions */
  229. /* Bits 0-17: Reserved */
  230. #define GTD_STATUS_R (1 << 18) /* Bit 18: Buffer rounding */
  231. #define GTD_STATUS_DP_SHIFT (19) /* Bits 19-20: Direction/PID */
  232. #define GTD_STATUS_DP_MASK (3 << GTD_STATUS_DP_SHIFT)
  233. # define GTD_STATUS_DP_SETUP (0 << GTD_STATUS_DP_SHIFT) /* To endpoint */
  234. # define GTD_STATUS_DP_OUT (1 << GTD_STATUS_DP_SHIFT) /* To endpoint */
  235. # define GTD_STATUS_DP_IN (2 << GTD_STATUS_DP_SHIFT) /* From endpoint */
  236. #define GTD_STATUS_DI_SHIFT (21) /* Bits 21-23: Delay input */
  237. #define GTD_STATUS_DI_MASK (7 << GTD_STATUS_DI_SHIFT)
  238. #define GTD_STATUS_T_SHIFT (24) /* Bits 24-25: Data Toggle */
  239. #define GTD_STATUS_T_MASK (3 << GTD_STATUS_T_SHIFT)
  240. # define GTD_STATUS_T_TOGGLE (0 << GTD_STATUS_T_SHIFT)
  241. # define GTD_STATUS_T_DATA0 (2 << GTD_STATUS_T_SHIFT)
  242. # define GTD_STATUS_T_DATA1 (3 << GTD_STATUS_T_SHIFT)
  243. #define GTD_STATUS_EC_SHIFT (26) /* Bits 26-27: Error count */
  244. #define GTD_STATUS_EC_MASK (3 << GTD_STATUS_EC_SHIFT)
  245. #define GTD_STATUS_CC_SHIFT (28) /* Bits 28-31: Condition code */
  246. #define GTD_STATUS_CC_MASK (15 << GTD_STATUS_CC_SHIFT)
  247. /* Isochronous Transfer Descriptor Offsets (4.3.2) */
  248. #define ITD_STATUS_OFFSET (0x00) /* TD status bits */
  249. #define ITD_BP0_OFFSET (0x04) /* Buffer page 0 (BP0) */
  250. #define ITD_NEXTTD_OFFSET (0x08) /* Next TD (NextTD) */
  251. #define ITD_BE_OFFSET (0x0c) /* Buffer End (BE) */
  252. #define ITD_NPSW (8)
  253. #define ITD_PSW0_OFFSET (0x10) /* Offset0/PSW0 */
  254. #define ITD_PSW1_OFFSET (0x12) /* Offset1/PSW1 */
  255. #define ITD_PSW2_OFFSET (0x14) /* Offset2/PSW2 */
  256. #define ITD_PSW3_OFFSET (0x16) /* Offset3/PSW3 */
  257. #define ITD_PSW4_OFFSET (0x18) /* Offset4/PSW4 */
  258. #define ITD_PSW5_OFFSET (0x1a) /* Offset5/PSW5 */
  259. #define ITD_PSW6_OFFSET (0x1c) /* Offset6/PSW6 */
  260. #define ITD_PSW7_OFFSET (0x1e) /* Offset7/PSW7 */
  261. /* Condition codes (Table 4-7) */
  262. #define TD_CC_NOERROR 0x00
  263. #define TD_CC_CRC 0x01
  264. #define TD_CC_BITSTUFFING 0x02
  265. #define TD_CC_DATATOGGLEMISMATCH 0x03
  266. #define TD_CC_STALL 0x04
  267. #define TD_CC_DEVNOTRESPONDING 0x05
  268. #define TD_CC_PIDCHECKFAILURE 0x06
  269. #define TD_CC_UNEXPECTEDPID 0x07
  270. #define TD_CC_DATAOVERRUN 0x08
  271. #define TD_CC_DATAUNDERRUN 0x09
  272. #define TD_CC_BUFFEROVERRUN 0x0c
  273. #define TD_CC_BUFFERUNDERRUN 0x0d
  274. #define TD_CC_NOTACCESSED 0x0f
  275. #define TD_CC_USER 0x10 /* For use by OHCI drivers */
  276. /* Host Controller Communications Area Format (4.4.1) ***********************/
  277. /* HccaInterruptTable: 32x32-bit pointers to interrupt EDs */
  278. #define HCCA_INTTBL_OFFSET (0x00)
  279. #define HCCA_INTTBL_WSIZE (32)
  280. #define HCCA_INTTBL_BSIZE (HCCA_INTTBL_WSIZE * 4)
  281. /* HccaFrameNumber: Current frame number */
  282. #define HCCA_FMNO_OFFSET (0x80)
  283. #define HCCA_FMNO_BSIZE (2)
  284. /* HccaPad1: Zero when frame no. updated */
  285. #define HCCA_PAD1_OFFSET (0x82)
  286. #define HCCA_PAD1_BSIZE (2)
  287. /* HccaDoneHead: When the HC reaches the end of a frame and its deferred
  288. * interrupt register is 0, it writes the current value of its HcDoneHead to
  289. * this location and generates an interrupt.
  290. *
  291. * The LSB of HCCADoneHead may be set to 1 to indicate that an unmasked
  292. * HcInterruptStatus was set when HccaDoneHead was written.
  293. */
  294. #define HCCA_DONEHEAD_OFFSET (0x84)
  295. #define HCCA_DONEHEAD_BSIZE (4)
  296. #define HCCA_DONEHEAD_MASK 0xfffffffe
  297. #define HCCA_DONEHEAD_INTSTA (1 << 0)
  298. /* 0x88: 116 bytes reserved */
  299. #define HCCA_RESERVED_OFFSET (0x88)
  300. #define HCCA_RESERVED_BSIZE (116)
  301. /****************************************************************************
  302. * Public Types
  303. ****************************************************************************/
  304. struct ohci_hcor
  305. {
  306. volatile uint32_t hcrevision; /* 0x00 */
  307. volatile uint32_t hccontrol; /* 0x04 */
  308. volatile uint32_t hccmdsts; /* 0x08 */
  309. volatile uint32_t hcintsts; /* 0x0c */
  310. volatile uint32_t hcinten; /* 0x10 */
  311. volatile uint32_t hcintdis; /* 0x14 */
  312. volatile uint32_t hchcca; /* 0x18 */
  313. volatile uint32_t hcperiodcurrented; /* 0x1c */
  314. volatile uint32_t hccontrolheaded; /* 0x20 */
  315. volatile uint32_t hccontrolcurrented; /* 0x24 */
  316. volatile uint32_t hcbulkheaded; /* 0x28 */
  317. volatile uint32_t hcbulkcurrented; /* 0x2c */
  318. volatile uint32_t hcdonehead; /* 0x30 */
  319. volatile uint32_t hcfminterval; /* 0x34 */
  320. volatile uint32_t hcfmremaining; /* 0x38 */
  321. volatile uint32_t hcfmnumber; /* 0x3c */
  322. volatile uint32_t hcperiodicstart; /* 0x40 */
  323. volatile uint32_t hclsthreshold; /* 0x44 */
  324. volatile uint32_t hcrhdescriptora; /* 0x48 */
  325. volatile uint32_t hcrhdescriptorb; /* 0x4c */
  326. volatile uint32_t hcrhsts; /* 0x50 */
  327. volatile uint32_t hcrhportsts[15]; /* 0x54 */
  328. };
  329. /* Endpoint Descriptor Offsets (4.2.1) */
  330. struct ohci_ed_s
  331. {
  332. volatile uint32_t ctrl; /* ED status/control bits */
  333. volatile uint32_t tailp; /* TD Queue Tail Pointer (TailP) */
  334. volatile uint32_t headp; /* TD Queue Head Pointer (HeadP) */
  335. volatile uint32_t nexted; /* Next Endpoint Descriptor (NextED) */
  336. };
  337. /* General Transfer Descriptor (4.3.1) */
  338. struct ohci_gtd_s
  339. {
  340. volatile uint32_t ctrl; /* TD status/control bits */
  341. volatile uint32_t cbp; /* Current Buffer Pointer (CBP) */
  342. volatile uint32_t nexttd; /* Next TD (NextTD) */
  343. volatile uint32_t be; /* Buffer End (BE) */
  344. };
  345. /* Isochronous Transfer Descriptor Offsets (4.3.2) */
  346. struct ohci_itd_s
  347. {
  348. volatile uint32_t ctrl; /* TD status/control bits */
  349. volatile uint32_t bp0; /* Buffer page 0 (BP0 */
  350. volatile uint32_t nexttd; /* Next TD (NextTD) */
  351. volatile uint32_t be; /* Buffer End (BE) */
  352. volatile uint16_t psw[ITD_NPSW]; /* Offset/PSW */
  353. };
  354. /* Host Controller Communications Area Format (4.4.1) */
  355. struct ohci_hcca_s
  356. {
  357. /* HccaInterruptTable: 32x32-bit pointers to interrupt EDs */
  358. volatile uint32_t inttbl[HCCA_INTTBL_WSIZE];
  359. /* HccaFrameNumber: Current frame number and
  360. * HccaPad1: Zero when frame no. updated
  361. */
  362. volatile uint16_t fmno;
  363. volatile uint16_t pad1;
  364. /* HccaDoneHead: When the HC reaches the end of a frame and its deferred
  365. * interrupt register is 0, it writes the current value of its HcDoneHead
  366. * to this location and generates an interrupt.
  367. */
  368. volatile uint32_t donehead;
  369. volatile uint8_t reserved[HCCA_RESERVED_BSIZE];
  370. volatile uint32_t extra;
  371. } __attribute__((aligned(256)));
  372. /****************************************************************************
  373. * Public Data
  374. ****************************************************************************/
  375. #ifdef __cplusplus
  376. #define EXTERN extern "C"
  377. extern "C"
  378. {
  379. #else
  380. #define EXTERN extern
  381. #endif
  382. /****************************************************************************
  383. * Public Function Prototypes
  384. ****************************************************************************/
  385. #undef EXTERN
  386. #ifdef __cplusplus
  387. }
  388. #endif
  389. #endif /* __INCLUDE_NUTTX_USB_OHCI_H */