tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / sound / soc / sprd / codec / sprd / v1 / sprd-codec.h
1 /*
2  * sound/soc/sprd/codec/sprd/v1/sprd-codec.h
3  *
4  * SPRD-CODEC -- SpreadTrum Tiger intergrated codec.
5  *
6  * Copyright (C) 2013 SpreadTrum Ltd.
7  *
8  * This software is licensed under the terms of the GNU General Public
9  * License version 2, as published by the Free Software Foundation, and
10  * may be copied, distributed, and modified under those terms.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY ork FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  */
17 #ifndef __SPRD_CODEC_H
18 #define __SPRD_CODEC_H
19
20 #include <mach/hardware.h>
21 #include <mach/globalregs.h>
22 #include <mach/sprd-audio.h>
23 #include <mach/adi.h>
24 #include <asm/io.h>
25
26 #ifndef CONFIG_SPRD_CODEC_USE_INT
27 /* #define CONFIG_SPRD_CODEC_USE_INT */
28 #endif
29 #ifndef CONFIG_CODEC_DAC_MUTE_WAIT
30 /* #define CONFIG_CODEC_DAC_MUTE_WAIT */
31 #endif
32
33 /* unit: ms */
34 #define SPRD_CODEC_LDO_WAIT_TIME        (5)
35 #define SPRD_CODEC_LDO_VCM_TIME         (2)
36 #ifdef CONFIG_SPRD_CODEC_USE_INT
37 #define SPRD_CODEC_DAC_MUTE_TIMEOUT     (600)
38 #else
39 #define SPRD_CODEC_DAC_MUTE_WAIT_TIME   (40)
40 #endif
41
42 #ifdef CONFIG_SPRD_CODEC_USE_INT
43 #define SPRD_CODEC_HP_POP_TIMEOUT       (1000)
44 #else
45 #define SPRD_CODEC_HP_POP_TIME_STEP     (10)
46 #define SPRD_CODEC_HP_POP_TIME_COUNT    (80)    /* max 800ms will timeout */
47 #endif
48
49 #define SPRD_CODEC_RATE_8000   (10)
50 #define SPRD_CODEC_RATE_9600   ( 9)
51 #define SPRD_CODEC_RATE_11025  ( 8)
52 #define SPRD_CODEC_RATE_12000  ( 7)
53 #define SPRD_CODEC_RATE_16000  ( 6)
54 #define SPRD_CODEC_RATE_22050  ( 5)
55 #define SPRD_CODEC_RATE_24000  ( 4)
56 #define SPRD_CODEC_RATE_32000  ( 3)
57 #define SPRD_CODEC_RATE_44100  ( 2)
58 #define SPRD_CODEC_RATE_48000  ( 1)
59 #define SPRD_CODEC_RATE_96000  ( 0)
60
61 /* AUD_TOP_CTL */
62 #define DAC_EN_L                (0)
63 #define ADC_EN_L                (1)
64 #define DAC_EN_R                (2)
65 #define ADC_EN_R                (3)
66
67 /* AUD_DAC_CTL */
68 #define DAC_MUTE_START          (14)
69 #define DAC_MUTE_EN             (15)
70
71 /* AUD_AUD_STS0 */
72 #define DAC_MUTE_U_MASK         (5)
73 #define DAC_MUTE_D_MASK         (4)
74 #define DAC_MUTE_U_RAW          (3)
75 #define DAC_MUTE_D_RAW          (2)
76 #define DAC_MUTE_ST             (0)
77 #define DAC_MUTE_ST_MASK        (0x3)
78
79 /* AUD_INT_CLR */
80 /* AUD_INT_EN */
81 #define DAC_MUTE_U              (1)
82 #define DAC_MUTE_D              (0)
83
84 /* AUDIF_ENB */
85 #define AUDIFA_DAC_EN           (0)
86 #define AUDIFA_ADC_EN           (1)
87
88 /* AUDIF_INT_EN */
89 /* AUDIF_INT_CLR */
90 /* AUDIF_INT_RAW */
91 /* AUDIF_INT_MASK */
92 #define AUDIO_POP_IRQ           (7)
93 #define OVP_IRQ                 (6)
94 #define OTP_IRQ                 (5)
95 #define PA_OCP_IRQ              (4)
96 #define LOR_OCP_IRQ             (3)
97 #define LOL_OCP_IRQ             (2)
98 #define EAR_OCP_IRQ             (1)
99 #define HP_OCP_IRQ              (0)
100
101 /* PMUR1 */
102 #define VB_EN                   (7)
103 #define BG_EN                   (6)
104 #define BG_IBIAS_EN             (5)
105 #define VCM_EN                  (4)
106 #define VCM_BUF_EN              (3)
107 #define VBO_EN                  (2)
108 #define MICBIAS_EN              (1)
109 #define AUXMICBIAS_EN           (0)
110
111 /* PMUR2 */
112 #define PA_SW_EN                (7)
113 #define PA_LDO_EN               (6)
114 #define PA_EN                   (5)
115 #define PAR_SW_EN               (4)
116 #define PAR_LDO_EN              (3)
117 #define PAR_EN                  (2)
118 #define OVP_PD                  (1)
119 #define OVP_LDO_EN              (0)
120
121 #define LDO_V_29                (0)
122 #define LDO_V_31                (1)
123 #define LDO_V_32                (2)
124 #define LDO_V_33                (3)
125 #define LDO_V_34                (4)
126 #define LDO_V_35                (5)
127 #define LDO_V_36                (6)
128 #define LDO_V_38                (7)
129
130 #define MIC_LDO_V_21            (0)
131 #define MIC_LDO_V_19            (1)
132 #define MIC_LDO_V_23            (2)
133 #define MIC_LDO_V_25            (3)
134
135 /* PMUR3 */
136 #define VCM_V                   (5)
137 #define VCM_V_MASK              (0x7)
138 #define MICBIAS_V               (3)
139 #define MICBIAS_V_MASK          (0x3)
140 #define AUXMICBIAS_V            (1)
141 #define AUXMICBIAS_V_MASK       (0x3)
142
143 /* PMUR4 */
144 #define PA_SWOCP_PD             (7)
145 #define PA_LDOOCP_PD            (6)
146 #define PA_LDO_V                (3)
147 #define PA_LDO_V_MASK           (0x7)
148 #define BG_RST                  (2)
149 #define BG_I                    (0)
150 #define BG_I_MASK               (0x3)
151
152 /* PMUR6 */
153 #define PA_OVP_V                (5)
154 #define PA_OVP_V_MASK           (0x7)
155 #define PA_OVP_542              (0)
156 #define PA_OVP_527              (1)
157 #define PA_OVP_512              (2)
158 #define PA_OVP_496              (3)
159 #define PA_OVP_481              (4)
160 #define PA_OVP_465              (5)
161 #define PA_OVP_450              (6)
162 #define PA_OVP_435              (7)
163
164 /* AACR1 */
165 #define ADC_IBUF_PD             (7)
166 #define ADC_VREF1P5             (6)
167 #define ADCL_PD                 (5)
168 #define ADCL_RST                (4)
169 #define ADCR_PD                 (3)
170 #define ADCR_RST                (2)
171 #define FM_REC_EN               (1)
172
173 /* AACR2 */
174 #define ADCPGAL_PD              (7)
175 #define ADCPGAL_BYP             (6)
176 #define ADCPGAR_PD              (5)
177 #define ADCPGAR_BYP             (4)
178 #define ADCPGAL_P_EN            (3)
179 #define ADCPGAL_N_EN            (2)
180 #define ADCPGAR_P_EN            (1)
181 #define ADCPGAR_N_EN            (0)
182
183 /* AAICR1 */
184 #define MICP_ADCL               (7)
185 #define MICN_ADCL               (6)
186 #define MICP_ADCR               (5)
187 #define MICN_ADCR               (4)
188 #define HPMICP_ADCL             (3)
189 #define HPMICN_ADCL             (2)
190 #define HPMICP_ADCR             (1)
191 #define HPMICN_ADCR             (0)
192
193 /* AAICR2 */
194 #define AUXMICP_ADCL            (7)
195 #define AUXMICN_ADCL            (6)
196 #define AUXMICP_ADCR            (5)
197 #define AUXMICN_ADCR            (4)
198
199 /* AAICR3 */
200 #define AIL_ADCL                (7)
201 #define AIR_ADCL                (6)
202 #define VCM_ADCL                (5)
203 #define AIL_ADCR                (4)
204 #define AIR_ADCR                (3)
205 #define VCM_ADCR                (2)
206
207 /* DACR */
208 #define DACL_EN                 (7)
209 #define DACR_EN                 (6)
210 #define DACBUF_I                (5)
211
212 /* DAOCR1 */
213 #define ADCL_P_HPL              (7)
214 #define ADCL_N_HPR              (6)
215 #define ADCR_P_HPL              (5)
216 #define ADCR_P_HPR              (4)
217 #define DACL_P_HPL              (3)
218 #define DACL_N_HPR              (2)
219 #define DACR_P_HPL              (1)
220 #define DACR_P_HPR              (0)
221
222 /* DAOCR2 */
223 #define ADCL_P_AOLP             (7)
224 #define ADCL_N_AOLN             (6)
225 #define ADCR_P_AOLP             (5)
226 #define ADCR_N_AOLN             (4)
227 #define DACL_P_AOLP             (3)
228 #define DACL_N_AOLN             (2)
229 #define DACR_P_AOLP             (1)
230 #define DACR_N_AOLN             (0)
231
232 /* DAOCR3 */
233 #define ADCL_P_AORP             (7)
234 #define ADCL_N_AORN             (6)
235 #define ADCR_P_AORP             (5)
236 #define ADCR_N_AORN             (4)
237 #define DACL_P_AORP             (3)
238 #define DACL_N_AORN             (2)
239 #define DACR_P_AORP             (1)
240 #define DACR_N_AORN             (0)
241
242 /* DAOCR4 */
243 #define DACL_P_EARP             (7)
244 #define DACL_N_EARN             (6)
245
246 /* DCR1 */
247 #define HPL_EN                  (7)
248 #define HPR_EN                  (6)
249 #define EAR_EN                  (5)
250 #define AOL_EN                  (4)
251 #define AOR_EN                  (3)
252 #define DIFF_EN                 (2)
253
254 /* DCR2 */
255 #define PA_D_EN                 (7)
256 #define PA_DTRI_F               (5)
257 #define PA_DTRI_F_MASK          (0x03)
258 #define PA_DEMI_EN              (4)
259 #define PA_SS_EN                (3)
260 #define PA_SS_RST               (2)
261 #define DRV_STOP_EN             (1)
262
263 /* DCR3 */
264 #define DRV_OCP_AOL_PD          (7)
265 #define DRV_OCP_AOR_PD          (6)
266 #define DRV_OCP_EAR_PD          (5)
267 #define DRV_OCP_HP_PD           (4)
268
269 /* PNRCR1 */
270 #define HP_POP_CTL              (6)
271 #define HP_POP_CTL_MASK         (0x03)
272 #define HP_POP_CTL_DIS          (0)
273 #define HP_POP_CTL_UP           (1)
274 #define HP_POP_CTL_DOWN         (2)
275 #define HP_POP_CTL_HOLD         (3)
276
277 #define HP_POP_STEP             (3)
278 #define HP_POP_STEP_MASK        (0x07)
279 #define HP_POP_STEP_012         (0)
280 #define HP_POP_STEP_025         (1)
281 #define HP_POP_STEP_05          (2)
282 #define HP_POP_STEP_1           (3)
283 #define HP_POP_STEP_2           (4)
284 #define HP_POP_STEP_4           (5)
285 #define HP_POP_STEP_8           (6)
286 #define HP_POP_STEP_16          (7)
287
288 /* CCR */
289 #define CLK_REVERSE             (7)
290 #define ADC_CLK_PD              (6)
291 #define ADC_CLK_RST             (5)
292 #define DAC_CLK_EN              (4)
293 #define DRV_CLK_EN              (3)
294
295 /* IFR1 */
296 #define HP_POP_FLG              (4)
297 #define HP_POP_FLG_MASK         (0x03)
298 #define HP_POP_FLG_NEAR_CMP     (3)
299 #define OVP_FLAG                (2)
300
301 #define SPRD_CODEC_DP_BASE (CODEC_DP_BASE)
302
303 #define AUD_TOP_CTL             (SPRD_CODEC_DP_BASE + 0x0000)
304 #define AUD_AUD_CTL             (SPRD_CODEC_DP_BASE + 0x0004)
305 #define AUD_I2S_CTL             (SPRD_CODEC_DP_BASE + 0x0008)
306 #define AUD_DAC_CTL             (SPRD_CODEC_DP_BASE + 0x000C)
307 #define AUD_SDM_CTL0            (SPRD_CODEC_DP_BASE + 0x0010)
308 #define AUD_SDM_CTL1            (SPRD_CODEC_DP_BASE + 0x0014)
309 #define AUD_ADC_CTL             (SPRD_CODEC_DP_BASE + 0x0018)
310 #define AUD_LOOP_CTL            (SPRD_CODEC_DP_BASE + 0x001C)
311 #define AUD_AUD_STS0            (SPRD_CODEC_DP_BASE + 0x0020)
312 #define AUD_INT_CLR             (SPRD_CODEC_DP_BASE + 0x0024)
313 #define AUD_INT_EN              (SPRD_CODEC_DP_BASE + 0x0028)
314
315 #define SPRD_CODEC_DP_END       (SPRD_CODEC_DP_BASE + 0x002C)
316 #define IS_SPRD_CODEC_DP_RANG(reg) (((reg) >= SPRD_CODEC_DP_BASE) && ((reg) < SPRD_CODEC_DP_END))
317
318 #define SPRD_CODEC_AP_BASE (CODEC_AP_BASE)
319
320 #define AUDIF_ENB               (SPRD_CODEC_AP_BASE + 0x0000)
321 #define AUDIF_CLR               (SPRD_CODEC_AP_BASE + 0x0004)
322 #define AUDIF_SYNC_CTL          (SPRD_CODEC_AP_BASE + 0x0008)
323 #define AUDIF_OCPTMR_CTL        (SPRD_CODEC_AP_BASE + 0x000C)
324 #define AUDIF_OTPTMR_CTL        (SPRD_CODEC_AP_BASE + 0x0010)
325 #define AUDIF_SHUTDOWN_CTL      (SPRD_CODEC_AP_BASE + 0x0014)
326 #define AUDIF_INT_EN            (SPRD_CODEC_AP_BASE + 0x0018)
327 #define AUDIF_INT_CLR           (SPRD_CODEC_AP_BASE + 0x001C)
328 #define AUDIF_INT_RAW           (SPRD_CODEC_AP_BASE + 0x0020)
329 #define AUDIF_INT_MASK          (SPRD_CODEC_AP_BASE + 0x0024)
330 #define AUDIF_OVPTMR_CTL        (SPRD_CODEC_AP_BASE + 0x0028)
331 /* 0x002C ~ 0x003C is reserved for ADIE digital part */
332
333 #define PMUR1                   (SPRD_CODEC_AP_BASE + 0x0040)
334 #define PMUR2                   (SPRD_CODEC_AP_BASE + 0x0044)
335 #define PMUR3                   (SPRD_CODEC_AP_BASE + 0x0048)
336 #define PMUR4                   (SPRD_CODEC_AP_BASE + 0x004C)
337 #define PMUR5                   (SPRD_CODEC_AP_BASE + 0x0050)
338 #define PMUR6                   (SPRD_CODEC_AP_BASE + 0x0054)
339
340 #define HIBDR                   (SPRD_CODEC_AP_BASE + 0x0058)
341
342 #define AACR1                   (SPRD_CODEC_AP_BASE + 0x005C)
343 #define AACR2                   (SPRD_CODEC_AP_BASE + 0x0060)
344 #define AAICR1                  (SPRD_CODEC_AP_BASE + 0x0064)
345 #define AAICR2                  (SPRD_CODEC_AP_BASE + 0x0068)
346 #define AAICR3                  (SPRD_CODEC_AP_BASE + 0x006C)
347 #define ACGR                    (SPRD_CODEC_AP_BASE + 0x0070)
348
349 #define DACR                    (SPRD_CODEC_AP_BASE + 0x0074)
350 #define DAOCR1                  (SPRD_CODEC_AP_BASE + 0x0078)
351 #define DAOCR2                  (SPRD_CODEC_AP_BASE + 0x007C)
352 #define DAOCR3                  (SPRD_CODEC_AP_BASE + 0x0080)
353 #define DAOCR4                  (SPRD_CODEC_AP_BASE + 0x00BC)
354 #define DCR1                    (SPRD_CODEC_AP_BASE + 0x0084)
355 #define DCR2                    (SPRD_CODEC_AP_BASE + 0x0088)
356 #define DCR3                    (SPRD_CODEC_AP_BASE + 0x008C)
357 #define DCR4                    (SPRD_CODEC_AP_BASE + 0x0090)
358 #define DCGR1                   (SPRD_CODEC_AP_BASE + 0x0094)
359 #define DCGR2                   (SPRD_CODEC_AP_BASE + 0x0098)
360 #define DCGR3                   (SPRD_CODEC_AP_BASE + 0x009C)
361
362 #define PNRCR1                  (SPRD_CODEC_AP_BASE + 0x00A0)
363 #define PNRCR2                  (SPRD_CODEC_AP_BASE + 0x00A4)
364 #define PNRCR3                  (SPRD_CODEC_AP_BASE + 0x00A8)
365
366 #define CCR                     (SPRD_CODEC_AP_BASE + 0x00AC)
367
368 #define IFR1                    (SPRD_CODEC_AP_BASE + 0x00B0)
369 #define IFR2                    (SPRD_CODEC_AP_BASE + 0x00B4)
370 #define IFR3                    (SPRD_CODEC_AP_BASE + 0x00B8)
371
372 #define SPRD_CODEC_AP_END       (SPRD_CODEC_AP_BASE + 0x00C0)
373 #define IS_SPRD_CODEC_AP_RANG(reg) (((reg) >= SPRD_CODEC_AP_BASE) && ((reg) < SPRD_CODEC_AP_END))
374
375 #endif /* __SPRD_CODEC_H */