Remove the calls to backlight_lcd_sleep_countdown from target specific code and move...
[kugel-rb.git] / firmware / export / as3514.h
blob53851335c84c734ac4496b9ceae3247d5c06f04f
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 extern int tenthdb2master(int db);
27 extern void audiohw_set_master_vol(int vol_l, int vol_r);
28 extern void audiohw_set_lineout_vol(int vol_l, int vol_r);
30 /* Register Descriptions */
31 #define AS3514_LINE_OUT_R 0x00
32 #define AS3514_LINE_OUT_L 0x01
33 #define AS3514_HPH_OUT_R 0x02
34 #define AS3514_HPH_OUT_L 0x03
35 #define AS3514_LSP_OUT_R 0x04
36 #define AS3514_LSP_OUT_L 0x05
37 #define AS3514_MIC1_R 0x06
38 #define AS3514_MIC1_L 0x07
39 #define AS3514_MIC2_R 0x08
40 #define AS3514_MIC2_L 0x09
41 #define AS3514_LINE_IN1_R 0x0a
42 #define AS3514_LINE_IN1_L 0x0b
43 #define AS3514_LINE_IN2_R 0x0c
44 #define AS3514_LINE_IN2_L 0x0d
45 #define AS3514_DAC_R 0x0e
46 #define AS3514_DAC_L 0x0f
47 #define AS3514_ADC_R 0x10
48 #define AS3514_ADC_L 0x11
49 #define AS3514_AUDIOSET1 0x14
50 #define AS3514_AUDIOSET2 0x15
51 #define AS3514_AUDIOSET3 0x16
52 #define AS3514_USB_UTIL 0x17 /* Only in AS3525 ? */
53 #define AS3514_PLLMODE 0x1d
55 #define AS3514_SYSTEM 0x20
56 #define AS3514_CVDD_DCDC3 0x21
57 #define AS3514_CHARGER 0x22
58 #define AS3514_DCDC15 0x23
59 #define AS3514_SUPERVISOR 0x24
61 #define AS3514_IRQ_ENRD0 0x25
62 #define AS3514_IRQ_ENRD1 0x26
63 #define AS3514_IRQ_ENRD2 0x27
65 #define AS3514_RTCV 0x28
66 #define AS3514_RTCT 0x29
67 #define AS3514_RTC_0 0x2a
68 #define AS3514_RTC_1 0x2b
69 #define AS3514_RTC_2 0x2c
70 #define AS3514_RTC_3 0x2d
71 #define AS3514_ADC_0 0x2e
72 #define AS3514_ADC_1 0x2f
74 #define AS3514_UID_0 0x30
76 /* Headphone volume goes from -73.5 ... +6dB */
77 #define VOLUME_MIN -735
78 #define VOLUME_MAX 60
80 /*** Audio Registers ***/
82 /* 00h (LINE_OUT_R) to 1Dh (PLLMODE) */
83 #define AS3514_NUM_AUDIO_REGS (0x1e)
85 /* Common registers masks */
86 #define AS3514_VOL_MASK (0x1f << 0)
88 /* LINE_OUT_R (0x00) */
89 /* Only has volume control bits */
91 /* LINE_OUT_L (0x01) */
92 #define LINE_OUT_L_LO_SES_DM (0x3 << 6)
93 #define LINE_OUT_L_LO_SES_DM_MUTE (0x0 << 6)
94 #define LINE_OUT_L_LO_SES_DM_DF_MO (0x1 << 6)
95 #define LINE_OUT_L_LO_SES_DM_SE_ST (0x2 << 6)
96 /* Use AS3514_VOL_MASK */
98 /* HPH_OUT_R (0x02) */
99 #define HPH_OUT_R_HP_OVC_TO (0x3 << 6)
100 #define HPH_OUT_R_HP_OVC_TO_0MS (0x3 << 6)
101 #define HPH_OUT_R_HP_OVC_TO_128MS (0x1 << 6)
102 #define HPH_OUT_R_HP_OVC_TO_256MS (0x0 << 6)
103 #define HPH_OUT_R_HP_OVC_TO_512MS (0x2 << 6)
104 /* Use AS3514_VOL_MASK */
106 /* HPH_OUT_L (0x03) */
107 #define HPH_OUT_L_HP_MUTE (0x1 << 7)
108 #define HPH_OUT_L_HP_ON (0x1 << 6)
109 #define HPH_OUT_L_HP_DET_ON (0x1 << 5)
110 /* Use AS3514_VOL_MASK */
112 /* LSP_OUT_R (0x04) */
113 #define LSP_OUT_R_SP_OVC_TO (0x3 << 6)
114 #define LSP_OUT_R_SP_OVC_TO_256MS (0x0 << 6)
115 #define LSP_OUT_R_SP_OVC_TO_128MS (0x1 << 6)
116 #define LSP_OUT_R_SP_OVC_TO_512MS (0x2 << 6)
117 #define LSP_OUT_R_SP_OVC_TO_0MS (0x3 << 6)
118 /* Use AS3514_VOL_MASK */
120 /* LSP_OUT_L (0x05) */
121 #define LSP_OUT_L_SP_MUTE (0x1 << 7)
122 #define LSP_OUT_L_SP_ON (0x1 << 6)
123 /* Use AS3514_VOL_MASK */
125 /* MIC1_R (0x06) */
126 #define MIC1_R_M1_AGC_off (0x1 << 7)
127 #define MIC1_R_M1_GAIN (0x3 << 5)
128 #define MIC1_R_M1_GAIN_28DB (0x0 << 5)
129 #define MIC1_R_M1_GAIN_34DB (0x1 << 5)
130 #define MIC1_R_M1_GAIN_40DB (0x2 << 5)
131 /* Use AS3514_VOL_MASK */
133 /* MIC1_L (0x07) */
134 #define MIC1_L_M1_SUP_off (0x1 << 7)
135 #define MIC1_L_M1_MUTE_off (0x1 << 6)
136 /* Use AS3514_VOL_MASK */
138 /* MIC2_R (0x08) */
139 #define MIC2_R_M2_AGC_off (0x1 << 7)
140 #define MIC2_R_M2_GAIN (0x3 << 5)
141 #define MIC2_R_M2_GAIN_28DB (0x0 << 5)
142 #define MIC2_R_M2_GAIN_34DB (0x1 << 5)
143 #define MIC2_R_M2_GAIN_40DB (0x2 << 5)
144 /* Use AS3514_VOL_MASK */
146 /* MIC2_L (0x09) */
147 #define MIC2_L_M2_SUP_off (0x1 << 7)
148 #define MIC2_L_M2_MUTE_off (0x1 << 6)
149 /* Use AS3514_VOL_MASK */
151 /* LINE_IN1_R (0Ah) */
152 #define LINE_IN1_R_LI1R_MUTE_off (0x1 << 5)
153 /* Use AS3514_VOL_MASK */
155 /* LINE_IN1_L (0Bh) */
156 #define LINE_IN1_L_LI1_MODE (0x3 << 6)
157 #define LINE_IN1_L_LI1_MODE_SE_ST (0x0 << 6)
158 #define LINE_IN1_L_LI1_MODE_DF_MO (0x1 << 6)
159 #define LINE_IN1_L_LI1_MODE_SE_MO (0x2 << 6)
160 #define LINE_IN1_L_LI1L_MUTE_off (0x1 << 5)
161 /* Use AS3514_VOL_MASK */
163 /* LINE_IN2_R (0Ch) */
164 #define LINE_IN2_R_LI2R_MUTE_off (0x1 << 5)
165 /* Use AS3514_VOL_MASK */
167 /* LINE_IN2_L (0Dh) */
168 #define LINE_IN2_L_LI2_MODE (0x3 << 6)
169 #define LINE_IN2_L_LI2_MODE_SE_ST (0x0 << 6)
170 #define LINE_IN2_L_LI2_MODE_DF_MO (0x1 << 6)
171 #define LINE_IN2_L_LI2_MODE_SE_MO (0x2 << 6)
172 #define LINE_IN2_L_LI2L_MUTE_off (0x1 << 5)
173 /* Use AS3514_VOL_MASK */
175 /* DAC_R (0Eh) */
176 /* Only has volume control bits */
177 /* Use AS3514_VOL_MASK */
179 /* DAC_L (0Fh) */
180 #define DAC_L_DAC_MUTE_off (0x1 << 6)
181 /* Use AS3514_VOL_MASK */
183 /* ADC_R (10h) */
184 #define ADC_R_ADCMUX (0x3 << 6)
185 #define ADC_R_ADCMUX_ST_MIC (0x0 << 6)
186 #define ADC_R_ADCMUX_LINE_IN1 (0x1 << 6)
187 #define ADC_R_ADCMUX_LINE_IN2 (0x2 << 6)
188 #define ADC_R_ADCMUX_AUDIO_SUM (0x3 << 6)
189 /* Use AS3514_VOL_MASK */
191 /* ADC_L (11h) */
192 #define ADC_L_FS_2 (0x1 << 7)
193 #define ADC_L_ADC_MUTE_off (0x1 << 6)
194 /* Use AS3514_VOL_MASK */
196 /* AUDIOSET1 (14h)*/
197 #define AUDIOSET1_ADC_on (0x1 << 7)
198 #define AUDIOSET1_SUM_on (0x1 << 6)
199 #define AUDIOSET1_DAC_on (0x1 << 5)
200 #define AUDIOSET1_LOUT_on (0x1 << 4)
201 #define AUDIOSET1_LIN2_on (0x1 << 3)
202 #define AUDIOSET1_LIN1_on (0x1 << 2)
203 #define AUDIOSET1_MIC2_on (0x1 << 1)
204 #define AUDIOSET1_MIC1_on (0x1 << 0)
205 #define AUDIOSET1_INPUT_MASK AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \
206 AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on
208 /* AUDIOSET2 (15h) */
209 #define AUDIOSET2_BIAS_off (0x1 << 7)
210 #define AUDIOSET2_DITH_off (0x1 << 6)
211 #define AUDIOSET2_AGC_off (0x1 << 5)
212 #define AUDIOSET2_IBR_DAC (0x3 << 3)
213 #define AUDIOSET2_IBR_DAC_0 (0x0 << 3)
214 #define AUDIOSET2_IBR_DAC_25 (0x1 << 3)
215 #define AUDIOSET2_IBR_DAC_40 (0x2 << 3)
216 #define AUDIOSET2_IBR_DAC_50 (0x3 << 3)
217 #define AUDIOSET2_LSP_LP (0x1 << 2)
218 #define AUDIOSET2_IBR_LSP (0x3 << 0)
219 #define AUDIOSET2_IBR_LSP_0 (0x0 << 0)
220 #define AUDIOSET2_IBR_LSP_17 (0x1 << 0)
221 #define AUDIOSET2_IBR_LSP_34 (0x2 << 0)
222 #define AUDIOSET2_IBR_LSP_50 (0x3 << 0)
224 /* AUDIOSET3 (16h) */
225 #define AUDIOSET3_ZCU_off (0x1 << 2)
226 #define AUDIOSET3_IBR_HPH (0x1 << 1)
227 #define AUDIOSET3_HPCM_off (0x1 << 0)
229 /* PLLMODE (1Dh) */
230 #define PLLMODE_LRCK (0x3 << 1)
231 #define PLLMODE_LRCK_24_48 (0x0 << 1)
232 #define PLLMODE_LRCK_8_23 (0x2 << 1)
234 /* ADC channels */
235 #define NUM_ADC_CHANNELS 13
237 #define ADC_BVDD 0 /* Battery voltage of 4V LiIo accumulator */
238 #define ADC_RTCSUP 1 /* RTC backup battery voltage */
239 #define ADC_UVDD 2 /* USB host voltage */
240 #define ADC_CHG_IN 3 /* Charger input voltage */
241 #define ADC_CVDD 4 /* Charger pump output voltage */
242 #define ADC_BATTEMP 5 /* Battery charging temperature */
243 #define ADC_MICSUP1 6 /* Voltage on MicSup1 for remote control
244 or external voltage measurement */
245 #define ADC_MICSUP2 7 /* Voltage on MicSup1 for remote control
246 or external voltage measurement */
247 #define ADC_VBE1 8 /* Measuring junction temperature @ 2uA */
248 #define ADC_VBE2 9 /* Measuring junction temperature @ 1uA */
249 #define ADC_I_MICSUP1 10 /* Current of MicSup1 for remote control detection */
250 #define ADC_I_MICSUP2 11 /* Current of MicSup2 for remote control detection */
251 #define ADC_VBAT 12 /* Single cell battery voltage */
253 /* AS3514_CHARGER */
254 #define TMPSUP_OFF (0x1 << 7)
255 #define CHG_I (0x7 << 4)
256 #define CHG_I_400MA (0x7 << 4)
257 #define CHG_I_350MA (0x6 << 4)
258 #define CHG_I_300MA (0x5 << 4)
259 #define CHG_I_250MA (0x4 << 4)
260 #define CHG_I_200MA (0x3 << 4)
261 #define CHG_I_150MA (0x2 << 4)
262 #define CHG_I_100MA (0x1 << 4)
263 #define CHG_I_50MA (0x0 << 4)
264 #define CHG_V (0x7 << 1)
265 #define CHG_V_4_25V (0x7 << 1)
266 #define CHG_V_4_20V (0x6 << 1)
267 #define CHG_V_4_15V (0x5 << 1)
268 #define CHG_V_4_10V (0x4 << 1)
269 #define CHG_V_4_05V (0x3 << 1)
270 #define CHG_V_4_00V (0x2 << 1)
271 #define CHG_V_3_95V (0x1 << 1)
272 #define CHG_V_3_90V (0x0 << 1)
273 #define CHG_OFF (0x1 << 0)
275 /* AS3514_IRQ_ENRD0 */
276 #define CHG_TMPHIGH (0x1 << 7)
277 #define CHG_ENDOFCH (0x1 << 6)
278 #define CHG_STATUS (0x1 << 5)
279 #define CHG_CHANGED (0x1 << 4)
280 #define USB_STATUS (0x1 << 3)
281 #define USB_CHANGED (0x1 << 2)
282 #define RVDD_WASLOW (0x1 << 1)
283 #define BVDD_ISLOW (0x1 << 0)
285 #define AS3514_I2C_ADDR 0x46
287 #endif /* _AS3514_H */