summaryrefslogtreecommitdiffstats
path: root/firmware/export/as3514.h
blob: afc982da398d7d25b1579733573df8c34bc3b988 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/***************************************************************************
 *             __________               __   ___.
 *   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
 *   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
 *   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 *   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 *                     \/            \/     \/    \/            \/
 * $Id$
 *
 * Copyright (C) 2007 by Daniel Ankers
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ****************************************************************************/

#ifndef _AS3514_H
#define _AS3514_H

extern int tenthdb2master(int db);

extern void audiohw_set_master_vol(int vol_l, int vol_r);
extern void audiohw_set_lineout_vol(int vol_l, int vol_r);

/* Register Descriptions */
#define AS3514_LINE_OUT_R 0x00
#define AS3514_LINE_OUT_L 0x01
#define AS3514_HPH_OUT_R  0x02
#define AS3514_HPH_OUT_L  0x03
#define AS3514_LSP_OUT_R  0x04
#define AS3514_LSP_OUT_L  0x05
#define AS3514_MIC1_R     0x06
#define AS3514_MIC1_L     0x07
#define AS3514_MIC2_R     0x08
#define AS3514_MIC2_L     0x09
#define AS3514_LINE_IN1_R 0x0a
#define AS3514_LINE_IN1_L 0x0b
#define AS3514_LINE_IN2_R 0x0c
#define AS3514_LINE_IN2_L 0x0d
#define AS3514_DAC_R      0x0e
#define AS3514_DAC_L      0x0f
#define AS3514_ADC_R      0x10
#define AS3514_ADC_L      0x11
#define AS3543_DAC_IF     0x12  /* only in as3543 */
#define AS3514_AUDIOSET1  0x14
#define AS3514_AUDIOSET2  0x15
#define AS3514_AUDIOSET3  0x16
#define AS3517_USB_UTIL   0x17  /* only in as3517+ */

#define AS3543_BACKLIGHT  0x1b  /* only in as3543 */
#define AS3543_PMU_ENABLE 0x1c  /* only in as3543 */

#define AS3514_PLLMODE    0x1d

#define AS3514_SYSTEM     0x20
#define AS3514_CVDD_DCDC3 0x21
#define AS3514_CHARGER    0x22
#define AS3514_DCDC15     0x23
#define AS3514_SUPERVISOR 0x24

#define AS3514_IRQ_ENRD0  0x25
#define AS3514_IRQ_ENRD1  0x26
#define AS3514_IRQ_ENRD2  0x27

#define AS3514_RTCV       0x28
#define AS3514_RTCT       0x29
#define AS3514_RTC_0      0x2a
#define AS3514_RTC_1      0x2b
#define AS3514_RTC_2      0x2c
#define AS3514_RTC_3      0x2d
#define AS3514_ADC_0      0x2e
#define AS3514_ADC_1      0x2f

#define AS3514_UID_0      0x30

/* Headphone volume goes from -73.5 ... +6dB */
#define VOLUME_MIN -735
#define VOLUME_MAX   60

/*** Audio Registers ***/

/* 00h (LINE_OUT_R) to 1Dh (PLLMODE) */
#define AS3514_NUM_AUDIO_REGS   (0x1e)

/* Common registers masks */
#define AS3514_VOL_MASK         (0x1f << 0)

/* LINE_OUT_R (0x00) */
/* Only has volume control bits */

/* LINE_OUT_L (0x01) */
#define LINE_OUT_L_LO_SES_DM    (0x3 << 6)
    #define LINE_OUT_L_LO_SES_DM_MUTE   (0x0 << 6)
    #define LINE_OUT_L_LO_SES_DM_DF_MO  (0x1 << 6)
    #define LINE_OUT_L_LO_SES_DM_SE_ST  (0x2 << 6)
/* Use AS3514_VOL_MASK */

