blob: ac9b146526eb5338d58ed94eb6aa8731a415e75e [file] [log] [blame]
Jyri Sarhae00447f2014-03-11 12:57:32 +02001/*
2 * ALSA SoC TLV320AIC31XX codec driver
3 *
4 * Copyright (C) 2013 Texas Instruments, Inc.
5 *
6 * This package is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 *
10 * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
11 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
12 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 *
14 */
15#ifndef _TLV320AIC31XX_H
16#define _TLV320AIC31XX_H
17
18#define AIC31XX_RATES SNDRV_PCM_RATE_8000_192000
19
20#define AIC31XX_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE \
Peter Ujfalusi9cfb7692014-09-04 10:59:41 +030021 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE \
22 | SNDRV_PCM_FMTBIT_S32_LE)
Jyri Sarhae00447f2014-03-11 12:57:32 +020023
24
25#define AIC31XX_STEREO_CLASS_D_BIT 0x1
26#define AIC31XX_MINIDSP_BIT 0x2
27
28enum aic31xx_type {
29 AIC3100 = 0,
30 AIC3110 = AIC31XX_STEREO_CLASS_D_BIT,
31 AIC3120 = AIC31XX_MINIDSP_BIT,
32 AIC3111 = (AIC31XX_STEREO_CLASS_D_BIT | AIC31XX_MINIDSP_BIT),
33};
34
35struct aic31xx_pdata {
36 enum aic31xx_type codec_type;
37 unsigned int gpio_reset;
38 int micbias_vg;
39};
40
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030041#define AIC31XX_REG(page, reg) ((page * 128) + reg)
42
Jyri Sarhae00447f2014-03-11 12:57:32 +020043/* Page Control Register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030044#define AIC31XX_PAGECTL AIC31XX_REG(0, 0)
Jyri Sarhae00447f2014-03-11 12:57:32 +020045
46/* Page 0 Registers */
47/* Software reset register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030048#define AIC31XX_RESET AIC31XX_REG(0, 1)
Jyri Sarhae00447f2014-03-11 12:57:32 +020049/* OT FLAG register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030050#define AIC31XX_OT_FLAG AIC31XX_REG(0, 3)
Jyri Sarhae00447f2014-03-11 12:57:32 +020051/* Clock clock Gen muxing, Multiplexers*/
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030052#define AIC31XX_CLKMUX AIC31XX_REG(0, 4)
Jyri Sarhae00447f2014-03-11 12:57:32 +020053/* PLL P and R-VAL register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030054#define AIC31XX_PLLPR AIC31XX_REG(0, 5)
Jyri Sarhae00447f2014-03-11 12:57:32 +020055/* PLL J-VAL register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030056#define AIC31XX_PLLJ AIC31XX_REG(0, 6)
Jyri Sarhae00447f2014-03-11 12:57:32 +020057/* PLL D-VAL MSB register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030058#define AIC31XX_PLLDMSB AIC31XX_REG(0, 7)
Jyri Sarhae00447f2014-03-11 12:57:32 +020059/* PLL D-VAL LSB register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030060#define AIC31XX_PLLDLSB AIC31XX_REG(0, 8)
Jyri Sarhae00447f2014-03-11 12:57:32 +020061/* DAC NDAC_VAL register*/
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030062#define AIC31XX_NDAC AIC31XX_REG(0, 11)
Jyri Sarhae00447f2014-03-11 12:57:32 +020063/* DAC MDAC_VAL register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030064#define AIC31XX_MDAC AIC31XX_REG(0, 12)
Jyri Sarhae00447f2014-03-11 12:57:32 +020065/* DAC OSR setting register 1, MSB value */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030066#define AIC31XX_DOSRMSB AIC31XX_REG(0, 13)
Jyri Sarhae00447f2014-03-11 12:57:32 +020067/* DAC OSR setting register 2, LSB value */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030068#define AIC31XX_DOSRLSB AIC31XX_REG(0, 14)
69#define AIC31XX_MINI_DSP_INPOL AIC31XX_REG(0, 16)
Jyri Sarhae00447f2014-03-11 12:57:32 +020070/* Clock setting register 8, PLL */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030071#define AIC31XX_NADC AIC31XX_REG(0, 18)
Jyri Sarhae00447f2014-03-11 12:57:32 +020072/* Clock setting register 9, PLL */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030073#define AIC31XX_MADC AIC31XX_REG(0, 19)
Jyri Sarhae00447f2014-03-11 12:57:32 +020074/* ADC Oversampling (AOSR) Register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030075#define AIC31XX_AOSR AIC31XX_REG(0, 20)
Jyri Sarhae00447f2014-03-11 12:57:32 +020076/* Clock setting register 9, Multiplexers */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030077#define AIC31XX_CLKOUTMUX AIC31XX_REG(0, 25)
Jyri Sarhae00447f2014-03-11 12:57:32 +020078/* Clock setting register 10, CLOCKOUT M divider value */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030079#define AIC31XX_CLKOUTMVAL AIC31XX_REG(0, 26)
Jyri Sarhae00447f2014-03-11 12:57:32 +020080/* Audio Interface Setting Register 1 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030081#define AIC31XX_IFACE1 AIC31XX_REG(0, 27)
Jyri Sarhae00447f2014-03-11 12:57:32 +020082/* Audio Data Slot Offset Programming */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030083#define AIC31XX_DATA_OFFSET AIC31XX_REG(0, 28)
Jyri Sarhae00447f2014-03-11 12:57:32 +020084/* Audio Interface Setting Register 2 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030085#define AIC31XX_IFACE2 AIC31XX_REG(0, 29)
Jyri Sarhae00447f2014-03-11 12:57:32 +020086/* Clock setting register 11, BCLK N Divider */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030087#define AIC31XX_BCLKN AIC31XX_REG(0, 30)
Jyri Sarhae00447f2014-03-11 12:57:32 +020088/* Audio Interface Setting Register 3, Secondary Audio Interface */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030089#define AIC31XX_IFACESEC1 AIC31XX_REG(0, 31)
Jyri Sarhae00447f2014-03-11 12:57:32 +020090/* Audio Interface Setting Register 4 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030091#define AIC31XX_IFACESEC2 AIC31XX_REG(0, 32)
Jyri Sarhae00447f2014-03-11 12:57:32 +020092/* Audio Interface Setting Register 5 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030093#define AIC31XX_IFACESEC3 AIC31XX_REG(0, 33)
Jyri Sarhae00447f2014-03-11 12:57:32 +020094/* I2C Bus Condition */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030095#define AIC31XX_I2C AIC31XX_REG(0, 34)
Jyri Sarhae00447f2014-03-11 12:57:32 +020096/* ADC FLAG */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030097#define AIC31XX_ADCFLAG AIC31XX_REG(0, 36)
Jyri Sarhae00447f2014-03-11 12:57:32 +020098/* DAC Flag Registers */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +030099#define AIC31XX_DACFLAG1 AIC31XX_REG(0, 37)
100#define AIC31XX_DACFLAG2 AIC31XX_REG(0, 38)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200101/* Sticky Interrupt flag (overflow) */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300102#define AIC31XX_OFFLAG AIC31XX_REG(0, 39)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200103/* Sticy DAC Interrupt flags */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300104#define AIC31XX_INTRDACFLAG AIC31XX_REG(0, 44)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200105/* Sticy ADC Interrupt flags */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300106#define AIC31XX_INTRADCFLAG AIC31XX_REG(0, 45)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200107/* DAC Interrupt flags 2 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300108#define AIC31XX_INTRDACFLAG2 AIC31XX_REG(0, 46)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200109/* ADC Interrupt flags 2 */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300110#define AIC31XX_INTRADCFLAG2 AIC31XX_REG(0, 47)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200111/* INT1 interrupt control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300112#define AIC31XX_INT1CTRL AIC31XX_REG(0, 48)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200113/* INT2 interrupt control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300114#define AIC31XX_INT2CTRL AIC31XX_REG(0, 49)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200115/* GPIO1 control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300116#define AIC31XX_GPIO1 AIC31XX_REG(0, 50)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200117
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300118#define AIC31XX_DACPRB AIC31XX_REG(0, 60)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200119/* ADC Instruction Set Register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300120#define AIC31XX_ADCPRB AIC31XX_REG(0, 61)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200121/* DAC channel setup register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300122#define AIC31XX_DACSETUP AIC31XX_REG(0, 63)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200123/* DAC Mute and volume control register */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300124#define AIC31XX_DACMUTE AIC31XX_REG(0, 64)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200125/* Left DAC channel digital volume control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300126#define AIC31XX_LDACVOL AIC31XX_REG(0, 65)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200127/* Right DAC channel digital volume control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300128#define AIC31XX_RDACVOL AIC31XX_REG(0, 66)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200129/* Headset detection */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300130#define AIC31XX_HSDETECT AIC31XX_REG(0, 67)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200131/* ADC Digital Mic */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300132#define AIC31XX_ADCSETUP AIC31XX_REG(0, 81)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200133/* ADC Digital Volume Control Fine Adjust */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300134#define AIC31XX_ADCFGA AIC31XX_REG(0, 82)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200135/* ADC Digital Volume Control Coarse Adjust */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300136#define AIC31XX_ADCVOL AIC31XX_REG(0, 83)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200137
138
139/* Page 1 Registers */
140/* Headphone drivers */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300141#define AIC31XX_HPDRIVER AIC31XX_REG(1, 31)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200142/* Class-D Speakear Amplifier */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300143#define AIC31XX_SPKAMP AIC31XX_REG(1, 32)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200144/* HP Output Drivers POP Removal Settings */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300145#define AIC31XX_HPPOP AIC31XX_REG(1, 33)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200146/* Output Driver PGA Ramp-Down Period Control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300147#define AIC31XX_SPPGARAMP AIC31XX_REG(1, 34)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200148/* DAC_L and DAC_R Output Mixer Routing */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300149#define AIC31XX_DACMIXERROUTE AIC31XX_REG(1, 35)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200150/* Left Analog Vol to HPL */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300151#define AIC31XX_LANALOGHPL AIC31XX_REG(1, 36)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200152/* Right Analog Vol to HPR */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300153#define AIC31XX_RANALOGHPR AIC31XX_REG(1, 37)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200154/* Left Analog Vol to SPL */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300155#define AIC31XX_LANALOGSPL AIC31XX_REG(1, 38)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200156/* Right Analog Vol to SPR */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300157#define AIC31XX_RANALOGSPR AIC31XX_REG(1, 39)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200158/* HPL Driver */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300159#define AIC31XX_HPLGAIN AIC31XX_REG(1, 40)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200160/* HPR Driver */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300161#define AIC31XX_HPRGAIN AIC31XX_REG(1, 41)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200162/* SPL Driver */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300163#define AIC31XX_SPLGAIN AIC31XX_REG(1, 42)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200164/* SPR Driver */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300165#define AIC31XX_SPRGAIN AIC31XX_REG(1, 43)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200166/* HP Driver Control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300167#define AIC31XX_HPCONTROL AIC31XX_REG(1, 44)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200168/* MIC Bias Control */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300169#define AIC31XX_MICBIAS AIC31XX_REG(1, 46)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200170/* MIC PGA*/
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300171#define AIC31XX_MICPGA AIC31XX_REG(1, 47)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200172/* Delta-Sigma Mono ADC Channel Fine-Gain Input Selection for P-Terminal */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300173#define AIC31XX_MICPGAPI AIC31XX_REG(1, 48)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200174/* ADC Input Selection for M-Terminal */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300175#define AIC31XX_MICPGAMI AIC31XX_REG(1, 49)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200176/* Input CM Settings */
Peter Ujfalusibafcbfe2016-05-26 10:36:35 +0300177#define AIC31XX_MICPGACM AIC31XX_REG(1, 50)
Jyri Sarhae00447f2014-03-11 12:57:32 +0200178
179/* Bits, masks and shifts */
180
181/* AIC31XX_CLKMUX */
182#define AIC31XX_PLL_CLKIN_MASK 0x0c
183#define AIC31XX_PLL_CLKIN_SHIFT 2
184#define AIC31XX_PLL_CLKIN_MCLK 0
185#define AIC31XX_CODEC_CLKIN_MASK 0x03
186#define AIC31XX_CODEC_CLKIN_SHIFT 0
187#define AIC31XX_CODEC_CLKIN_PLL 3
188#define AIC31XX_CODEC_CLKIN_BCLK 1
189
190/* AIC31XX_PLLPR, AIC31XX_NDAC, AIC31XX_MDAC, AIC31XX_NADC, AIC31XX_MADC,
191 AIC31XX_BCLKN */
192#define AIC31XX_PLL_MASK 0x7f
193#define AIC31XX_PM_MASK 0x80
194
195/* AIC31XX_IFACE1 */
196#define AIC31XX_WORD_LEN_16BITS 0x00
197#define AIC31XX_WORD_LEN_20BITS 0x01
198#define AIC31XX_WORD_LEN_24BITS 0x02
199#define AIC31XX_WORD_LEN_32BITS 0x03
200#define AIC31XX_IFACE1_DATALEN_MASK 0x30
201#define AIC31XX_IFACE1_DATALEN_SHIFT (4)
202#define AIC31XX_IFACE1_DATATYPE_MASK 0xC0
203#define AIC31XX_IFACE1_DATATYPE_SHIFT (6)
204#define AIC31XX_I2S_MODE 0x00
205#define AIC31XX_DSP_MODE 0x01
206#define AIC31XX_RIGHT_JUSTIFIED_MODE 0x02
207#define AIC31XX_LEFT_JUSTIFIED_MODE 0x03
208#define AIC31XX_IFACE1_MASTER_MASK 0x0C
209#define AIC31XX_BCLK_MASTER 0x08
210#define AIC31XX_WCLK_MASTER 0x04
211
212/* AIC31XX_DATA_OFFSET */
213#define AIC31XX_DATA_OFFSET_MASK 0xFF
214
215/* AIC31XX_IFACE2 */
216#define AIC31XX_BCLKINV_MASK 0x08
217#define AIC31XX_BDIVCLK_MASK 0x03
218#define AIC31XX_DAC2BCLK 0x00
219#define AIC31XX_DACMOD2BCLK 0x01
220#define AIC31XX_ADC2BCLK 0x02
221#define AIC31XX_ADCMOD2BCLK 0x03
222
223/* AIC31XX_ADCFLAG */
224#define AIC31XX_ADCPWRSTATUS_MASK 0x40
225
226/* AIC31XX_DACFLAG1 */
227#define AIC31XX_LDACPWRSTATUS_MASK 0x80
228#define AIC31XX_RDACPWRSTATUS_MASK 0x08
229#define AIC31XX_HPLDRVPWRSTATUS_MASK 0x20
230#define AIC31XX_HPRDRVPWRSTATUS_MASK 0x02
231#define AIC31XX_SPLDRVPWRSTATUS_MASK 0x10
232#define AIC31XX_SPRDRVPWRSTATUS_MASK 0x01
233
234/* AIC31XX_INTRDACFLAG */
235#define AIC31XX_HPSCDETECT_MASK 0x80
236#define AIC31XX_BUTTONPRESS_MASK 0x20
237#define AIC31XX_HSPLUG_MASK 0x10
238#define AIC31XX_LDRCTHRES_MASK 0x08
239#define AIC31XX_RDRCTHRES_MASK 0x04
240#define AIC31XX_DACSINT_MASK 0x02
241#define AIC31XX_DACAINT_MASK 0x01
242
243/* AIC31XX_INT1CTRL */
244#define AIC31XX_HSPLUGDET_MASK 0x80
245#define AIC31XX_BUTTONPRESSDET_MASK 0x40
246#define AIC31XX_DRCTHRES_MASK 0x20
247#define AIC31XX_AGCNOISE_MASK 0x10
248#define AIC31XX_OC_MASK 0x08
249#define AIC31XX_ENGINE_MASK 0x04
250
251/* AIC31XX_DACSETUP */
252#define AIC31XX_SOFTSTEP_MASK 0x03
253
254/* AIC31XX_DACMUTE */
255#define AIC31XX_DACMUTE_MASK 0x0C
256
257/* AIC31XX_MICBIAS */
258#define AIC31XX_MICBIAS_MASK 0x03
259#define AIC31XX_MICBIAS_SHIFT 0
260
261#endif /* _TLV320AIC31XX_H */