tlv320aic3x.h 8.6 KB

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