rockchip_i2s.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. /*
  2. * sound/soc/rockchip/rockchip_i2s.h
  3. *
  4. * ALSA SoC Audio Layer - Rockchip I2S Controller driver
  5. *
  6. * Copyright (c) 2014 Rockchip Electronics Co. Ltd.
  7. * Author: Jianqun xu <jay.xu@rock-chips.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef _ROCKCHIP_IIS_H
  14. #define _ROCKCHIP_IIS_H
  15. /*
  16. * TXCR
  17. * transmit operation control register
  18. */
  19. #define I2S_TXCR_RCNT_SHIFT 17
  20. #define I2S_TXCR_RCNT_MASK (0x3f << I2S_TXCR_RCNT_SHIFT)
  21. #define I2S_TXCR_CSR_SHIFT 15
  22. #define I2S_TXCR_CSR(x) (x << I2S_TXCR_CSR_SHIFT)
  23. #define I2S_TXCR_CSR_MASK (3 << I2S_TXCR_CSR_SHIFT)
  24. #define I2S_TXCR_HWT BIT(14)
  25. #define I2S_TXCR_SJM_SHIFT 12
  26. #define I2S_TXCR_SJM_R (0 << I2S_TXCR_SJM_SHIFT)
  27. #define I2S_TXCR_SJM_L (1 << I2S_TXCR_SJM_SHIFT)
  28. #define I2S_TXCR_FBM_SHIFT 11
  29. #define I2S_TXCR_FBM_MSB (0 << I2S_TXCR_FBM_SHIFT)
  30. #define I2S_TXCR_FBM_LSB (1 << I2S_TXCR_FBM_SHIFT)
  31. #define I2S_TXCR_IBM_SHIFT 9
  32. #define I2S_TXCR_IBM_NORMAL (0 << I2S_TXCR_IBM_SHIFT)
  33. #define I2S_TXCR_IBM_LSJM (1 << I2S_TXCR_IBM_SHIFT)
  34. #define I2S_TXCR_IBM_RSJM (2 << I2S_TXCR_IBM_SHIFT)
  35. #define I2S_TXCR_IBM_MASK (3 << I2S_TXCR_IBM_SHIFT)
  36. #define I2S_TXCR_PBM_SHIFT 7
  37. #define I2S_TXCR_PBM_MODE(x) (x << I2S_TXCR_PBM_SHIFT)
  38. #define I2S_TXCR_PBM_MASK (3 << I2S_TXCR_PBM_SHIFT)
  39. #define I2S_TXCR_TFS_SHIFT 5
  40. #define I2S_TXCR_TFS_I2S (0 << I2S_TXCR_TFS_SHIFT)
  41. #define I2S_TXCR_TFS_PCM (1 << I2S_TXCR_TFS_SHIFT)
  42. #define I2S_TXCR_VDW_SHIFT 0
  43. #define I2S_TXCR_VDW(x) ((x - 1) << I2S_TXCR_VDW_SHIFT)
  44. #define I2S_TXCR_VDW_MASK (0x1f << I2S_TXCR_VDW_SHIFT)
  45. /*
  46. * RXCR
  47. * receive operation control register
  48. */
  49. #define I2S_RXCR_HWT BIT(14)
  50. #define I2S_RXCR_SJM_SHIFT 12
  51. #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT)
  52. #define I2S_RXCR_SJM_L (1 << I2S_RXCR_SJM_SHIFT)
  53. #define I2S_RXCR_FBM_SHIFT 11
  54. #define I2S_RXCR_FBM_MSB (0 << I2S_RXCR_FBM_SHIFT)
  55. #define I2S_RXCR_FBM_LSB (1 << I2S_RXCR_FBM_SHIFT)
  56. #define I2S_RXCR_IBM_SHIFT 9
  57. #define I2S_RXCR_IBM_NORMAL (0 << I2S_RXCR_IBM_SHIFT)
  58. #define I2S_RXCR_IBM_LSJM (1 << I2S_RXCR_IBM_SHIFT)
  59. #define I2S_RXCR_IBM_RSJM (2 << I2S_RXCR_IBM_SHIFT)
  60. #define I2S_RXCR_IBM_MASK (3 << I2S_RXCR_IBM_SHIFT)
  61. #define I2S_RXCR_PBM_SHIFT 7
  62. #define I2S_RXCR_PBM_MODE(x) (x << I2S_RXCR_PBM_SHIFT)
  63. #define I2S_RXCR_PBM_MASK (3 << I2S_RXCR_PBM_SHIFT)
  64. #define I2S_RXCR_TFS_SHIFT 5
  65. #define I2S_RXCR_TFS_I2S (0 << I2S_RXCR_TFS_SHIFT)
  66. #define I2S_RXCR_TFS_PCM (1 << I2S_RXCR_TFS_SHIFT)
  67. #define I2S_RXCR_VDW_SHIFT 0
  68. #define I2S_RXCR_VDW(x) ((x - 1) << I2S_RXCR_VDW_SHIFT)
  69. #define I2S_RXCR_VDW_MASK (0x1f << I2S_RXCR_VDW_SHIFT)
  70. /*
  71. * CKR
  72. * clock generation register
  73. */
  74. #define I2S_CKR_MSS_SHIFT 27
  75. #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT)
  76. #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT)
  77. #define I2S_CKR_MSS_MASK (1 << I2S_CKR_MSS_SHIFT)
  78. #define I2S_CKR_CKP_SHIFT 26
  79. #define I2S_CKR_CKP_NEG (0 << I2S_CKR_CKP_SHIFT)
  80. #define I2S_CKR_CKP_POS (1 << I2S_CKR_CKP_SHIFT)
  81. #define I2S_CKR_RLP_SHIFT 25
  82. #define I2S_CKR_RLP_NORMAL (0 << I2S_CKR_RLP_SHIFT)
  83. #define I2S_CKR_RLP_OPPSITE (1 << I2S_CKR_RLP_SHIFT)
  84. #define I2S_CKR_TLP_SHIFT 24
  85. #define I2S_CKR_TLP_NORMAL (0 << I2S_CKR_TLP_SHIFT)
  86. #define I2S_CKR_TLP_OPPSITE (1 << I2S_CKR_TLP_SHIFT)
  87. #define I2S_CKR_MDIV_SHIFT 16
  88. #define I2S_CKR_MDIV(x) ((x - 1) << I2S_CKR_MDIV_SHIFT)
  89. #define I2S_CKR_MDIV_MASK (0xff << I2S_CKR_MDIV_SHIFT)
  90. #define I2S_CKR_RSD_SHIFT 8
  91. #define I2S_CKR_RSD(x) ((x - 1) << I2S_CKR_RSD_SHIFT)
  92. #define I2S_CKR_RSD_MASK (0xff << I2S_CKR_RSD_SHIFT)
  93. #define I2S_CKR_TSD_SHIFT 0
  94. #define I2S_CKR_TSD(x) ((x - 1) << I2S_CKR_TSD_SHIFT)
  95. #define I2S_CKR_TSD_MASK (0xff << I2S_CKR_TSD_SHIFT)
  96. /*
  97. * FIFOLR
  98. * FIFO level register
  99. */
  100. #define I2S_FIFOLR_RFL_SHIFT 24
  101. #define I2S_FIFOLR_RFL_MASK (0x3f << I2S_FIFOLR_RFL_SHIFT)
  102. #define I2S_FIFOLR_TFL3_SHIFT 18
  103. #define I2S_FIFOLR_TFL3_MASK (0x3f << I2S_FIFOLR_TFL3_SHIFT)
  104. #define I2S_FIFOLR_TFL2_SHIFT 12
  105. #define I2S_FIFOLR_TFL2_MASK (0x3f << I2S_FIFOLR_TFL2_SHIFT)
  106. #define I2S_FIFOLR_TFL1_SHIFT 6
  107. #define I2S_FIFOLR_TFL1_MASK (0x3f << I2S_FIFOLR_TFL1_SHIFT)
  108. #define I2S_FIFOLR_TFL0_SHIFT 0
  109. #define I2S_FIFOLR_TFL0_MASK (0x3f << I2S_FIFOLR_TFL0_SHIFT)
  110. /*
  111. * DMACR
  112. * DMA control register
  113. */
  114. #define I2S_DMACR_RDE_SHIFT 24
  115. #define I2S_DMACR_RDE_DISABLE (0 << I2S_DMACR_RDE_SHIFT)
  116. #define I2S_DMACR_RDE_ENABLE (1 << I2S_DMACR_RDE_SHIFT)
  117. #define I2S_DMACR_RDL_SHIFT 16
  118. #define I2S_DMACR_RDL(x) ((x - 1) << I2S_DMACR_RDL_SHIFT)
  119. #define I2S_DMACR_RDL_MASK (0x1f << I2S_DMACR_RDL_SHIFT)
  120. #define I2S_DMACR_TDE_SHIFT 8
  121. #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT)
  122. #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT)
  123. #define I2S_DMACR_TDL_SHIFT 0
  124. #define I2S_DMACR_TDL(x) ((x) << I2S_DMACR_TDL_SHIFT)
  125. #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT)
  126. /*
  127. * INTCR
  128. * interrupt control register
  129. */
  130. #define I2S_INTCR_RFT_SHIFT 20
  131. #define I2S_INTCR_RFT(x) ((x - 1) << I2S_INTCR_RFT_SHIFT)
  132. #define I2S_INTCR_RXOIC BIT(18)
  133. #define I2S_INTCR_RXOIE_SHIFT 17
  134. #define I2S_INTCR_RXOIE_DISABLE (0 << I2S_INTCR_RXOIE_SHIFT)
  135. #define I2S_INTCR_RXOIE_ENABLE (1 << I2S_INTCR_RXOIE_SHIFT)
  136. #define I2S_INTCR_RXFIE_SHIFT 16
  137. #define I2S_INTCR_RXFIE_DISABLE (0 << I2S_INTCR_RXFIE_SHIFT)
  138. #define I2S_INTCR_RXFIE_ENABLE (1 << I2S_INTCR_RXFIE_SHIFT)
  139. #define I2S_INTCR_TFT_SHIFT 4
  140. #define I2S_INTCR_TFT(x) ((x - 1) << I2S_INTCR_TFT_SHIFT)
  141. #define I2S_INTCR_TFT_MASK (0x1f << I2S_INTCR_TFT_SHIFT)
  142. #define I2S_INTCR_TXUIC BIT(2)
  143. #define I2S_INTCR_TXUIE_SHIFT 1
  144. #define I2S_INTCR_TXUIE_DISABLE (0 << I2S_INTCR_TXUIE_SHIFT)
  145. #define I2S_INTCR_TXUIE_ENABLE (1 << I2S_INTCR_TXUIE_SHIFT)
  146. /*
  147. * INTSR
  148. * interrupt status register
  149. */
  150. #define I2S_INTSR_TXEIE_SHIFT 0
  151. #define I2S_INTSR_TXEIE_DISABLE (0 << I2S_INTSR_TXEIE_SHIFT)
  152. #define I2S_INTSR_TXEIE_ENABLE (1 << I2S_INTSR_TXEIE_SHIFT)
  153. #define I2S_INTSR_RXOI_SHIFT 17
  154. #define I2S_INTSR_RXOI_INA (0 << I2S_INTSR_RXOI_SHIFT)
  155. #define I2S_INTSR_RXOI_ACT (1 << I2S_INTSR_RXOI_SHIFT)
  156. #define I2S_INTSR_RXFI_SHIFT 16
  157. #define I2S_INTSR_RXFI_INA (0 << I2S_INTSR_RXFI_SHIFT)
  158. #define I2S_INTSR_RXFI_ACT (1 << I2S_INTSR_RXFI_SHIFT)
  159. #define I2S_INTSR_TXUI_SHIFT 1
  160. #define I2S_INTSR_TXUI_INA (0 << I2S_INTSR_TXUI_SHIFT)
  161. #define I2S_INTSR_TXUI_ACT (1 << I2S_INTSR_TXUI_SHIFT)
  162. #define I2S_INTSR_TXEI_SHIFT 0
  163. #define I2S_INTSR_TXEI_INA (0 << I2S_INTSR_TXEI_SHIFT)
  164. #define I2S_INTSR_TXEI_ACT (1 << I2S_INTSR_TXEI_SHIFT)
  165. /*
  166. * XFER
  167. * Transfer start register
  168. */
  169. #define I2S_XFER_RXS_SHIFT 1
  170. #define I2S_XFER_RXS_STOP (0 << I2S_XFER_RXS_SHIFT)
  171. #define I2S_XFER_RXS_START (1 << I2S_XFER_RXS_SHIFT)
  172. #define I2S_XFER_TXS_SHIFT 0
  173. #define I2S_XFER_TXS_STOP (0 << I2S_XFER_TXS_SHIFT)
  174. #define I2S_XFER_TXS_START (1 << I2S_XFER_TXS_SHIFT)
  175. /*
  176. * CLR
  177. * clear SCLK domain logic register
  178. */
  179. #define I2S_CLR_RXC BIT(1)
  180. #define I2S_CLR_TXC BIT(0)
  181. /*
  182. * TXDR
  183. * Transimt FIFO data register, write only.
  184. */
  185. #define I2S_TXDR_MASK (0xff)
  186. /*
  187. * RXDR
  188. * Receive FIFO data register, write only.
  189. */
  190. #define I2S_RXDR_MASK (0xff)
  191. /* Clock divider id */
  192. enum {
  193. ROCKCHIP_DIV_MCLK = 0,
  194. ROCKCHIP_DIV_BCLK,
  195. };
  196. /* I2S REGS */
  197. #define I2S_TXCR (0x0000)
  198. #define I2S_RXCR (0x0004)
  199. #define I2S_CKR (0x0008)
  200. #define I2S_FIFOLR (0x000c)
  201. #define I2S_DMACR (0x0010)
  202. #define I2S_INTCR (0x0014)
  203. #define I2S_INTSR (0x0018)
  204. #define I2S_XFER (0x001c)
  205. #define I2S_CLR (0x0020)
  206. #define I2S_TXDR (0x0024)
  207. #define I2S_RXDR (0x0028)
  208. #endif /* _ROCKCHIP_IIS_H */