tlv320aic3x.h 6.6 KB

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