gitscraper: Provide way to get timestamps for files.
[maemo-rb.git] / firmware / export / as3514.h
blob85da14493f11e743359e4162de2ef14658efcf11
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);
31 extern void audiohw_set_sampr_dividers(int fsel);
33 /* Register Descriptions */
35 #ifndef HAVE_AS3543
36 #define AS3514_LINE_OUT_R 0x00
37 #define AS3514_LINE_OUT_L 0x01
38 #endif
40 #define AS3514_HPH_OUT_R 0x02
41 #define AS3514_HPH_OUT_L 0x03
43 #ifndef HAVE_AS3543
44 #define AS3514_LSP_OUT_R 0x04
45 #define AS3514_LSP_OUT_L 0x05
46 #endif
48 #define AS3514_MIC1_R 0x06
49 #define AS3514_MIC1_L 0x07
51 #ifndef HAVE_AS3543
52 #define AS3514_MIC2_R 0x08
53 #define AS3514_MIC2_L 0x09
54 #endif
56 #define AS3514_LINE_IN1_R 0x0a
57 #define AS3514_LINE_IN1_L 0x0b
59 #ifndef HAVE_AS3543
60 #define AS3514_LINE_IN2_R 0x0c
61 #define AS3514_LINE_IN2_L 0x0d
62 #endif
64 #define AS3514_DAC_R 0x0e
65 #define AS3514_DAC_L 0x0f
66 #define AS3514_ADC_R 0x10
67 #define AS3514_ADC_L 0x11
69 #ifdef HAVE_AS3543
70 #define AS3543_DAC_IF 0x12
71 #endif
73 #define AS3514_AUDIOSET1 0x14
74 #define AS3514_AUDIOSET2 0x15
75 #define AS3514_AUDIOSET3 0x16
76 #define AS3515_USB_UTIL 0x17 /* only in as3515 */
78 #ifdef HAVE_AS3543
79 #define AS3543_BACKLIGHT 0x1b
80 #define AS3543_PMU_ENABLE 0x1c
81 #endif
83 #ifndef HAVE_AS3543
84 #define AS3514_PLLMODE 0x1d
85 #endif
87 #ifdef HAVE_AS3543
88 #define AS3543_CHARGER 0x19 /* PMU: 2 sub registers */
89 #endif
91 #define AS3514_SYSTEM 0x20
93 #ifndef HAVE_AS3543
94 #define AS3514_CVDD_DCDC3 0x21
95 #define AS3514_CHARGER 0x22
96 #define AS3514_DCDC15 0x23
97 #define AS3514_SUPERVISOR 0x24
98 #endif
100 #ifdef HAVE_AS3543
101 #define AS3543_WAKEUP 0x22
102 #endif
104 /* AS3543 has 2 IRQ_ENRD registers at 0x23 and 0x24, but we don't use them
105 * We call the real IRQ_ENRD2 register, IRQ_ENRD0, to stay compatible with
106 * as3514, because the bits we use are the same
108 #define AS3514_IRQ_ENRD0 0x25
109 #define AS3514_IRQ_ENRD1 0x26
110 #define AS3514_IRQ_ENRD2 0x27
112 #define AS3514_RTCV 0x28
113 #define AS3514_RTCT 0x29
114 #define AS3514_RTC_0 0x2a
115 #define AS3514_RTC_1 0x2b
116 #define AS3514_RTC_2 0x2c
117 #define AS3514_RTC_3 0x2d
118 #define AS3514_ADC_0 0x2e
119 #define AS3514_ADC_1 0x2f
121 #ifdef HAVE_AS3543
122 #define AS3514_UID_0 0x38
123 #define AS3514_UID_LEN 8
124 #else
125 #define AS3514_UID_0 0x30
126 #define AS3514_UID_LEN 16
127 #endif
129 /*different volume ranges for different AMS chips*/
130 #if CONFIG_CPU == AS3525v2
131 /* Headphone volume goes from -81.0 ... +6dB */
132 #define VOLUME_MIN -810
133 #else
134 /* Headphone volume goes from -73.5 ... +6dB */
135 #define VOLUME_MIN -735
136 #endif
137 #define VOLUME_MAX 60
139 /*** Audio Registers ***/
141 /* 00h (LINE_OUT_R) to 16h (AUDIOSET3) */
142 #define AS3514_NUM_AUDIO_REGS (0x17)
144 /* Common registers masks */
145 #define AS3514_VOL_MASK (0x1f << 0)
147 /* LINE_OUT_R (0x00) */
148 /* Only has volume control bits */
150 /* LINE_OUT_L (0x01) */
151 #define LINE_OUT_L_LO_SES_DM (0x3 << 6)
152 #define LINE_OUT_L_LO_SES_DM_MUTE (0x0 << 6)
153 #define LINE_OUT_L_LO_SES_DM_DF_MO (0x1 << 6)
154 #define LINE_OUT_L_LO_SES_DM_SE_ST (0x2 << 6)
155 /* Use AS3514_VOL_MASK */
157 /* HPH_OUT_R (0x02) */
158 #define HPH_OUT_R_HP_OVC_TO (0x3 << 6)
159 /* AS3514/AS3515 */
160 #define HPH_OUT_R_HP_OVC_TO_0MS (0x3 << 6)
161 #define HPH_OUT_R_HP_OVC_TO_128MS (0x1 << 6)
162 #define HPH_OUT_R_HP_OVC_TO_256MS (0x0 << 6)
163 #define HPH_OUT_R_HP_OVC_TO_512MS (0x2 << 6)
164 /* AS3543 */
165 #define HPH_OUT_R_LINEOUT (0x1 << 7)
166 #define HPH_OUT_R_HEADPHONES (0x0 << 7)
167 #define HPH_OUT_R_HP_OUT_SUM (0x0 << 5)
168 #define HPH_OUT_R_HP_OUT_DAC (0x1 << 5)
169 #define HPH_OUT_R_HP_OUT_LINE (0x2 << 5)
170 #define HPH_OUT_R_HP_OUT_MIC (0x3 << 5)
171 #define HPH_OUT_R_HP_OUT_MASK (0x3 << 5)
172 /* Use AS3514_VOL_MASK */
174 /* HPH_OUT_L (0x03) */
175 #define HPH_OUT_L_HP_MUTE (0x1 << 7)
176 #define HPH_OUT_L_HP_ON (0x1 << 6)
177 #define HPH_OUT_L_HP_DET_ON (0x1 << 5)
178 /* Use AS3514_VOL_MASK */
180 /* LSP_OUT_R (0x04) */
181 #define LSP_OUT_R_SP_OVC_TO (0x3 << 6)
182 #define LSP_OUT_R_SP_OVC_TO_256MS (0x0 << 6)
183 #define LSP_OUT_R_SP_OVC_TO_128MS (0x1 << 6)
184 #define LSP_OUT_R_SP_OVC_TO_512MS (0x2 << 6)
185 #define LSP_OUT_R_SP_OVC_TO_0MS (0x3 << 6)
186 /* Use AS3514_VOL_MASK */
188 /* LSP_OUT_L (0x05) */
189 #define LSP_OUT_L_SP_MUTE (0x1 << 7)
190 #define LSP_OUT_L_SP_ON (0x1 << 6)
191 /* Use AS3514_VOL_MASK */
193 /* MIC1_R (0x06) */
194 #define MIC1_R_M1_AGC_off (0x1 << 7)
195 #define MIC1_R_M1_GAIN (0x3 << 5)
196 #define MIC1_R_M1_GAIN_28DB (0x0 << 5)
197 #define MIC1_R_M1_GAIN_34DB (0x1 << 5)
198 #define MIC1_R_M1_GAIN_40DB (0x2 << 5)
199 /* Use AS3514_VOL_MASK */
201 /* MIC1_L (0x07) */
202 #define MIC1_L_M1_SUP_off (0x1 << 7)
203 #define MIC1_L_M1_MUTE_off (0x1 << 6)
204 /* Use AS3514_VOL_MASK */
206 /* MIC2_R (0x08) */
207 #define MIC2_R_M2_AGC_off (0x1 << 7)
208 #define MIC2_R_M2_GAIN (0x3 << 5)
209 #define MIC2_R_M2_GAIN_28DB (0x0 << 5)
210 #define MIC2_R_M2_GAIN_34DB (0x1 << 5)
211 #define MIC2_R_M2_GAIN_40DB (0x2 << 5)
212 /* Use AS3514_VOL_MASK */
214 /* MIC2_L (0x09) */
215 #define MIC2_L_M2_SUP_off (0x1 << 7)
216 #define MIC2_L_M2_MUTE_off (0x1 << 6)
217 /* Use AS3514_VOL_MASK */
219 /* LINE_IN1_R (0Ah) */
220 #ifdef HAVE_AS3543
221 #define LINE_IN_R_LINE_SELECT (0x1 << 6)
222 #endif
223 #define LINE_IN1_R_LI1R_MUTE_off (0x1 << 5)
224 /* Use AS3514_VOL_MASK */
226 /* LINE_IN1_L (0Bh) */
227 #define LINE_IN1_L_LI1_MODE (0x3 << 6)
228 #define LINE_IN1_L_LI1_MODE_SE_ST (0x0 << 6)
229 #define LINE_IN1_L_LI1_MODE_DF_MO (0x1 << 6)
230 #define LINE_IN1_L_LI1_MODE_SE_MO (0x2 << 6)
231 #define LINE_IN1_L_LI1L_MUTE_off (0x1 << 5)
232 /* Use AS3514_VOL_MASK */
234 /* LINE_IN2_R (0Ch) */
235 #define LINE_IN2_R_LI2R_MUTE_off (0x1 << 5)
236 /* Use AS3514_VOL_MASK */
238 /* LINE_IN2_L (0Dh) */
239 #define LINE_IN2_L_LI2_MODE (0x3 << 6)
240 #define LINE_IN2_L_LI2_MODE_SE_ST (0x0 << 6)
241 #define LINE_IN2_L_LI2_MODE_DF_MO (0x1 << 6)
242 #define LINE_IN2_L_LI2_MODE_SE_MO (0x2 << 6)
243 #define LINE_IN2_L_LI2L_MUTE_off (0x1 << 5)
244 /* Use AS3514_VOL_MASK */
246 /* DAC_R (0Eh) */
247 /* Only has volume control bits */
248 /* Use AS3514_VOL_MASK */
250 /* DAC_L (0Fh) */
251 #ifdef HAVE_AS3543
252 #define DAC_L_DAC_MUTE_off (0x1 << 5)
253 #else
254 #define DAC_L_DAC_MUTE_off (0x1 << 6)
255 #endif
256 /* Use AS3514_VOL_MASK */
258 /* ADC_R (10h) */
259 #define ADC_R_ADCMUX (0x3 << 6)
260 #define ADC_R_ADCMUX_ST_MIC (0x0 << 6)
261 #define ADC_R_ADCMUX_LINE_IN1 (0x1 << 6)
262 #define ADC_R_ADCMUX_LINE_IN2 (0x2 << 6)
263 #define ADC_R_ADCMUX_AUDIO_SUM (0x3 << 6)
264 /* Use AS3514_VOL_MASK */
266 /* ADC_L (11h) */
267 #ifdef HAVE_AS3543
268 #define ADC_L_ADC_MUTE_off (0x1 << 5)
269 #else
270 #define ADC_L_FS_2 (0x1 << 7)
271 #define ADC_L_ADC_MUTE_off (0x1 << 6)
272 #endif
273 /* Use AS3514_VOL_MASK */
275 /* DAC_IF (11h) */
276 #ifdef HAVE_AS3543
277 #define AS3543_DAC_INT_PLL (0x0 << 7)
278 #define AS3543_DAC_EXT_MCLK (0x1 << 7)
279 #endif
281 /* AUDIOSET1 (14h)*/
282 #ifdef HAVE_AS3543
283 #define AUDIOSET1_DAC_on (0x1 << 6)
284 #define AUDIOSET1_DAC_GAIN_on (0x1 << 5)
285 #else
286 #define AUDIOSET1_SUM_on (0x1 << 6)
287 #define AUDIOSET1_DAC_on (0x1 << 5)
288 #define AUDIOSET1_LOUT_on (0x1 << 4)
289 #endif /* HAVE_AS3543 */
290 /* common bits */
291 #define AUDIOSET1_ADC_on (0x1 << 7)
292 #define AUDIOSET1_LIN2_on (0x1 << 3)
293 #define AUDIOSET1_LIN1_on (0x1 << 2)
294 #define AUDIOSET1_MIC2_on (0x1 << 1)
295 #define AUDIOSET1_MIC1_on (0x1 << 0)
297 #define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \
298 AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on
301 /* AUDIOSET2 (15h) */
302 #ifdef HAVE_AS3543
303 #define AUDIOSET2_BIAS_on (0x0 << 7)
304 #define AUDIOSET2_BIAS_off (0x1 << 7)
305 #define AUDIOSET2_SUM_off (0x1 << 6)
306 #define AUDIOSET2_AGC_off (0x1 << 5)
307 #define AUDIOSET2_HPH_QUALITY_LOW_POWER (0x0 << 4)
308 #define AUDIOSET2_HPH_QUALITY_HIGH (0x1 << 4)
309 #else
310 #define AUDIOSET2_BIAS_off (0x1 << 7)
311 #define AUDIOSET2_DITH_off (0x1 << 6)
312 #define AUDIOSET2_AGC_off (0x1 << 5)
313 #define AUDIOSET2_IBR_DAC (0x3 << 3)
314 #define AUDIOSET2_IBR_DAC_0 (0x0 << 3)
315 #define AUDIOSET2_IBR_DAC_25 (0x1 << 3)
316 #define AUDIOSET2_IBR_DAC_40 (0x2 << 3)
317 #define AUDIOSET2_IBR_DAC_50 (0x3 << 3)
318 #define AUDIOSET2_LSP_LP (0x1 << 2)
319 #define AUDIOSET2_IBR_LSP (0x3 << 0)
320 #define AUDIOSET2_IBR_LSP_0 (0x0 << 0)
321 #define AUDIOSET2_IBR_LSP_17 (0x1 << 0)
322 #define AUDIOSET2_IBR_LSP_34 (0x2 << 0)
323 #define AUDIOSET2_IBR_LSP_50 (0x3 << 0)
324 #endif
326 /* AUDIOSET3 (16h) */
327 #ifdef HAVE_AS3543
328 #define AUDIOSET3_HP_FASTSTART (0x1 << 2)
329 #define AUDIOSET3_HP_LONGSTART (0x0 << 2)
330 #define AUDIOSET3_HP_BIAS_150 (0x1 << 1)
331 #define AUDIOSET3_HPCM_on (0x1 << 0)
332 #define AUDIOSET3_HPCM_off (0x0 << 0)
333 #else
334 #define AUDIOSET3_ZCU_off (0x1 << 2)
335 #define AUDIOSET3_IBR_HPH (0x1 << 1)
336 #define AUDIOSET3_HPCM_off (0x1 << 0)
337 #endif
339 /* PLLMODE (1Dh) */
340 #define PLLMODE_LRCK (0x3 << 1)
341 #define PLLMODE_LRCK_24_48 (0x0 << 1)
342 #define PLLMODE_LRCK_8_23 (0x2 << 1)
344 /* ADC channels */
345 #define NUM_ADC_CHANNELS 13
347 #define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
348 #define ADC_RTCSUP 1 /* RTC backup battery voltage */
349 #define ADC_UVDD 2 /* USB host voltage */
350 #define ADC_CHG_IN 3 /* Charger input voltage */
351 #define ADC_CVDD 4 /* Charger pump output voltage */
352 #define ADC_BATTEMP 5 /* Battery charging temperature */
353 #define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
354 or external voltage measurement */
355 #define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
356 or external voltage measurement */
357 #define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
358 #define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
359 #define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
360 #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
361 #define ADC_VBAT 12 /* Single cell battery voltage */
363 /* AS3514_CHARGER */
364 #define TMPSUP_OFF (0x1 << 7)
365 #define CHG_I (0x7 << 4)
366 #ifdef HAVE_AS3543 /* AS3543 uses charge current steps of 70 mA */
367 #define CHG_I_55MA (0x0 << 4)
368 #define CHG_I_70MA (0x1 << 4)
369 #define CHG_I_140MA (0x2 << 4)
370 #define CHG_I_210MA (0x3 << 4)
371 #define CHG_I_280MA (0x4 << 4)
372 #define CHG_I_350MA (0x5 << 4)
373 #define CHG_I_420MA (0x6 << 4)
374 #define CHG_I_460MA (0x7 << 4)
375 #else /* AS3514 uses charge current steps of 50 mA */
376 #define CHG_I_50MA (0x0 << 4)
377 #define CHG_I_100MA (0x1 << 4)
378 #define CHG_I_150MA (0x2 << 4)
379 #define CHG_I_200MA (0x3 << 4)
380 #define CHG_I_250MA (0x4 << 4)
381 #define CHG_I_300MA (0x5 << 4)
382 #define CHG_I_350MA (0x6 << 4)
383 #define CHG_I_400MA (0x7 << 4)
384 #endif
385 #define CHG_V (0x7 << 1)
386 #define CHG_V_4_25V (0x7 << 1)
387 #define CHG_V_4_20V (0x6 << 1)
388 #define CHG_V_4_15V (0x5 << 1)
389 #define CHG_V_4_10V (0x4 << 1)
390 #define CHG_V_4_05V (0x3 << 1)
391 #define CHG_V_4_00V (0x2 << 1)
392 #define CHG_V_3_95V (0x1 << 1)
393 #define CHG_V_3_90V (0x0 << 1)
394 #define CHG_OFF (0x1 << 0)
396 /* AS3514_IRQ_ENRD0 */
397 #define CHG_TMPHIGH (0x1 << 7)
398 #define CHG_ENDOFCH (0x1 << 6)
399 #define CHG_STATUS (0x1 << 5)
400 #define CHG_CHANGED (0x1 << 4)
401 #define USB_STATUS (0x1 << 3)
402 #define USB_CHANGED (0x1 << 2)
403 #define RVDD_WASLOW (0x1 << 1)
404 #define BVDD_ISLOW (0x1 << 0)
406 #define IRQ_ENDOFCH (0x1 << 6)
407 #define IRQ_CHGSTAT (0x1 << 4)
408 #define IRQ_USBSTAT (0x1 << 2)
410 /* AS3514_IRQ_ENRD2 */
411 #define DEBOUNCE_128MS (0x2 << 6)
412 #define DEBOUNCE_256MS (0x1 << 6)
413 #define DEBOUNCE_512MS (0x0 << 6)
414 #define IRQ_HIGHACTIVE (0x1 << 5)
415 #define IRQ_PUSHPULL (0x1 << 4)
416 #define IRQ_REMDET2 (0x1 << 3)
417 #define IRQ_REMDET1 (0x1 << 2)
418 #define IRQ_RTC (0x1 << 1)
419 #define IRQ_ADC (0x1 << 0)
421 #define AS3514_I2C_ADDR 0x46
423 #endif /* _AS3514_H */