tlv320aic3x.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /*
  2. * ALSA SoC TLV320AIC3X codec driver
  3. *
  4. * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
  5. * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #ifndef _AIC3X_H
  12. #define _AIC3X_H
  13. /* AIC3X register space */
  14. #define AIC3X_CACHEREGNUM 110
  15. /* Page select register */
  16. #define AIC3X_PAGE_SELECT 0
  17. /* Software reset register */
  18. #define AIC3X_RESET 1
  19. /* Codec Sample rate select register */
  20. #define AIC3X_SAMPLE_RATE_SEL_REG 2
  21. /* PLL progrramming register A */
  22. #define AIC3X_PLL_PROGA_REG 3
  23. /* PLL progrramming register B */
  24. #define AIC3X_PLL_PROGB_REG 4
  25. /* PLL progrramming register C */
  26. #define AIC3X_PLL_PROGC_REG 5
  27. /* PLL progrramming register D */
  28. #define AIC3X_PLL_PROGD_REG 6
  29. /* Codec datapath setup register */
  30. #define AIC3X_CODEC_DATAPATH_REG 7
  31. /* Audio serial data interface control register A */
  32. #define AIC3X_ASD_INTF_CTRLA 8
  33. /* Audio serial data interface control register B */
  34. #define AIC3X_ASD_INTF_CTRLB 9
  35. /* Audio serial data interface control register C */
  36. #define AIC3X_ASD_INTF_CTRLC 10
  37. /* Audio overflow status and PLL R value programming register */
  38. #define AIC3X_OVRF_STATUS_AND_PLLR_REG 11
  39. /* Audio codec digital filter control register */
  40. #define AIC3X_CODEC_DFILT_CTRL 12
  41. /* Headset/button press detection register */
  42. #define AIC3X_HEADSET_DETECT_CTRL_A 13
  43. #define AIC3X_HEADSET_DETECT_CTRL_B 14
  44. /* ADC PGA Gain control registers */
  45. #define LADC_VOL 15
  46. #define RADC_VOL 16
  47. /* MIC3 control registers */
  48. #define MIC3LR_2_LADC_CTRL 17
  49. #define MIC3LR_2_RADC_CTRL 18
  50. /* Line1 Input control registers */
  51. #define LINE1L_2_LADC_CTRL 19
  52. #define LINE1R_2_LADC_CTRL 21
  53. #define LINE1R_2_RADC_CTRL 22
  54. #define LINE1L_2_RADC_CTRL 24
  55. /* Line2 Input control registers */
  56. #define LINE2L_2_LADC_CTRL 20
  57. #define LINE2R_2_RADC_CTRL 23
  58. /* MICBIAS Control Register */
  59. #define MICBIAS_CTRL 25
  60. /* AGC Control Registers A, B, C */
  61. #define LAGC_CTRL_A 26
  62. #define LAGC_CTRL_B 27
  63. #define LAGC_CTRL_C 28
  64. #define RAGC_CTRL_A 29
  65. #define RAGC_CTRL_B 30
  66. #define RAGC_CTRL_C 31
  67. /* DAC Power and Left High Power Output control registers */
  68. #define DAC_PWR 37
  69. #define HPLCOM_CFG 37
  70. /* Right High Power Output control registers */
  71. #define HPRCOM_CFG 38
  72. /* High Power Output Stage Control Register */
  73. #define HPOUT_SC 40
  74. /* DAC Output Switching control registers */
  75. #define DAC_LINE_MUX 41
  76. /* High Power Output Driver Pop Reduction registers */
  77. #define HPOUT_POP_REDUCTION 42
  78. /* DAC Digital control registers */
  79. #define LDAC_VOL 43
  80. #define RDAC_VOL 44
  81. /* Left High Power Output control registers */
  82. #define LINE2L_2_HPLOUT_VOL 45
  83. #define PGAL_2_HPLOUT_VOL 46
  84. #define DACL1_2_HPLOUT_VOL 47
  85. #define LINE2R_2_HPLOUT_VOL 48
  86. #define PGAR_2_HPLOUT_VOL 49
  87. #define DACR1_2_HPLOUT_VOL 50
  88. #define HPLOUT_CTRL 51
  89. /* Left High Power COM control registers */
  90. #define LINE2L_2_HPLCOM_VOL 52
  91. #define PGAL_2_HPLCOM_VOL 53
  92. #define DACL1_2_HPLCOM_VOL 54
  93. #define LINE2R_2_HPLCOM_VOL 55
  94. #define PGAR_2_HPLCOM_VOL 56
  95. #define DACR1_2_HPLCOM_VOL 57
  96. #define HPLCOM_CTRL 58
  97. /* Right High Power Output control registers */
  98. #define LINE2L_2_HPROUT_VOL 59
  99. #define PGAL_2_HPROUT_VOL 60
  100. #define DACL1_2_HPROUT_VOL 61
  101. #define LINE2R_2_HPROUT_VOL 62
  102. #define PGAR_2_HPROUT_VOL 63
  103. #define DACR1_2_HPROUT_VOL 64
  104. #define HPROUT_CTRL 65
  105. /* Right High Power COM control registers */
  106. #define LINE2L_2_HPRCOM_VOL 66
  107. #define PGAL_2_HPRCOM_VOL 67
  108. #define DACL1_2_HPRCOM_VOL 68
  109. #define LINE2R_2_HPRCOM_VOL 69
  110. #define PGAR_2_HPRCOM_VOL 70
  111. #define DACR1_2_HPRCOM_VOL 71
  112. #define HPRCOM_CTRL 72
  113. /* Mono Line Output Plus/Minus control registers */
  114. #define LINE2L_2_MONOLOPM_VOL 73
  115. #define PGAL_2_MONOLOPM_VOL 74
  116. #define DACL1_2_MONOLOPM_VOL 75
  117. #define LINE2R_2_MONOLOPM_VOL 76
  118. #define PGAR_2_MONOLOPM_VOL 77
  119. #define DACR1_2_MONOLOPM_VOL 78
  120. #define MONOLOPM_CTRL 79
  121. /* Class-D speaker driver on tlv320aic3007 */
  122. #define CLASSD_CTRL 73
  123. /* Left Line Output Plus/Minus control registers */
  124. #define LINE2L_2_LLOPM_VOL 80
  125. #define PGAL_2_LLOPM_VOL 81
  126. #define DACL1_2_LLOPM_VOL 82
  127. #define LINE2R_2_LLOPM_VOL 83
  128. #define PGAR_2_LLOPM_VOL 84
  129. #define DACR1_2_LLOPM_VOL 85
  130. #define LLOPM_CTRL 86
  131. /* Right Line Output Plus/Minus control registers */
  132. #define LINE2L_2_RLOPM_VOL 87
  133. #define PGAL_2_RLOPM_VOL 88
  134. #define DACL1_2_RLOPM_VOL 89
  135. #define LINE2R_2_RLOPM_VOL 90
  136. #define PGAR_2_RLOPM_VOL 91
  137. #define DACR1_2_RLOPM_VOL 92
  138. #define RLOPM_CTRL 93
  139. /* GPIO/IRQ registers */
  140. #define AIC3X_STICKY_IRQ_FLAGS_REG 96
  141. #define AIC3X_RT_IRQ_FLAGS_REG 97
  142. #define AIC3X_GPIO1_REG 98
  143. #define AIC3X_GPIO2_REG 99
  144. #define AIC3X_GPIOA_REG 100
  145. #define AIC3X_GPIOB_REG 101
  146. /* Clock generation control register */
  147. #define AIC3X_CLKGEN_CTRL_REG 102
  148. /* New AGC registers */
  149. #define LAGCN_ATTACK 103
  150. #define LAGCN_DECAY 104
  151. #define RAGCN_ATTACK 105
  152. #define RAGCN_DECAY 106
  153. /* New Programmable ADC Digital Path and I2C Bus Condition Register */
  154. #define NEW_ADC_DIGITALPATH 107
  155. /* Passive Analog Signal Bypass Selection During Powerdown Register */
  156. #define PASSIVE_BYPASS 108
  157. /* DAC Quiescent Current Adjustment Register */
  158. #define DAC_ICC_ADJ 109
  159. /* Page select register bits */
  160. #define PAGE0_SELECT 0
  161. #define PAGE1_SELECT 1
  162. /* Audio serial data interface control register A bits */
  163. #define BIT_CLK_MASTER 0x80
  164. #define WORD_CLK_MASTER 0x40
  165. #define DOUT_TRISTATE 0x20
  166. /* Codec Datapath setup register 7 */
  167. #define FSREF_44100 (1 << 7)
  168. #define FSREF_48000 (0 << 7)
  169. #define DUAL_RATE_MODE ((1 << 5) | (1 << 6))
  170. #define LDAC2LCH (0x1 << 3)
  171. #define RDAC2RCH (0x1 << 1)
  172. #define LDAC2RCH (0x2 << 3)
  173. #define RDAC2LCH (0x2 << 1)
  174. #define LDAC2MONOMIX (0x3 << 3)
  175. #define RDAC2MONOMIX (0x3 << 1)
  176. /* PLL registers bitfields */
  177. #define PLLP_SHIFT 0
  178. #define PLLP_MASK 7
  179. #define PLLQ_SHIFT 3
  180. #define PLLR_SHIFT 0
  181. #define PLLJ_SHIFT 2
  182. #define PLLD_MSB_SHIFT 0
  183. #define PLLD_LSB_SHIFT 2
  184. /* Clock generation register bits */
  185. #define CODEC_CLKIN_PLLDIV 0
  186. #define CODEC_CLKIN_CLKDIV 1
  187. #define PLL_CLKIN_SHIFT 4
  188. #define MCLK_SOURCE 0x0
  189. #define PLL_CLKDIV_SHIFT 0
  190. #define PLLCLK_IN_MASK 0x30
  191. #define PLLCLK_IN_SHIFT 4
  192. #define CLKDIV_IN_MASK 0xc0
  193. #define CLKDIV_IN_SHIFT 6
  194. /* clock in source */
  195. #define CLKIN_MCLK 0
  196. #define CLKIN_GPIO2 1
  197. #define CLKIN_BCLK 2
  198. /* Software reset register bits */
  199. #define SOFT_RESET 0x80
  200. /* PLL progrramming register A bits */
  201. #define PLL_ENABLE 0x80
  202. /* Route bits */
  203. #define ROUTE_ON 0x80
  204. /* Mute bits */
  205. #define UNMUTE 0x08
  206. #define MUTE_ON 0x80
  207. /* Power bits */
  208. #define LADC_PWR_ON 0x04
  209. #define RADC_PWR_ON 0x04
  210. #define LDAC_PWR_ON 0x80
  211. #define RDAC_PWR_ON 0x40
  212. #define HPLOUT_PWR_ON 0x01
  213. #define HPROUT_PWR_ON 0x01
  214. #define HPLCOM_PWR_ON 0x01
  215. #define HPRCOM_PWR_ON 0x01
  216. #define MONOLOPM_PWR_ON 0x01
  217. #define LLOPM_PWR_ON 0x01
  218. #define RLOPM_PWR_ON 0x01
  219. #define INVERT_VOL(val) (0x7f - val)
  220. /* Default output volume (inverted) */
  221. #define DEFAULT_VOL INVERT_VOL(0x50)
  222. /* Default input volume */
  223. #define DEFAULT_GAIN 0x20
  224. /* MICBIAS Control Register */
  225. #define MICBIAS_LEVEL_SHIFT (6)
  226. #define MICBIAS_LEVEL_MASK (3 << 6)
  227. /* headset detection / button API */
  228. /* The AIC3x supports detection of stereo headsets (GND + left + right signal)
  229. * and cellular headsets (GND + speaker output + microphone input).
  230. * It is recommended to enable MIC bias for this function to work properly.
  231. * For more information, please refer to the datasheet. */
  232. enum {
  233. AIC3X_HEADSET_DETECT_OFF = 0,
  234. AIC3X_HEADSET_DETECT_STEREO = 1,
  235. AIC3X_HEADSET_DETECT_CELLULAR = 2,
  236. AIC3X_HEADSET_DETECT_BOTH = 3
  237. };
  238. enum {
  239. AIC3X_HEADSET_DEBOUNCE_16MS = 0,
  240. AIC3X_HEADSET_DEBOUNCE_32MS = 1,
  241. AIC3X_HEADSET_DEBOUNCE_64MS = 2,
  242. AIC3X_HEADSET_DEBOUNCE_128MS = 3,
  243. AIC3X_HEADSET_DEBOUNCE_256MS = 4,
  244. AIC3X_HEADSET_DEBOUNCE_512MS = 5
  245. };
  246. enum {
  247. AIC3X_BUTTON_DEBOUNCE_0MS = 0,
  248. AIC3X_BUTTON_DEBOUNCE_8MS = 1,
  249. AIC3X_BUTTON_DEBOUNCE_16MS = 2,
  250. AIC3X_BUTTON_DEBOUNCE_32MS = 3
  251. };
  252. #define AIC3X_HEADSET_DETECT_ENABLED 0x80
  253. #define AIC3X_HEADSET_DETECT_SHIFT 5
  254. #define AIC3X_HEADSET_DETECT_MASK 3
  255. #define AIC3X_HEADSET_DEBOUNCE_SHIFT 2
  256. #define AIC3X_HEADSET_DEBOUNCE_MASK 7
  257. #define AIC3X_BUTTON_DEBOUNCE_SHIFT 0
  258. #define AIC3X_BUTTON_DEBOUNCE_MASK 3
  259. #endif /* _AIC3X_H */