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