blob: 6f097fb60683e7b5605b38e373c7f1c75f4158c9 [file] [log] [blame]
Vladimir Barinov44d0a872007-11-14 17:07:17 +01001/*
2 * ALSA SoC TLV320AIC3X codec driver
3 *
Vladimir Barinovd6b52032008-09-29 23:14:11 +04004 * Author: Vladimir Barinov, <vbarinov@embeddedalley.com>
Vladimir Barinov44d0a872007-11-14 17:07:17 +01005 * Copyright: (C) 2007 MontaVista Software, Inc., <source@mvista.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _AIC3X_H
13#define _AIC3X_H
14
15/* AIC3X register space */
16#define AIC3X_CACHEREGNUM 103
17
18/* Page select register */
19#define AIC3X_PAGE_SELECT 0
20/* Software reset register */
21#define AIC3X_RESET 1
22/* Codec Sample rate select register */
23#define AIC3X_SAMPLE_RATE_SEL_REG 2
24/* PLL progrramming register A */
25#define AIC3X_PLL_PROGA_REG 3
26/* PLL progrramming register B */
27#define AIC3X_PLL_PROGB_REG 4
28/* PLL progrramming register C */
29#define AIC3X_PLL_PROGC_REG 5
30/* PLL progrramming register D */
31#define AIC3X_PLL_PROGD_REG 6
32/* Codec datapath setup register */
33#define AIC3X_CODEC_DATAPATH_REG 7
34/* Audio serial data interface control register A */
35#define AIC3X_ASD_INTF_CTRLA 8
36/* Audio serial data interface control register B */
37#define AIC3X_ASD_INTF_CTRLB 9
Troy Kiskya24f4f62008-12-19 13:05:22 -070038/* Audio serial data interface control register C */
39#define AIC3X_ASD_INTF_CTRLC 10
Vladimir Barinov44d0a872007-11-14 17:07:17 +010040/* Audio overflow status and PLL R value programming register */
41#define AIC3X_OVRF_STATUS_AND_PLLR_REG 11
Jarkko Nikula4d20f702008-06-27 14:07:57 +030042/* Audio codec digital filter control register */
43#define AIC3X_CODEC_DFILT_CTRL 12
Daniel Mack6f2a9742008-12-03 11:44:17 +010044/* Headset/button press detection register */
45#define AIC3X_HEADSET_DETECT_CTRL_A 13
46#define AIC3X_HEADSET_DETECT_CTRL_B 14
Vladimir Barinov44d0a872007-11-14 17:07:17 +010047/* ADC PGA Gain control registers */
48#define LADC_VOL 15
49#define RADC_VOL 16
50/* MIC3 control registers */
51#define MIC3LR_2_LADC_CTRL 17
52#define MIC3LR_2_RADC_CTRL 18
53/* Line1 Input control registers */
54#define LINE1L_2_LADC_CTRL 19
Daniel Mack54f01912008-11-26 17:47:36 +010055#define LINE1R_2_LADC_CTRL 21
Vladimir Barinov44d0a872007-11-14 17:07:17 +010056#define LINE1R_2_RADC_CTRL 22
Daniel Mack54f01912008-11-26 17:47:36 +010057#define LINE1L_2_RADC_CTRL 24
Vladimir Barinov44d0a872007-11-14 17:07:17 +010058/* Line2 Input control registers */
59#define LINE2L_2_LADC_CTRL 20
60#define LINE2R_2_RADC_CTRL 23
61/* MICBIAS Control Register */
62#define MICBIAS_CTRL 25
63
64/* AGC Control Registers A, B, C */
65#define LAGC_CTRL_A 26
66#define LAGC_CTRL_B 27
67#define LAGC_CTRL_C 28
68#define RAGC_CTRL_A 29
69#define RAGC_CTRL_B 30
70#define RAGC_CTRL_C 31
71
72/* DAC Power and Left High Power Output control registers */
73#define DAC_PWR 37
74#define HPLCOM_CFG 37
75/* Right High Power Output control registers */
76#define HPRCOM_CFG 38
77/* DAC Output Switching control registers */
78#define DAC_LINE_MUX 41
79/* High Power Output Driver Pop Reduction registers */
80#define HPOUT_POP_REDUCTION 42
81/* DAC Digital control registers */
82#define LDAC_VOL 43
83#define RDAC_VOL 44
Jarkko Nikulab2eaac22010-08-27 16:56:48 +030084/* Left High Power Output control registers */
Vladimir Barinov44d0a872007-11-14 17:07:17 +010085#define LINE2L_2_HPLOUT_VOL 45
Vladimir Barinov44d0a872007-11-14 17:07:17 +010086#define PGAL_2_HPLOUT_VOL 46
Vladimir Barinov44d0a872007-11-14 17:07:17 +010087#define DACL1_2_HPLOUT_VOL 47
Jarkko Nikulac3b79e02010-08-27 16:56:49 +030088#define LINE2R_2_HPLOUT_VOL 48
Jarkko Nikulab2eaac22010-08-27 16:56:48 +030089#define PGAR_2_HPLOUT_VOL 49
Jarkko Nikulac3b79e02010-08-27 16:56:49 +030090#define DACR1_2_HPLOUT_VOL 50
Vladimir Barinov44d0a872007-11-14 17:07:17 +010091#define HPLOUT_CTRL 51
Jarkko Nikulab2eaac22010-08-27 16:56:48 +030092/* Left High Power COM control registers */
Vladimir Barinov44d0a872007-11-14 17:07:17 +010093#define LINE2L_2_HPLCOM_VOL 52
Vladimir Barinov44d0a872007-11-14 17:07:17 +010094#define PGAL_2_HPLCOM_VOL 53
Vladimir Barinov44d0a872007-11-14 17:07:17 +010095#define DACL1_2_HPLCOM_VOL 54
Jarkko Nikulac3b79e02010-08-27 16:56:49 +030096#define LINE2R_2_HPLCOM_VOL 55
Jarkko Nikulab2eaac22010-08-27 16:56:48 +030097#define PGAR_2_HPLCOM_VOL 56
Jarkko Nikulac3b79e02010-08-27 16:56:49 +030098#define DACR1_2_HPLCOM_VOL 57
Vladimir Barinov44d0a872007-11-14 17:07:17 +010099#define HPLCOM_CTRL 58
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300100/* Right High Power Output control registers */
Jarkko Nikulac3b79e02010-08-27 16:56:49 +0300101#define LINE2L_2_HPROUT_VOL 59
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300102#define PGAL_2_HPROUT_VOL 60
Jarkko Nikulac3b79e02010-08-27 16:56:49 +0300103#define DACL1_2_HPROUT_VOL 61
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300104#define LINE2R_2_HPROUT_VOL 62
105#define PGAR_2_HPROUT_VOL 63
106#define DACR1_2_HPROUT_VOL 64
107#define HPROUT_CTRL 65
108/* Right High Power COM control registers */
Jarkko Nikulac3b79e02010-08-27 16:56:49 +0300109#define LINE2L_2_HPRCOM_VOL 66
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300110#define PGAL_2_HPRCOM_VOL 67
Jarkko Nikulac3b79e02010-08-27 16:56:49 +0300111#define DACL1_2_HPRCOM_VOL 68
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300112#define LINE2R_2_HPRCOM_VOL 69
113#define PGAR_2_HPRCOM_VOL 70
114#define DACR1_2_HPRCOM_VOL 71
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100115#define HPRCOM_CTRL 72
116/* Mono Line Output Plus/Minus control registers */
117#define LINE2L_2_MONOLOPM_VOL 73
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100118#define PGAL_2_MONOLOPM_VOL 74
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100119#define DACL1_2_MONOLOPM_VOL 75
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300120#define LINE2R_2_MONOLOPM_VOL 76
121#define PGAR_2_MONOLOPM_VOL 77
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100122#define DACR1_2_MONOLOPM_VOL 78
123#define MONOLOPM_CTRL 79
Randolph Chung6184f102010-08-20 12:47:53 +0800124/* Class-D speaker driver on tlv320aic3007 */
125#define CLASSD_CTRL 73
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300126/* Left Line Output Plus/Minus control registers */
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100127#define LINE2L_2_LLOPM_VOL 80
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100128#define PGAL_2_LLOPM_VOL 81
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100129#define DACL1_2_LLOPM_VOL 82
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300130#define LINE2R_2_LLOPM_VOL 83
131#define PGAR_2_LLOPM_VOL 84
Daniel Mack54f01912008-11-26 17:47:36 +0100132#define DACR1_2_LLOPM_VOL 85
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100133#define LLOPM_CTRL 86
Jarkko Nikulab2eaac22010-08-27 16:56:48 +0300134/* Right Line Output Plus/Minus control registers */
135#define LINE2L_2_RLOPM_VOL 87
136#define PGAL_2_RLOPM_VOL 88
137#define DACL1_2_RLOPM_VOL 89
138#define LINE2R_2_RLOPM_VOL 90
139#define PGAR_2_RLOPM_VOL 91
140#define DACR1_2_RLOPM_VOL 92
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100141#define RLOPM_CTRL 93
Daniel Mack54e7e612008-04-30 16:20:52 +0200142/* GPIO/IRQ registers */
143#define AIC3X_STICKY_IRQ_FLAGS_REG 96
144#define AIC3X_RT_IRQ_FLAGS_REG 97
145#define AIC3X_GPIO1_REG 98
146#define AIC3X_GPIO2_REG 99
147#define AIC3X_GPIOA_REG 100
Daniel Mack4f9c16c2008-04-30 16:20:19 +0200148#define AIC3X_GPIOB_REG 101
Daniel Mack54e7e612008-04-30 16:20:52 +0200149/* Clock generation control register */
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100150#define AIC3X_CLKGEN_CTRL_REG 102
151
152/* Page select register bits */
153#define PAGE0_SELECT 0
154#define PAGE1_SELECT 1
155
156/* Audio serial data interface control register A bits */
157#define BIT_CLK_MASTER 0x80
158#define WORD_CLK_MASTER 0x40
159
160/* Codec Datapath setup register 7 */
161#define FSREF_44100 (1 << 7)
162#define FSREF_48000 (0 << 7)
163#define DUAL_RATE_MODE ((1 << 5) | (1 << 6))
164#define LDAC2LCH (0x1 << 3)
165#define RDAC2RCH (0x1 << 1)
166
167/* PLL registers bitfields */
168#define PLLP_SHIFT 0
Daniel Mack4f9c16c2008-04-30 16:20:19 +0200169#define PLLQ_SHIFT 3
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100170#define PLLR_SHIFT 0
171#define PLLJ_SHIFT 2
172#define PLLD_MSB_SHIFT 0
173#define PLLD_LSB_SHIFT 2
174
175/* Clock generation register bits */
Daniel Mack4f9c16c2008-04-30 16:20:19 +0200176#define CODEC_CLKIN_PLLDIV 0
177#define CODEC_CLKIN_CLKDIV 1
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100178#define PLL_CLKIN_SHIFT 4
179#define MCLK_SOURCE 0x0
180#define PLL_CLKDIV_SHIFT 0
181
182/* Software reset register bits */
183#define SOFT_RESET 0x80
184
185/* PLL progrramming register A bits */
186#define PLL_ENABLE 0x80
187
188/* Route bits */
189#define ROUTE_ON 0x80
190
191/* Mute bits */
192#define UNMUTE 0x08
193#define MUTE_ON 0x80
194
195/* Power bits */
196#define LADC_PWR_ON 0x04
197#define RADC_PWR_ON 0x04
198#define LDAC_PWR_ON 0x80
199#define RDAC_PWR_ON 0x40
200#define HPLOUT_PWR_ON 0x01
201#define HPROUT_PWR_ON 0x01
202#define HPLCOM_PWR_ON 0x01
203#define HPRCOM_PWR_ON 0x01
204#define MONOLOPM_PWR_ON 0x01
205#define LLOPM_PWR_ON 0x01
206#define RLOPM_PWR_ON 0x01
207
208#define INVERT_VOL(val) (0x7f - val)
209
210/* Default output volume (inverted) */
211#define DEFAULT_VOL INVERT_VOL(0x50)
212/* Default input volume */
213#define DEFAULT_GAIN 0x20
214
Daniel Mack6f2a9742008-12-03 11:44:17 +0100215/* headset detection / button API */
216
217/* The AIC3x supports detection of stereo headsets (GND + left + right signal)
218 * and cellular headsets (GND + speaker output + microphone input).
219 * It is recommended to enable MIC bias for this function to work properly.
220 * For more information, please refer to the datasheet. */
221enum {
222 AIC3X_HEADSET_DETECT_OFF = 0,
223 AIC3X_HEADSET_DETECT_STEREO = 1,
224 AIC3X_HEADSET_DETECT_CELLULAR = 2,
225 AIC3X_HEADSET_DETECT_BOTH = 3
226};
227
228enum {
229 AIC3X_HEADSET_DEBOUNCE_16MS = 0,
230 AIC3X_HEADSET_DEBOUNCE_32MS = 1,
231 AIC3X_HEADSET_DEBOUNCE_64MS = 2,
232 AIC3X_HEADSET_DEBOUNCE_128MS = 3,
233 AIC3X_HEADSET_DEBOUNCE_256MS = 4,
234 AIC3X_HEADSET_DEBOUNCE_512MS = 5
235};
236
237enum {
238 AIC3X_BUTTON_DEBOUNCE_0MS = 0,
239 AIC3X_BUTTON_DEBOUNCE_8MS = 1,
240 AIC3X_BUTTON_DEBOUNCE_16MS = 2,
241 AIC3X_BUTTON_DEBOUNCE_32MS = 3
242};
243
244#define AIC3X_HEADSET_DETECT_ENABLED 0x80
245#define AIC3X_HEADSET_DETECT_SHIFT 5
246#define AIC3X_HEADSET_DETECT_MASK 3
247#define AIC3X_HEADSET_DEBOUNCE_SHIFT 2
248#define AIC3X_HEADSET_DEBOUNCE_MASK 7
249#define AIC3X_BUTTON_DEBOUNCE_SHIFT 0
250#define AIC3X_BUTTON_DEBOUNCE_MASK 3
251
Vladimir Barinov44d0a872007-11-14 17:07:17 +0100252#endif /* _AIC3X_H */