/* HPH_OUT_R (0x02) */
#define HPH_OUT_R_HP_OVC_TO     (0x3 << 6)
    /* AS3514/AS3517 */
    #define HPH_OUT_R_HP_OVC_TO_0MS     (0x3 << 6)
    #define HPH_OUT_R_HP_OVC_TO_128MS   (0x1 << 6)
    #define HPH_OUT_R_HP_OVC_TO_256MS   (0x0 << 6)
    #define HPH_OUT_R_HP_OVC_TO_512MS   (0x2 << 6)
    /* AS3543 */
    #define HPH_OUT_R_HP_OUT_SUM        (0x0 << 5)
    #define HPH_OUT_R_HP_OUT_DAC        (0x1 << 5)
    #define HPH_OUT_R_HP_OUT_LINE       (0x2 << 5)
    #define HPH_OUT_R_HP_OUT_MIC        (0x3 << 5)
    #define HPH_OUT_R_HP_OUT_MASK       (0x3 << 5)
/* Use AS3514_VOL_MASK */

/* HPH_OUT_L (0x03) */
#define HPH_OUT_L_HP_MUTE       (0x1 << 7)
#define HPH_OUT_L_HP_ON         (0x1 << 6)
#define HPH_OUT_L_HP_DET_ON     (0x1 << 5)
/* Use AS3514_VOL_MASK */

/* LSP_OUT_R (0x04) */
#define LSP_OUT_R_SP_OVC_TO     (0x3 << 6)
    #define LSP_OUT_R_SP_OVC_TO_256MS (0x0 << 6)
    #define LSP_OUT_R_SP_OVC_TO_128MS (0x1 << 6)
    #define LSP_OUT_R_SP_OVC_TO_512MS (0x2 << 6)
    #define LSP_OUT_R_SP_OVC_TO_0MS   (0x3 << 6)
/* Use AS3514_VOL_MASK */

/* LSP_OUT_L (0x05) */
#define LSP_OUT_L_SP_MUTE       (0x1 << 7)
#define LSP_OUT_L_SP_ON         (0x1 << 6)
/* Use AS3514_VOL_MASK */

/* MIC1_R (0x06) */
#define MIC1_R_M1_AGC_off       (0x1 << 7)
#define MIC1_R_M1_GAIN          (0x3 << 5)
    #define MIC1_R_M1_GAIN_28DB (0x0 << 5)
    #define MIC1_R_M1_GAIN_34DB (0x1 << 5)
    #define MIC1_R_M1_GAIN_40DB (0x2 << 5)
/* Use AS3514_VOL_MASK */

/* MIC1_L (0x07) */
#define MIC1_L_M1_SUP_off       (0x1 << 7)
#define MIC1_L_M1_MUTE_off      (0x1 << 6)
/* Use AS3514_VOL_MASK */

/* MIC2_R (0x08) */
#define MIC2_R_M2_AGC_off       (0x1 << 7)
#define MIC2_R_M2_GAIN          (0x3 << 5)
    #define MIC2_R_M2_GAIN_28DB (0x0 << 5)
    #define MIC2_R_M2_GAIN_34DB (0x1 << 5)
    #define MIC2_R_M2_GAIN_40DB (0x2 << 5)
/* Use AS3514_VOL_MASK */

/* MIC2_L (0x09) */
#define MIC2_L_M2_SUP_off       (0x1 << 7)
#define MIC2_L_M2_MUTE_off      (0x1 << 6)
/* Use AS3514_VOL_MASK */

/* LINE_IN1_R (0Ah) */
#define LINE_IN1_R_LI1R_MUTE_off    (0x1 << 5)
/* Use AS3514_VOL_MASK */

/* LINE_IN1_L (0Bh) */
#define LINE_IN1_L_LI1_MODE      (0x3 << 6)
    #define LINE_IN1_L_LI1_MODE_SE_ST   (0x0 << 6)
    #define LINE_IN1_L_LI1_MODE_DF_MO   (0x1 << 6)
    #define LINE_IN1_L_LI1_MODE_SE_MO   (0x2 << 6)
