tlv320aic3x.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 103
  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. /* DAC Output Switching control registers */
  73. #define DAC_LINE_MUX 41
  74. /* High Power Output Driver Pop Reduction registers */
  75. #define HPOUT_POP_REDUCTION 42
  76. /* DAC Digital control registers */
  77. #define LDAC_VOL 43
  78. #define RDAC_VOL 44
  79. /* Left High Power Output control registers */
  80. #define LINE2L_2_HPLOUT_VOL 45
  81. #define PGAL_2_HPLOUT_VOL 46
  82. #define DACL1_2_HPLOUT_VOL 47
  83. #define LINE2R_2_HPLOUT_VOL 48
  84. #define PGAR_2_HPLOUT_VOL 49
  85. #define DACR1_2_HPLOUT_VOL 50
  86. #define HPLOUT_CTRL 51
  87. /* Left High Power COM control registers */
  88. #define LINE2L_2_HPLCOM_VOL 52
  89. #define PGAL_2_HPLCOM_VOL 53
  90. #define DACL1_2_HPLCOM_VOL 54
  91. #define LINE2R_2_HPLCOM_VOL 55
  92. #define PGAR_2_HPLCOM_VOL 56
  93. #define DACR1_2_HPLCOM_VOL 57
  94. #define HPLCOM_CTRL 58
  95. /* Right High Power Output control registers */
  96. #define LINE2L_2_HPROUT_VOL 59
  97. #define PGAL_2_HPROUT_VOL 60
  98. #define DACL1_2_HPROUT_VOL 61
  99. #define LINE2R_2_HPROUT_VOL 62
  100. #define PGAR_2_HPROUT_VOL 63
  101. #define DACR1_2_HPROUT_VOL 64
  102. #define HPROUT_CTRL 65
  103. /* Right High Power COM control registers */
  104. #define LINE2L_2_HPRCOM_VOL 66
  105. #define PGAL_2_HPRCOM_VOL 67
  106. #define DACL1_2_HPRCOM_VOL 68
  107. #define LINE2R_2_HPRCOM_VOL 69
  108. #define PGAR_2_HPRCOM_VOL 70
  109. #define DACR1_2_HPRCOM_VOL 71
  110. #define HPRCOM_CTRL 72
  111. /* Mono Line Output Plus/Minus control registers */
  112. #define LINE2L_2_MONOLOPM_VOL 73
  113. #define PGAL_2_MONOLOPM_VOL 74
  114. #define DACL1_2_MONOLOPM_VOL 75
  115. #define LINE2R_2_MONOLOPM_VOL 76
  116. #define PGAR_2_MONOLOPM_VOL 77
  117. #define DACR1_2_MONOLOPM_VOL 78
  118. #define MONOLOPM_CTRL 79
  119. /* Class-D speaker driver on tlv320aic3007 */
  120. #define CLASSD_CTRL 73
  121. /* Left Line Output Plus/Minus control registers */
  122. #define LINE2L_2_LLOPM_VOL 80
  123. #define PGAL_2_LLOPM_VOL 81
  124. #define DACL1_2_LLOPM_VOL 82
  125. #define LINE2R_2_LLOPM_VOL 83
  126. #define PGAR_2_LLOPM_VOL 84
  127. #define DACR1_2_LLOPM_VOL 85
  128. #define LLOPM_CTRL 86
  129. /* Right Line Output Plus/Minus control registers */
  130. #define LINE2L_2_RLOPM_VOL 87
  131. #define PGAL_2_RLOPM_VOL 88
  132. #define DACL1_2_RLOPM_VOL 89
  133. #define LINE2R_2_RLOPM_VOL 90
  134. #define PGAR_2_RLOPM_VOL 91
  135. #define DACR1_2_RLOPM_VOL 92
  136. #define RLOPM_CTRL 93
  137. /* GPIO/IRQ registers */
  138. #define AIC3X_STICKY_IRQ_FLAGS_REG 96
  139. #define AIC3X_RT_IRQ_FLAGS_REG 97
  140. #define AIC3X_GPIO1_REG 98
  141. #define AIC3X_GPIO2_REG 99
  142. #define AIC3X_GPIOA_REG 100
  143. #define AIC3X_GPIOB_REG 101
  144. /* Clock generation control register */
  145. #define AIC3X_CLKGEN_CTRL_REG 102
  146. /* Page select register bits */
  147. #define PAGE0_SELECT 0
  148. #define PAGE1_SELECT 1
  149. /* Audio serial data interface control register A bits */
  150. #define BIT_CLK_MASTER 0x80
  151. #define WORD_CLK_MASTER 0x40
  152. /* Codec Datapath setup register 7 */
  153. #define FSREF_44100 (1 << 7)
  154. #define FSREF_48000 (0 << 7)
  155. #define DUAL_RATE_MODE ((1 << 5) | (1 << 6))
  156. #define LDAC2LCH (0x1 << 3)
  157. #define RDAC2RCH (0x1 << 1)
  158. /* PLL registers bitfields */
  159. #define PLLP_SHIFT 0
  160. #define PLLP_MASK 7
  161. #define PLLQ_SHIFT 3
  162. #define PLLR_SHIFT 0
  163. #define PLLJ_SHIFT 2
  164. #define PLLD_MSB_SHIFT 0
  165. #define PLLD_LSB_SHIFT 2
  166. /* Clock generation register bits */
  167. #define CODEC_CLKIN_PLLDIV 0
  168. #define CODEC_CLKIN_CLKDIV 1
  169. #define PLL_CLKIN_SHIFT 4
  170. #define MCLK_SOURCE 0x0
  171. #define PLL_CLKDIV_SHIFT 0
  172. /* Software reset register bits */
  173. #define SOFT_RESET 0x80
  174. /* PLL progrramming register A bits */
  175. #define PLL_ENABLE 0x80
  176. /* Route bits */
  177. #define ROUTE_ON 0x80
  178. /* Mute bits */
  179. #define UNMUTE 0x08
  180. #define MUTE_ON 0x80
  181. /* Power bits */
  182. #define LADC_PWR_ON 0x04
  183. #define RADC_PWR_ON 0x04
  184. #define LDAC_PWR_ON 0x80
  185. #define RDAC_PWR_ON 0x40
  186. #define HPLOUT_PWR_ON 0x01
  187. #define HPROUT_PWR_ON 0x01
  188. #define HPLCOM_PWR_ON 0x01
  189. #define HPRCOM_PWR_ON 0x01
  190. #define MONOLOPM_PWR_ON 0x01
  191. #define LLOPM_PWR_ON 0x01
  192. #define RLOPM_PWR_ON 0x01
  193. #define INVERT_VOL(val) (0x7f - val)
  194. /* Default output volume (inverted) */
  195. #define DEFAULT_VOL INVERT_VOL(0x50)
  196. /* Default input volume */
  197. #define DEFAULT_GAIN 0x20
  198. /* headset detection / button API */
  199. /* The AIC3x supports detection of stereo headsets (GND + left + right signal)
  200. * and cellular headsets (GND + speaker output + microphone input).
  201. * It is recommended to enable MIC bias for this function to work properly.
  202. * For more information, please refer to the datasheet. */
  203. enum {
  204. AIC3X_HEADSET_DETECT_OFF = 0,
  205. AIC3X_HEADSET_DETECT_STEREO = 1,
  206. AIC3X_HEADSET_DETECT_CELLULAR = 2,
  207. AIC3X_HEADSET_DETECT_BOTH = 3
  208. };
  209. enum {
  210. AIC3X_HEADSET_DEBOUNCE_16MS = 0,
  211. AIC3X_HEADSET_DEBOUNCE_32MS = 1,
  212. AIC3X_HEADSET_DEBOUNCE_64MS = 2,
  213. AIC3X_HEADSET_DEBOUNCE_128MS = 3,
  214. AIC3X_HEADSET_DEBOUNCE_256MS = 4,
  215. AIC3X_HEADSET_DEBOUNCE_512MS = 5
  216. };
  217. enum {
  218. AIC3X_BUTTON_DEBOUNCE_0MS = 0,
  219. AIC3X_BUTTON_DEBOUNCE_8MS = 1,
  220. AIC3X_BUTTON_DEBOUNCE_16MS = 2,
  221. AIC3X_BUTTON_DEBOUNCE_32MS = 3
  222. };
  223. #define AIC3X_HEADSET_DETECT_ENABLED 0x80
  224. #define AIC3X_HEADSET_DETECT_SHIFT 5
  225. #define AIC3X_HEADSET_DETECT_MASK 3
  226. #define AIC3X_HEADSET_DEBOUNCE_SHIFT 2
  227. #define AIC3X_HEADSET_DEBOUNCE_MASK 7
  228. #define AIC3X_BUTTON_DEBOUNCE_SHIFT 0
  229. #define AIC3X_BUTTON_DEBOUNCE_MASK 3
  230. #endif /* _AIC3X_H */