ark1668ed_i2s.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * ark1668ed_i2s.h
  3. *
  4. */
  5. #ifndef __ARK1668ED_I2S_H
  6. #define __ARK1668ED_I2S_H
  7. #if 0
  8. /*
  9. * I2S Controller Register and Bit Definitions
  10. */
  11. //#define I2S_SACR0 0x00 /* Global Control Register */
  12. //#define I2S_SACR1 0x04 /* Serial Audio I 2 S/MSB-Justified Control Register */
  13. #define I2S_DACR0 0x08 /* Volume Control Register 0 */
  14. #define I2S_DACR1 0x10 /* Volume Control Register 1 */
  15. //#define I2S_SASR0 0x0C /* Serial Audio I 2 S/MSB-Justified Interface and FIFO Status Register */
  16. //#define I2S_SAIMR 0x14 /* Serial Audio Interrupt Mask Register */
  17. //#define I2S_SAICR 0x18 /* Serial Audio Interrupt Clear Register */
  18. #define I2S_ADCR0 0x1C /* ADC Contol Register */
  19. //#define I2S_SADR 0x80 /* Serial Audio Data Register (TX and RX FIFO access Register). */
  20. #define SACR0_CH_ALIGH (1 << 27) /* channel align in 32bit mode */
  21. #define SACR0_RLFIRST (1 << 26) /* RX FIFO left ch first */
  22. #define SACR0_TLFIRST (1 << 25) /* TX FIFO left ch first */
  23. #define SACR0_CH_LOCK (1 << 24) /* Load RLFIRST TLFIRST setting */
  24. #define SACR0_MOLO_MODE (1 << 23) /* single channel mode */
  25. #define SACR0_32BIT_MODE (1 << 22) /* S32_LE mode */
  26. #define SACR0_SYNC_INV (1 << 21) /* Left/Right ch switch */
  27. #define SACR0_VREF_PD (1 << 21) /* VREF Power down */
  28. #define SACR0_RFTH_MASK (0x1F << 16)
  29. #define SACR0_TFTH_MASK (0x1F << 8)
  30. #define SACR0_RFTH(x) ((x) << 16) /* Rx FIFO Interrupt or DMA Trigger Threshold */
  31. #define SACR0_TFTH(x) ((x) << 8) /* Tx FIFO Interrupt or DMA Trigger Threshold */
  32. #define SACR0_STRF (1 << 7) /* DAC output clk edge select */
  33. #define SACR0_RDMAEN (1 << 6) /* RX DMA Enable */
  34. #define SACR0_ENLBF (1 << 5) /* Enable Loopback */
  35. #define SACR0_RST (1 << 4) /* FIFO, i2s Register Reset */
  36. #define SACR0_TDMAEN (1 << 3) /* TX DMA Enable */
  37. #define SACR0_BCKD (1 << 2) /* Bit Clock Direction */
  38. #define SACR0_SYNCD (1 << 1) /* Wprd Select Clock Direction */
  39. #define SACR0_ENB (1 << 0) /* Enable I2S Link */
  40. #define SACR1_DRPL (1 << 1) /* Disable Replaying Function */
  41. #define SACR1_DREC (1 << 0) /* Disable Recording Function */
  42. //ark1668
  43. //#define DACR0_LVOL_MASK (0x7f << 0)
  44. //#define DACR0_LVOL(x) (((x) & 0x7f) << 0) /* Lefit Channel Volume */
  45. //#define DACR0_RVOL_MASK (0x7f << 8)
  46. //#define DACR0_RVOL(x) (((x) & 0x7f) << 8) /* Right Channel Volume */
  47. //ark1668e
  48. #define DACR0_LVOL_MASK (0x3f << 6)
  49. #define DACR0_LVOL(x) (((x) & 0x3f) << 6) /* Lefit Channel Volume */
  50. #define DACR0_RVOL_MASK (0x3f << 0)
  51. #define DACR0_RVOL(x) (((x) & 0x3f) << 0) /* Right Channel Volume */
  52. #define DACR0_LHPVOL_MASK (0x3f << 0)
  53. #define DACR0_LHPVOL(x) (((x) & 0x3f) << 0) /* HPOUT Lefit Channel Volume */
  54. #define DACR0_RHPVOL_MASK (0x3f << 24)
  55. #define DACR0_RHPVOL(x) (((x) & 0x3f) << 24) /* HPOUT Right Channel Volume */
  56. #define DACR0_L_R_OUT_MUTE(x) ((x) << 27) /* LOUT and ROUT mute control */
  57. #define SASR0_RFL(x) ((x) << 16) /* Rx FIFO Level */
  58. #define SASR0_TFL(x) ((x) << 8) /* Tx FIFO Level */
  59. #define SASR0_ROR (1 << 6) /* Rx FIFO Overrun */
  60. #define SASR0_TUR (1 << 5) /* Tx FIFO Underrun */
  61. #define SASR0_RFS (1 << 4) /* Rx FIFO Service Request */
  62. #define SASR0_TFS (1 << 3) /* Tx FIFO Service Request */
  63. #define SASR0_BSY (1 << 2) /* I2S Busy */
  64. #define SASR0_RNE (1 << 1) /* Rx FIFO Not Empty */
  65. #define SASR0_TNF (1 << 0) /* Tx FIFO Not Full */
  66. #define SAICR_ROR (1 << 6) /* Clear Rx FIFO Overrun Interrupt */
  67. #define SAICR_TUR (1 << 5) /* Clear Tx FIFO Underrun Interrupt */
  68. #define SAICR_RFS (1 << 4) /* Clear Rx FIFO Service Interrupt */
  69. #define SAICR_TFS (1 << 3) /* Clear Tx FIFO Service Interrupt */
  70. #define SAIMR_ROR (1 << 6) /* Enable Rx FIFO Overrun Condition Interrupt */
  71. #define SAIMR_TUR (1 << 5) /* Enable Tx FIFO Underrun Condition Interrupt */
  72. #define SAIMR_RFS (1 << 4) /* Enable Rx FIFO Service Interrupt */
  73. #define SAIMR_TFS (1 << 3) /* Enable Tx FIFO Service Interrupt */
  74. //#define ADCR0_LVOL_MASK (0xf << 0)
  75. //#define ADCR0_LVOL(x) (((x) & 0xf) << 0) /* Lefit Channel Volume */
  76. //#define ADCR0_RVOL_MASK (0xf << 4)
  77. //#define ADCR0_RVOL(x) (((x) & 0xf) << 4) /* Right Channel Volume */
  78. //ark1668e
  79. #define ADCR0_LVOL_MASK (0x7f << 0)
  80. #define ADCR0_LVOL(x) (((x) & 0x7f) << 19) /* Lefit Channel Digital Volume */
  81. #define ADCR0_RVOL_MASK (0x7f << 4)
  82. #define ADCR0_RVOL(x) (((x) & 0x7f) << 12) /* Right Channel Digital Volume */
  83. #define ADCR0_LFS_MASK (0x3 << 9) /* Left Filter Sel Mask */
  84. #define ADCR0_RFS_MASK (0x3 << 11) /* Right Filter Sel Mask */
  85. #define ADCR0_LFS_1P4 (0 << 9) /* 1/4 sample rate filter */
  86. #define ADCR0_LFS_1P2 (1 << 9) /* 1/2 sample rate filter */
  87. #define ADCR0_LFS_1P8 (2 << 9) /* 1/8 sample rate filter */
  88. #define ADCR0_LFS_1 (3 << 9) /* bypass */
  89. #define ADCR0_RFS_1P4 (0 << 11) /* 1/4 sample rate filter */
  90. #define ADCR0_RFS_1P2 (1 << 11) /* 1/2 sample rate filter */
  91. #define ADCR0_RFS_1P8 (2 << 11) /* 1/8 sample rate filter */
  92. #define ADCR0_RFS_1 (3 << 11) /* bypass */
  93. #define ADCR0_LME (1 << 14) /* Left Channel mic enhance */
  94. #define ADCR0_RME (1 << 15) /* Right Channel mic enhance */
  95. #define rSYS_SD_CLK_CFG 0x58
  96. #define rSYS_SD1_CLK_CFG 0x5c
  97. #define rSYS_DEVICE_CLK_CFG0 0x60
  98. #define rSYS_DEVICE_CLK_CFG1 0x64
  99. #define rSYS_DEVICE_CLK_CFG2 0x68
  100. #define rSYS_DEVICE_CLK_CFG3 0x6c
  101. #define rSYS_SOFT_RSTNA 0x74
  102. #define rSYS_SOFT_RSTNB 0x78
  103. #define rSYS_DDR_STATUS 0x180
  104. #define rSYS_DDR_IO_CFG 0x19C
  105. #define rSYS_PAD_CTRL00 0x1c0
  106. #define rSYS_PAD_CTRL01 0x1c4
  107. #define rSYS_PAD_CTRL02 0x1c8
  108. #define rSYS_PAD_CTRL05 0x1d4
  109. #define rSYS_PAD_CTRL06 0x1d8
  110. #define rSYS_PAD_CTRL07 0x1dc
  111. #define rSYS_PAD_CTRL08 0x1e0
  112. #define rSYS_PAD_CTRL09 0x1e4
  113. #define rSYS_PAD_CTRL0A 0x1e8
  114. #define rSYS_PAD_CTRL0B 0x1ec
  115. #define rSYS_PAD_CTRL0C 0x1f0
  116. #define rSYS_PAD_CTRL0D 0x1f4
  117. #define rSYS_PAD_CTRL0E 0x1f8
  118. #define rSYS_PAD_CTRL38 0x1fc
  119. #define rSYS_PAD_CTRL3E 0x200
  120. #define rSYS_PAD_CTRL0F 0x204
  121. #define rSYS_CPU_CTL 0x208
  122. #define rSYS_MFC_GMAC_CTL 0x20c
  123. #define rSYS_DEVICE_CLK_CFG7 0x230
  124. #define rSYS_I2S_NCO_CFG 0x174
  125. //#define rSYS_I2S1_NCO_CFG 0x19c
  126. //#define rSYS_I2S2_NCO_CFG 0x178
  127. #define rSYS_PLL_RFCK_CTL 0x14c
  128. #define rSYS_AUDIO_CFG_0 0x240
  129. #define rSYS_AUDIO_CFG_1 0x244
  130. #define rSYS_AUDIO_CFG_2 0x248
  131. #define rSYS_AUDIO_CFG_3 0x24c
  132. #define rSYS_AUDIO_CFG_4 0x250
  133. #define rSYS_AUDIO_CFG_5 0x254
  134. #define SACR1_DISABLE_REPLAYING (1<<1)
  135. #define SACR1_DISABLE_RECORD (1<<0)
  136. #endif
  137. /**************ark1668ed**************/
  138. /*
  139. * I2S Controller Register and Bit Definitions
  140. */
  141. #define SYS_BASE 0x50000000
  142. #define I2S0_BASE 0x50d00000
  143. #define I2S1_BASE 0x50e00000
  144. #define I2S2_AUDIO_BASE 0x50100000
  145. #define I2S_SACR0 0x00 /* Global Control Register */
  146. #define I2S_SACR1 0x04 /* Serial Audio I2S Control Register*/
  147. #define I2S_WRCTL 0x08 /* Tx_fifo Write Control Register*/
  148. #define I2S_RDCTL 0x10 /* Tx_fifo Write Control Register*/
  149. #define I2S_SASR0 0x0C /* Serial Audio I2S and FIFO Status Register */
  150. #define I2S_SAIMR 0x14 /* Serial Audio Interrupt Mask Register*/
  151. #define I2S_SAICR 0x18 /* Serial Audio Interrupt Clear Register */
  152. #define I2S_SADR 0x80 /* Serial Audio Data Register (TX and RX FIFO Access Register)*/
  153. //#ifdef TDM_MUL_MODE_VER
  154. //#define SACR0_SAMERATE_ENB (1 << 27)
  155. //#else
  156. //#define SACR0_SAMERATE_ENB (1 << 29)
  157. //#endif
  158. #define SACR0_SAMERATE_ENB (1 << 27)
  159. #define SACR0_SYNCINV_ADC (1 << 28) /* invert sync_adc */
  160. #define SACR0_RFIFIFIRSTBIT (1 << 26) /* rx fifo first bit */
  161. #define SACR0_TFIFOFIRSTBIT (1 << 25) /* Tx fifo first bit */
  162. #define SACR0_CHANLOCK (1 << 24) /* Channel lock(left first or right first) */
  163. #define SACR0_SCBIT (1 << 23) /* */
  164. #define SACR0_32BIT_MODE (1 << 22) /* I2S Bit Select(16/32 bits) */
  165. #define SACR0_SYNCINV (1 << 21) /* SYNC Clock Invert */
  166. #define SACR0_RFTH_MASK (0x1F << 16)
  167. #define SACR0_RFTH(x) ((x) << 16) /* Rx FIFO Interrupt or DMA Trigger Threshold */
  168. #define SACR0_TFTH_MASK (0X1F << 8)
  169. #define SACR0_TFTH(x) ((x) << 8) /* Tx FIFO Interrupt or DMA Trigger Threshold */
  170. #define SACR0_RDMAEN (1 << 6) /* RX DMA Enable */
  171. #define SACR0_ENLBF (1 << 5) /* Enable Loopback */
  172. #define SACR0_RST (1 << 4) /* FIFO, i2s Register Reset */
  173. #define SACR0_TDMAEN (1 << 3) /* TX DMA Enable */
  174. #define SACR0_BCKD (1 << 2) /* Bit Clock Direction */
  175. #define SACR0_SYNCD (1 << 1) /* Word Select(sync) Clock Direction */
  176. #define SACR0_ENB (1 << 0) /* Enable I2S Link */
  177. #define SACR1_TDM_MODE (1 << 5)
  178. #define SACR1_TDMENB (1 << 4)
  179. #define SACR1_DRPL_DAT (1 << 3)
  180. #define SACR1_DREC_DAT (1 << 2)
  181. #define SACR1_DRPL (1 << 1) /* Disable Replaying Function */
  182. #define SACR1_DREC (1 << 0) /* Disable Recording Function */
  183. #define SAICR_ROR (1 << 6) /* Clear Rx FIFO Overrun Interrupt */
  184. #define SAICR_TUR (1 << 5) /* Clear Tx FIFO Underrun Interrupt */
  185. #define SAICR_RFS (1 << 4) /* Clear Rx FIFO Service Interrupt */
  186. #define SAICR_TFS (1 << 3) /* Clear Tx FIFO Service Interrupt */
  187. #define SAIMR_ROR (1 << 6) /* Enable Rx FIFO Overrun Condition Interrupt */
  188. #define SAIMR_TUR (1 << 5) /* Enable Tx FIFO Underrun Condition Interrupt */
  189. #define SAIMR_RFS (1 << 4) /* Enable Rx FIFO Service Interrupt */
  190. #define SAIMR_TFS (1 << 3) /* Enable Tx FIFO Service Interrupt */
  191. #define rSYS_PER_CLK_EN1 0x64
  192. #define rSYS_BUS_CLK_EN1 0x5c
  193. #define rSYS_PER_CLK_CFG1 0x4c
  194. #define rSYS_I2S0_ADC_NCO_CFG 0x80
  195. #define rSYS_I2S0_NCO_CFG 0x7C
  196. #define rSYS_I2S1_ADC_NCO_CFG 0x88
  197. #define rSYS_I2S1_NCO_CFG 0x84
  198. #define rSYS_I2S2_ADC_NCO_CFG 0x90
  199. #define rSYS_I2S2_NCO_CFG 0x8C
  200. #define CODEC_REG_RESET 0x0 /*Power control*/
  201. #define CODEC_REG_CLK_EXT_SELECT 0x1 /*Overall power-down signal*/
  202. #define CODEC_REG_I2S1_CONFIG_0 0x3 /*Digital audio interface 1 control signals definition*/
  203. #define CODEC_REG_I2S1_CONFIG_1 0x4 /**/
  204. #define CODEC_REG_I2S1_CONFIG_2 0x5 /**/
  205. #define CODEC_REG_I2S1_CONFIG_3 0x6 /**/
  206. #define CODEC_REG_I2S1_CONFIG_4 0x7 /**/
  207. #define CODEC_REG_BP_PWR 0x13 /*Bypass power up sequence selection*/
  208. #define CODEC_REG_POWER_DOWN_0 0x15 /*Overall power-down signal*/
  209. #define CODEC_REG_POWER_DOWN_1 0x16 /**/
  210. #define CODEC_REG_POWER_DOWN_3 0x18 /**/
  211. #define CODEC_REG_POWER_DOWN_4 0x19 /**/
  212. #define CODEC_REG_POPFREE_0 0xA2 /*ramp up timeand Ramp configuration*/
  213. #define CODEC_REG_REFGEN_0 0xDC /*REFGEN test mode*/
  214. #define CODEC_REG_TEST_1 0xF3 /*ADC sigma-delta dither modulator:*/
  215. #define CODEC_REG_RESERVED_3 0xFB /*Pure analog test mode*/
  216. //2byte-data
  217. #define CODEC_REG_RECVOL 0x24
  218. #define CODEC_REG_PGA1VOL 0x26 /**/
  219. #define CODEC_REG_LMVOL 0x34 /**/
  220. #define CODEC_REG_HS1VOL 0x38 /**/
  221. #define CODEC_REG_PGA1SEL 0x47 /**/
  222. #define CODEC_REG_LDR1SEL 0x59
  223. #define CODEC_REG_LDR2SEL 0x5D
  224. #define CODEC_REG_RECPBVOL 0x80
  225. #define CODEC_REG_RECI2S1VOL 0x82
  226. #define CODEC_REG_I2S1PBVOL 0x88
  227. #define CODEC_REG_I2S1I2S1VOL 0x8A
  228. #define CODEC_REG_ADC_DAC_RESET 0x00
  229. #define CODEC_REG_POWER_DOWN 0x15
  230. #define CODEC_REG_LINE_MUTE 0x21
  231. #define CODEC_REG_CAPTURE_MUTE 0x1D
  232. #define CODEC_REG_PLAYBACK_MUTE 0x1F
  233. #define CODEC_REG_DAC_SOFT_MUTE (1 << 0)
  234. #define CODEC_REG_DAC_SOFT_UNMUTE (0 << 0)
  235. #define CODEC_REG_DAC_RESET_CTRL (1 << 0)
  236. #define CODEC_REG_ADC_RESET_CTRL (1 << 1)
  237. #define CODEC_REG_I2S1_MODE_SEL (1 << 3)
  238. /* ¾²Òô¿ØÖÆÎ» */
  239. #define MUTE_BIT_LEFT (1 << 0)
  240. #define MUTE_BIT_RIGHT (1 << 1)
  241. /************************************/
  242. #endif