davinci-mcasp.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*
  2. * ALSA SoC McASP Audio Layer for TI DAVINCI processor
  3. *
  4. * MCASP related definitions
  5. *
  6. * Author: Nirmal Pandey <n-pandey@ti.com>,
  7. * Suresh Rajashekara <suresh.r@ti.com>
  8. * Steve Chen <schen@.mvista.com>
  9. *
  10. * Copyright: (C) 2009 MontaVista Software, Inc., <source@mvista.com>
  11. * Copyright: (C) 2009 Texas Instruments, India
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. */
  17. #ifndef DAVINCI_MCASP_H
  18. #define DAVINCI_MCASP_H
  19. /*
  20. * McASP register definitions
  21. */
  22. #define DAVINCI_MCASP_PID_REG 0x00
  23. #define DAVINCI_MCASP_PWREMUMGT_REG 0x04
  24. #define DAVINCI_MCASP_PFUNC_REG 0x10
  25. #define DAVINCI_MCASP_PDIR_REG 0x14
  26. #define DAVINCI_MCASP_PDOUT_REG 0x18
  27. #define DAVINCI_MCASP_PDSET_REG 0x1c
  28. #define DAVINCI_MCASP_PDCLR_REG 0x20
  29. #define DAVINCI_MCASP_TLGC_REG 0x30
  30. #define DAVINCI_MCASP_TLMR_REG 0x34
  31. #define DAVINCI_MCASP_GBLCTL_REG 0x44
  32. #define DAVINCI_MCASP_AMUTE_REG 0x48
  33. #define DAVINCI_MCASP_LBCTL_REG 0x4c
  34. #define DAVINCI_MCASP_TXDITCTL_REG 0x50
  35. #define DAVINCI_MCASP_GBLCTLR_REG 0x60
  36. #define DAVINCI_MCASP_RXMASK_REG 0x64
  37. #define DAVINCI_MCASP_RXFMT_REG 0x68
  38. #define DAVINCI_MCASP_RXFMCTL_REG 0x6c
  39. #define DAVINCI_MCASP_ACLKRCTL_REG 0x70
  40. #define DAVINCI_MCASP_AHCLKRCTL_REG 0x74
  41. #define DAVINCI_MCASP_RXTDM_REG 0x78
  42. #define DAVINCI_MCASP_EVTCTLR_REG 0x7c
  43. #define DAVINCI_MCASP_RXSTAT_REG 0x80
  44. #define DAVINCI_MCASP_RXTDMSLOT_REG 0x84
  45. #define DAVINCI_MCASP_RXCLKCHK_REG 0x88
  46. #define DAVINCI_MCASP_REVTCTL_REG 0x8c
  47. #define DAVINCI_MCASP_GBLCTLX_REG 0xa0
  48. #define DAVINCI_MCASP_TXMASK_REG 0xa4
  49. #define DAVINCI_MCASP_TXFMT_REG 0xa8
  50. #define DAVINCI_MCASP_TXFMCTL_REG 0xac
  51. #define DAVINCI_MCASP_ACLKXCTL_REG 0xb0
  52. #define DAVINCI_MCASP_AHCLKXCTL_REG 0xb4
  53. #define DAVINCI_MCASP_TXTDM_REG 0xb8
  54. #define DAVINCI_MCASP_EVTCTLX_REG 0xbc
  55. #define DAVINCI_MCASP_TXSTAT_REG 0xc0
  56. #define DAVINCI_MCASP_TXTDMSLOT_REG 0xc4
  57. #define DAVINCI_MCASP_TXCLKCHK_REG 0xc8
  58. #define DAVINCI_MCASP_XEVTCTL_REG 0xcc
  59. /* Left(even TDM Slot) Channel Status Register File */
  60. #define DAVINCI_MCASP_DITCSRA_REG 0x100
  61. /* Right(odd TDM slot) Channel Status Register File */
  62. #define DAVINCI_MCASP_DITCSRB_REG 0x118
  63. /* Left(even TDM slot) User Data Register File */
  64. #define DAVINCI_MCASP_DITUDRA_REG 0x130
  65. /* Right(odd TDM Slot) User Data Register File */
  66. #define DAVINCI_MCASP_DITUDRB_REG 0x148
  67. /* Serializer n Control Register */
  68. #define DAVINCI_MCASP_XRSRCTL_BASE_REG 0x180
  69. #define DAVINCI_MCASP_XRSRCTL_REG(n) (DAVINCI_MCASP_XRSRCTL_BASE_REG + \
  70. (n << 2))
  71. /* Transmit Buffer for Serializer n */
  72. #define DAVINCI_MCASP_TXBUF_REG(n) (0x200 + (n << 2))
  73. /* Receive Buffer for Serializer n */
  74. #define DAVINCI_MCASP_RXBUF_REG(n) (0x280 + (n << 2))
  75. /* McASP FIFO Registers */
  76. #define DAVINCI_MCASP_V2_AFIFO_BASE (0x1010)
  77. #define DAVINCI_MCASP_V3_AFIFO_BASE (0x1000)
  78. /* FIFO register offsets from AFIFO base */
  79. #define MCASP_WFIFOCTL_OFFSET (0x0)
  80. #define MCASP_WFIFOSTS_OFFSET (0x4)
  81. #define MCASP_RFIFOCTL_OFFSET (0x8)
  82. #define MCASP_RFIFOSTS_OFFSET (0xc)
  83. /* DAVINCI_MCASP_PID_REG - Peripheral Identification Register Bits */
  84. #define MCASP_V4_REVMINOR_MASK (0x3f)
  85. #define MCASP_V4_REVMAJOR_MASK (0x7 << 8)
  86. #define MCASP_V4_REV_MASK (MCASP_V4_REVMAJOR_MASK | \
  87. MCASP_V4_REVMINOR_MASK)
  88. #define MCASP_V4_REV(maj, min) ((maj) << 8 | (min))
  89. /*
  90. * DAVINCI_MCASP_PWREMUMGT_REG - Power Down and Emulation Management
  91. * Register Bits
  92. */
  93. #define MCASP_FREE BIT(0)
  94. #define MCASP_SOFT BIT(1)
  95. /*
  96. * DAVINCI_MCASP_PFUNC_REG - Pin Function / GPIO Enable Register Bits
  97. */
  98. #define AXR(n) (1<<n)
  99. #define PFUNC_AMUTE BIT(25)
  100. #define ACLKX BIT(26)
  101. #define AHCLKX BIT(27)
  102. #define AFSX BIT(28)
  103. #define ACLKR BIT(29)
  104. #define AHCLKR BIT(30)
  105. #define AFSR BIT(31)
  106. /*
  107. * DAVINCI_MCASP_PDIR_REG - Pin Direction Register Bits
  108. */
  109. #define AXR(n) (1<<n)
  110. #define PDIR_AMUTE BIT(25)
  111. #define ACLKX BIT(26)
  112. #define AHCLKX BIT(27)
  113. #define AFSX BIT(28)
  114. #define ACLKR BIT(29)
  115. #define AHCLKR BIT(30)
  116. #define AFSR BIT(31)
  117. /*
  118. * DAVINCI_MCASP_TXDITCTL_REG - Transmit DIT Control Register Bits
  119. */
  120. #define DITEN BIT(0) /* Transmit DIT mode enable/disable */
  121. #define VA BIT(2)
  122. #define VB BIT(3)
  123. /*
  124. * DAVINCI_MCASP_TXFMT_REG - Transmit Bitstream Format Register Bits
  125. */
  126. #define TXROT(val) (val)
  127. #define TXSEL BIT(3)
  128. #define TXSSZ(val) (val<<4)
  129. #define TXPBIT(val) (val<<8)
  130. #define TXPAD(val) (val<<13)
  131. #define TXORD BIT(15)
  132. #define FSXDLY(val) (val<<16)
  133. /*
  134. * DAVINCI_MCASP_RXFMT_REG - Receive Bitstream Format Register Bits
  135. */
  136. #define RXROT(val) (val)
  137. #define RXSEL BIT(3)
  138. #define RXSSZ(val) (val<<4)
  139. #define RXPBIT(val) (val<<8)
  140. #define RXPAD(val) (val<<13)
  141. #define RXORD BIT(15)
  142. #define FSRDLY(val) (val<<16)
  143. /*
  144. * DAVINCI_MCASP_TXFMCTL_REG - Transmit Frame Control Register Bits
  145. */
  146. #define FSXPOL BIT(0)
  147. #define AFSXE BIT(1)
  148. #define FSXDUR BIT(4)
  149. #define FSXMOD(val) (val<<7)
  150. /*
  151. * DAVINCI_MCASP_RXFMCTL_REG - Receive Frame Control Register Bits
  152. */
  153. #define FSRPOL BIT(0)
  154. #define AFSRE BIT(1)
  155. #define FSRDUR BIT(4)
  156. #define FSRMOD(val) (val<<7)
  157. /*
  158. * DAVINCI_MCASP_ACLKXCTL_REG - Transmit Clock Control Register Bits
  159. */
  160. #define ACLKXDIV(val) (val)
  161. #define ACLKXE BIT(5)
  162. #define TX_ASYNC BIT(6)
  163. #define ACLKXPOL BIT(7)
  164. #define ACLKXDIV_MASK 0x1f
  165. /*
  166. * DAVINCI_MCASP_ACLKRCTL_REG Receive Clock Control Register Bits
  167. */
  168. #define ACLKRDIV(val) (val)
  169. #define ACLKRE BIT(5)
  170. #define RX_ASYNC BIT(6)
  171. #define ACLKRPOL BIT(7)
  172. #define ACLKRDIV_MASK 0x1f
  173. /*
  174. * DAVINCI_MCASP_AHCLKXCTL_REG - High Frequency Transmit Clock Control
  175. * Register Bits
  176. */
  177. #define AHCLKXDIV(val) (val)
  178. #define AHCLKXPOL BIT(14)
  179. #define AHCLKXE BIT(15)
  180. #define AHCLKXDIV_MASK 0xfff
  181. /*
  182. * DAVINCI_MCASP_AHCLKRCTL_REG - High Frequency Receive Clock Control
  183. * Register Bits
  184. */
  185. #define AHCLKRDIV(val) (val)
  186. #define AHCLKRPOL BIT(14)
  187. #define AHCLKRE BIT(15)
  188. #define AHCLKRDIV_MASK 0xfff
  189. /*
  190. * DAVINCI_MCASP_XRSRCTL_BASE_REG - Serializer Control Register Bits
  191. */
  192. #define MODE(val) (val)
  193. #define DISMOD_3STATE (0x0)
  194. #define DISMOD_LOW (0x2 << 2)
  195. #define DISMOD_HIGH (0x3 << 2)
  196. #define DISMOD_MASK DISMOD_HIGH
  197. #define TXSTATE BIT(4)
  198. #define RXSTATE BIT(5)
  199. #define SRMOD_MASK 3
  200. #define SRMOD_INACTIVE 0
  201. /*
  202. * DAVINCI_MCASP_LBCTL_REG - Loop Back Control Register Bits
  203. */
  204. #define LBEN BIT(0)
  205. #define LBORD BIT(1)
  206. #define LBGENMODE(val) (val<<2)
  207. /*
  208. * DAVINCI_MCASP_TXTDMSLOT_REG - Transmit TDM Slot Register configuration
  209. */
  210. #define TXTDMS(n) (1<<n)
  211. /*
  212. * DAVINCI_MCASP_RXTDMSLOT_REG - Receive TDM Slot Register configuration
  213. */
  214. #define RXTDMS(n) (1<<n)
  215. /*
  216. * DAVINCI_MCASP_GBLCTL_REG - Global Control Register Bits
  217. */
  218. #define RXCLKRST BIT(0) /* Receiver Clock Divider Reset */
  219. #define RXHCLKRST BIT(1) /* Receiver High Frequency Clock Divider */
  220. #define RXSERCLR BIT(2) /* Receiver Serializer Clear */
  221. #define RXSMRST BIT(3) /* Receiver State Machine Reset */
  222. #define RXFSRST BIT(4) /* Frame Sync Generator Reset */
  223. #define TXCLKRST BIT(8) /* Transmitter Clock Divider Reset */
  224. #define TXHCLKRST BIT(9) /* Transmitter High Frequency Clock Divider*/
  225. #define TXSERCLR BIT(10) /* Transmit Serializer Clear */
  226. #define TXSMRST BIT(11) /* Transmitter State Machine Reset */
  227. #define TXFSRST BIT(12) /* Frame Sync Generator Reset */
  228. /*
  229. * DAVINCI_MCASP_TXSTAT_REG - Transmitter Status Register Bits
  230. * DAVINCI_MCASP_RXSTAT_REG - Receiver Status Register Bits
  231. */
  232. #define XRERR BIT(8) /* Transmit/Receive error */
  233. #define XRDATA BIT(5) /* Transmit/Receive data ready */
  234. /*
  235. * DAVINCI_MCASP_AMUTE_REG - Mute Control Register Bits
  236. */
  237. #define MUTENA(val) (val)
  238. #define MUTEINPOL BIT(2)
  239. #define MUTEINENA BIT(3)
  240. #define MUTEIN BIT(4)
  241. #define MUTER BIT(5)
  242. #define MUTEX BIT(6)
  243. #define MUTEFSR BIT(7)
  244. #define MUTEFSX BIT(8)
  245. #define MUTEBADCLKR BIT(9)
  246. #define MUTEBADCLKX BIT(10)
  247. #define MUTERXDMAERR BIT(11)
  248. #define MUTETXDMAERR BIT(12)
  249. /*
  250. * DAVINCI_MCASP_REVTCTL_REG - Receiver DMA Event Control Register bits
  251. */
  252. #define RXDATADMADIS BIT(0)
  253. /*
  254. * DAVINCI_MCASP_XEVTCTL_REG - Transmitter DMA Event Control Register bits
  255. */
  256. #define TXDATADMADIS BIT(0)
  257. /*
  258. * DAVINCI_MCASP_EVTCTLR_REG - Receiver Interrupt Control Register Bits
  259. */
  260. #define ROVRN BIT(0)
  261. /*
  262. * DAVINCI_MCASP_EVTCTLX_REG - Transmitter Interrupt Control Register Bits
  263. */
  264. #define XUNDRN BIT(0)
  265. /*
  266. * DAVINCI_MCASP_W[R]FIFOCTL - Write/Read FIFO Control Register bits
  267. */
  268. #define FIFO_ENABLE BIT(16)
  269. #define NUMEVT_MASK (0xFF << 8)
  270. #define NUMEVT(x) (((x) & 0xFF) << 8)
  271. #define NUMDMA_MASK (0xFF)
  272. #endif /* DAVINCI_MCASP_H */