Commit FS#11364 by me. Increases the A3525v2 volume range by 7.5dB. Each volume...
[kugel-rb.git] / firmware / export / as3514.h
blobffcf9186e773243a2611f7244e43bb6a5e4311e2
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 by Daniel Ankers
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef _AS3514_H
23 #define _AS3514_H
25 #include "config.h"
27 extern int tenthdb2master(int db);
29 extern void audiohw_set_master_vol(int vol_l, int vol_r);
30 extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
32 /* Register Descriptions */
34 #ifndef HAVE_AS3543
35 #define AS3514_LINE_OUT_R 0x00
36 #define AS3514_LINE_OUT_L 0x01
37 #endif
39 #define AS3514_HPH_OUT_R 0x02
40 #define AS3514_HPH_OUT_L 0x03
42 #ifndef HAVE_AS3543
43 #define AS3514_LSP_OUT_R 0x04
44 #define AS3514_LSP_OUT_L 0x05
45 #endif
47 #define AS3514_MIC1_R 0x06
48 #define AS3514_MIC1_L 0x07
50 #ifndef HAVE_AS3543
51 #define AS3514_MIC2_R 0x08
52 #define AS3514_MIC2_L 0x09
53 #endif
55 #define AS3514_LINE_IN1_R 0x0a
56 #define AS3514_LINE_IN1_L 0x0b
58 #ifndef HAVE_AS3543
59 #define AS3514_LINE_IN2_R 0x0c
60 #define AS3514_LINE_IN2_L 0x0d
61 #endif
63 #define AS3514_DAC_R 0x0e
64 #define AS3514_DAC_L 0x0f
65 #define AS3514_ADC_R 0x10
66 #define AS3514_ADC_L 0x11
68 #ifdef HAVE_AS3543
69 #define AS3543_DAC_IF 0x12
70 #endif
72 #define AS3514_AUDIOSET1 0x14
73 #define AS3514_AUDIOSET2 0x15
74 #define AS3514_AUDIOSET3 0x16
75 #define AS3515_USB_UTIL 0x17 /* only in as3515 */
77 #ifdef HAVE_AS3543
78 #define AS3543_BACKLIGHT 0x1b
79 #define AS3543_PMU_ENABLE 0x1c
80 #endif
82 #ifndef HAVE_AS3543
83 #define AS3514_PLLMODE 0x1d
84 #endif
86 #ifdef HAVE_AS3543
87 #define AS3543_CHARGER 0x19 /* PMU: 2 sub registers */
88 #endif
90 #define AS3514_SYSTEM 0x20
91 #define AS3514_CVDD_DCDC3 0x21
93 #ifndef HAVE_AS3543
94 #define AS3514_CHARGER 0x22
95 #define AS3514_DCDC15 0x23
96 #define AS3514_SUPERVISOR 0x24
97 #endif
99 #ifdef HAVE_AS3543
100 #define AS3543_WAKEUP 0x22
101 #endif
103 /* AS3543 has 2 IRQ_ENRD registers at 0x23 and 0x24, but we don't use them
104 * We call the real IRQ_ENRD2 register, IRQ_ENRD0, to stay compatible with
105 * as3514, because the bits we use are the same
107 #define AS3514_IRQ_ENRD0 0x25
108 #define AS3514_IRQ_ENRD1 0x26
109 #define AS3514_IRQ_ENRD2 0x27
111 #define AS3514_RTCV 0x28
112 #define AS3514_RTCT 0x29
113 #define AS3514_RTC_0 0x2a
114 #define AS3514_RTC_1 0x2b
115 #define AS3514_RTC_2 0x2c
116 #define AS3514_RTC_3 0x2d
117 #define AS3514_ADC_0 0x2e
118 #define AS3514_ADC_1 0x2f
120 #define AS3514_UID_0 0x30
122 /*different volume ranges for different AMS chips*/
123 #if CONFIG_CPU == AS3525v2
124 /* Headphone volume goes from -81.0 ... +6dB */
125 #define VOLUME_MIN -810
126 #else
127 /* Headphone volume goes from -73.5 ... +6dB */
128 #define VOLUME_MIN -735
129 #endif
130 #define VOLUME_MAX 60
132 /*** Audio Registers ***/
134 /* 00h (LINE_OUT_R) to 16h (AUDIOSET3) */
135 #define AS3514_NUM_AUDIO_REGS (0x17)
137 /* Common registers masks */
138 #define AS3514_VOL_MASK (0x1f << 0)
140 /* LINE_OUT_R (0x00) */
141 /* Only has volume control bits */
143 /* LINE_OUT_L (0x01) */
144 #define LINE_OUT_L_LO_SES_DM (0x3 << 6)
145 #define LINE_OUT_L_LO_SES_DM_MUTE (0x0 << 6)
146 #define LINE_OUT_L_LO_SES_DM_DF_MO (0x1 << 6)
147 #define LINE_OUT_L_LO_SES_DM_SE_ST (0x2 << 6)
148 /* Use AS3514_VOL_MASK */
150 /* HPH_OUT_R (0x02) */
151 #define HPH_OUT_R_HP_OVC_TO (0x3 << 6)
152 /* AS3514/AS3515 */
153 #define HPH_OUT_R_HP_OVC_TO_0MS (0x3 << 6)
154 #define HPH_OUT_R_HP_OVC_TO_128MS (0x1 << 6)
155 #define HPH_OUT_R_HP_OVC_TO_256MS (0x0 << 6)
156 #define HPH_OUT_R_HP_OVC_TO_512MS (0x2 << 6)
157 /* AS3543 */
158 #define HPH_OUT_R_LINEOUT (0x1 << 7)
159 #define HPH_OUT_R_HEADPHONES (0x0 << 7)
160 #define HPH_OUT_R_HP_OUT_SUM (0x0 << 5)
161 #define HPH_OUT_R_HP_OUT_DAC (0x1 << 5)
162 #define HPH_OUT_R_HP_OUT_LINE (0x2 << 5)
163 #define HPH_OUT_R_HP_OUT_MIC (0x3 << 5)
164 #define HPH_OUT_R_HP_OUT_MASK (0x3 << 5)
165 /* Use AS3514_VOL_MASK */
167 /* HPH_OUT_L (0x03) */
168 #define HPH_OUT_L_HP_MUTE (0x1 << 7)
169 #define HPH_OUT_L_HP_ON (0x1 << 6)
170 #define HPH_OUT_L_HP_DET_ON (0x1 << 5)
171 /* Use AS3514_VOL_MASK */
173 /* LSP_OUT_R (0x04) */
174 #define LSP_OUT_R_SP_OVC_TO (0x3 << 6)
175 #define LSP_OUT_R_SP_OVC_TO_256MS (0x0 << 6)
176 #define LSP_OUT_R_SP_OVC_TO_128MS (0x1 << 6)
177 #define LSP_OUT_R_SP_OVC_TO_512MS (0x2 << 6)
178 #define LSP_OUT_R_SP_OVC_TO_0MS (0x3 << 6)
179 /* Use AS3514_VOL_MASK */
181 /* LSP_OUT_L (0x05) */
182 #define LSP_OUT_L_SP_MUTE (0x1 << 7)
183 #define LSP_OUT_L_SP_ON (0x1 << 6)
184 /* Use AS3514_VOL_MASK */
186 /* MIC1_R (0x06) */
187 #define MIC1_R_M1_AGC_off (0x1 << 7)
188 #define MIC1_R_M1_GAIN (0x3 << 5)
189 #define MIC1_R_M1_GAIN_28DB (0x0 << 5)
190 #define MIC1_R_M1_GAIN_34DB (0x1 << 5)
191 #define MIC1_R_M1_GAIN_40DB (0x2 << 5)
192 /* Use AS3514_VOL_MASK */
194 /* MIC1_L (0x07) */
195 #define MIC1_L_M1_SUP_off (0x1 << 7)
196 #define MIC1_L_M1_MUTE_off (0x1 << 6)
197 /* Use AS3514_VOL_MASK */
199 /* MIC2_R (0x08) */
200 #define MIC2_R_M2_AGC_off (0x1 << 7)
201 #define MIC2_R_M2_GAIN (0x3 << 5)
202 #define MIC2_R_M2_GAIN_28DB (0x0 << 5)
203 #define MIC2_R_M2_GAIN_34DB (0x1 << 5)
204 #define MIC2_R_M2_GAIN_40DB (0x2 << 5)
205 /* Use AS3514_VOL_MASK */
207 /* MIC2_L (0x09) */
208 #define MIC2_L_M2_SUP_off (0x1 << 7)
209 #define MIC2_L_M2_MUTE_off (0x1 << 6)
210 /* Use AS3514_VOL_MASK */
212 /* LINE_IN1_R (0Ah) */
213 #ifdef HAVE_AS3543
214 #define LINE_IN_R_LINE_SELECT (0x1 << 6)
215 #endif
216 #define LINE_IN1_R_LI1R_MUTE_off (0x1 << 5)
217 /* Use AS3514_VOL_MASK */
219 /* LINE_IN1_L (0Bh) */
220 #define LINE_IN1_L_LI1_MODE (0x3 << 6)
221 #define LINE_IN1_L_LI1_MODE_SE_ST (0x0 << 6)
222 #define LINE_IN1_L_LI1_MODE_DF_MO (0x1 << 6)
223 #define LINE_IN1_L_LI1_MODE_SE_MO (0x2 << 6)
224 #define LINE_IN1_L_LI1L_MUTE_off (0x1 << 5)
225 /* Use AS3514_VOL_MASK */
227 /* LINE_IN2_R (0Ch) */
228 #define LINE_IN2_R_LI2R_MUTE_off (0x1 << 5)
229 /* Use AS3514_VOL_MASK */
231 /* LINE_IN2_L (0Dh) */
232 #define LINE_IN2_L_LI2_MODE (0x3 << 6)
233 #define LINE_IN2_L_LI2_MODE_SE_ST (0x0 << 6)
234 #define LINE_IN2_L_LI2_MODE_DF_MO (0x1 << 6)
235 #define LINE_IN2_L_LI2_MODE_SE_MO (0x2 << 6)
236 #define LINE_IN2_L_LI2L_MUTE_off (0x1 << 5)
237 /* Use AS3514_VOL_MASK */
239 /* DAC_R (0Eh) */
240 /* Only has volume control bits */
241 /* Use AS3514_VOL_MASK */
243 /* DAC_L (0Fh) */
244 #ifdef HAVE_AS3543
245 #define DAC_L_DAC_MUTE_off (0x1 << 5)
246 #else
247 #define DAC_L_DAC_MUTE_off (0x1 << 6)
248 #endif
249 /* Use AS3514_VOL_MASK */
251 /* ADC_R (10h) */
252 #define ADC_R_ADCMUX (0x3 << 6)
253 #define ADC_R_ADCMUX_ST_MIC (0x0 << 6)
254 #define ADC_R_ADCMUX_LINE_IN1 (0x1 << 6)
255 #define ADC_R_ADCMUX_LINE_IN2 (0x2 << 6)
256 #define ADC_R_ADCMUX_AUDIO_SUM (0x3 << 6)
257 /* Use AS3514_VOL_MASK */
259 /* ADC_L (11h) */
260 #ifdef HAVE_AS3543
261 #define ADC_L_ADC_MUTE_off (0x1 << 5)
262 #else
263 #define ADC_L_FS_2 (0x1 << 7)
264 #define ADC_L_ADC_MUTE_off (0x1 << 6)
265 #endif
266 /* Use AS3514_VOL_MASK */
268 /* DAC_IF (11h) */
269 #ifdef HAVE_AS3543
270 #define AS3543_DAC_INT_PLL (0x0 << 7)
271 #define AS3543_DAC_EXT_MCLK (0x1 << 7)
272 #endif
274 /* AUDIOSET1 (14h)*/
275 #ifdef HAVE_AS3543
276 #define AUDIOSET1_DAC_on (0x1 << 6)
277 #define AUDIOSET1_DAC_GAIN_on (0x1 << 5)
278 #else
279 #define AUDIOSET1_SUM_on (0x1 << 6)
280 #define AUDIOSET1_DAC_on (0x1 << 5)
281 #define AUDIOSET1_LOUT_on (0x1 << 4)
282 #endif /* HAVE_AS3543 */
283 /* common bits */
284 #define AUDIOSET1_ADC_on (0x1 << 7)
285 #define AUDIOSET1_LIN2_on (0x1 << 3)
286 #define AUDIOSET1_LIN1_on (0x1 << 2)
287 #define AUDIOSET1_MIC2_on (0x1 << 1)
288 #define AUDIOSET1_MIC1_on (0x1 << 0)
290 #define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \
291 AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on
294 /* AUDIOSET2 (15h) */
295 #ifdef HAVE_AS3543
296 #define AUDIOSET2_HPH_QUALITY_LOW_POWER (0x0 << 4)
297 #define AUDIOSET2_HPH_QUALITY_HIGH (0x1 << 4)
298 #else
299 #define AUDIOSET2_BIAS_off (0x1 << 7)
300 #define AUDIOSET2_DITH_off (0x1 << 6)
301 #define AUDIOSET2_AGC_off (0x1 << 5)
302 #define AUDIOSET2_IBR_DAC (0x3 << 3)
303 #define AUDIOSET2_IBR_DAC_0 (0x0 << 3)
304 #define AUDIOSET2_IBR_DAC_25 (0x1 << 3)
305 #define AUDIOSET2_IBR_DAC_40 (0x2 << 3)
306 #define AUDIOSET2_IBR_DAC_50 (0x3 << 3)
307 #define AUDIOSET2_LSP_LP (0x1 << 2)
308 #define AUDIOSET2_IBR_LSP (0x3 << 0)
309 #define AUDIOSET2_IBR_LSP_0 (0x0 << 0)
310 #define AUDIOSET2_IBR_LSP_17 (0x1 << 0)
311 #define AUDIOSET2_IBR_LSP_34 (0x2 << 0)
312 #define AUDIOSET2_IBR_LSP_50 (0x3 << 0)
313 #endif
315 /* AUDIOSET3 (16h) */
316 #ifdef HAVE_AS3543
317 #define AUDIOSET3_HP_FASTSTART (0x1 << 2)
318 #define AUDIOSET3_HP_LONGSTART (0x0 << 2)
319 #define AUDIOSET3_HP_BIAS_150 (0x1 << 1)
320 #define AUDIOSET3_HPCM_on (0x1 << 0)
321 #define AUDIOSET3_HPCM_off (0x0 << 0)
322 #else
323 #define AUDIOSET3_ZCU_off (0x1 << 2)
324 #define AUDIOSET3_IBR_HPH (0x1 << 1)
325 #define AUDIOSET3_HPCM_off (0x1 << 0)
326 #endif
328 /* PLLMODE (1Dh) */
329 #define PLLMODE_LRCK (0x3 << 1)
330 #define PLLMODE_LRCK_24_48 (0x0 << 1)
331 #define PLLMODE_LRCK_8_23 (0x2 << 1)
333 /* ADC channels */
334 #define NUM_ADC_CHANNELS 13
336 #define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
337 #define ADC_RTCSUP 1 /* RTC backup battery voltage */
338 #define ADC_UVDD 2 /* USB host voltage */
339 #define ADC_CHG_IN 3 /* Charger input voltage */
340 #define ADC_CVDD 4 /* Charger pump output voltage */
341 #define ADC_BATTEMP 5 /* Battery charging temperature */
342 #define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
343 or external voltage measurement */
344 #define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
345 or external voltage measurement */
346 #define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
347 #define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
348 #define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
349 #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
350 #define ADC_VBAT 12 /* Single cell battery voltage */
352 /* AS3514_CHARGER */
353 #define TMPSUP_OFF (0x1 << 7)
354 #define CHG_I (0x7 << 4)
355 #define CHG_I_400MA (0x7 << 4)
356 #define CHG_I_350MA (0x6 << 4)
357 #define CHG_I_300MA (0x5 << 4)
358 #define CHG_I_250MA (0x4 << 4)
359 #define CHG_I_200MA (0x3 << 4)
360 #define CHG_I_150MA (0x2 << 4)
361 #define CHG_I_100MA (0x1 << 4)
362 #define CHG_I_50MA (0x0 << 4)
363 #define CHG_V (0x7 << 1)
364 #define CHG_V_4_25V (0x7 << 1)
365 #define CHG_V_4_20V (0x6 << 1)
366 #define CHG_V_4_15V (0x5 << 1)
367 #define CHG_V_4_10V (0x4 << 1)
368 #define CHG_V_4_05V (0x3 << 1)
369 #define CHG_V_4_00V (0x2 << 1)
370 #define CHG_V_3_95V (0x1 << 1)
371 #define CHG_V_3_90V (0x0 << 1)
372 #define CHG_OFF (0x1 << 0)
374 /* AS3514_IRQ_ENRD0 */
375 #define CHG_TMPHIGH (0x1 << 7)
376 #define CHG_ENDOFCH (0x1 << 6)
377 #define CHG_STATUS (0x1 << 5)
378 #define CHG_CHANGED (0x1 << 4)
379 #define USB_STATUS (0x1 << 3)
380 #define USB_CHANGED (0x1 << 2)
381 #define RVDD_WASLOW (0x1 << 1)
382 #define BVDD_ISLOW (0x1 << 0)
384 #define IRQ_ENDOFCH (0x1 << 6)
385 #define IRQ_CHGSTAT (0x1 << 4)
386 #define IRQ_USBSTAT (0x1 << 2)
388 /* AS3514_IRQ_ENRD2 */
389 #define DEBOUNCE_128MS (0x2 << 6)
390 #define DEBOUNCE_256MS (0x1 << 6)
391 #define DEBOUNCE_512MS (0x0 << 6)
392 #define IRQ_HIGHACTIVE (0x1 << 5)
393 #define IRQ_PUSHPULL (0x1 << 4)
394 #define IRQ_REMDET2 (0x1 << 3)
395 #define IRQ_REMDET1 (0x1 << 2)
396 #define IRQ_RTC (0x1 << 1)
397 #define IRQ_ADC (0x1 << 0)
399 #define AS3514_I2C_ADDR 0x46
401 #endif /* _AS3514_H */