xref: /openbmc/linux/sound/soc/codecs/tlv320aic23.h (revision 95e9fd10)
1 /*
2  * ALSA SoC TLV320AIC23 codec driver
3  *
4  * Author:      Arun KS, <arunks@mistralsolutions.com>
5  * Copyright:   (C) 2008 Mistral Solutions Pvt Ltd
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 _TLV320AIC23_H
13 #define _TLV320AIC23_H
14 
15 /* Codec TLV320AIC23 */
16 #define TLV320AIC23_LINVOL		0x00
17 #define TLV320AIC23_RINVOL		0x01
18 #define TLV320AIC23_LCHNVOL		0x02
19 #define TLV320AIC23_RCHNVOL		0x03
20 #define TLV320AIC23_ANLG		0x04
21 #define TLV320AIC23_DIGT		0x05
22 #define TLV320AIC23_PWR			0x06
23 #define TLV320AIC23_DIGT_FMT		0x07
24 #define TLV320AIC23_SRATE		0x08
25 #define TLV320AIC23_ACTIVE		0x09
26 #define TLV320AIC23_RESET		0x0F
27 
28 /* Left (right) line input volume control register */
29 #define TLV320AIC23_LRS_ENABLED		0x0100
30 #define TLV320AIC23_LIM_MUTED		0x0080
31 #define TLV320AIC23_LIV_DEFAULT		0x0017
32 #define TLV320AIC23_LIV_MAX		0x001f
33 #define TLV320AIC23_LIV_MIN		0x0000
34 
35 /* Left (right) channel headphone volume control register */
36 #define TLV320AIC23_LZC_ON		0x0080
37 #define TLV320AIC23_LHV_DEFAULT		0x0079
38 #define TLV320AIC23_LHV_MAX		0x007f
39 #define TLV320AIC23_LHV_MIN		0x0000
40 
41 /* Analog audio path control register */
42 #define TLV320AIC23_STA_REG(x)		((x)<<6)
43 #define TLV320AIC23_STE_ENABLED		0x0020
44 #define TLV320AIC23_DAC_SELECTED	0x0010
45 #define TLV320AIC23_BYPASS_ON		0x0008
46 #define TLV320AIC23_INSEL_MIC		0x0004
47 #define TLV320AIC23_MICM_MUTED		0x0002
48 #define TLV320AIC23_MICB_20DB		0x0001
49 
50 /* Digital audio path control register */
51 #define TLV320AIC23_DACM_MUTE		0x0008
52 #define TLV320AIC23_DEEMP_32K		0x0002
53 #define TLV320AIC23_DEEMP_44K		0x0004
54 #define TLV320AIC23_DEEMP_48K		0x0006
55 #define TLV320AIC23_ADCHP_ON		0x0001
56 
57 /* Power control down register */
58 #define TLV320AIC23_DEVICE_PWR_OFF  	0x0080
59 #define TLV320AIC23_CLK_OFF		0x0040
60 #define TLV320AIC23_OSC_OFF		0x0020
61 #define TLV320AIC23_OUT_OFF		0x0010
62 #define TLV320AIC23_DAC_OFF		0x0008
63 #define TLV320AIC23_ADC_OFF		0x0004
64 #define TLV320AIC23_MIC_OFF		0x0002
65 #define TLV320AIC23_LINE_OFF		0x0001
66 
67 /* Digital audio interface register */
68 #define TLV320AIC23_MS_MASTER		0x0040
69 #define TLV320AIC23_LRSWAP_ON		0x0020
70 #define TLV320AIC23_LRP_ON		0x0010
71 #define TLV320AIC23_IWL_16		0x0000
72 #define TLV320AIC23_IWL_20		0x0004
73 #define TLV320AIC23_IWL_24		0x0008
74 #define TLV320AIC23_IWL_32		0x000C
75 #define TLV320AIC23_FOR_I2S		0x0002
76 #define TLV320AIC23_FOR_DSP		0x0003
77 #define TLV320AIC23_FOR_LJUST		0x0001
78 
79 /* Sample rate control register */
80 #define TLV320AIC23_CLKOUT_HALF		0x0080
81 #define TLV320AIC23_CLKIN_HALF		0x0040
82 #define TLV320AIC23_BOSR_384fs		0x0002	/* BOSR_272fs in USB mode */
83 #define TLV320AIC23_USB_CLK_ON		0x0001
84 #define TLV320AIC23_SR_MASK             0xf
85 #define TLV320AIC23_CLKOUT_SHIFT        7
86 #define TLV320AIC23_CLKIN_SHIFT         6
87 #define TLV320AIC23_SR_SHIFT            2
88 #define TLV320AIC23_BOSR_SHIFT          1
89 
90 /* Digital interface register */
91 #define TLV320AIC23_ACT_ON		0x0001
92 
93 /*
94  * AUDIO related MACROS
95  */
96 
97 #define TLV320AIC23_DEFAULT_OUT_VOL	0x70
98 #define TLV320AIC23_DEFAULT_IN_VOLUME	0x10
99 
100 #define TLV320AIC23_OUT_VOL_MIN		TLV320AIC23_LHV_MIN
101 #define TLV320AIC23_OUT_VOL_MAX		TLV320AIC23_LHV_MAX
102 #define TLV320AIC23_OUT_VO_RANGE	(TLV320AIC23_OUT_VOL_MAX - \
103 					TLV320AIC23_OUT_VOL_MIN)
104 #define TLV320AIC23_OUT_VOL_MASK	TLV320AIC23_OUT_VOL_MAX
105 
106 #define TLV320AIC23_IN_VOL_MIN		TLV320AIC23_LIV_MIN
107 #define TLV320AIC23_IN_VOL_MAX		TLV320AIC23_LIV_MAX
108 #define TLV320AIC23_IN_VOL_RANGE	(TLV320AIC23_IN_VOL_MAX - \
109 					TLV320AIC23_IN_VOL_MIN)
110 #define TLV320AIC23_IN_VOL_MASK		TLV320AIC23_IN_VOL_MAX
111 
112 #define TLV320AIC23_SIDETONE_MASK	0x1c0
113 #define TLV320AIC23_SIDETONE_0		0x100
114 #define TLV320AIC23_SIDETONE_6		0x000
115 #define TLV320AIC23_SIDETONE_9		0x040
116 #define TLV320AIC23_SIDETONE_12		0x080
117 #define TLV320AIC23_SIDETONE_18		0x0c0
118 
119 #endif /* _TLV320AIC23_H */
120