1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
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 */
33 #define AS3514_LINE_OUT_R 0x00
34 #define AS3514_LINE_OUT_L 0x01
35 #define AS3514_HPH_OUT_R 0x02
36 #define AS3514_HPH_OUT_L 0x03
37 #define AS3514_LSP_OUT_R 0x04
38 #define AS3514_LSP_OUT_L 0x05
39 #define AS3514_MIC1_R 0x06
40 #define AS3514_MIC1_L 0x07
42 #define AS3514_MIC2_R 0x08
43 #define AS3514_MIC2_L 0x09
45 #define AS3514_LINE_IN1_R 0x0a
46 #define AS3514_LINE_IN1_L 0x0b
48 #define AS3514_LINE_IN2_R 0x0c
49 #define AS3514_LINE_IN2_L 0x0d
51 #define AS3514_DAC_R 0x0e
52 #define AS3514_DAC_L 0x0f
53 #define AS3514_ADC_R 0x10
54 #define AS3514_ADC_L 0x11
56 #define AS3543_DAC_IF 0x12
58 #define AS3514_AUDIOSET1 0x14
59 #define AS3514_AUDIOSET2 0x15
60 #define AS3514_AUDIOSET3 0x16
61 #define AS3517_USB_UTIL 0x17 /* only in as3517+ */
64 #define AS3543_BACKLIGHT 0x1b
65 #define AS3543_PMU_ENABLE 0x1c
68 #define AS3514_PLLMODE 0x1d
70 #define AS3514_SYSTEM 0x20
71 #define AS3514_CVDD_DCDC3 0x21
72 #define AS3514_CHARGER 0x22
73 #define AS3514_DCDC15 0x23
74 #define AS3514_SUPERVISOR 0x24
76 #define AS3514_IRQ_ENRD0 0x25
77 #define AS3514_IRQ_ENRD1 0x26
78 #define AS3514_IRQ_ENRD2 0x27
80 #define AS3514_RTCV 0x28
81 #define AS3514_RTCT 0x29
82 #define AS3514_RTC_0 0x2a
83 #define AS3514_RTC_1 0x2b
84 #define AS3514_RTC_2 0x2c
85 #define AS3514_RTC_3 0x2d
86 #define AS3514_ADC_0 0x2e
87 #define AS3514_ADC_1 0x2f
89 #define AS3514_UID_0 0x30
91 /* Headphone volume goes from -73.5 ... +6dB */
92 #define VOLUME_MIN -735
95 /*** Audio Registers ***/
97 /* 00h (LINE_OUT_R) to 1Dh (PLLMODE) */
98 #define AS3514_NUM_AUDIO_REGS (0x1e)
100 /* Common registers masks */
101 #define AS3514_VOL_MASK (0x1f << 0)
103 /* LINE_OUT_R (0x00) */
104 /* Only has volume control bits */
106 /* LINE_OUT_L (0x01) */
107 #define LINE_OUT_L_LO_SES_DM (0x3 << 6)
108 #define LINE_OUT_L_LO_SES_DM_MUTE (0x0 << 6)
109 #define LINE_OUT_L_LO_SES_DM_DF_MO (0x1 << 6)
110 #define LINE_OUT_L_LO_SES_DM_SE_ST (0x2 << 6)
111 /* Use AS3514_VOL_MASK */
113 /* HPH_OUT_R (0x02) */
114 #define HPH_OUT_R_HP_OVC_TO (0x3 << 6)
116 #define HPH_OUT_R_HP_OVC_TO_0MS (0x3 << 6)
117 #define HPH_OUT_R_HP_OVC_TO_128MS (0x1 << 6)
118 #define HPH_OUT_R_HP_OVC_TO_256MS (0x0 << 6)
119 #define HPH_OUT_R_HP_OVC_TO_512MS (0x2 << 6)
121 #define HPH_OUT_R_HP_OUT_SUM (0x0 << 5)
122 #define HPH_OUT_R_HP_OUT_DAC (0x1 << 5)
123 #define HPH_OUT_R_HP_OUT_LINE (0x2 << 5)
124 #define HPH_OUT_R_HP_OUT_MIC (0x3 << 5)
125 #define HPH_OUT_R_HP_OUT_MASK (0x3 << 5)
126 /* Use AS3514_VOL_MASK */
128 /* HPH_OUT_L (0x03) */
129 #define HPH_OUT_L_HP_MUTE (0x1 << 7)
130 #define HPH_OUT_L_HP_ON (0x1 << 6)
131 #define HPH_OUT_L_HP_DET_ON (0x1 << 5)
132 /* Use AS3514_VOL_MASK */
134 /* LSP_OUT_R (0x04) */
135 #define LSP_OUT_R_SP_OVC_TO (0x3 << 6)
136 #define LSP_OUT_R_SP_OVC_TO_256MS (0x0 << 6)
137 #define LSP_OUT_R_SP_OVC_TO_128MS (0x1 << 6)
138 #define LSP_OUT_R_SP_OVC_TO_512MS (0x2 << 6)
139 #define LSP_OUT_R_SP_OVC_TO_0MS (0x3 << 6)
140 /* Use AS3514_VOL_MASK */
142 /* LSP_OUT_L (0x05) */
143 #define LSP_OUT_L_SP_MUTE (0x1 << 7)
144 #define LSP_OUT_L_SP_ON (0x1 << 6)
145 /* Use AS3514_VOL_MASK */
148 #define MIC1_R_M1_AGC_off (0x1 << 7)
149 #define MIC1_R_M1_GAIN (0x3 << 5)
150 #define MIC1_R_M1_GAIN_28DB (0x0 << 5)
151 #define MIC1_R_M1_GAIN_34DB (0x1 << 5)
152 #define MIC1_R_M1_GAIN_40DB (0x2 << 5)
153 /* Use AS3514_VOL_MASK */
156 #define MIC1_L_M1_SUP_off (0x1 << 7)
157 #define MIC1_L_M1_MUTE_off (0x1 << 6)
158 /* Use AS3514_VOL_MASK */
161 #define MIC2_R_M2_AGC_off (0x1 << 7)
162 #define MIC2_R_M2_GAIN (0x3 << 5)
163 #define MIC2_R_M2_GAIN_28DB (0x0 << 5)
164 #define MIC2_R_M2_GAIN_34DB (0x1 << 5)
165 #define MIC2_R_M2_GAIN_40DB (0x2 << 5)
166 /* Use AS3514_VOL_MASK */
169 #define MIC2_L_M2_SUP_off (0x1 << 7)
170 #define MIC2_L_M2_MUTE_off (0x1 << 6)
171 /* Use AS3514_VOL_MASK */
173 /* LINE_IN1_R (0Ah) */
175 #define LINE_IN_R_LINE_SELECT (0x1 << 6)
177 #define LINE_IN1_R_LI1R_MUTE_off (0x1 << 5)
178 /* Use AS3514_VOL_MASK */
180 /* LINE_IN1_L (0Bh) */
181 #define LINE_IN1_L_LI1_MODE (0x3 << 6)
182 #define LINE_IN1_L_LI1_MODE_SE_ST (0x0 << 6)
183 #define LINE_IN1_L_LI1_MODE_DF_MO (0x1 << 6)
184 #define LINE_IN1_L_LI1_MODE_SE_MO (0x2 << 6)
185 #define LINE_IN1_L_LI1L_MUTE_off (0x1 << 5)
186 /* Use AS3514_VOL_MASK */
188 /* LINE_IN2_R (0Ch) */
189 #define LINE_IN2_R_LI2R_MUTE_off (0x1 << 5)
190 /* Use AS3514_VOL_MASK */
192 /* LINE_IN2_L (0Dh) */
193 #define LINE_IN2_L_LI2_MODE (0x3 << 6)
194 #define LINE_IN2_L_LI2_MODE_SE_ST (0x0 << 6)
195 #define LINE_IN2_L_LI2_MODE_DF_MO (0x1 << 6)
196 #define LINE_IN2_L_LI2_MODE_SE_MO (0x2 << 6)
197 #define LINE_IN2_L_LI2L_MUTE_off (0x1 << 5)
198 /* Use AS3514_VOL_MASK */
201 /* Only has volume control bits */
202 /* Use AS3514_VOL_MASK */
205 #define DAC_L_DAC_MUTE_off (0x1 << 6)
206 /* Use AS3514_VOL_MASK */
209 #define ADC_R_ADCMUX (0x3 << 6)
210 #define ADC_R_ADCMUX_ST_MIC (0x0 << 6)
211 #define ADC_R_ADCMUX_LINE_IN1 (0x1 << 6)
212 #define ADC_R_ADCMUX_LINE_IN2 (0x2 << 6)
213 #define ADC_R_ADCMUX_AUDIO_SUM (0x3 << 6)
214 /* Use AS3514_VOL_MASK */
218 #define ADC_L_ADC_MUTE_off (0x1 << 5)
220 #define ADC_L_FS_2 (0x1 << 7)
221 #define ADC_L_ADC_MUTE_off (0x1 << 6)
223 /* Use AS3514_VOL_MASK */
226 #define AUDIOSET1_ADC_on (0x1 << 7)
227 #define AUDIOSET1_SUM_on (0x1 << 6)
228 #define AUDIOSET1_DAC_on (0x1 << 5)
229 #define AUDIOSET1_LOUT_on (0x1 << 4)
230 #define AUDIOSET1_LIN2_on (0x1 << 3)
231 #define AUDIOSET1_LIN1_on (0x1 << 2)
232 #define AUDIOSET1_MIC2_on (0x1 << 1)
233 #define AUDIOSET1_MIC1_on (0x1 << 0)
234 #define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \
235 AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on
237 /* AUDIOSET2 (15h) */
238 #define AUDIOSET2_BIAS_off (0x1 << 7)
239 #define AUDIOSET2_DITH_off (0x1 << 6)
240 #define AUDIOSET2_AGC_off (0x1 << 5)
241 #define AUDIOSET2_IBR_DAC (0x3 << 3)
242 #define AUDIOSET2_IBR_DAC_0 (0x0 << 3)
243 #define AUDIOSET2_IBR_DAC_25 (0x1 << 3)
244 #define AUDIOSET2_IBR_DAC_40 (0x2 << 3)
245 #define AUDIOSET2_IBR_DAC_50 (0x3 << 3)
246 #define AUDIOSET2_LSP_LP (0x1 << 2)
247 #define AUDIOSET2_IBR_LSP (0x3 << 0)
248 #define AUDIOSET2_IBR_LSP_0 (0x0 << 0)
249 #define AUDIOSET2_IBR_LSP_17 (0x1 << 0)
250 #define AUDIOSET2_IBR_LSP_34 (0x2 << 0)
251 #define AUDIOSET2_IBR_LSP_50 (0x3 << 0)
253 /* AUDIOSET3 (16h) */
254 #define AUDIOSET3_ZCU_off (0x1 << 2)
255 #define AUDIOSET3_IBR_HPH (0x1 << 1)
256 #define AUDIOSET3_HPCM_off (0x1 << 0)
259 #define PLLMODE_LRCK (0x3 << 1)
260 #define PLLMODE_LRCK_24_48 (0x0 << 1)
261 #define PLLMODE_LRCK_8_23 (0x2 << 1)
264 #define NUM_ADC_CHANNELS 13
266 #define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
267 #define ADC_RTCSUP 1 /* RTC backup battery voltage */
268 #define ADC_UVDD 2 /* USB host voltage */
269 #define ADC_CHG_IN 3 /* Charger input voltage */
270 #define ADC_CVDD 4 /* Charger pump output voltage */
271 #define ADC_BATTEMP 5 /* Battery charging temperature */
272 #define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
273 or external voltage measurement */
274 #define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
275 or external voltage measurement */
276 #define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
277 #define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
278 #define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
279 #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
280 #define ADC_VBAT 12 /* Single cell battery voltage */
283 #define TMPSUP_OFF (0x1 << 7)
284 #define CHG_I (0x7 << 4)
285 #define CHG_I_400MA (0x7 << 4)
286 #define CHG_I_350MA (0x6 << 4)
287 #define CHG_I_300MA (0x5 << 4)
288 #define CHG_I_250MA (0x4 << 4)
289 #define CHG_I_200MA (0x3 << 4)
290 #define CHG_I_150MA (0x2 << 4)
291 #define CHG_I_100MA (0x1 << 4)
292 #define CHG_I_50MA (0x0 << 4)
293 #define CHG_V (0x7 << 1)
294 #define CHG_V_4_25V (0x7 << 1)
295 #define CHG_V_4_20V (0x6 << 1)
296 #define CHG_V_4_15V (0x5 << 1)
297 #define CHG_V_4_10V (0x4 << 1)
298 #define CHG_V_4_05V (0x3 << 1)
299 #define CHG_V_4_00V (0x2 << 1)
300 #define CHG_V_3_95V (0x1 << 1)
301 #define CHG_V_3_90V (0x0 << 1)
302 #define CHG_OFF (0x1 << 0)
304 /* AS3514_IRQ_ENRD0 */
305 #define CHG_TMPHIGH (0x1 << 7)
306 #define CHG_ENDOFCH (0x1 << 6)
307 #define CHG_STATUS (0x1 << 5)
308 #define CHG_CHANGED (0x1 << 4)
309 #define USB_STATUS (0x1 << 3)
310 #define USB_CHANGED (0x1 << 2)
311 #define RVDD_WASLOW (0x1 << 1)
312 #define BVDD_ISLOW (0x1 << 0)
314 #define IRQ_ENDOFCH (0x1 << 6)
315 #define IRQ_CHGSTAT (0x1 << 4)
316 #define IRQ_USBSTAT (0x1 << 2)
318 /* AS3514_IRQ_ENRD2 */
319 #define DEBOUNCE_128MS (0x2 << 6)
320 #define DEBOUNCE_256MS (0x1 << 6)
321 #define DEBOUNCE_512MS (0x0 << 6)
322 #define IRQ_HIGHACTIVE (0x1 << 5)
323 #define IRQ_PUSHPULL (0x1 << 4)
324 #define IRQ_REMDET2 (0x1 << 3)
325 #define IRQ_REMDET1 (0x1 << 2)
326 #define IRQ_RTC (0x1 << 1)
327 #define IRQ_ADC (0x1 << 0)
329 #define AS3514_I2C_ADDR 0x46
331 #endif /* _AS3514_H */