#define LINE_IN1_L_LI1L_MUTE_off (0x1 << 5)
/* Use AS3514_VOL_MASK */

/* LINE_IN2_R (0Ch) */
#define LINE_IN2_R_LI2R_MUTE_off (0x1 << 5)
/* Use AS3514_VOL_MASK */

/* LINE_IN2_L (0Dh) */
#define LINE_IN2_L_LI2_MODE      (0x3 << 6)
    #define LINE_IN2_L_LI2_MODE_SE_ST   (0x0 << 6)
    #define LINE_IN2_L_LI2_MODE_DF_MO   (0x1 << 6)
    #define LINE_IN2_L_LI2_MODE_SE_MO   (0x2 << 6)
#define LINE_IN2_L_LI2L_MUTE_off (0x1 << 5)
/* Use AS3514_VOL_MASK */

/* DAC_R (0Eh) */
/* Only has volume control bits */
/* Use AS3514_VOL_MASK */

/* DAC_L (0Fh) */
#define DAC_L_DAC_MUTE_off      (0x1 << 6)
/* Use AS3514_VOL_MASK */

/* ADC_R (10h) */
#define ADC_R_ADCMUX            (0x3 << 6)
    #define ADC_R_ADCMUX_ST_MIC     (0x0 << 6)
    #define ADC_R_ADCMUX_LINE_IN1   (0x1 << 6)
    #define ADC_R_ADCMUX_LINE_IN2   (0x2 << 6)
    #define ADC_R_ADCMUX_AUDIO_SUM  (0x3 << 6)
/* Use AS3514_VOL_MASK */

/* ADC_L (11h) */
#define ADC_L_FS_2              (0x1 << 7)
#define ADC_L_ADC_MUTE_off      (0x1 << 6)
/* Use AS3514_VOL_MASK */

/* AUDIOSET1 (14h)*/
#define AUDIOSET1_ADC_on        (0x1 << 7)
#define AUDIOSET1_SUM_on        (0x1 << 6)
#define AUDIOSET1_DAC_on        (0x1 << 5)
#define AUDIOSET1_LOUT_on       (0x1 << 4)
#define AUDIOSET1_LIN2_on       (0x1 << 3)
#define AUDIOSET1_LIN1_on       (0x1 << 2)
#define AUDIOSET1_MIC2_on       (0x1 << 1)
#define AUDIOSET1_MIC1_on       (0x1 << 0)
#define AUDIOSET1_INPUT_MASK    AUDIOSET1_MIC1_on | AUDIOSET1_MIC2_on | \
                                AUDIOSET1_LIN1_on | AUDIOSET1_LIN2_on

/* AUDIOSET2 (15h) */
#define AUDIOSET2_BIAS_off      (0x1 << 7)
#define AUDIOSET2_DITH_off      (0x1 << 6)
#define AUDIOSET2_AGC_off       (0x1 << 5)
#define AUDIOSET2_IBR_DAC       (0x3 << 3)
    #define AUDIOSET2_IBR_DAC_0     (0x0 << 3)
    #define AUDIOSET2_IBR_DAC_25    (0x1 << 3)
    #define AUDIOSET2_IBR_DAC_40    (0x2 << 3)
    #define AUDIOSET2_IBR_DAC_50    (0x3 << 3)
#define AUDIOSET2_LSP_LP        (0x1 << 2)
#define AUDIOSET2_IBR_LSP       (0x3 << 0)
    #define AUDIOSET2_IBR_LSP_0     (0x0 << 0)
    #define AUDIOSET2_IBR_LSP_17    (0x1 << 0)
    #define AUDIOSET2_IBR_LSP_34    (0x2 << 0)
    #define AUDIOSET2_IBR_LSP_50    (0x3 << 0)

/* AUDIOSET3 (16h) */
#define AUDIOSET3_ZCU_off       (0x1 << 2)
#define AUDIOSET3_IBR_HPH       (0x1 << 1)
#define AUDIOSET3_HPCM_off      (0x1 << 0)

