tlv320aic31xx.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /*
  2. * ALSA SoC TLV320AIC31XX codec driver
  3. *
  4. * Copyright (C) 2013 Texas Instruments, Inc.
  5. *
  6. * This package is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  11. * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  12. * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  13. *
  14. */
  15. #ifndef _TLV320AIC31XX_H
  16. #define _TLV320AIC31XX_H
  17. #define AIC31XX_RATES SNDRV_PCM_RATE_8000_192000
  18. #define AIC31XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \
  19. | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE \
  20. | SNDRV_PCM_FMTBIT_S32_LE)
  21. #define AIC31XX_STEREO_CLASS_D_BIT 0x1
  22. #define AIC31XX_MINIDSP_BIT 0x2
  23. #define DAC31XX_BIT 0x4
  24. enum aic31xx_type {
  25. AIC3100 = 0,
  26. AIC3110 = AIC31XX_STEREO_CLASS_D_BIT,
  27. AIC3120 = AIC31XX_MINIDSP_BIT,
  28. AIC3111 = (AIC31XX_STEREO_CLASS_D_BIT | AIC31XX_MINIDSP_BIT),
  29. DAC3100 = DAC31XX_BIT,
  30. };
  31. struct aic31xx_pdata {
  32. enum aic31xx_type codec_type;
  33. unsigned int gpio_reset;
  34. int micbias_vg;
  35. };
  36. #define AIC31XX_REG(page, reg) ((page * 128) + reg)
  37. /* Page Control Register */
  38. #define AIC31XX_PAGECTL AIC31XX_REG(0, 0)
  39. /* Page 0 Registers */
  40. /* Software reset register */
  41. #define AIC31XX_RESET AIC31XX_REG(0, 1)
  42. /* OT FLAG register */
  43. #define AIC31XX_OT_FLAG AIC31XX_REG(0, 3)
  44. /* Clock clock Gen muxing, Multiplexers*/
  45. #define AIC31XX_CLKMUX AIC31XX_REG(0, 4)
  46. /* PLL P and R-VAL register */
  47. #define AIC31XX_PLLPR AIC31XX_REG(0, 5)
  48. /* PLL J-VAL register */
  49. #define AIC31XX_PLLJ AIC31XX_REG(0, 6)
  50. /* PLL D-VAL MSB register */
  51. #define AIC31XX_PLLDMSB AIC31XX_REG(0, 7)
  52. /* PLL D-VAL LSB register */
  53. #define AIC31XX_PLLDLSB AIC31XX_REG(0, 8)
  54. /* DAC NDAC_VAL register*/
  55. #define AIC31XX_NDAC AIC31XX_REG(0, 11)
  56. /* DAC MDAC_VAL register */
  57. #define AIC31XX_MDAC AIC31XX_REG(0, 12)
  58. /* DAC OSR setting register 1, MSB value */
  59. #define AIC31XX_DOSRMSB AIC31XX_REG(0, 13)
  60. /* DAC OSR setting register 2, LSB value */
  61. #define AIC31XX_DOSRLSB AIC31XX_REG(0, 14)
  62. #define AIC31XX_MINI_DSP_INPOL AIC31XX_REG(0, 16)
  63. /* Clock setting register 8, PLL */
  64. #define AIC31XX_NADC AIC31XX_REG(0, 18)
  65. /* Clock setting register 9, PLL */
  66. #define AIC31XX_MADC AIC31XX_REG(0, 19)
  67. /* ADC Oversampling (AOSR) Register */
  68. #define AIC31XX_AOSR AIC31XX_REG(0, 20)
  69. /* Clock setting register 9, Multiplexers */
  70. #define AIC31XX_CLKOUTMUX AIC31XX_REG(0, 25)
  71. /* Clock setting register 10, CLOCKOUT M divider value */
  72. #define AIC31XX_CLKOUTMVAL AIC31XX_REG(0, 26)
  73. /* Audio Interface Setting Register 1 */
  74. #define AIC31XX_IFACE1 AIC31XX_REG(0, 27)
  75. /* Audio Data Slot Offset Programming */
  76. #define AIC31XX_DATA_OFFSET AIC31XX_REG(0, 28)
  77. /* Audio Interface Setting Register 2 */
  78. #define AIC31XX_IFACE2 AIC31XX_REG(0, 29)
  79. /* Clock setting register 11, BCLK N Divider */
  80. #define AIC31XX_BCLKN AIC31XX_REG(0, 30)
  81. /* Audio Interface Setting Register 3, Secondary Audio Interface */
  82. #define AIC31XX_IFACESEC1 AIC31XX_REG(0, 31)
  83. /* Audio Interface Setting Register 4 */
  84. #define AIC31XX_IFACESEC2 AIC31XX_REG(0, 32)
  85. /* Audio Interface Setting Register 5 */
  86. #define AIC31XX_IFACESEC3 AIC31XX_REG(0, 33)
  87. /* I2C Bus Condition */
  88. #define AIC31XX_I2C AIC31XX_REG(0, 34)
  89. /* ADC FLAG */
  90. #define AIC31XX_ADCFLAG AIC31XX_REG(0, 36)
  91. /* DAC Flag Registers */
  92. #define AIC31XX_DACFLAG1 AIC31XX_REG(0, 37)
  93. #define AIC31XX_DACFLAG2 AIC31XX_REG(0, 38)
  94. /* Sticky Interrupt flag (overflow) */
  95. #define AIC31XX_OFFLAG AIC31XX_REG(0, 39)
  96. /* Sticy DAC Interrupt flags */
  97. #define AIC31XX_INTRDACFLAG AIC31XX_REG(0, 44)
  98. /* Sticy ADC Interrupt flags */
  99. #define AIC31XX_INTRADCFLAG AIC31XX_REG(0, 45)
  100. /* DAC Interrupt flags 2 */
  101. #define AIC31XX_INTRDACFLAG2 AIC31XX_REG(0, 46)
  102. /* ADC Interrupt flags 2 */
  103. #define AIC31XX_INTRADCFLAG2 AIC31XX_REG(0, 47)
  104. /* INT1 interrupt control */
  105. #define AIC31XX_INT1CTRL AIC31XX_REG(0, 48)
  106. /* INT2 interrupt control */
  107. #define AIC31XX_INT2CTRL AIC31XX_REG(0, 49)
  108. /* GPIO1 control */
  109. #define AIC31XX_GPIO1 AIC31XX_REG(0, 51)
  110. #define AIC31XX_DACPRB AIC31XX_REG(0, 60)
  111. /* ADC Instruction Set Register */
  112. #define AIC31XX_ADCPRB AIC31XX_REG(0, 61)
  113. /* DAC channel setup register */
  114. #define AIC31XX_DACSETUP AIC31XX_REG(0, 63)
  115. /* DAC Mute and volume control register */
  116. #define AIC31XX_DACMUTE AIC31XX_REG(0, 64)
  117. /* Left DAC channel digital volume control */
  118. #define AIC31XX_LDACVOL AIC31XX_REG(0, 65)
  119. /* Right DAC channel digital volume control */
  120. #define AIC31XX_RDACVOL AIC31XX_REG(0, 66)
  121. /* Headset detection */
  122. #define AIC31XX_HSDETECT AIC31XX_REG(0, 67)
  123. /* ADC Digital Mic */
  124. #define AIC31XX_ADCSETUP AIC31XX_REG(0, 81)
  125. /* ADC Digital Volume Control Fine Adjust */
  126. #define AIC31XX_ADCFGA AIC31XX_REG(0, 82)
  127. /* ADC Digital Volume Control Coarse Adjust */
  128. #define AIC31XX_ADCVOL AIC31XX_REG(0, 83)
  129. /* Page 1 Registers */
  130. /* Headphone drivers */
  131. #define AIC31XX_HPDRIVER AIC31XX_REG(1, 31)
  132. /* Class-D Speakear Amplifier */
  133. #define AIC31XX_SPKAMP AIC31XX_REG(1, 32)
  134. /* HP Output Drivers POP Removal Settings */
  135. #define AIC31XX_HPPOP AIC31XX_REG(1, 33)
  136. /* Output Driver PGA Ramp-Down Period Control */
  137. #define AIC31XX_SPPGARAMP AIC31XX_REG(1, 34)
  138. /* DAC_L and DAC_R Output Mixer Routing */
  139. #define AIC31XX_DACMIXERROUTE AIC31XX_REG(1, 35)
  140. /* Left Analog Vol to HPL */
  141. #define AIC31XX_LANALOGHPL AIC31XX_REG(1, 36)
  142. /* Right Analog Vol to HPR */
  143. #define AIC31XX_RANALOGHPR AIC31XX_REG(1, 37)
  144. /* Left Analog Vol to SPL */
  145. #define AIC31XX_LANALOGSPL AIC31XX_REG(1, 38)
  146. /* Right Analog Vol to SPR */
  147. #define AIC31XX_RANALOGSPR AIC31XX_REG(1, 39)
  148. /* HPL Driver */
  149. #define AIC31XX_HPLGAIN AIC31XX_REG(1, 40)
  150. /* HPR Driver */
  151. #define AIC31XX_HPRGAIN AIC31XX_REG(1, 41)
  152. /* SPL Driver */
  153. #define AIC31XX_SPLGAIN AIC31XX_REG(1, 42)
  154. /* SPR Driver */
  155. #define AIC31XX_SPRGAIN AIC31XX_REG(1, 43)
  156. /* HP Driver Control */
  157. #define AIC31XX_HPCONTROL AIC31XX_REG(1, 44)
  158. /* MIC Bias Control */
  159. #define AIC31XX_MICBIAS AIC31XX_REG(1, 46)
  160. /* MIC PGA*/
  161. #define AIC31XX_MICPGA AIC31XX_REG(1, 47)
  162. /* Delta-Sigma Mono ADC Channel Fine-Gain Input Selection for P-Terminal */
  163. #define AIC31XX_MICPGAPI AIC31XX_REG(1, 48)
  164. /* ADC Input Selection for M-Terminal */
  165. #define AIC31XX_MICPGAMI AIC31XX_REG(1, 49)
  166. /* Input CM Settings */
  167. #define AIC31XX_MICPGACM AIC31XX_REG(1, 50)
  168. /* Bits, masks and shifts */
  169. /* AIC31XX_CLKMUX */
  170. #define AIC31XX_PLL_CLKIN_MASK 0x0c
  171. #define AIC31XX_PLL_CLKIN_SHIFT 2
  172. #define AIC31XX_PLL_CLKIN_MCLK 0
  173. #define AIC31XX_CODEC_CLKIN_MASK 0x03
  174. #define AIC31XX_CODEC_CLKIN_SHIFT 0
  175. #define AIC31XX_CODEC_CLKIN_PLL 3
  176. #define AIC31XX_CODEC_CLKIN_BCLK 1
  177. /* AIC31XX_PLLPR, AIC31XX_NDAC, AIC31XX_MDAC, AIC31XX_NADC, AIC31XX_MADC,
  178. AIC31XX_BCLKN */
  179. #define AIC31XX_PLL_MASK 0x7f
  180. #define AIC31XX_PM_MASK 0x80
  181. /* AIC31XX_IFACE1 */
  182. #define AIC31XX_WORD_LEN_16BITS 0x00
  183. #define AIC31XX_WORD_LEN_20BITS 0x01
  184. #define AIC31XX_WORD_LEN_24BITS 0x02
  185. #define AIC31XX_WORD_LEN_32BITS 0x03
  186. #define AIC31XX_IFACE1_DATALEN_MASK 0x30
  187. #define AIC31XX_IFACE1_DATALEN_SHIFT (4)
  188. #define AIC31XX_IFACE1_DATATYPE_MASK 0xC0
  189. #define AIC31XX_IFACE1_DATATYPE_SHIFT (6)
  190. #define AIC31XX_I2S_MODE 0x00
  191. #define AIC31XX_DSP_MODE 0x01
  192. #define AIC31XX_RIGHT_JUSTIFIED_MODE 0x02
  193. #define AIC31XX_LEFT_JUSTIFIED_MODE 0x03
  194. #define AIC31XX_IFACE1_MASTER_MASK 0x0C
  195. #define AIC31XX_BCLK_MASTER 0x08
  196. #define AIC31XX_WCLK_MASTER 0x04
  197. /* AIC31XX_DATA_OFFSET */
  198. #define AIC31XX_DATA_OFFSET_MASK 0xFF
  199. /* AIC31XX_IFACE2 */
  200. #define AIC31XX_BCLKINV_MASK 0x08
  201. #define AIC31XX_BDIVCLK_MASK 0x03
  202. #define AIC31XX_DAC2BCLK 0x00
  203. #define AIC31XX_DACMOD2BCLK 0x01
  204. #define AIC31XX_ADC2BCLK 0x02
  205. #define AIC31XX_ADCMOD2BCLK 0x03
  206. /* AIC31XX_ADCFLAG */
  207. #define AIC31XX_ADCPWRSTATUS_MASK 0x40
  208. /* AIC31XX_DACFLAG1 */
  209. #define AIC31XX_LDACPWRSTATUS_MASK 0x80
  210. #define AIC31XX_RDACPWRSTATUS_MASK 0x08
  211. #define AIC31XX_HPLDRVPWRSTATUS_MASK 0x20
  212. #define AIC31XX_HPRDRVPWRSTATUS_MASK 0x02
  213. #define AIC31XX_SPLDRVPWRSTATUS_MASK 0x10
  214. #define AIC31XX_SPRDRVPWRSTATUS_MASK 0x01
  215. /* AIC31XX_INTRDACFLAG */
  216. #define AIC31XX_HPSCDETECT_MASK 0x80
  217. #define AIC31XX_BUTTONPRESS_MASK 0x20
  218. #define AIC31XX_HSPLUG_MASK 0x10
  219. #define AIC31XX_LDRCTHRES_MASK 0x08
  220. #define AIC31XX_RDRCTHRES_MASK 0x04
  221. #define AIC31XX_DACSINT_MASK 0x02
  222. #define AIC31XX_DACAINT_MASK 0x01
  223. /* AIC31XX_INT1CTRL */
  224. #define AIC31XX_HSPLUGDET_MASK 0x80
  225. #define AIC31XX_BUTTONPRESSDET_MASK 0x40
  226. #define AIC31XX_DRCTHRES_MASK 0x20
  227. #define AIC31XX_AGCNOISE_MASK 0x10
  228. #define AIC31XX_OC_MASK 0x08
  229. #define AIC31XX_ENGINE_MASK 0x04
  230. /* AIC31XX_DACSETUP */
  231. #define AIC31XX_SOFTSTEP_MASK 0x03
  232. /* AIC31XX_DACMUTE */
  233. #define AIC31XX_DACMUTE_MASK 0x0C
  234. /* AIC31XX_MICBIAS */
  235. #define AIC31XX_MICBIAS_MASK 0x03
  236. #define AIC31XX_MICBIAS_SHIFT 0
  237. #endif /* _TLV320AIC31XX_H */