cs42l52.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /*
  2. * cs42l52.h -- CS42L52 ALSA SoC audio driver
  3. *
  4. * Copyright 2012 CirrusLogic, Inc.
  5. *
  6. * Author: Georgi Vlaev <joe@nucleusys.com>
  7. * Author: Brian Austin <brian.austin@cirrus.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #ifndef __CS42L52_H__
  15. #define __CS42L52_H__
  16. #define CS42L52_NAME "CS42L52"
  17. #define CS42L52_DEFAULT_CLK 12000000
  18. #define CS42L52_MIN_CLK 11000000
  19. #define CS42L52_MAX_CLK 27000000
  20. #define CS42L52_DEFAULT_FORMAT SNDRV_PCM_FMTBIT_S16_LE
  21. #define CS42L52_DEFAULT_MAX_CHANS 2
  22. #define CS42L52_SYSCLK 1
  23. #define CS42L52_CHIP_SWICTH (1 << 17)
  24. #define CS42L52_ALL_IN_ONE (1 << 16)
  25. #define CS42L52_CHIP_ONE 0x00
  26. #define CS42L52_CHIP_TWO 0x01
  27. #define CS42L52_CHIP_THR 0x02
  28. #define CS42L52_CHIP_MASK 0x0f
  29. #define CS42L52_FIX_BITS_CTL 0x00
  30. #define CS42L52_CHIP 0x01
  31. #define CS42L52_CHIP_ID 0xE0
  32. #define CS42L52_CHIP_ID_MASK 0xF8
  33. #define CS42L52_CHIP_REV_A0 0x00
  34. #define CS42L52_CHIP_REV_A1 0x01
  35. #define CS42L52_CHIP_REV_B0 0x02
  36. #define CS42L52_CHIP_REV_MASK 0x07
  37. #define CS42L52_PWRCTL1 0x02
  38. #define CS42L52_PWRCTL1_PDN_ALL 0x9F
  39. #define CS42L52_PWRCTL1_PDN_CHRG 0x80
  40. #define CS42L52_PWRCTL1_PDN_PGAB 0x10
  41. #define CS42L52_PWRCTL1_PDN_PGAA 0x08
  42. #define CS42L52_PWRCTL1_PDN_ADCB 0x04
  43. #define CS42L52_PWRCTL1_PDN_ADCA 0x02
  44. #define CS42L52_PWRCTL1_PDN_CODEC 0x01
  45. #define CS42L52_PWRCTL2 0x03
  46. #define CS42L52_PWRCTL2_OVRDB (1 << 4)
  47. #define CS42L52_PWRCTL2_OVRDA (1 << 3)
  48. #define CS42L52_PWRCTL2_PDN_MICB (1 << 2)
  49. #define CS42L52_PWRCTL2_PDN_MICB_SHIFT 2
  50. #define CS42L52_PWRCTL2_PDN_MICA (1 << 1)
  51. #define CS42L52_PWRCTL2_PDN_MICA_SHIFT 1
  52. #define CS42L52_PWRCTL2_PDN_MICBIAS (1 << 0)
  53. #define CS42L52_PWRCTL2_PDN_MICBIAS_SHIFT 0
  54. #define CS42L52_PWRCTL3 0x04
  55. #define CS42L52_PWRCTL3_HPB_PDN_SHIFT 6
  56. #define CS42L52_PWRCTL3_HPB_ON_LOW 0x00
  57. #define CS42L52_PWRCTL3_HPB_ON_HIGH 0x01
  58. #define CS42L52_PWRCTL3_HPB_ALWAYS_ON 0x02
  59. #define CS42L52_PWRCTL3_HPB_ALWAYS_OFF 0x03
  60. #define CS42L52_PWRCTL3_HPA_PDN_SHIFT 4
  61. #define CS42L52_PWRCTL3_HPA_ON_LOW 0x00
  62. #define CS42L52_PWRCTL3_HPA_ON_HIGH 0x01
  63. #define CS42L52_PWRCTL3_HPA_ALWAYS_ON 0x02
  64. #define CS42L52_PWRCTL3_HPA_ALWAYS_OFF 0x03
  65. #define CS42L52_PWRCTL3_SPKB_PDN_SHIFT 2
  66. #define CS42L52_PWRCTL3_SPKB_ON_LOW 0x00
  67. #define CS42L52_PWRCTL3_SPKB_ON_HIGH 0x01
  68. #define CS42L52_PWRCTL3_SPKB_ALWAYS_ON 0x02
  69. #define CS42L52_PWRCTL3_PDN_SPKB (1 << 2)
  70. #define CS42L52_PWRCTL3_PDN_SPKA (1 << 0)
  71. #define CS42L52_PWRCTL3_SPKA_PDN_SHIFT 0
  72. #define CS42L52_PWRCTL3_SPKA_ON_LOW 0x00
  73. #define CS42L52_PWRCTL3_SPKA_ON_HIGH 0x01
  74. #define CS42L52_PWRCTL3_SPKA_ALWAYS_ON 0x02
  75. #define CS42L52_DEFAULT_OUTPUT_STATE 0x05
  76. #define CS42L52_PWRCTL3_CONF_MASK 0x03
  77. #define CS42L52_CLK_CTL 0x05
  78. #define CLK_AUTODECT_ENABLE (1 << 7)
  79. #define CLK_SPEED_SHIFT 5
  80. #define CLK_DS_MODE 0x00
  81. #define CLK_SS_MODE 0x01
  82. #define CLK_HS_MODE 0x02
  83. #define CLK_QS_MODE 0x03
  84. #define CLK_32K_SR_SHIFT 4
  85. #define CLK_32K 0x01
  86. #define CLK_NO_32K 0x00
  87. #define CLK_27M_MCLK_SHIFT 3
  88. #define CLK_27M_MCLK 0x01
  89. #define CLK_NO_27M 0x00
  90. #define CLK_RATIO_SHIFT 1
  91. #define CLK_R_128 0x00
  92. #define CLK_R_125 0x01
  93. #define CLK_R_132 0x02
  94. #define CLK_R_136 0x03
  95. #define CS42L52_IFACE_CTL1 0x06
  96. #define CS42L52_IFACE_CTL1_MASTER (1 << 7)
  97. #define CS42L52_IFACE_CTL1_SLAVE (0 << 7)
  98. #define CS42L52_IFACE_CTL1_INV_SCLK (1 << 6)
  99. #define CS42L52_IFACE_CTL1_ADC_FMT_I2S (1 << 5)
  100. #define CS42L52_IFACE_CTL1_ADC_FMT_LEFT_J (0 << 5)
  101. #define CS42L52_IFACE_CTL1_DSP_MODE_EN (1 << 4)
  102. #define CS42L52_IFACE_CTL1_DAC_FMT_LEFT_J (0 << 2)
  103. #define CS42L52_IFACE_CTL1_DAC_FMT_I2S (1 << 2)
  104. #define CS42L52_IFACE_CTL1_DAC_FMT_RIGHT_J (2 << 2)
  105. #define CS42L52_IFACE_CTL1_WL_32BIT (0x00)
  106. #define CS42L52_IFACE_CTL1_WL_24BIT (0x01)
  107. #define CS42L52_IFACE_CTL1_WL_20BIT (0x02)
  108. #define CS42L52_IFACE_CTL1_WL_16BIT (0x03)
  109. #define CS42L52_IFACE_CTL1_WL_MASK 0xFFFF
  110. #define CS42L52_IFACE_CTL2 0x07
  111. #define CS42L52_IFACE_CTL2_SC_MC_EQ (1 << 6)
  112. #define CS42L52_IFACE_CTL2_LOOPBACK (1 << 5)
  113. #define CS42L52_IFACE_CTL2_S_MODE_OUTPUT_EN (0 << 4)
  114. #define CS42L52_IFACE_CTL2_S_MODE_OUTPUT_HIZ (1 << 4)
  115. #define CS42L52_IFACE_CTL2_HP_SW_INV (1 << 3)
  116. #define CS42L52_IFACE_CTL2_BIAS_LVL 0x07
  117. #define CS42L52_ADC_PGA_A 0x08
  118. #define CS42L52_ADC_PGA_B 0x09
  119. #define CS42L52_ADC_SEL_SHIFT 5
  120. #define CS42L52_ADC_SEL_AIN1 0x00
  121. #define CS42L52_ADC_SEL_AIN2 0x01
  122. #define CS42L52_ADC_SEL_AIN3 0x02
  123. #define CS42L52_ADC_SEL_AIN4 0x03
  124. #define CS42L52_ADC_SEL_PGA 0x04
  125. #define CS42L52_ANALOG_HPF_CTL 0x0A
  126. #define CS42L52_HPF_CTL_ANLGSFTB (1 << 3)
  127. #define CS42L52_HPF_CTL_ANLGSFTA (1 << 0)
  128. #define CS42L52_ADC_HPF_FREQ 0x0B
  129. #define CS42L52_ADC_MISC_CTL 0x0C
  130. #define CS42L52_ADC_MISC_CTL_SOURCE_DSP (1 << 6)
  131. #define CS42L52_PB_CTL1 0x0D
  132. #define CS42L52_PB_CTL1_HP_GAIN_SHIFT 5
  133. #define CS42L52_PB_CTL1_HP_GAIN_03959 0x00
  134. #define CS42L52_PB_CTL1_HP_GAIN_04571 0x01
  135. #define CS42L52_PB_CTL1_HP_GAIN_05111 0x02
  136. #define CS42L52_PB_CTL1_HP_GAIN_06047 0x03
  137. #define CS42L52_PB_CTL1_HP_GAIN_07099 0x04
  138. #define CS42L52_PB_CTL1_HP_GAIN_08399 0x05
  139. #define CS42L52_PB_CTL1_HP_GAIN_10000 0x06
  140. #define CS42L52_PB_CTL1_HP_GAIN_11430 0x07
  141. #define CS42L52_PB_CTL1_INV_PCMB (1 << 3)
  142. #define CS42L52_PB_CTL1_INV_PCMA (1 << 2)
  143. #define CS42L52_PB_CTL1_MSTB_MUTE (1 << 1)
  144. #define CS42L52_PB_CTL1_MSTA_MUTE (1 << 0)
  145. #define CS42L52_PB_CTL1_MUTE_MASK 0x03
  146. #define CS42L52_PB_CTL1_MUTE 3
  147. #define CS42L52_PB_CTL1_UNMUTE 0
  148. #define CS42L52_MISC_CTL 0x0E
  149. #define CS42L52_MISC_CTL_DEEMPH (1 << 2)
  150. #define CS42L52_MISC_CTL_DIGSFT (1 << 1)
  151. #define CS42L52_MISC_CTL_DIGZC (1 << 0)
  152. #define CS42L52_PB_CTL2 0x0F
  153. #define CS42L52_PB_CTL2_HPB_MUTE (1 << 7)
  154. #define CS42L52_PB_CTL2_HPA_MUTE (1 << 6)
  155. #define CS42L52_PB_CTL2_SPKB_MUTE (1 << 5)
  156. #define CS42L52_PB_CTL2_SPKA_MUTE (1 << 4)
  157. #define CS42L52_PB_CTL2_SPK_SWAP (1 << 2)
  158. #define CS42L52_PB_CTL2_SPK_MONO (1 << 1)
  159. #define CS42L52_PB_CTL2_SPK_MUTE50 (1 << 0)
  160. #define CS42L52_MICA_CTL 0x10
  161. #define CS42L52_MICB_CTL 0x11
  162. #define CS42L52_MIC_CTL_MIC_SEL_MASK 0xBF
  163. #define CS42L52_MIC_CTL_MIC_SEL_SHIFT 6
  164. #define CS42L52_MIC_CTL_TYPE_MASK 0x20
  165. #define CS42L52_MIC_CTL_TYPE_SHIFT 5
  166. #define CS42L52_PGAA_CTL 0x12
  167. #define CS42L52_PGAB_CTL 0x13
  168. #define CS42L52_PGAX_CTL_VOL_12DB 24
  169. #define CS42L52_PGAX_CTL_VOL_6DB 12 /*step size 0.5db*/
  170. #define CS42L52_PASSTHRUA_VOL 0x14
  171. #define CS42L52_PASSTHRUB_VOL 0x15
  172. #define CS42L52_ADCA_VOL 0x16
  173. #define CS42L52_ADCB_VOL 0x17
  174. #define CS42L52_ADCX_VOL_24DB 24 /*step size 1db*/
  175. #define CS42L52_ADCX_VOL_12DB 12
  176. #define CS42L52_ADCX_VOL_6DB 6
  177. #define CS42L52_ADCA_MIXER_VOL 0x18
  178. #define CS42L52_ADCB_MIXER_VOL 0x19
  179. #define CS42L52_ADC_MIXER_VOL_12DB 0x18
  180. #define CS42L52_PCMA_MIXER_VOL 0x1A
  181. #define CS42L52_PCMB_MIXER_VOL 0x1B
  182. #define CS42L52_BEEP_FREQ 0x1C
  183. #define CS42L52_BEEP_VOL 0x1D
  184. #define CS42L52_BEEP_TONE_CTL 0x1E
  185. #define CS42L52_BEEP_RATE_SHIFT 4
  186. #define CS42L52_BEEP_RATE_MASK 0x0F
  187. #define CS42L52_TONE_CTL 0x1F
  188. #define CS42L52_BEEP_EN_MASK 0x3F
  189. #define CS42L52_MASTERA_VOL 0x20
  190. #define CS42L52_MASTERB_VOL 0x21
  191. #define CS42L52_HPA_VOL 0x22
  192. #define CS42L52_HPB_VOL 0x23
  193. #define CS42L52_DEFAULT_HP_VOL 0xF0
  194. #define CS42L52_SPKA_VOL 0x24
  195. #define CS42L52_SPKB_VOL 0x25
  196. #define CS42L52_DEFAULT_SPK_VOL 0xF0
  197. #define CS42L52_ADC_PCM_MIXER 0x26
  198. #define CS42L52_LIMITER_CTL1 0x27
  199. #define CS42L52_LIMITER_CTL2 0x28
  200. #define CS42L52_LIMITER_AT_RATE 0x29
  201. #define CS42L52_ALC_CTL 0x2A
  202. #define CS42L52_ALC_CTL_ALCB_ENABLE_SHIFT 7
  203. #define CS42L52_ALC_CTL_ALCA_ENABLE_SHIFT 6
  204. #define CS42L52_ALC_CTL_FASTEST_ATTACK 0
  205. #define CS42L52_ALC_RATE 0x2B
  206. #define CS42L52_ALC_SLOWEST_RELEASE 0x3F
  207. #define CS42L52_ALC_THRESHOLD 0x2C
  208. #define CS42L52_ALC_MAX_RATE_SHIFT 5
  209. #define CS42L52_ALC_MIN_RATE_SHIFT 2
  210. #define CS42L52_ALC_RATE_0DB 0
  211. #define CS42L52_ALC_RATE_3DB 1
  212. #define CS42L52_ALC_RATE_6DB 2
  213. #define CS42L52_NOISE_GATE_CTL 0x2D
  214. #define CS42L52_NG_ENABLE_SHIFT 6
  215. #define CS42L52_NG_THRESHOLD_SHIFT 2
  216. #define CS42L52_NG_MIN_70DB 2
  217. #define CS42L52_NG_DELAY_SHIFT 0
  218. #define CS42L52_NG_DELAY_100MS 1
  219. #define CS42L52_CLK_STATUS 0x2E
  220. #define CS42L52_BATT_COMPEN 0x2F
  221. #define CS42L52_BATT_LEVEL 0x30
  222. #define CS42L52_SPK_STATUS 0x31
  223. #define CS42L52_SPK_STATUS_PIN_SHIFT 3
  224. #define CS42L52_SPK_STATUS_PIN_HIGH 1
  225. #define CS42L52_TEM_CTL 0x32
  226. #define CS42L52_TEM_CTL_SET 0x80
  227. #define CS42L52_THE_FOLDBACK 0x33
  228. #define CS42L52_CHARGE_PUMP 0x34
  229. #define CS42L52_CHARGE_PUMP_MASK 0xF0
  230. #define CS42L52_CHARGE_PUMP_SHIFT 4
  231. #define CS42L52_FIX_BITS1 0x3E
  232. #define CS42L52_FIX_BITS2 0x47
  233. #define CS42L52_MAX_REGISTER 0x47
  234. #endif