/* PLLMODE (1Dh) */
#define PLLMODE_LRCK             (0x3 << 1)
    #define PLLMODE_LRCK_24_48      (0x0 << 1)
    #define PLLMODE_LRCK_8_23       (0x2 << 1)

/* ADC channels */
#define NUM_ADC_CHANNELS 13

#define ADC_BVDD         0  /* Battery voltage of 4V LiIo accumulator */
#define ADC_RTCSUP       1  /* RTC backup battery voltage */
#define ADC_UVDD         2  /* USB host voltage */
#define ADC_CHG_IN       3  /* Charger input voltage */
#define ADC_CVDD         4  /* Charger pump output voltage */
#define ADC_BATTEMP      5  /* Battery charging temperature */
#define ADC_MICSUP1      6  /* Voltage on MicSup1 for remote control
                               or external voltage measurement */
#define ADC_MICSUP2      7  /* Voltage on MicSup1 for remote control
                               or external voltage measurement */
#define ADC_VBE1         8  /* Measuring junction temperature @ 2uA */
#define ADC_VBE2         9  /* Measuring junction temperature @ 1uA */
#define ADC_I_MICSUP1    10 /* Current of MicSup1 for remote control detection */
#define ADC_I_MICSUP2    11 /* Current of MicSup2 for remote control detection */
#define ADC_VBAT         12 /* Single cell battery voltage */

/* AS3514_CHARGER */
#define TMPSUP_OFF      (0x1 << 7)
#define CHG_I           (0x7 << 4)
#define CHG_I_400MA     (0x7 << 4)
#define CHG_I_350MA     (0x6 << 4)
#define CHG_I_300MA     (0x5 << 4)
#define CHG_I_250MA     (0x4 << 4)
#define CHG_I_200MA     (0x3 << 4)
#define CHG_I_150MA     (0x2 << 4)
#define CHG_I_100MA     (0x1 << 4)
#define CHG_I_50MA      (0x0 << 4)
#define CHG_V           (0x7 << 1)
#define CHG_V_4_25V     (0x7 << 1)
#define CHG_V_4_20V     (0x6 << 1)
#define CHG_V_4_15V     (0x5 << 1)
#define CHG_V_4_10V     (0x4 << 1)
#define CHG_V_4_05V     (0x3 << 1)
#define CHG_V_4_00V     (0x2 << 1)
#define CHG_V_3_95V     (0x1 << 1)
#define CHG_V_3_90V     (0x0 << 1)
#define CHG_OFF         (0x1 << 0)

/* AS3514_IRQ_ENRD0 */
#define CHG_TMPHIGH     (0x1 << 7)
#define CHG_ENDOFCH     (0x1 << 6)
#define CHG_STATUS      (0x1 << 5)
#define CHG_CHANGED     (0x1 << 4)
#define USB_STATUS      (0x1 << 3)
#define USB_CHANGED     (0x1 << 2)
#define RVDD_WASLOW     (0x1 << 1)
#define BVDD_ISLOW      (0x1 << 0)

#define IRQ_ENDOFCH     (0x1 << 6)
#define IRQ_CHGSTAT     (0x1 << 4)
#define IRQ_USBSTAT     (0x1 << 2)

/* AS3514_IRQ_ENRD2 */
#define DEBOUNCE_128MS  (0x2 << 6)
#define DEBOUNCE_256MS  (0x1 << 6)
#define DEBOUNCE_512MS  (0x0 << 6)
#define IRQ_HIGHACTIVE  (0x1 << 5)
#define IRQ_PUSHPULL    (0x1 << 4)
#define IRQ_REMDET2     (0x1 << 3)
#define IRQ_REMDET1     (0x1 << 2)
#define IRQ_RTC         (0x1 << 1)
#define IRQ_ADC         (0x1 << 0)

#define AS3514_I2C_ADDR 0x46

#endif /* _AS3514_H */