tlv320aic3x.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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 overflow status and PLL R value programming register */
  36. #define AIC3X_OVRF_STATUS_AND_PLLR_REG 11
  37. /* Audio codec digital filter control register */
  38. #define AIC3X_CODEC_DFILT_CTRL 12
  39. /* ADC PGA Gain control registers */
  40. #define LADC_VOL 15
  41. #define RADC_VOL 16
  42. /* MIC3 control registers */
  43. #define MIC3LR_2_LADC_CTRL 17
  44. #define MIC3LR_2_RADC_CTRL 18
  45. /* Line1 Input control registers */
  46. #define LINE1L_2_LADC_CTRL 19
  47. #define LINE1R_2_LADC_CTRL 21
  48. #define LINE1R_2_RADC_CTRL 22
  49. #define LINE1L_2_RADC_CTRL 24
  50. /* Line2 Input control registers */
  51. #define LINE2L_2_LADC_CTRL 20
  52. #define LINE2R_2_RADC_CTRL 23
  53. /* MICBIAS Control Register */
  54. #define MICBIAS_CTRL 25
  55. /* AGC Control Registers A, B, C */
  56. #define LAGC_CTRL_A 26
  57. #define LAGC_CTRL_B 27
  58. #define LAGC_CTRL_C 28
  59. #define RAGC_CTRL_A 29
  60. #define RAGC_CTRL_B 30
  61. #define RAGC_CTRL_C 31
  62. /* DAC Power and Left High Power Output control registers */
  63. #define DAC_PWR 37
  64. #define HPLCOM_CFG 37
  65. /* Right High Power Output control registers */
  66. #define HPRCOM_CFG 38
  67. /* DAC Output Switching control registers */
  68. #define DAC_LINE_MUX 41
  69. /* High Power Output Driver Pop Reduction registers */
  70. #define HPOUT_POP_REDUCTION 42
  71. /* DAC Digital control registers */
  72. #define LDAC_VOL 43
  73. #define RDAC_VOL 44
  74. /* High Power Output control registers */
  75. #define LINE2L_2_HPLOUT_VOL 45
  76. #define LINE2R_2_HPROUT_VOL 62
  77. #define PGAL_2_HPLOUT_VOL 46
  78. #define PGAL_2_HPROUT_VOL 60
  79. #define PGAR_2_HPLOUT_VOL 49
  80. #define PGAR_2_HPROUT_VOL 63
  81. #define DACL1_2_HPLOUT_VOL 47
  82. #define DACR1_2_HPROUT_VOL 64
  83. #define HPLOUT_CTRL 51
  84. #define HPROUT_CTRL 65
  85. /* High Power COM control registers */
  86. #define LINE2L_2_HPLCOM_VOL 52
  87. #define LINE2R_2_HPRCOM_VOL 69
  88. #define PGAL_2_HPLCOM_VOL 53
  89. #define PGAR_2_HPLCOM_VOL 56
  90. #define PGAL_2_HPRCOM_VOL 67
  91. #define PGAR_2_HPRCOM_VOL 70
  92. #define DACL1_2_HPLCOM_VOL 54
  93. #define DACR1_2_HPRCOM_VOL 71
  94. #define HPLCOM_CTRL 58
  95. #define HPRCOM_CTRL 72
  96. /* Mono Line Output Plus/Minus control registers */
  97. #define LINE2L_2_MONOLOPM_VOL 73
  98. #define LINE2R_2_MONOLOPM_VOL 76
  99. #define PGAL_2_MONOLOPM_VOL 74
  100. #define PGAR_2_MONOLOPM_VOL 77
  101. #define DACL1_2_MONOLOPM_VOL 75
  102. #define DACR1_2_MONOLOPM_VOL 78
  103. #define MONOLOPM_CTRL 79
  104. /* Line Output Plus/Minus control registers */
  105. #define LINE2L_2_LLOPM_VOL 80
  106. #define LINE2L_2_RLOPM_VOL 87
  107. #define LINE2R_2_LLOPM_VOL 83
  108. #define LINE2R_2_RLOPM_VOL 90
  109. #define PGAL_2_LLOPM_VOL 81
  110. #define PGAL_2_RLOPM_VOL 88
  111. #define PGAR_2_LLOPM_VOL 84
  112. #define PGAR_2_RLOPM_VOL 91
  113. #define DACL1_2_LLOPM_VOL 82
  114. #define DACL1_2_RLOPM_VOL 89
  115. #define DACR1_2_RLOPM_VOL 92
  116. #define DACR1_2_LLOPM_VOL 85
  117. #define LLOPM_CTRL 86
  118. #define RLOPM_CTRL 93
  119. /* GPIO/IRQ registers */
  120. #define AIC3X_STICKY_IRQ_FLAGS_REG 96
  121. #define AIC3X_RT_IRQ_FLAGS_REG 97
  122. #define AIC3X_GPIO1_REG 98
  123. #define AIC3X_GPIO2_REG 99
  124. #define AIC3X_GPIOA_REG 100
  125. #define AIC3X_GPIOB_REG 101
  126. /* Clock generation control register */
  127. #define AIC3X_CLKGEN_CTRL_REG 102
  128. /* Page select register bits */
  129. #define PAGE0_SELECT 0
  130. #define PAGE1_SELECT 1
  131. /* Audio serial data interface control register A bits */
  132. #define BIT_CLK_MASTER 0x80
  133. #define WORD_CLK_MASTER 0x40
  134. /* Codec Datapath setup register 7 */
  135. #define FSREF_44100 (1 << 7)
  136. #define FSREF_48000 (0 << 7)
  137. #define DUAL_RATE_MODE ((1 << 5) | (1 << 6))
  138. #define LDAC2LCH (0x1 << 3)
  139. #define RDAC2RCH (0x1 << 1)
  140. /* PLL registers bitfields */
  141. #define PLLP_SHIFT 0
  142. #define PLLQ_SHIFT 3
  143. #define PLLR_SHIFT 0
  144. #define PLLJ_SHIFT 2
  145. #define PLLD_MSB_SHIFT 0
  146. #define PLLD_LSB_SHIFT 2
  147. /* Clock generation register bits */
  148. #define CODEC_CLKIN_PLLDIV 0
  149. #define CODEC_CLKIN_CLKDIV 1
  150. #define PLL_CLKIN_SHIFT 4
  151. #define MCLK_SOURCE 0x0
  152. #define PLL_CLKDIV_SHIFT 0
  153. /* Software reset register bits */
  154. #define SOFT_RESET 0x80
  155. /* PLL progrramming register A bits */
  156. #define PLL_ENABLE 0x80
  157. /* Route bits */
  158. #define ROUTE_ON 0x80
  159. /* Mute bits */
  160. #define UNMUTE 0x08
  161. #define MUTE_ON 0x80
  162. /* Power bits */
  163. #define LADC_PWR_ON 0x04
  164. #define RADC_PWR_ON 0x04
  165. #define LDAC_PWR_ON 0x80
  166. #define RDAC_PWR_ON 0x40
  167. #define HPLOUT_PWR_ON 0x01
  168. #define HPROUT_PWR_ON 0x01
  169. #define HPLCOM_PWR_ON 0x01
  170. #define HPRCOM_PWR_ON 0x01
  171. #define MONOLOPM_PWR_ON 0x01
  172. #define LLOPM_PWR_ON 0x01
  173. #define RLOPM_PWR_ON 0x01
  174. #define INVERT_VOL(val) (0x7f - val)
  175. /* Default output volume (inverted) */
  176. #define DEFAULT_VOL INVERT_VOL(0x50)
  177. /* Default input volume */
  178. #define DEFAULT_GAIN 0x20
  179. /* GPIO API */
  180. enum {
  181. AIC3X_GPIO1_FUNC_DISABLED = 0,
  182. AIC3X_GPIO1_FUNC_AUDIO_WORDCLK_ADC = 1,
  183. AIC3X_GPIO1_FUNC_CLOCK_MUX = 2,
  184. AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV2 = 3,
  185. AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV4 = 4,
  186. AIC3X_GPIO1_FUNC_CLOCK_MUX_DIV8 = 5,
  187. AIC3X_GPIO1_FUNC_SHORT_CIRCUIT_IRQ = 6,
  188. AIC3X_GPIO1_FUNC_AGC_NOISE_IRQ = 7,
  189. AIC3X_GPIO1_FUNC_INPUT = 8,
  190. AIC3X_GPIO1_FUNC_OUTPUT = 9,
  191. AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK = 10,
  192. AIC3X_GPIO1_FUNC_AUDIO_WORDCLK = 11,
  193. AIC3X_GPIO1_FUNC_BUTTON_IRQ = 12,
  194. AIC3X_GPIO1_FUNC_HEADSET_DETECT_IRQ = 13,
  195. AIC3X_GPIO1_FUNC_HEADSET_DETECT_OR_BUTTON_IRQ = 14,
  196. AIC3X_GPIO1_FUNC_ALL_IRQ = 16
  197. };
  198. enum {
  199. AIC3X_GPIO2_FUNC_DISABLED = 0,
  200. AIC3X_GPIO2_FUNC_HEADSET_DETECT_IRQ = 2,
  201. AIC3X_GPIO2_FUNC_INPUT = 3,
  202. AIC3X_GPIO2_FUNC_OUTPUT = 4,
  203. AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT = 5,
  204. AIC3X_GPIO2_FUNC_AUDIO_BITCLK = 8,
  205. AIC3X_GPIO2_FUNC_HEADSET_DETECT_OR_BUTTON_IRQ = 9,
  206. AIC3X_GPIO2_FUNC_ALL_IRQ = 10,
  207. AIC3X_GPIO2_FUNC_SHORT_CIRCUIT_OR_AGC_IRQ = 11,
  208. AIC3X_GPIO2_FUNC_HEADSET_OR_BUTTON_PRESS_OR_SHORT_CIRCUIT_IRQ = 12,
  209. AIC3X_GPIO2_FUNC_SHORT_CIRCUIT_IRQ = 13,
  210. AIC3X_GPIO2_FUNC_AGC_NOISE_IRQ = 14,
  211. AIC3X_GPIO2_FUNC_BUTTON_PRESS_IRQ = 15
  212. };
  213. void aic3x_set_gpio(struct snd_soc_codec *codec, int gpio, int state);
  214. int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio);
  215. int aic3x_headset_detected(struct snd_soc_codec *codec);
  216. struct aic3x_setup_data {
  217. int i2c_bus;
  218. unsigned short i2c_address;
  219. unsigned int gpio_func[2];
  220. };
  221. extern struct snd_soc_dai aic3x_dai;
  222. extern struct snd_soc_codec_device soc_codec_dev_aic3x;
  223. #endif /* _AIC3X_H */