Merge remote-tracking branch 'origin/upstream/linux-linaro-lsk-v3.10-android+android...
[firefly-linux-kernel-4.4.55.git] / sound / soc / codecs / rk616_codec.h
1 /*
2  * rk616.h  --  RK616 CODEC ALSA SoC audio driver
3  *
4  * Copyright 2013 Rockship
5  * Author: chenjq <chenjq@rock-chips.com>
6  *
7  */
8
9 #ifndef __RK616_CODEC_H__
10 #define __RK616_CODEC_H__
11
12 /* mfd register */
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)
18
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
24
25 /* codec register */
26 #define RK616_CODEC_BASE                        0x0800
27
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)
86
87 /* global definition (0x8c 0x90 0x94 0x98) */
88 #define RK616_PWRD                              (0x1 << 7)
89 #define RK616_PWRD_SFT                          7
90
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)
95
96 #define RK616_MUTE                              (0x1 << 5)
97 #define RK616_MUTE_SFT                          5
98
99 #define RK616_VOL_MASK                          0x1f
100 #define RK616_VOL_SFT                           0
101
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)
107
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)
114
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)
121
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)
126
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
131
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)
137
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)
144
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)
149
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
154
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)
160
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)
167
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)
174
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)
179
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)
187
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)
192
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
197
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)
203
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)
208
209 /* Power Management Addition 1 (0x3c) */
210 #define RK616_ADC_PWRD                          (0x1 << 6)
211 #define RK616_ADC_PWRD_SFT                      6
212
213 #define RK616_DIFFIN_MIR_PGAR_RLPWRD            (0x1 << 5)
214 #define RK616_DIFFIN_MIR_PGAR_RLPWRD_SFT        5
215
216 #define RK616_MIC1_MIC2_MIL_PGAL_RLPWRD         (0x1 << 4)
217 #define RK616_MIC1_MIC2_MIL_PGAL_RLPWRD_SFT     4
218
219 #define RK616_ADCL_RLPWRD                       (0x1 << 3)
220 #define RK616_ADCL_RLPWRD_SFT                   3
221
222 #define RK616_ADCR_RLPWRD                       (0x1 << 2)
223 #define RK616_ADCR_RLPWRD_SFT                   2
224
225 /* BST Control (0x40) */
226 #define RK616_BSTL_PWRD                         (0x1 << 7)
227 #define RK616_BSTL_PWRD_SFT                     7
228
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)
233
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)
238
239 #define RK616_BSTL_MUTE                         (0x1 << 4)
240 #define RK616_BSTL_MUTE_SFT                     4
241
242 #define RK616_BSTR_PWRD                         (0x1 << 3)
243 #define RK616_BSTR_PWRD_SFT                     3
244
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)
249
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)
254
255 #define RK616_BSTR_MUTE                         0x1
256 #define RK616_BSTR_MUTE_SFT                     0
257
258 /* DIFFIN Control (0x44) */
259 #define RK616_DIFFIN_PWRD                       (0x1 << 5)
260 #define RK616_DIFFIN_PWRD_SFT                   5
261
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)
266
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)
271
272 #define RK616_DIFFIN_MUTE                       (0x1 << 2)
273 #define RK616_DIFFIN_MUTE_SFT                   2
274
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)
279
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
284
285
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)
291
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)
296
297 #define RK616_MIL_PWRD                          (0x1 << 4)
298 #define RK616_MIL_PWRD_SFT                      4
299
300 #define RK616_MIL_MUTE                          (0x1 << 3)
301 #define RK616_MIL_MUTE_SFT                      3
302
303 #define RK616_MIL_F_IN3L                        (0x1 << 2)
304 #define RK616_MIL_F_IN3L_SFT                    2
305
306 #define RK616_MIL_F_IN1P                        (0x1 << 1)
307 #define RK616_MIL_F_IN1P_SFT                    1
308
309 #define RK616_MIL_F_MUX                         (0x1 << 0)
310 #define RK616_MIL_F_MUX_SFT                     0
311
312 /* MIXINL volume 1 (0x4c) */
313 #define RK616_MIL_F_MUX_VOL_MASK                (0x7 << 3)
314 #define RK616_MIL_F_MUX_VOL_SFT                 3
315
316 #define RK616_MIL_F_IN1P_VOL_MASK               0x7
317 #define RK616_MIL_F_IN1P_VOL_SFT                0
318
319 /* MIXINL volume 2 (0x50) */
320 #define RK616_MIL_F_IN3L_VOL_MASK               0x7
321 #define RK616_MIL_F_IN3L_VOL_SFT                0
322
323 /* MIXINR Control (0x54) */
324 #define RK616_MIR_PWRD                          (0x1 << 5)
325 #define RK616_MIR_PWRD_SFT                      5
326
327 #define RK616_MIR_MUTE                          (0x1 << 4)
328 #define RK616_MIR_MUTE_SFT                      4
329
330 #define RK616_MIR_F_MIC2N                       (0x1 << 3)
331 #define RK616_MIR_F_MIC2N_SFT                   3
332
333 #define RK616_MIR_F_IN1P                        (0x1 << 2)
334 #define RK616_MIR_F_IN1P_SFT                    2
335
336 #define RK616_MIR_F_IN3R                        (0x1 << 1)
337 #define RK616_MIR_F_IN3R_SFT                    1
338
339 #define RK616_MIR_F_MIRM                        0x1
340 #define RK616_MIR_F_MIRM_SFT                    0
341
342 /* MIXINR volume 1 (0x58) */
343 #define RK616_MIR_F_MIRM_VOL_MASK               (0x7 << 3)
344 #define RK616_MIR_F_MIRM_VOL_SFT                3
345
346 #define RK616_MIR_F_IN3R_VOL_MASK               0x7
347 #define RK616_MIR_F_IN3R_VOL_SFT                0
348
349 /* MIXINR volume 2 (0x5c) */
350 #define RK616_MIR_F_MIC2N_VOL_MASK              (0x7 << 3)
351 #define RK616_MIR_F_MIC2N_VOL_SFT               3
352
353 #define RK616_MIR_F_IN1P_VOL_MASK               0x7
354 #define RK616_MIR_F_IN1P_VOL_SFT                0
355
356 /* PGA Control (0x60 0x64) */
357 #define RK616_PGA_PWRD                          (0x1 << 7)
358 #define RK616_PGA_PWRD_SFT                      7
359
360 #define RK616_PGA_MUTE                          (0x1 << 6)
361 #define RK616_PGA_MUTE_SFT                      6
362
363 #define RK616_PGA_VOL_MASK                      (0x1f << 0)
364 #define RK616_PGA_VOL_SFT                       0
365
366
367 /* Power Management Addition 2 (0x68) */
368 #define RK616_HPL_HPR_PWRD                      (0x1 << 7)
369 #define RK616_HPL_HPR_PWRD_SFT                  7
370
371 #define RK616_DAC_PWRD                          (0x1 << 6)
372 #define RK616_DAC_PWRD_SFT                      6
373
374 #define RK616_DACL_RLPWRD                       (0x1 << 5)
375 #define RK616_DACL_RLPWRD_SFT                   5
376
377 #define RK616_DACL_SPKL_RLPWRD                  (0x1 << 4)
378 #define RK616_DACL_SPKL_RLPWRD_SFT              4
379
380 #define RK616_DACR_RLPWRD                       (0x1 << 3)
381 #define RK616_DACR_RLPWRD_SFT                   3
382
383 #define RK616_DACR_SPKR_RLPWRD                  (0x1 << 2)//? BIT 3 BIT 6 BIT 2
384 #define RK616_DACR_SPKR_RLPWRD_SFT              2
385
386 #define RK616_LM_LO_RLPWRD                      (0x1 << 1)
387 #define RK616_LM_LO_RLPWRD_SFT                  1
388
389 #define RK616_HM_RLPWRD                         0x1
390 #define RK616_HM_RLPWRD_SFT                     0
391
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)
397
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)
402
403 #define RK616_DACL_PWRD                         (0x1 << 3)
404 #define RK616_DACL_PWRD_SFT                     3
405
406 #define RK616_DACR_PWRD                         (0x1 << 2)
407 #define RK616_DACR_PWRD_SFT                     2
408
409 #define RK616_DACR_CLK_PWRD                     (0x1 << 1)
410 #define RK616_DACR_CLK_PWRD_SFT                 1
411
412 #define RK616_DACL_CLK_PWRD                     0x1
413 #define RK616_DACL_CLK_PWRD_SFT                 0
414
415 /* Linemix Control (0x70) */
416 #define RK616_LM_PWRD                           (0x1 << 4)
417 #define RK616_LM_PWRD_SFT                       4
418
419 #define RK616_LM_F_PGAR                         (0x1 << 3)
420 #define RK616_LM_F_PGAR_SFT                     3
421
422 #define RK616_LM_F_PGAL                         (0x1 << 2)
423 #define RK616_LM_F_PGAL_SFT                     2
424
425 #define RK616_LM_F_DACR                         (0x1 << 1)
426 #define RK616_LM_F_DACR_SFT                     1
427
428 #define RK616_LM_F_DACL                         0x1
429 #define RK616_LM_F_DACL_SFT                     0
430
431 /* MUXHP HPMIX Control (0x74) */
432 #define RK616_HML_PWRD                          (0x1 << 5)
433 #define RK616_HML_PWRD_SFT                      5
434
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)
439
440 #define RK616_HMR_PWRD                          (0x1 << 3)
441 #define RK616_HMR_PWRD_SFT                      3
442
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)
447
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)
452
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
457
458 /* HPMIX Control (0x78) */
459 #define RK616_HML_F_HMM                         (0x1 << 7)
460 #define RK616_HML_F_HMM_SFT                     7
461
462 #define RK616_HML_F_IN1P                        (0x1 << 6)
463 #define RK616_HML_F_IN1P_SFT                    6
464
465 #define RK616_HML_F_PGAL                        (0x1 << 5)
466 #define RK616_HML_F_PGAL_SFT                    5
467
468 #define RK616_HML_F_DACL                        (0x1 << 4)
469 #define RK616_HML_F_DACL_SFT                    4
470
471 #define RK616_HMR_F_HMM                         (0x1 << 3)
472 #define RK616_HMR_F_HMM_SFT                     3
473
474 #define RK616_HMR_F_PGAR                        (0x1 << 2)
475 #define RK616_HMR_F_PGAR_SFT                    2
476
477 #define RK616_HMR_F_PGAL                        (0x1 << 1)
478 #define RK616_HMR_F_PGAL_SFT                    1
479
480 #define RK616_HMR_F_DACR                        0x1
481 #define RK616_HMR_F_DACR_SFT                    0
482
483 /* HPMIX Volume Control 1 (0x7c) */
484 #define RK616_HML_F_IN1P_VOL_MASK               0x7
485 #define RK616_HML_F_IN1P_VOL_SFT                0
486
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
490
491 #define RK616_HMR_F_HMM_VOL_MASK                0x7
492 #define RK616_HMR_F_HMM_VOL_SFT                 0
493
494 /* Lineout1 Control (0x84 0x88) */
495 #define RK616_LINEOUT_PWRD                      (0x1 << 6)
496 #define RK616_LINEOUT_PWRD_SFT                  6
497
498 #define RK616_LINEOUT_MUTE                      (0x1 << 5)
499 #define RK616_LINEOUT_MUTE_SFT                  5
500
501 #define RK616_LINEOUT_VOL_MASK                  0x1f
502 #define RK616_LINEOUT_VOL_SFT                   0
503
504 /* Micbias Control 1 (0x9c) */
505 #define RK616_MICBIAS1_PWRD                     (0x1 << 7)
506 #define RK616_MICBIAS1_PWRD_SFT                 7
507
508 #define RK616_MICBIAS2_PWRD                     (0x1 << 6)
509 #define RK616_MICBIAS2_PWRD_SFT                 6
510
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)
521
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
532
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)
538
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)
543
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)
554
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
565
566 /* Power Management Addition 3 (0xa4) */
567 #define RK616_ADCL_ZO_PWRD                      (0x1 << 3)
568 #define RK616_ADCL_ZO_PWRD_SFT                  3
569
570 #define RK616_ADCR_ZO_PWRD                      (0x1 << 2)
571 #define RK616_ADCR_ZO_PWRD_SFT                  2
572
573 #define RK616_DACL_ZO_PWRD                      (0x1 << 1)
574 #define RK616_DACL_ZO_PWRD_SFT                  1
575
576 #define RK616_DACR_ZO_PWRD                      0x1
577 #define RK616_DACR_ZO_PWRD_SFT                  0
578
579 /* ADC control (0xa8) */
580 #define RK616_ADCL_CLK_PWRD                     (0x1 << 5)
581 #define RK616_ADCL_CLK_PWRD_SFT                 5
582
583 #define RK616_ADCL_PWRD                         (0x1 << 4)
584 #define RK616_ADCL_PWRD_SFT                     4
585
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)
590
591 #define RK616_ADCR_CLK_PWRD                     (0x1 << 2)
592 #define RK616_ADCR_CLK_PWRD_SFT                 2
593
594 #define RK616_ADCR_PWRD                         (0x1 << 1)
595 #define RK616_ADCR_PWRD_SFT                     1
596
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
601
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)
607
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
621
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)
636
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
650
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)
656
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)
661
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)
666
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)
671
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)
676
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
687
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)
693
694 #define RK616_PGA_AGC_VOL_MASK                  0x1f
695 #define RK616_PGA_AGC_VOL_SFT                   0
696
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)
702
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
711
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)
717
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)
728
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
739
740 enum {
741         RK616_HIFI,
742         RK616_VOICE,
743 };
744
745 enum {
746         RK616_MONO = 1,
747         RK616_STEREO,
748 };
749
750 enum {
751         OFF,
752         RCV,
753         SPK_PATH,
754         HP_PATH,
755         HP_NO_MIC,
756         BT,
757         SPK_HP,
758         RING_SPK,
759         RING_HP,
760         RING_HP_NO_MIC,
761         RING_SPK_HP,
762 };
763
764 enum {
765         MIC_OFF,
766         Main_Mic,
767         Hands_Free_Mic,
768         BT_Sco_Mic,
769 };
770
771 struct rk616_reg_val_typ {
772         unsigned int reg;
773         unsigned int value;
774 };
775
776 struct rk616_init_bit_typ {
777         unsigned int reg;
778         unsigned int power_bit;
779         unsigned int init_bit;
780 };
781
782 bool rk616_get_for_mid(void);
783 bool get_hdmi_state(void);
784
785 #endif //__RK616_CODEC_H__