2 * rk616.h -- RK616 CODEC ALSA SoC audio driver
4 * Copyright 2013 Rockship
5 * Author: chenjq <chenjq@rock-chips.com>
9 #ifndef __RK616_CODEC_H__
10 #define __RK616_CODEC_H__
13 //#define CRU_PCM2IS2_CON2 0x0098
14 #define PCM_TO_I2S_MUX (1 << 3)
15 #define APS_SEL (1 << 2)
16 #define APS_CLR (1 << 1)
17 #define I2S_CHANNEL_SEL (1 << 0)
19 //#define CRU_CFGMISC_CON 0x009C
20 #define MICDET1_PIN_F_CODEC (1 << 18)
21 #define MICDET2_PIN_F_CODEC (1 << 17)
22 #define AD_DA_LOOP (1 << 0)
23 #define AD_DA_LOOP_SFT 0
26 #define RK616_CODEC_BASE 0x0800
28 #define RK616_RESET (RK616_CODEC_BASE + 0x00)
29 #define RK616_DAC_VOL (RK616_CODEC_BASE + 0x04)
30 #define RK616_ADC_INT_CTL1 (RK616_CODEC_BASE + 0x08)
31 #define RK616_ADC_INT_CTL2 (RK616_CODEC_BASE + 0x0c)
32 #define RK616_DAC_INT_CTL1 (RK616_CODEC_BASE + 0x10)
33 #define RK616_DAC_INT_CTL2 (RK616_CODEC_BASE + 0x14)
34 #define RK616_CLK_CHPUMP (RK616_CODEC_BASE + 0x1c)
35 #define RK616_PGA_AGC_CTL (RK616_CODEC_BASE + 0x28)
36 #define RK616_PWR_ADD1 (RK616_CODEC_BASE + 0x3c)
37 #define RK616_BST_CTL (RK616_CODEC_BASE + 0x40)
38 #define RK616_DIFFIN_CTL (RK616_CODEC_BASE + 0x44)
39 #define RK616_MIXINL_CTL (RK616_CODEC_BASE + 0x48)
40 #define RK616_MIXINL_VOL1 (RK616_CODEC_BASE + 0x4c)
41 #define RK616_MIXINL_VOL2 (RK616_CODEC_BASE + 0x50)
42 #define RK616_MIXINR_CTL (RK616_CODEC_BASE + 0x54)
43 #define RK616_MIXINR_VOL1 (RK616_CODEC_BASE + 0x58)
44 #define RK616_MIXINR_VOL2 (RK616_CODEC_BASE + 0x5c)
45 #define RK616_PGAL_CTL (RK616_CODEC_BASE + 0x60)
46 #define RK616_PGAR_CTL (RK616_CODEC_BASE + 0x64)
47 #define RK616_PWR_ADD2 (RK616_CODEC_BASE + 0x68)
48 #define RK616_DAC_CTL (RK616_CODEC_BASE + 0x6c)
49 #define RK616_LINEMIX_CTL (RK616_CODEC_BASE + 0x70)
50 #define RK616_MUXHP_HPMIX_CTL (RK616_CODEC_BASE + 0x74)
51 #define RK616_HPMIX_CTL (RK616_CODEC_BASE + 0x78)
52 #define RK616_HPMIX_VOL1 (RK616_CODEC_BASE + 0x7c)
53 #define RK616_HPMIX_VOL2 (RK616_CODEC_BASE + 0x80)
54 #define RK616_LINEOUT1_CTL (RK616_CODEC_BASE + 0x84)
55 #define RK616_LINEOUT2_CTL (RK616_CODEC_BASE + 0x88)
56 #define RK616_SPKL_CTL (RK616_CODEC_BASE + 0x8c)
57 #define RK616_SPKR_CTL (RK616_CODEC_BASE + 0x90)
58 #define RK616_HPL_CTL (RK616_CODEC_BASE + 0x94)
59 #define RK616_HPR_CTL (RK616_CODEC_BASE + 0x98)
60 #define RK616_MICBIAS_CTL (RK616_CODEC_BASE + 0x9c)
61 #define RK616_MICKEY_DET_CTL (RK616_CODEC_BASE + 0xa0)
62 #define RK616_PWR_ADD3 (RK616_CODEC_BASE + 0xa4)
63 #define RK616_ADC_CTL (RK616_CODEC_BASE + 0xa8)
64 #define RK616_SINGNAL_ZC_CTL1 (RK616_CODEC_BASE + 0xac)//Signal zero-crossing detection
65 #define RK616_SINGNAL_ZC_CTL2 (RK616_CODEC_BASE + 0xB0)//Signal zero-crossing detection
66 #define RK616_PGAL_AGC_CTL1 (RK616_CODEC_BASE + 0xc0)
67 #define RK616_PGAL_AGC_CTL2 (RK616_CODEC_BASE + 0xc4)
68 #define RK616_PGAL_AGC_CTL3 (RK616_CODEC_BASE + 0xc8)
69 #define RK616_PGAL_AGC_CTL4 (RK616_CODEC_BASE + 0xcc)
70 #define RK616_PGAL_ASR_CTL (RK616_CODEC_BASE + 0xd0)
71 #define RK616_PGAL_AGC_MAX_H (RK616_CODEC_BASE + 0xd4)
72 #define RK616_PGAL_AGC_MAX_L (RK616_CODEC_BASE + 0xd8)
73 #define RK616_PGAL_AGC_MIN_H (RK616_CODEC_BASE + 0xdc)
74 #define RK616_PGAL_AGC_MIN_L (RK616_CODEC_BASE + 0xe0)
75 #define RK616_PGAL_AGC_CTL5 (RK616_CODEC_BASE + 0xe4)
76 #define RK616_PGAR_AGC_CTL1 (RK616_CODEC_BASE + 0x100)
77 #define RK616_PGAR_AGC_CTL2 (RK616_CODEC_BASE + 0x104)
78 #define RK616_PGAR_AGC_CTL3 (RK616_CODEC_BASE + 0x108)
79 #define RK616_PGAR_AGC_CTL4 (RK616_CODEC_BASE + 0x10c)
80 #define RK616_PGAR_ASR_CTL (RK616_CODEC_BASE + 0x110)
81 #define RK616_PGAR_AGC_MAX_H (RK616_CODEC_BASE + 0x114)
82 #define RK616_PGAR_AGC_MAX_L (RK616_CODEC_BASE + 0x118)
83 #define RK616_PGAR_AGC_MIN_H (RK616_CODEC_BASE + 0x11c)
84 #define RK616_PGAR_AGC_MIN_L (RK616_CODEC_BASE + 0x120)
85 #define RK616_PGAR_AGC_CTL5 (RK616_CODEC_BASE + 0x124)
87 /* global definition (0x8c 0x90 0x94 0x98) */
88 #define RK616_PWRD (0x1 << 7)
89 #define RK616_PWRD_SFT 7
91 #define RK616_INIT_MASK (0x1 << 6)
92 #define RK616_INIT_SFT 6
93 #define RK616_INIT_RN (0x1 << 6)
94 #define RK616_INIT_AFT (0x0 << 6)
96 #define RK616_MUTE (0x1 << 5)
97 #define RK616_MUTE_SFT 5
99 #define RK616_VOL_MASK 0x1f
100 #define RK616_VOL_SFT 0
102 /* ADC Interface Control 1 (0x08) */
103 #define RK616_ALRCK_POL_MASK (0x1 << 7)
104 #define RK616_ALRCK_POL_SFT 7
105 #define RK616_ALRCK_POL_EN (0x1 << 7)
106 #define RK616_ALRCK_POL_DIS (0x0 << 7)
108 #define RK616_ADC_VWL_MASK (0x3 << 5)
109 #define RK616_ADC_VWL_SFT 5
110 #define RK616_ADC_VWL_32 (0x3 << 5)
111 #define RK616_ADC_VWL_24 (0x2 << 5)
112 #define RK616_ADC_VWL_20 (0x1 << 5)
113 #define RK616_ADC_VWL_16 (0x0 << 5)
115 #define RK616_ADC_DF_MASK (0x3 << 3)
116 #define RK616_ADC_DF_SFT 3
117 #define RK616_ADC_DF_PCM (0x3 << 3)
118 #define RK616_ADC_DF_I2S (0x2 << 3)
119 #define RK616_ADC_DF_LJ (0x1 << 3)
120 #define RK616_ADC_DF_RJ (0x0 << 3)
122 #define RK616_ADC_SWAP_MASK (0x1 << 1)
123 #define RK616_ADC_SWAP_SFT 1
124 #define RK616_ADC_SWAP_EN (0x1 << 1)
125 #define RK616_ADC_SWAP_DIS (0x0 << 1)
127 #define RK616_ADC_TYPE_MASK 0x1
128 #define RK616_ADC_TYPE_SFT 0
129 #define RK616_ADC_TYPE_MONO 0x1
130 #define RK616_ADC_TYPE_STEREO 0x0
132 /* ADC Interface Control 2 (0x0c) */
133 #define RK616_I2S_MODE_MASK (0x1 << 4)
134 #define RK616_I2S_MODE_SFT 4
135 #define RK616_I2S_MODE_MST (0x1 << 4)
136 #define RK616_I2S_MODE_SLV (0x0 << 4)
138 #define RK616_ADC_WL_MASK (0x3 << 2)
139 #define RK616_ADC_WL_SFT 2
140 #define RK616_ADC_WL_32 (0x3 << 2)
141 #define RK616_ADC_WL_24 (0x2 << 2)
142 #define RK616_ADC_WL_20 (0x1 << 2)
143 #define RK616_ADC_WL_16 (0x0 << 2)
145 #define RK616_ADC_RST_MASK (0x1 << 1)
146 #define RK616_ADC_RST_SFT 1
147 #define RK616_ADC_RST_DIS (0x1 << 1)
148 #define RK616_ADC_RST_EN (0x0 << 1)
150 #define RK616_ABCLK_POL_MASK 0x1
151 #define RK616_ABCLK_POL_SFT 0
152 #define RK616_ABCLK_POL_EN 0x1
153 #define RK616_ABCLK_POL_DIS 0x0
155 /* DAC Interface Control 1 (0x10) */
156 #define RK616_DLRCK_POL_MASK (0x1 << 7)
157 #define RK616_DLRCK_POL_SFT 7
158 #define RK616_DLRCK_POL_EN (0x1 << 7)
159 #define RK616_DLRCK_POL_DIS (0x0 << 7)
161 #define RK616_DAC_VWL_MASK (0x3 << 5)
162 #define RK616_DAC_VWL_SFT 5
163 #define RK616_DAC_VWL_32 (0x3 << 5)
164 #define RK616_DAC_VWL_24 (0x2 << 5)
165 #define RK616_DAC_VWL_20 (0x1 << 5)
166 #define RK616_DAC_VWL_16 (0x0 << 5)
168 #define RK616_DAC_DF_MASK (0x3 << 3)
169 #define RK616_DAC_DF_SFT 3
170 #define RK616_DAC_DF_PCM (0x3 << 3)
171 #define RK616_DAC_DF_I2S (0x2 << 3)
172 #define RK616_DAC_DF_LJ (0x1 << 3)
173 #define RK616_DAC_DF_RJ (0x0 << 3)
175 #define RK616_DAC_SWAP_MASK (0x1 << 2)
176 #define RK616_DAC_SWAP_SFT 2
177 #define RK616_DAC_SWAP_EN (0x1 << 2)
178 #define RK616_DAC_SWAP_DIS (0x0 << 2)
180 /* DAC Interface Control 2 (0x14) */
181 #define RK616_DAC_WL_MASK (0x3 << 2)
182 #define RK616_DAC_WL_SFT 2
183 #define RK616_DAC_WL_32 (0x3 << 2)
184 #define RK616_DAC_WL_24 (0x2 << 2)
185 #define RK616_DAC_WL_20 (0x1 << 2)
186 #define RK616_DAC_WL_16 (0x0 << 2)
188 #define RK616_DAC_RST_MASK (0x1 << 1)
189 #define RK616_DAC_RST_SFT 1
190 #define RK616_DAC_RST_DIS (0x1 << 1)
191 #define RK616_DAC_RST_EN (0x0 << 1)
193 #define RK616_DBCLK_POL_MASK 0x1
194 #define RK616_DBCLK_POL_SFT 0
195 #define RK616_DBCLK_POL_EN 0x1
196 #define RK616_DBCLK_POL_DIS 0x0
198 /* PGA AGC Enable (0x28) */
199 #define RK616_PGAL_AGC_EN_MASK (0x1 << 5)
200 #define RK616_PGAL_AGC_EN_SFT 5
201 #define RK616_PGAL_AGC_EN (0x1 << 5)
202 #define RK616_PGAL_AGC_DIS (0x0 << 5)
204 #define RK616_PGAR_AGC_EN_MASK (0x1 << 4)
205 #define RK616_PGAR_AGC_EN_SFT 4
206 #define RK616_PGAR_AGC_EN (0x1 << 4)
207 #define RK616_PGAR_AGC_DIS (0x0 << 4)
209 /* Power Management Addition 1 (0x3c) */
210 #define RK616_ADC_PWRD (0x1 << 6)
211 #define RK616_ADC_PWRD_SFT 6
213 #define RK616_DIFFIN_MIR_PGAR_RLPWRD (0x1 << 5)
214 #define RK616_DIFFIN_MIR_PGAR_RLPWRD_SFT 5
216 #define RK616_MIC1_MIC2_MIL_PGAL_RLPWRD (0x1 << 4)
217 #define RK616_MIC1_MIC2_MIL_PGAL_RLPWRD_SFT 4
219 #define RK616_ADCL_RLPWRD (0x1 << 3)
220 #define RK616_ADCL_RLPWRD_SFT 3
222 #define RK616_ADCR_RLPWRD (0x1 << 2)
223 #define RK616_ADCR_RLPWRD_SFT 2
225 /* BST Control (0x40) */
226 #define RK616_BSTL_PWRD (0x1 << 7)
227 #define RK616_BSTL_PWRD_SFT 7
229 #define RK616_BSTL_MODE_MASK (0x1 << 6)
230 #define RK616_BSTL_MODE_SFT 6
231 #define RK616_BSTL_MODE_SE (0x1 << 6)
232 #define RK616_BSTL_MODE_DIFF (0x0 << 6)
234 #define RK616_BSTL_GAIN_MASK (0x1 << 5)
235 #define RK616_BSTL_GAIN_SFT 5
236 #define RK616_BSTL_GAIN_20DB (0x1 << 5)
237 #define RK616_BSTL_GAIN_0DB (0x0 << 5)
239 #define RK616_BSTL_MUTE (0x1 << 4)
240 #define RK616_BSTL_MUTE_SFT 4
242 #define RK616_BSTR_PWRD (0x1 << 3)
243 #define RK616_BSTR_PWRD_SFT 3
245 #define RK616_BSTR_MODE_MASK (0x1 << 2)
246 #define RK616_BSTR_MODE_SFT 2
247 #define RK616_BSTR_MODE_SE (0x1 << 2)
248 #define RK616_BSTR_MODE_DIFF (0x0 << 2)
250 #define RK616_BSTR_GAIN_MASK (0x1 << 1)
251 #define RK616_BSTR_GAIN_SFT 1
252 #define RK616_BSTR_GAIN_20DB (0x1 << 1)
253 #define RK616_BSTR_GAIN_0DB (0x0 << 1)
255 #define RK616_BSTR_MUTE 0x1
256 #define RK616_BSTR_MUTE_SFT 0
258 /* DIFFIN Control (0x44) */
259 #define RK616_DIFFIN_PWRD (0x1 << 5)
260 #define RK616_DIFFIN_PWRD_SFT 5
262 #define RK616_DIFFIN_MODE_MASK (0x1 << 4)
263 #define RK616_DIFFIN_MODE_SFT 4
264 #define RK616_DIFFIN_MODE_SE (0x1 << 4)
265 #define RK616_DIFFIN_MODE_DIFF (0x0 << 4)
267 #define RK616_DIFFIN_GAIN_MASK (0x1 << 3)
268 #define RK616_DIFFIN_GAIN_SFT 3
269 #define RK616_DIFFIN_GAIN_20DB (0x1 << 3)
270 #define RK616_DIFFIN_GAIN_0DB (0x0 << 3)
272 #define RK616_DIFFIN_MUTE (0x1 << 2)
273 #define RK616_DIFFIN_MUTE_SFT 2
275 #define RK616_MIRM_F_MASK (0x1 << 1)
276 #define RK616_MIRM_F_SFT 1
277 #define RK616_MIRM_F_IN1N (0x1 << 1)
278 #define RK616_MIRM_F_DIFFIN (0x0 << 1)
280 #define RK616_HMM_F_MASK 0x1
281 #define RK616_HMM_F_SFT 0
282 #define RK616_HMM_F_IN1N 0x1
283 #define RK616_HMM_F_DIFFIN 0x0
286 /* BSTR MUXMIC MIXINL Control (0x48) */
287 #define RK616_SE_BSTR_F_MASK (0x1 << 6)
288 #define RK616_SE_BSTR_F_SFT 6
289 #define RK616_SE_BSTR_F_MIN2P (0x1 << 6)
290 #define RK616_SE_BSTR_F_MIN2N (0x0 << 6)
292 #define RK616_MM_F_MASK (0x1 << 5)
293 #define RK616_MM_F_SFT 5
294 #define RK616_MM_F_BSTR (0x1 << 5)
295 #define RK616_MM_F_BSTL (0x0 << 5)
297 #define RK616_MIL_PWRD (0x1 << 4)
298 #define RK616_MIL_PWRD_SFT 4
300 #define RK616_MIL_MUTE (0x1 << 3)
301 #define RK616_MIL_MUTE_SFT 3
303 #define RK616_MIL_F_IN3L (0x1 << 2)
304 #define RK616_MIL_F_IN3L_SFT 2
306 #define RK616_MIL_F_IN1P (0x1 << 1)
307 #define RK616_MIL_F_IN1P_SFT 1
309 #define RK616_MIL_F_MUX (0x1 << 0)
310 #define RK616_MIL_F_MUX_SFT 0
312 /* MIXINL volume 1 (0x4c) */
313 #define RK616_MIL_F_MUX_VOL_MASK (0x7 << 3)
314 #define RK616_MIL_F_MUX_VOL_SFT 3
316 #define RK616_MIL_F_IN1P_VOL_MASK 0x7
317 #define RK616_MIL_F_IN1P_VOL_SFT 0
319 /* MIXINL volume 2 (0x50) */
320 #define RK616_MIL_F_IN3L_VOL_MASK 0x7
321 #define RK616_MIL_F_IN3L_VOL_SFT 0
323 /* MIXINR Control (0x54) */
324 #define RK616_MIR_PWRD (0x1 << 5)
325 #define RK616_MIR_PWRD_SFT 5
327 #define RK616_MIR_MUTE (0x1 << 4)
328 #define RK616_MIR_MUTE_SFT 4
330 #define RK616_MIR_F_MIC2N (0x1 << 3)
331 #define RK616_MIR_F_MIC2N_SFT 3
333 #define RK616_MIR_F_IN1P (0x1 << 2)
334 #define RK616_MIR_F_IN1P_SFT 2
336 #define RK616_MIR_F_IN3R (0x1 << 1)
337 #define RK616_MIR_F_IN3R_SFT 1
339 #define RK616_MIR_F_MIRM 0x1
340 #define RK616_MIR_F_MIRM_SFT 0
342 /* MIXINR volume 1 (0x58) */
343 #define RK616_MIR_F_MIRM_VOL_MASK (0x7 << 3)
344 #define RK616_MIR_F_MIRM_VOL_SFT 3
346 #define RK616_MIR_F_IN3R_VOL_MASK 0x7
347 #define RK616_MIR_F_IN3R_VOL_SFT 0
349 /* MIXINR volume 2 (0x5c) */
350 #define RK616_MIR_F_MIC2N_VOL_MASK (0x7 << 3)
351 #define RK616_MIR_F_MIC2N_VOL_SFT 3
353 #define RK616_MIR_F_IN1P_VOL_MASK 0x7
354 #define RK616_MIR_F_IN1P_VOL_SFT 0
356 /* PGA Control (0x60 0x64) */
357 #define RK616_PGA_PWRD (0x1 << 7)
358 #define RK616_PGA_PWRD_SFT 7
360 #define RK616_PGA_MUTE (0x1 << 6)
361 #define RK616_PGA_MUTE_SFT 6
363 #define RK616_PGA_VOL_MASK (0x1f << 0)
364 #define RK616_PGA_VOL_SFT 0
367 /* Power Management Addition 2 (0x68) */
368 #define RK616_HPL_HPR_PWRD (0x1 << 7)
369 #define RK616_HPL_HPR_PWRD_SFT 7
371 #define RK616_DAC_PWRD (0x1 << 6)
372 #define RK616_DAC_PWRD_SFT 6
374 #define RK616_DACL_RLPWRD (0x1 << 5)
375 #define RK616_DACL_RLPWRD_SFT 5
377 #define RK616_DACL_SPKL_RLPWRD (0x1 << 4)
378 #define RK616_DACL_SPKL_RLPWRD_SFT 4
380 #define RK616_DACR_RLPWRD (0x1 << 3)
381 #define RK616_DACR_RLPWRD_SFT 3
383 #define RK616_DACR_SPKR_RLPWRD (0x1 << 2)//? BIT 3 BIT 6 BIT 2
384 #define RK616_DACR_SPKR_RLPWRD_SFT 2
386 #define RK616_LM_LO_RLPWRD (0x1 << 1)
387 #define RK616_LM_LO_RLPWRD_SFT 1
389 #define RK616_HM_RLPWRD 0x1
390 #define RK616_HM_RLPWRD_SFT 0
392 /* DAC Control (0x6c) */
393 #define RK616_DACL_INIT_MASK (0x1 << 5)
394 #define RK616_DACL_INIT_SFT 5
395 #define RK616_DACL_INIT_WORK (0x1 << 5)
396 #define RK616_DACL_INIT_NOT (0x0 << 5)
398 #define RK616_DACR_INIT_MASK (0x1 << 4)
399 #define RK616_DACR_INIT_SFT 4
400 #define RK616_DACR_INIT_WORK (0x1 << 4)
401 #define RK616_DACR_INIT_NOT (0x0 << 4)
403 #define RK616_DACL_PWRD (0x1 << 3)
404 #define RK616_DACL_PWRD_SFT 3
406 #define RK616_DACR_PWRD (0x1 << 2)
407 #define RK616_DACR_PWRD_SFT 2
409 #define RK616_DACR_CLK_PWRD (0x1 << 1)
410 #define RK616_DACR_CLK_PWRD_SFT 1
412 #define RK616_DACL_CLK_PWRD 0x1
413 #define RK616_DACL_CLK_PWRD_SFT 0
415 /* Linemix Control (0x70) */
416 #define RK616_LM_PWRD (0x1 << 4)
417 #define RK616_LM_PWRD_SFT 4
419 #define RK616_LM_F_PGAR (0x1 << 3)
420 #define RK616_LM_F_PGAR_SFT 3
422 #define RK616_LM_F_PGAL (0x1 << 2)
423 #define RK616_LM_F_PGAL_SFT 2
425 #define RK616_LM_F_DACR (0x1 << 1)
426 #define RK616_LM_F_DACR_SFT 1
428 #define RK616_LM_F_DACL 0x1
429 #define RK616_LM_F_DACL_SFT 0
431 /* MUXHP HPMIX Control (0x74) */
432 #define RK616_HML_PWRD (0x1 << 5)
433 #define RK616_HML_PWRD_SFT 5
435 #define RK616_HML_INIT_MASK (0x1 << 4)
436 #define RK616_HML_INIT_SFT 4
437 #define RK616_HML_INIT_RN (0x1 << 4)
438 #define RK616_HML_INIT_AFT (0x0 << 4)
440 #define RK616_HMR_PWRD (0x1 << 3)
441 #define RK616_HMR_PWRD_SFT 3
443 #define RK616_HMR_INIT_MASK (0x1 << 2)
444 #define RK616_HMR_INIT_SFT 2
445 #define RK616_HMR_INIT_RN (0x1 << 2)
446 #define RK616_HMR_INIT_AFT (0x0 << 2)
448 #define RK616_MHL_F_MASK (0x1 << 1)
449 #define RK616_MHL_F_SFT 1
450 #define RK616_MHL_F_DACL (0x1 << 1)
451 #define RK616_MHL_F_HPMIXL (0x0 << 1)
453 #define RK616_MHR_F_MASK 0x1
454 #define RK616_MHR_F_SFT 0
455 #define RK616_MHR_F_DACR 0x1
456 #define RK616_MHR_F_HPMIXR 0x0
458 /* HPMIX Control (0x78) */
459 #define RK616_HML_F_HMM (0x1 << 7)
460 #define RK616_HML_F_HMM_SFT 7
462 #define RK616_HML_F_IN1P (0x1 << 6)
463 #define RK616_HML_F_IN1P_SFT 6
465 #define RK616_HML_F_PGAL (0x1 << 5)
466 #define RK616_HML_F_PGAL_SFT 5
468 #define RK616_HML_F_DACL (0x1 << 4)
469 #define RK616_HML_F_DACL_SFT 4
471 #define RK616_HMR_F_HMM (0x1 << 3)
472 #define RK616_HMR_F_HMM_SFT 3
474 #define RK616_HMR_F_PGAR (0x1 << 2)
475 #define RK616_HMR_F_PGAR_SFT 2
477 #define RK616_HMR_F_PGAL (0x1 << 1)
478 #define RK616_HMR_F_PGAL_SFT 1
480 #define RK616_HMR_F_DACR 0x1
481 #define RK616_HMR_F_DACR_SFT 0
483 /* HPMIX Volume Control 1 (0x7c) */
484 #define RK616_HML_F_IN1P_VOL_MASK 0x7
485 #define RK616_HML_F_IN1P_VOL_SFT 0
487 /* HPMIX Volume Control 2 (0x80) */
488 #define RK616_HML_F_HMM_VOL_MASK (0x7 << 3)
489 #define RK616_HML_F_HMM_VOL_SFT 3
491 #define RK616_HMR_F_HMM_VOL_MASK 0x7
492 #define RK616_HMR_F_HMM_VOL_SFT 0
494 /* Lineout1 Control (0x84 0x88) */
495 #define RK616_LINEOUT_PWRD (0x1 << 6)
496 #define RK616_LINEOUT_PWRD_SFT 6
498 #define RK616_LINEOUT_MUTE (0x1 << 5)
499 #define RK616_LINEOUT_MUTE_SFT 5
501 #define RK616_LINEOUT_VOL_MASK 0x1f
502 #define RK616_LINEOUT_VOL_SFT 0
504 /* Micbias Control 1 (0x9c) */
505 #define RK616_MICBIAS1_PWRD (0x1 << 7)
506 #define RK616_MICBIAS1_PWRD_SFT 7
508 #define RK616_MICBIAS2_PWRD (0x1 << 6)
509 #define RK616_MICBIAS2_PWRD_SFT 6
511 #define RK616_MICBIAS1_V_MASK (0x7 << 3)
512 #define RK616_MICBIAS1_V_SFT 3
513 #define RK616_MICBIAS1_V_1_7 (0x7 << 3)
514 #define RK616_MICBIAS1_V_1_6 (0x6 << 3)
515 #define RK616_MICBIAS1_V_1_5 (0x5 << 3)
516 #define RK616_MICBIAS1_V_1_4 (0x4 << 3)
517 #define RK616_MICBIAS1_V_1_3 (0x3 << 3)
518 #define RK616_MICBIAS1_V_1_2 (0x2 << 3)
519 #define RK616_MICBIAS1_V_1_1 (0x1 << 3)
520 #define RK616_MICBIAS1_V_1_0 (0x0 << 3)
522 #define RK616_MICBIAS2_V_MASK 0x7
523 #define RK616_MICBIAS2_V_SFT 0
524 #define RK616_MICBIAS2_V_1_7 0x7
525 #define RK616_MICBIAS2_V_1_6 0x6
526 #define RK616_MICBIAS2_V_1_5 0x5
527 #define RK616_MICBIAS2_V_1_4 0x4
528 #define RK616_MICBIAS2_V_1_3 0x3
529 #define RK616_MICBIAS2_V_1_2 0x2
530 #define RK616_MICBIAS2_V_1_1 0x1
531 #define RK616_MICBIAS2_V_1_0 0x0
533 /* MIC Key Detection Control (0xa0) */
534 #define RK616_MK1_DET_MASK (0x1 << 7)
535 #define RK616_MK1_DET_SFT 7
536 #define RK616_MK1_EN (0x1 << 7)
537 #define RK616_MK1_DIS (0x0 << 7)
539 #define RK616_MK2_DET_MASK (0x1 << 6)
540 #define RK616_MK2_DET_SFT 6
541 #define RK616_MK2_EN (0x1 << 6)
542 #define RK616_MK2_DIS (0x0 << 6)
544 #define RK616_MK1_DET_I_MASK (0x7 << 3)
545 #define RK616_MK1_DET_I_SFT 3
546 #define RK616_MK1_DET_I_1500 (0x7 << 3)
547 #define RK616_MK1_DET_I_1300 (0x6 << 3)
548 #define RK616_MK1_DET_I_1100 (0x5 << 3)
549 #define RK616_MK1_DET_I_900 (0x4 << 3)
550 #define RK616_MK1_DET_I_700 (0x3 << 3)
551 #define RK616_MK1_DET_I_500 (0x2 << 3)
552 #define RK616_MK1_DET_I_300 (0x1 << 3)
553 #define RK616_MK1_DET_I_100 (0x0 << 3)
555 #define RK616_MK2_DET_I_MASK 0x7
556 #define RK616_MK2_DET_I_SFT 0
557 #define RK616_MK2_DET_I_1500 0x7
558 #define RK616_MK2_DET_I_1300 0x6
559 #define RK616_MK2_DET_I_1100 0x5
560 #define RK616_MK2_DET_I_900 0x4
561 #define RK616_MK2_DET_I_700 0x3
562 #define RK616_MK2_DET_I_500 0x2
563 #define RK616_MK2_DET_I_300 0x1
564 #define RK616_MK2_DET_I_100 0x0
566 /* Power Management Addition 3 (0xa4) */
567 #define RK616_ADCL_ZO_PWRD (0x1 << 3)
568 #define RK616_ADCL_ZO_PWRD_SFT 3
570 #define RK616_ADCR_ZO_PWRD (0x1 << 2)
571 #define RK616_ADCR_ZO_PWRD_SFT 2
573 #define RK616_DACL_ZO_PWRD (0x1 << 1)
574 #define RK616_DACL_ZO_PWRD_SFT 1
576 #define RK616_DACR_ZO_PWRD 0x1
577 #define RK616_DACR_ZO_PWRD_SFT 0
579 /* ADC control (0xa8) */
580 #define RK616_ADCL_CLK_PWRD (0x1 << 5)
581 #define RK616_ADCL_CLK_PWRD_SFT 5
583 #define RK616_ADCL_PWRD (0x1 << 4)
584 #define RK616_ADCL_PWRD_SFT 4
586 #define RK616_ADCL_CLEAR_MASK (0x1 << 3)//clear buf
587 #define RK616_ADCL_CLEAR_SFT 3
588 #define RK616_ADCL_CLEAR_EN (0x1 << 3)
589 #define RK616_ADCL_CLEAR_DIS (0x0 << 3)
591 #define RK616_ADCR_CLK_PWRD (0x1 << 2)
592 #define RK616_ADCR_CLK_PWRD_SFT 2
594 #define RK616_ADCR_PWRD (0x1 << 1)
595 #define RK616_ADCR_PWRD_SFT 1
597 #define RK616_ADCR_CLEAR_MASK 0x1//clear buf
598 #define RK616_ADCR_CLEAR_SFT 0
599 #define RK616_ADCR_CLEAR_EN 0x1
600 #define RK616_ADCR_CLEAR_DIS 0x0
602 /* PGA AGC control 1 (0xc0 0x110) */
603 #define RK616_PGA_AGC_WAY_MASK (0x1 << 4)
604 #define RK616_PGA_AGC_WAY_SFT 4
605 #define RK616_PGA_AGC_WAY_JACK (0x1 << 4)
606 #define RK616_PGA_AGC_WAY_NOR (0x0 << 4)
608 #define RK616_PGA_AGC_HOLD_T_MASK 0xf
609 #define RK616_PGA_AGC_HOLD_T_SFT 0
610 #define RK616_PGA_AGC_HOLD_T_1024 0xa
611 #define RK616_PGA_AGC_HOLD_T_512 0x9
612 #define RK616_PGA_AGC_HOLD_T_256 0x8
613 #define RK616_PGA_AGC_HOLD_T_128 0x7
614 #define RK616_PGA_AGC_HOLD_T_64 0x6
615 #define RK616_PGA_AGC_HOLD_T_32 0x5
616 #define RK616_PGA_AGC_HOLD_T_16 0x4
617 #define RK616_PGA_AGC_HOLD_T_8 0x3
618 #define RK616_PGA_AGC_HOLD_T_4 0x2
619 #define RK616_PGA_AGC_HOLD_T_2 0x1
620 #define RK616_PGA_AGC_HOLD_T_0 0x0
622 /* PGA AGC control 2 (0xc4 0x104) */
623 #define RK616_PGA_AGC_GRU_T_MASK (0xf << 4)
624 #define RK616_PGA_AGC_GRU_T_SFT 4
625 #define RK616_PGA_AGC_GRU_T_512 (0xa << 4)
626 #define RK616_PGA_AGC_GRU_T_256 (0x9 << 4)
627 #define RK616_PGA_AGC_GRU_T_128 (0x8 << 4)
628 #define RK616_PGA_AGC_GRU_T_64 (0x7 << 4)
629 #define RK616_PGA_AGC_GRU_T_32 (0x6 << 4)
630 #define RK616_PGA_AGC_GRU_T_16 (0x5 << 4)
631 #define RK616_PGA_AGC_GRU_T_8 (0x4 << 4)
632 #define RK616_PGA_AGC_GRU_T_4 (0x3 << 4)
633 #define RK616_PGA_AGC_GRU_T_2 (0x2 << 4)
634 #define RK616_PGA_AGC_GRU_T_1 (0x1 << 4)
635 #define RK616_PGA_AGC_GRU_T_0_5 (0x0 << 4)
637 #define RK616_PGA_AGC_GRD_T_MASK 0xf
638 #define RK616_PGA_AGC_GRD_T_SFT 0
639 #define RK616_PGA_AGC_GRD_T_128_32 0xa
640 #define RK616_PGA_AGC_GRD_T_64_16 0x9
641 #define RK616_PGA_AGC_GRD_T_32_8 0x8
642 #define RK616_PGA_AGC_GRD_T_16_4 0x7
643 #define RK616_PGA_AGC_GRD_T_8_2 0x6
644 #define RK616_PGA_AGC_GRD_T_4_1 0x5
645 #define RK616_PGA_AGC_GRD_T_2_0_512 0x4
646 #define RK616_PGA_AGC_GRD_T_1_0_256 0x3
647 #define RK616_PGA_AGC_GRD_T_0_500_128 0x2
648 #define RK616_PGA_AGC_GRD_T_0_250_64 0x1
649 #define RK616_PGA_AGC_GRD_T_0_125_32 0x0
651 /* PGA AGC control 3 (0xc8 0x108) */
652 #define RK616_PGA_AGC_MODE_MASK (0x1 << 7)
653 #define RK616_PGA_AGC_MODE_SFT 7
654 #define RK616_PGA_AGC_MODE_LIMIT (0x1 << 7)
655 #define RK616_PGA_AGC_MODE_NOR (0x0 << 7)
657 #define RK616_PGA_AGC_ZO_MASK (0x1 << 6)
658 #define RK616_PGA_AGC_ZO_SFT 6
659 #define RK616_PGA_AGC_ZO_EN (0x1 << 6)
660 #define RK616_PGA_AGC_ZO_DIS (0x0 << 6)
662 #define RK616_PGA_AGC_REC_MODE_MASK (0x1 << 5)
663 #define RK616_PGA_AGC_REC_MODE_SFT 5
664 #define RK616_PGA_AGC_REC_MODE_AC (0x1 << 5)
665 #define RK616_PGA_AGC_REC_MODE_RN (0x0 << 5)
667 #define RK616_PGA_AGC_FAST_D_MASK (0x1 << 4)
668 #define RK616_PGA_AGC_FAST_D_SFT 4
669 #define RK616_PGA_AGC_FAST_D_EN (0x1 << 4)
670 #define RK616_PGA_AGC_FAST_D_DIS (0x0 << 4)
672 #define RK616_PGA_AGC_NG_MASK (0x1 << 3)
673 #define RK616_PGA_AGC_NG_SFT 3
674 #define RK616_PGA_AGC_NG_EN (0x1 << 3)
675 #define RK616_PGA_AGC_NG_DIS (0x0 << 3)
677 #define RK616_PGA_AGC_NG_THR_MASK 0x7
678 #define RK616_PGA_AGC_NG_THR_SFT 0
679 #define RK616_PGA_AGC_NG_THR_N81DB 0x7
680 #define RK616_PGA_AGC_NG_THR_N75DB 0x6
681 #define RK616_PGA_AGC_NG_THR_N69DB 0x5
682 #define RK616_PGA_AGC_NG_THR_N63DB 0x4
683 #define RK616_PGA_AGC_NG_THR_N57DB 0x3
684 #define RK616_PGA_AGC_NG_THR_N51DB 0x2
685 #define RK616_PGA_AGC_NG_THR_N45DB 0x1
686 #define RK616_PGA_AGC_NG_THR_N39DB 0x0
688 /* PGA AGC Control 4 (0xcc 0x10c) */
689 #define RK616_PGA_AGC_ZO_MODE_MASK (0x1 << 5)
690 #define RK616_PGA_AGC_ZO_MODE_SFT 5
691 #define RK616_PGA_AGC_ZO_MODE_UWRC (0x1 << 5)
692 #define RK616_PGA_AGC_ZO_MODE_UARC (0x0 << 5)
694 #define RK616_PGA_AGC_VOL_MASK 0x1f
695 #define RK616_PGA_AGC_VOL_SFT 0
697 /* PGA ASR Control (0xd0 0x110) */
698 #define RK616_PGA_SLOW_CLK_MASK (0x1 << 3)
699 #define RK616_PGA_SLOW_CLK_SFT 3
700 #define RK616_PGA_SLOW_CLK_EN (0x1 << 3)
701 #define RK616_PGA_SLOW_CLK_DIS (0x0 << 3)
703 #define RK616_PGA_ASR_MASK 0x7
704 #define RK616_PGA_ASR_SFT 0
705 #define RK616_PGA_ASR_8KHz 0x5
706 #define RK616_PGA_ASR_12KHz 0x4
707 #define RK616_PGA_ASR_16KHz 0x3
708 #define RK616_PGA_ASR_24KHz 0x2
709 #define RK616_PGA_ASR_32KHz 0x1
710 #define RK616_PGA_ASR_48KHz 0x0
712 /* PGA AGC Control 5 (0xe4 0x124) */
713 #define RK616_PGA_AGC_MASK (0x1 << 6)
714 #define RK616_PGA_AGC_SFT 6
715 #define RK616_PGA_AGC_EN (0x1 << 6)
716 #define RK616_PGA_AGC_DIS (0x0 << 6)
718 #define RK616_PGA_AGC_MAX_G_MASK (0x7 << 3)
719 #define RK616_PGA_AGC_MAX_G_SFT 3
720 #define RK616_PGA_AGC_MAX_G_28_5DB (0x7 << 3)
721 #define RK616_PGA_AGC_MAX_G_22_5DB (0x6 << 3)
722 #define RK616_PGA_AGC_MAX_G_16_5DB (0x5 << 3)
723 #define RK616_PGA_AGC_MAX_G_10_5DB (0x4 << 3)
724 #define RK616_PGA_AGC_MAX_G_4_5DB (0x3 << 3)
725 #define RK616_PGA_AGC_MAX_G_N1_5DB (0x2 << 3)
726 #define RK616_PGA_AGC_MAX_G_N7_5DB (0x1 << 3)
727 #define RK616_PGA_AGC_MAX_G_N13_5DB (0x0 << 3)
729 #define RK616_PGA_AGC_MIN_G_MASK 0x7
730 #define RK616_PGA_AGC_MIN_G_SFT 0
731 #define RK616_PGA_AGC_MIN_G_24DB 0x7
732 #define RK616_PGA_AGC_MIN_G_18DB 0x6
733 #define RK616_PGA_AGC_MIN_G_12DB 0x5
734 #define RK616_PGA_AGC_MIN_G_6DB 0x4
735 #define RK616_PGA_AGC_MIN_G_0DB 0x3
736 #define RK616_PGA_AGC_MIN_G_N6DB 0x2
737 #define RK616_PGA_AGC_MIN_G_N12DB 0x1
738 #define RK616_PGA_AGC_MIN_G_N18DB 0x0
771 struct rk616_reg_val_typ {
776 struct rk616_init_bit_typ {
778 unsigned int power_bit;
779 unsigned int init_bit;
782 bool rk616_get_for_mid(void);
783 bool get_hdmi_state(void);
785 #endif //__RK616_CODEC_H__