2 * sound/soc/sprd/codec/sprd/v1/sprd-codec.h
4 * SPRD-CODEC -- SpreadTrum Tiger intergrated codec.
6 * Copyright (C) 2013 SpreadTrum Ltd.
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.
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.
17 #ifndef __SPRD_CODEC_H
18 #define __SPRD_CODEC_H
20 #include <mach/hardware.h>
21 #include <mach/globalregs.h>
22 #include <mach/sprd-audio.h>
26 #ifndef CONFIG_SPRD_CODEC_USE_INT
27 /* #define CONFIG_SPRD_CODEC_USE_INT */
29 #ifndef CONFIG_CODEC_DAC_MUTE_WAIT
30 /* #define CONFIG_CODEC_DAC_MUTE_WAIT */
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)
39 #define SPRD_CODEC_DAC_MUTE_WAIT_TIME (40)
42 #ifdef CONFIG_SPRD_CODEC_USE_INT
43 #define SPRD_CODEC_HP_POP_TIMEOUT (1000)
45 #define SPRD_CODEC_HP_POP_TIME_STEP (10)
46 #define SPRD_CODEC_HP_POP_TIME_COUNT (80) /* max 800ms will timeout */
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)
68 #define DAC_MUTE_START (14)
69 #define DAC_MUTE_EN (15)
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)
81 #define DAC_MUTE_U (1)
82 #define DAC_MUTE_D (0)
85 #define AUDIFA_DAC_EN (0)
86 #define AUDIFA_ADC_EN (1)
92 #define AUDIO_POP_IRQ (7)
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)
104 #define BG_IBIAS_EN (5)
106 #define VCM_BUF_EN (3)
108 #define MICBIAS_EN (1)
109 #define AUXMICBIAS_EN (0)
113 #define PA_LDO_EN (6)
115 #define PAR_SW_EN (4)
116 #define PAR_LDO_EN (3)
119 #define OVP_LDO_EN (0)
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)
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)
144 #define PA_SWOCP_PD (7)
145 #define PA_LDOOCP_PD (6)
147 #define PA_LDO_V_MASK (0x7)
150 #define BG_I_MASK (0x3)
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)
165 #define ADC_IBUF_PD (7)
166 #define ADC_VREF1P5 (6)
171 #define FM_REC_EN (1)
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)
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)
194 #define AUXMICP_ADCL (7)
195 #define AUXMICN_ADCL (6)
196 #define AUXMICP_ADCR (5)
197 #define AUXMICN_ADCR (4)
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)
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)
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)
243 #define DACL_P_EARP (7)
244 #define DACL_N_EARN (6)
256 #define PA_DTRI_F (5)
257 #define PA_DTRI_F_MASK (0x03)
258 #define PA_DEMI_EN (4)
260 #define PA_SS_RST (2)
261 #define DRV_STOP_EN (1)
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)
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)
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)
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)
296 #define HP_POP_FLG (4)
297 #define HP_POP_FLG_MASK (0x03)
298 #define HP_POP_FLG_NEAR_CMP (3)
301 #define SPRD_CODEC_DP_BASE (CODEC_DP_BASE)
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)
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))
318 #define SPRD_CODEC_AP_BASE (CODEC_AP_BASE)
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 */
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)
340 #define HIBDR (SPRD_CODEC_AP_BASE + 0x0058)
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)
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)
362 #define PNRCR1 (SPRD_CODEC_AP_BASE + 0x00A0)
363 #define PNRCR2 (SPRD_CODEC_AP_BASE + 0x00A4)
364 #define PNRCR3 (SPRD_CODEC_AP_BASE + 0x00A8)
366 #define CCR (SPRD_CODEC_AP_BASE + 0x00AC)
368 #define IFR1 (SPRD_CODEC_AP_BASE + 0x00B0)
369 #define IFR2 (SPRD_CODEC_AP_BASE + 0x00B4)
370 #define IFR3 (SPRD_CODEC_AP_BASE + 0x00B8)
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))
375 #endif /* __SPRD_CODEC_H */