diff options
author | Adam Thomson <Adam.Thomson@diasemi.com> | 2012-06-11 08:15:27 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2012-06-11 08:23:55 -0400 |
commit | 48e278746070b5fc62ec3da2e65f7cd511f6bbf4 (patch) | |
tree | d9d534698405dc2ae5b0a7a2c34952fe373e7b63 | |
parent | af691fb62c626fe374955ab306092b09f672e27d (diff) |
ASoC: codecs: Add DA732x codec driver
This patch adds support for Dialog DA732x audio codecs.
Signed-off-by: Michal Hajduk <Michal.Hajduk@diasemi.com>
Signed-off-by: Adam Thomson <Adam.Thomson@diasemi.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/Kconfig | 4 | ||||
-rw-r--r-- | sound/soc/codecs/Makefile | 2 | ||||
-rw-r--r-- | sound/soc/codecs/da732x.c | 1627 | ||||
-rw-r--r-- | sound/soc/codecs/da732x.h | 133 | ||||
-rw-r--r-- | sound/soc/codecs/da732x_reg.h | 654 |
5 files changed, 2420 insertions, 0 deletions
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index f63776d422b3..43f5240e6942 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
@@ -36,6 +36,7 @@ config SND_SOC_ALL_CODECS | |||
36 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI | 36 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI |
37 | select SND_SOC_CX20442 | 37 | select SND_SOC_CX20442 |
38 | select SND_SOC_DA7210 if I2C | 38 | select SND_SOC_DA7210 if I2C |
39 | select SND_SOC_DA732X if I2C | ||
39 | select SND_SOC_DFBMCS320 | 40 | select SND_SOC_DFBMCS320 |
40 | select SND_SOC_ISABELLE if I2C | 41 | select SND_SOC_ISABELLE if I2C |
41 | select SND_SOC_JZ4740_CODEC | 42 | select SND_SOC_JZ4740_CODEC |
@@ -224,6 +225,9 @@ config SND_SOC_L3 | |||
224 | config SND_SOC_DA7210 | 225 | config SND_SOC_DA7210 |
225 | tristate | 226 | tristate |
226 | 227 | ||
228 | config SND_SOC_DA732X | ||
229 | tristate | ||
230 | |||
227 | config SND_SOC_DFBMCS320 | 231 | config SND_SOC_DFBMCS320 |
228 | tristate | 232 | tristate |
229 | 233 | ||
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index fc93b4b0c2c5..3d30654f6fcc 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
@@ -22,6 +22,7 @@ snd-soc-cs4270-objs := cs4270.o | |||
22 | snd-soc-cs4271-objs := cs4271.o | 22 | snd-soc-cs4271-objs := cs4271.o |
23 | snd-soc-cx20442-objs := cx20442.o | 23 | snd-soc-cx20442-objs := cx20442.o |
24 | snd-soc-da7210-objs := da7210.o | 24 | snd-soc-da7210-objs := da7210.o |
25 | snd-soc-da732x-objs := da732x.o | ||
25 | snd-soc-dfbmcs320-objs := dfbmcs320.o | 26 | snd-soc-dfbmcs320-objs := dfbmcs320.o |
26 | snd-soc-dmic-objs := dmic.o | 27 | snd-soc-dmic-objs := dmic.o |
27 | snd-soc-isabelle-objs := isabelle.o | 28 | snd-soc-isabelle-objs := isabelle.o |
@@ -135,6 +136,7 @@ obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o | |||
135 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o | 136 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o |
136 | obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o | 137 | obj-$(CONFIG_SND_SOC_CX20442) += snd-soc-cx20442.o |
137 | obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o | 138 | obj-$(CONFIG_SND_SOC_DA7210) += snd-soc-da7210.o |
139 | obj-$(CONFIG_SND_SOC_DA732X) += snd-soc-da732x.o | ||
138 | obj-$(CONFIG_SND_SOC_DFBMCS320) += snd-soc-dfbmcs320.o | 140 | obj-$(CONFIG_SND_SOC_DFBMCS320) += snd-soc-dfbmcs320.o |
139 | obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o | 141 | obj-$(CONFIG_SND_SOC_DMIC) += snd-soc-dmic.o |
140 | obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o | 142 | obj-$(CONFIG_SND_SOC_ISABELLE) += snd-soc-isabelle.o |
diff --git a/sound/soc/codecs/da732x.c b/sound/soc/codecs/da732x.c new file mode 100644 index 000000000000..04af369f228c --- /dev/null +++ b/sound/soc/codecs/da732x.c | |||
@@ -0,0 +1,1627 @@ | |||
1 | /* | ||
2 | * da732x.c --- Dialog DA732X ALSA SoC Audio Driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Dialog Semiconductor GmbH | ||
5 | * | ||
6 | * Author: Michal Hajduk <Michal.Hajduk@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/module.h> | ||
14 | #include <linux/moduleparam.h> | ||
15 | #include <linux/init.h> | ||
16 | #include <linux/delay.h> | ||
17 | #include <linux/pm.h> | ||
18 | #include <linux/i2c.h> | ||
19 | #include <linux/regmap.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/sysfs.h> | ||
23 | #include <sound/core.h> | ||
24 | #include <sound/pcm.h> | ||
25 | #include <sound/pcm_params.h> | ||
26 | #include <sound/soc.h> | ||
27 | #include <sound/soc-dapm.h> | ||
28 | #include <sound/initval.h> | ||
29 | #include <sound/tlv.h> | ||
30 | #include <asm/div64.h> | ||
31 | |||
32 | #include "da732x.h" | ||
33 | #include "da732x_reg.h" | ||
34 | |||
35 | |||
36 | struct da732x_priv { | ||
37 | struct regmap *regmap; | ||
38 | struct snd_soc_codec *codec; | ||
39 | |||
40 | unsigned int sysclk; | ||
41 | bool pll_en; | ||
42 | }; | ||
43 | |||
44 | /* | ||
45 | * da732x register cache - default settings | ||
46 | */ | ||
47 | static struct reg_default da732x_reg_cache[] = { | ||
48 | { DA732X_REG_REF1 , 0x02 }, | ||
49 | { DA732X_REG_BIAS_EN , 0x80 }, | ||
50 | { DA732X_REG_BIAS1 , 0x00 }, | ||
51 | { DA732X_REG_BIAS2 , 0x00 }, | ||
52 | { DA732X_REG_BIAS3 , 0x00 }, | ||
53 | { DA732X_REG_BIAS4 , 0x00 }, | ||
54 | { DA732X_REG_MICBIAS2 , 0x00 }, | ||
55 | { DA732X_REG_MICBIAS1 , 0x00 }, | ||
56 | { DA732X_REG_MICDET , 0x00 }, | ||
57 | { DA732X_REG_MIC1_PRE , 0x01 }, | ||
58 | { DA732X_REG_MIC1 , 0x40 }, | ||
59 | { DA732X_REG_MIC2_PRE , 0x01 }, | ||
60 | { DA732X_REG_MIC2 , 0x40 }, | ||
61 | { DA732X_REG_AUX1L , 0x75 }, | ||
62 | { DA732X_REG_AUX1R , 0x75 }, | ||
63 | { DA732X_REG_MIC3_PRE , 0x01 }, | ||
64 | { DA732X_REG_MIC3 , 0x40 }, | ||
65 | { DA732X_REG_INP_PINBIAS , 0x00 }, | ||
66 | { DA732X_REG_INP_ZC_EN , 0x00 }, | ||
67 | { DA732X_REG_INP_MUX , 0x50 }, | ||
68 | { DA732X_REG_HP_DET , 0x00 }, | ||
69 | { DA732X_REG_HPL_DAC_OFFSET , 0x00 }, | ||
70 | { DA732X_REG_HPL_DAC_OFF_CNTL , 0x00 }, | ||
71 | { DA732X_REG_HPL_OUT_OFFSET , 0x00 }, | ||
72 | { DA732X_REG_HPL , 0x40 }, | ||
73 | { DA732X_REG_HPL_VOL , 0x0F }, | ||
74 | { DA732X_REG_HPR_DAC_OFFSET , 0x00 }, | ||
75 | { DA732X_REG_HPR_DAC_OFF_CNTL , 0x00 }, | ||
76 | { DA732X_REG_HPR_OUT_OFFSET , 0x00 }, | ||
77 | { DA732X_REG_HPR , 0x40 }, | ||
78 | { DA732X_REG_HPR_VOL , 0x0F }, | ||
79 | { DA732X_REG_LIN2 , 0x4F }, | ||
80 | { DA732X_REG_LIN3 , 0x4F }, | ||
81 | { DA732X_REG_LIN4 , 0x4F }, | ||
82 | { DA732X_REG_OUT_ZC_EN , 0x00 }, | ||
83 | { DA732X_REG_HP_LIN1_GNDSEL , 0x00 }, | ||
84 | { DA732X_REG_CP_HP1 , 0x0C }, | ||
85 | { DA732X_REG_CP_HP2 , 0x03 }, | ||
86 | { DA732X_REG_CP_CTRL1 , 0x00 }, | ||
87 | { DA732X_REG_CP_CTRL2 , 0x99 }, | ||
88 | { DA732X_REG_CP_CTRL3 , 0x25 }, | ||
89 | { DA732X_REG_CP_LEVEL_MASK , 0x3F }, | ||
90 | { DA732X_REG_CP_DET , 0x00 }, | ||
91 | { DA732X_REG_CP_STATUS , 0x00 }, | ||
92 | { DA732X_REG_CP_THRESH1 , 0x00 }, | ||
93 | { DA732X_REG_CP_THRESH2 , 0x00 }, | ||
94 | { DA732X_REG_CP_THRESH3 , 0x00 }, | ||
95 | { DA732X_REG_CP_THRESH4 , 0x00 }, | ||
96 | { DA732X_REG_CP_THRESH5 , 0x00 }, | ||
97 | { DA732X_REG_CP_THRESH6 , 0x00 }, | ||
98 | { DA732X_REG_CP_THRESH7 , 0x00 }, | ||
99 | { DA732X_REG_CP_THRESH8 , 0x00 }, | ||
100 | { DA732X_REG_PLL_DIV_LO , 0x00 }, | ||
101 | { DA732X_REG_PLL_DIV_MID , 0x00 }, | ||
102 | { DA732X_REG_PLL_DIV_HI , 0x00 }, | ||
103 | { DA732X_REG_PLL_CTRL , 0x02 }, | ||
104 | { DA732X_REG_CLK_CTRL , 0xaa }, | ||
105 | { DA732X_REG_CLK_DSP , 0x07 }, | ||
106 | { DA732X_REG_CLK_EN1 , 0x00 }, | ||
107 | { DA732X_REG_CLK_EN2 , 0x00 }, | ||
108 | { DA732X_REG_CLK_EN3 , 0x00 }, | ||
109 | { DA732X_REG_CLK_EN4 , 0x00 }, | ||
110 | { DA732X_REG_CLK_EN5 , 0x00 }, | ||
111 | { DA732X_REG_AIF_MCLK , 0x00 }, | ||
112 | { DA732X_REG_AIFA1 , 0x02 }, | ||
113 | { DA732X_REG_AIFA2 , 0x00 }, | ||
114 | { DA732X_REG_AIFA3 , 0x08 }, | ||
115 | { DA732X_REG_AIFB1 , 0x02 }, | ||
116 | { DA732X_REG_AIFB2 , 0x00 }, | ||
117 | { DA732X_REG_AIFB3 , 0x08 }, | ||
118 | { DA732X_REG_PC_CTRL , 0xC0 }, | ||
119 | { DA732X_REG_DATA_ROUTE , 0x00 }, | ||
120 | { DA732X_REG_DSP_CTRL , 0x00 }, | ||
121 | { DA732X_REG_CIF_CTRL2 , 0x00 }, | ||
122 | { DA732X_REG_HANDSHAKE , 0x00 }, | ||
123 | { DA732X_REG_SPARE1_OUT , 0x00 }, | ||
124 | { DA732X_REG_SPARE2_OUT , 0x00 }, | ||
125 | { DA732X_REG_SPARE1_IN , 0x00 }, | ||
126 | { DA732X_REG_ADC1_PD , 0x00 }, | ||
127 | { DA732X_REG_ADC1_HPF , 0x00 }, | ||
128 | { DA732X_REG_ADC1_SEL , 0x00 }, | ||
129 | { DA732X_REG_ADC1_EQ12 , 0x00 }, | ||
130 | { DA732X_REG_ADC1_EQ34 , 0x00 }, | ||
131 | { DA732X_REG_ADC1_EQ5 , 0x00 }, | ||
132 | { DA732X_REG_ADC2_PD , 0x00 }, | ||
133 | { DA732X_REG_ADC2_HPF , 0x00 }, | ||
134 | { DA732X_REG_ADC2_SEL , 0x00 }, | ||
135 | { DA732X_REG_ADC2_EQ12 , 0x00 }, | ||
136 | { DA732X_REG_ADC2_EQ34 , 0x00 }, | ||
137 | { DA732X_REG_ADC2_EQ5 , 0x00 }, | ||
138 | { DA732X_REG_DAC1_HPF , 0x00 }, | ||
139 | { DA732X_REG_DAC1_L_VOL , 0x00 }, | ||
140 | { DA732X_REG_DAC1_R_VOL , 0x00 }, | ||
141 | { DA732X_REG_DAC1_SEL , 0x00 }, | ||
142 | { DA732X_REG_DAC1_SOFTMUTE , 0x00 }, | ||
143 | { DA732X_REG_DAC1_EQ12 , 0x00 }, | ||
144 | { DA732X_REG_DAC1_EQ34 , 0x00 }, | ||
145 | { DA732X_REG_DAC1_EQ5 , 0x00 }, | ||
146 | { DA732X_REG_DAC2_HPF , 0x00 }, | ||
147 | { DA732X_REG_DAC2_L_VOL , 0x00 }, | ||
148 | { DA732X_REG_DAC2_R_VOL , 0x00 }, | ||
149 | { DA732X_REG_DAC2_SEL , 0x00 }, | ||
150 | { DA732X_REG_DAC2_SOFTMUTE , 0x00 }, | ||
151 | { DA732X_REG_DAC2_EQ12 , 0x00 }, | ||
152 | { DA732X_REG_DAC2_EQ34 , 0x00 }, | ||
153 | { DA732X_REG_DAC2_EQ5 , 0x00 }, | ||
154 | { DA732X_REG_DAC3_HPF , 0x00 }, | ||
155 | { DA732X_REG_DAC3_VOL , 0x00 }, | ||
156 | { DA732X_REG_DAC3_SEL , 0x00 }, | ||
157 | { DA732X_REG_DAC3_SOFTMUTE , 0x00 }, | ||
158 | { DA732X_REG_DAC3_EQ12 , 0x00 }, | ||
159 | { DA732X_REG_DAC3_EQ34 , 0x00 }, | ||
160 | { DA732X_REG_DAC3_EQ5 , 0x00 }, | ||
161 | { DA732X_REG_BIQ_BYP , 0x00 }, | ||
162 | { DA732X_REG_DMA_CMD , 0x00 }, | ||
163 | { DA732X_REG_DMA_ADDR0 , 0x00 }, | ||
164 | { DA732X_REG_DMA_ADDR1 , 0x00 }, | ||
165 | { DA732X_REG_DMA_DATA0 , 0x00 }, | ||
166 | { DA732X_REG_DMA_DATA1 , 0x00 }, | ||
167 | { DA732X_REG_DMA_DATA2 , 0x00 }, | ||
168 | { DA732X_REG_DMA_DATA3 , 0x00 }, | ||
169 | { DA732X_REG_UNLOCK , 0x00 }, | ||
170 | }; | ||
171 | |||
172 | static inline int da732x_get_input_div(struct snd_soc_codec *codec, int sysclk) | ||
173 | { | ||
174 | int val; | ||
175 | int ret; | ||
176 | |||
177 | if (sysclk < DA732X_MCLK_10MHZ) { | ||
178 | val = DA732X_MCLK_RET_0_10MHZ; | ||
179 | ret = DA732X_MCLK_VAL_0_10MHZ; | ||
180 | } else if ((sysclk >= DA732X_MCLK_10MHZ) && | ||
181 | (sysclk < DA732X_MCLK_20MHZ)) { | ||
182 | val = DA732X_MCLK_RET_10_20MHZ; | ||
183 | ret = DA732X_MCLK_VAL_10_20MHZ; | ||
184 | } else if ((sysclk >= DA732X_MCLK_20MHZ) && | ||
185 | (sysclk < DA732X_MCLK_40MHZ)) { | ||
186 | val = DA732X_MCLK_RET_20_40MHZ; | ||
187 | ret = DA732X_MCLK_VAL_20_40MHZ; | ||
188 | } else if ((sysclk >= DA732X_MCLK_40MHZ) && | ||
189 | (sysclk <= DA732X_MCLK_54MHZ)) { | ||
190 | val = DA732X_MCLK_RET_40_54MHZ; | ||
191 | ret = DA732X_MCLK_VAL_40_54MHZ; | ||
192 | } else { | ||
193 | return -EINVAL; | ||
194 | } | ||
195 | |||
196 | snd_soc_write(codec, DA732X_REG_PLL_CTRL, val); | ||
197 | |||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | static void da732x_set_charge_pump(struct snd_soc_codec *codec, int state) | ||
202 | { | ||
203 | switch (state) { | ||
204 | case DA732X_ENABLE_CP: | ||
205 | snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_EN); | ||
206 | snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_EN | | ||
207 | DA732X_HP_CP_REG | DA732X_HP_CP_PULSESKIP); | ||
208 | snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA732X_CP_EN | | ||
209 | DA732X_CP_CTRL_CPVDD1); | ||
210 | snd_soc_write(codec, DA732X_REG_CP_CTRL2, | ||
211 | DA732X_CP_MANAGE_MAGNITUDE | DA732X_CP_BOOST); | ||
212 | snd_soc_write(codec, DA732X_REG_CP_CTRL3, DA732X_CP_1MHZ); | ||
213 | break; | ||
214 | case DA732X_DISABLE_CP: | ||
215 | snd_soc_write(codec, DA732X_REG_CLK_EN2, DA732X_CP_CLK_DIS); | ||
216 | snd_soc_write(codec, DA732X_REG_CP_HP2, DA732X_HP_CP_DIS); | ||
217 | snd_soc_write(codec, DA732X_REG_CP_CTRL1, DA723X_CP_DIS); | ||
218 | break; | ||
219 | default: | ||
220 | pr_err(KERN_ERR "Wrong charge pump state\n"); | ||
221 | break; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static const DECLARE_TLV_DB_SCALE(mic_boost_tlv, DA732X_MIC_PRE_VOL_DB_MIN, | ||
226 | DA732X_MIC_PRE_VOL_DB_INC, 0); | ||
227 | |||
228 | static const DECLARE_TLV_DB_SCALE(mic_pga_tlv, DA732X_MIC_VOL_DB_MIN, | ||
229 | DA732X_MIC_VOL_DB_INC, 0); | ||
230 | |||
231 | static const DECLARE_TLV_DB_SCALE(aux_pga_tlv, DA732X_AUX_VOL_DB_MIN, | ||
232 | DA732X_AUX_VOL_DB_INC, 0); | ||
233 | |||
234 | static const DECLARE_TLV_DB_SCALE(hp_pga_tlv, DA732X_HP_VOL_DB_MIN, | ||
235 | DA732X_AUX_VOL_DB_INC, 0); | ||
236 | |||
237 | static const DECLARE_TLV_DB_SCALE(lin2_pga_tlv, DA732X_LIN2_VOL_DB_MIN, | ||
238 | DA732X_LIN2_VOL_DB_INC, 0); | ||
239 | |||
240 | static const DECLARE_TLV_DB_SCALE(lin3_pga_tlv, DA732X_LIN3_VOL_DB_MIN, | ||
241 | DA732X_LIN3_VOL_DB_INC, 0); | ||
242 | |||
243 | static const DECLARE_TLV_DB_SCALE(lin4_pga_tlv, DA732X_LIN4_VOL_DB_MIN, | ||
244 | DA732X_LIN4_VOL_DB_INC, 0); | ||
245 | |||
246 | static const DECLARE_TLV_DB_SCALE(adc_pga_tlv, DA732X_ADC_VOL_DB_MIN, | ||
247 | DA732X_ADC_VOL_DB_INC, 0); | ||
248 | |||
249 | static const DECLARE_TLV_DB_SCALE(dac_pga_tlv, DA732X_DAC_VOL_DB_MIN, | ||
250 | DA732X_DAC_VOL_DB_INC, 0); | ||
251 | |||
252 | static const DECLARE_TLV_DB_SCALE(eq_band_pga_tlv, DA732X_EQ_BAND_VOL_DB_MIN, | ||
253 | DA732X_EQ_BAND_VOL_DB_INC, 0); | ||
254 | |||
255 | static const DECLARE_TLV_DB_SCALE(eq_overall_tlv, DA732X_EQ_OVERALL_VOL_DB_MIN, | ||
256 | DA732X_EQ_OVERALL_VOL_DB_INC, 0); | ||
257 | |||
258 | /* High Pass Filter */ | ||
259 | static const char *da732x_hpf_mode[] = { | ||
260 | "Disable", "Music", "Voice", | ||
261 | }; | ||
262 | |||
263 | static const char *da732x_hpf_music[] = { | ||
264 | "1.8Hz", "3.75Hz", "7.5Hz", "15Hz", | ||
265 | }; | ||
266 | |||
267 | static const char *da732x_hpf_voice[] = { | ||
268 | "2.5Hz", "25Hz", "50Hz", "100Hz", | ||
269 | "150Hz", "200Hz", "300Hz", "400Hz" | ||
270 | }; | ||
271 | |||
272 | static const struct soc_enum da732x_dac1_hpf_mode_enum[] = { | ||
273 | SOC_ENUM_SINGLE(DA732X_REG_DAC1_HPF, DA732X_HPF_MODE_SHIFT, | ||
274 | DA732X_HPF_MODE_MAX, da732x_hpf_mode) | ||
275 | }; | ||
276 | |||
277 | static const struct soc_enum da732x_dac2_hpf_mode_enum[] = { | ||
278 | SOC_ENUM_SINGLE(DA732X_REG_DAC2_HPF, DA732X_HPF_MODE_SHIFT, | ||
279 | DA732X_HPF_MODE_MAX, da732x_hpf_mode) | ||
280 | }; | ||
281 | |||
282 | static const struct soc_enum da732x_dac3_hpf_mode_enum[] = { | ||
283 | SOC_ENUM_SINGLE(DA732X_REG_DAC3_HPF, DA732X_HPF_MODE_SHIFT, | ||
284 | DA732X_HPF_MODE_MAX, da732x_hpf_mode) | ||
285 | }; | ||
286 | |||
287 | static const struct soc_enum da732x_adc1_hpf_mode_enum[] = { | ||
288 | SOC_ENUM_SINGLE(DA732X_REG_ADC1_HPF, DA732X_HPF_MODE_SHIFT, | ||
289 | DA732X_HPF_MODE_MAX, da732x_hpf_mode) | ||
290 | }; | ||
291 | |||
292 | static const struct soc_enum da732x_adc2_hpf_mode_enum[] = { | ||
293 | SOC_ENUM_SINGLE(DA732X_REG_ADC2_HPF, DA732X_HPF_MODE_SHIFT, | ||
294 | DA732X_HPF_MODE_MAX, da732x_hpf_mode) | ||
295 | }; | ||
296 | |||
297 | static const struct soc_enum da732x_dac1_hp_filter_enum[] = { | ||
298 | SOC_ENUM_SINGLE(DA732X_REG_DAC1_HPF, DA732X_HPF_MUSIC_SHIFT, | ||
299 | DA732X_HPF_MUSIC_MAX, da732x_hpf_music) | ||
300 | }; | ||
301 | |||
302 | static const struct soc_enum da732x_dac2_hp_filter_enum[] = { | ||
303 | SOC_ENUM_SINGLE(DA732X_REG_DAC2_HPF, DA732X_HPF_MUSIC_SHIFT, | ||
304 | DA732X_HPF_MUSIC_MAX, da732x_hpf_music) | ||
305 | }; | ||
306 | |||
307 | static const struct soc_enum da732x_dac3_hp_filter_enum[] = { | ||
308 | SOC_ENUM_SINGLE(DA732X_REG_DAC3_HPF, DA732X_HPF_MUSIC_SHIFT, | ||
309 | DA732X_HPF_MUSIC_MAX, da732x_hpf_music) | ||
310 | }; | ||
311 | |||
312 | static const struct soc_enum da732x_adc1_hp_filter_enum[] = { | ||
313 | SOC_ENUM_SINGLE(DA732X_REG_ADC1_HPF, DA732X_HPF_MUSIC_SHIFT, | ||
314 | DA732X_HPF_MUSIC_MAX, da732x_hpf_music) | ||
315 | }; | ||
316 | |||
317 | static const struct soc_enum da732x_adc2_hp_filter_enum[] = { | ||
318 | SOC_ENUM_SINGLE(DA732X_REG_ADC2_HPF, DA732X_HPF_MUSIC_SHIFT, | ||
319 | DA732X_HPF_MUSIC_MAX, da732x_hpf_music) | ||
320 | }; | ||
321 | |||
322 | static const struct soc_enum da732x_dac1_voice_filter_enum[] = { | ||
323 | SOC_ENUM_SINGLE(DA732X_REG_DAC1_HPF, DA732X_HPF_VOICE_SHIFT, | ||
324 | DA732X_HPF_VOICE_MAX, da732x_hpf_voice) | ||
325 | }; | ||
326 | |||
327 | static const struct soc_enum da732x_dac2_voice_filter_enum[] = { | ||
328 | SOC_ENUM_SINGLE(DA732X_REG_DAC2_HPF, DA732X_HPF_VOICE_SHIFT, | ||
329 | DA732X_HPF_VOICE_MAX, da732x_hpf_voice) | ||
330 | }; | ||
331 | |||
332 | static const struct soc_enum da732x_dac3_voice_filter_enum[] = { | ||
333 | SOC_ENUM_SINGLE(DA732X_REG_DAC3_HPF, DA732X_HPF_VOICE_SHIFT, | ||
334 | DA732X_HPF_VOICE_MAX, da732x_hpf_voice) | ||
335 | }; | ||
336 | |||
337 | static const struct soc_enum da732x_adc1_voice_filter_enum[] = { | ||
338 | SOC_ENUM_SINGLE(DA732X_REG_ADC1_HPF, DA732X_HPF_VOICE_SHIFT, | ||
339 | DA732X_HPF_VOICE_MAX, da732x_hpf_voice) | ||
340 | }; | ||
341 | |||
342 | static const struct soc_enum da732x_adc2_voice_filter_enum[] = { | ||
343 | SOC_ENUM_SINGLE(DA732X_REG_ADC2_HPF, DA732X_HPF_VOICE_SHIFT, | ||
344 | DA732X_HPF_VOICE_MAX, da732x_hpf_voice) | ||
345 | }; | ||
346 | |||
347 | |||
348 | static int da732x_hpf_set(struct snd_kcontrol *kcontrol, | ||
349 | struct snd_ctl_elem_value *ucontrol) | ||
350 | { | ||
351 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
352 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; | ||
353 | unsigned int reg = enum_ctrl->reg; | ||
354 | unsigned int sel = ucontrol->value.integer.value[0]; | ||
355 | unsigned int bits; | ||
356 | |||
357 | switch (sel) { | ||
358 | case DA732X_HPF_DISABLED: | ||
359 | bits = DA732X_HPF_DIS; | ||
360 | break; | ||
361 | case DA732X_HPF_VOICE: | ||
362 | bits = DA732X_HPF_VOICE_EN; | ||
363 | break; | ||
364 | case DA732X_HPF_MUSIC: | ||
365 | bits = DA732X_HPF_MUSIC_EN; | ||
366 | break; | ||
367 | default: | ||
368 | return -EINVAL; | ||
369 | } | ||
370 | |||
371 | snd_soc_update_bits(codec, reg, DA732X_HPF_MASK, bits); | ||
372 | |||
373 | return 0; | ||
374 | } | ||
375 | |||
376 | static int da732x_hpf_get(struct snd_kcontrol *kcontrol, | ||
377 | struct snd_ctl_elem_value *ucontrol) | ||
378 | { | ||
379 | struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); | ||
380 | struct soc_enum *enum_ctrl = (struct soc_enum *)kcontrol->private_value; | ||
381 | unsigned int reg = enum_ctrl->reg; | ||
382 | int val; | ||
383 | |||
384 | val = snd_soc_read(codec, reg) & DA732X_HPF_MASK; | ||
385 | |||
386 | switch (val) { | ||
387 | case DA732X_HPF_VOICE_EN: | ||
388 | ucontrol->value.integer.value[0] = DA732X_HPF_VOICE; | ||
389 | break; | ||
390 | case DA732X_HPF_MUSIC_EN: | ||
391 | ucontrol->value.integer.value[0] = DA732X_HPF_MUSIC; | ||
392 | break; | ||
393 | default: | ||
394 | ucontrol->value.integer.value[0] = DA732X_HPF_DISABLED; | ||
395 | break; | ||
396 | } | ||
397 | |||
398 | return 0; | ||
399 | } | ||
400 | |||
401 | static const struct snd_kcontrol_new da732x_snd_controls[] = { | ||
402 | /* Input PGAs */ | ||
403 | SOC_SINGLE_RANGE_TLV("MIC1 Boost Volume", DA732X_REG_MIC1_PRE, | ||
404 | DA732X_MICBOOST_SHIFT, DA732X_MICBOOST_MIN, | ||
405 | DA732X_MICBOOST_MAX, 0, mic_boost_tlv), | ||
406 | SOC_SINGLE_RANGE_TLV("MIC2 Boost Volume", DA732X_REG_MIC2_PRE, | ||
407 | DA732X_MICBOOST_SHIFT, DA732X_MICBOOST_MIN, | ||
408 | DA732X_MICBOOST_MAX, 0, mic_boost_tlv), | ||
409 | SOC_SINGLE_RANGE_TLV("MIC3 Boost Volume", DA732X_REG_MIC3_PRE, | ||
410 | DA732X_MICBOOST_SHIFT, DA732X_MICBOOST_MIN, | ||
411 | DA732X_MICBOOST_MAX, 0, mic_boost_tlv), | ||
412 | |||
413 | /* MICs */ | ||
414 | SOC_SINGLE("MIC1 Switch", DA732X_REG_MIC1, DA732X_MIC_MUTE_SHIFT, | ||
415 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
416 | SOC_SINGLE_RANGE_TLV("MIC1 Volume", DA732X_REG_MIC1, | ||
417 | DA732X_MIC_VOL_SHIFT, DA732X_MIC_VOL_VAL_MIN, | ||
418 | DA732X_MIC_VOL_VAL_MAX, 0, mic_pga_tlv), | ||
419 | SOC_SINGLE("MIC2 Switch", DA732X_REG_MIC2, DA732X_MIC_MUTE_SHIFT, | ||
420 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
421 | SOC_SINGLE_RANGE_TLV("MIC2 Volume", DA732X_REG_MIC2, | ||
422 | DA732X_MIC_VOL_SHIFT, DA732X_MIC_VOL_VAL_MIN, | ||
423 | DA732X_MIC_VOL_VAL_MAX, 0, mic_pga_tlv), | ||
424 | SOC_SINGLE("MIC3 Switch", DA732X_REG_MIC3, DA732X_MIC_MUTE_SHIFT, | ||
425 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
426 | SOC_SINGLE_RANGE_TLV("MIC3 Volume", DA732X_REG_MIC3, | ||
427 | DA732X_MIC_VOL_SHIFT, DA732X_MIC_VOL_VAL_MIN, | ||
428 | DA732X_MIC_VOL_VAL_MAX, 0, mic_pga_tlv), | ||
429 | |||
430 | /* AUXs */ | ||
431 | SOC_SINGLE("AUX1L Switch", DA732X_REG_AUX1L, DA732X_AUX_MUTE_SHIFT, | ||
432 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
433 | SOC_SINGLE_TLV("AUX1L Volume", DA732X_REG_AUX1L, | ||
434 | DA732X_AUX_VOL_SHIFT, DA732X_AUX_VOL_VAL_MAX, | ||
435 | DA732X_NO_INVERT, aux_pga_tlv), | ||
436 | SOC_SINGLE("AUX1R Switch", DA732X_REG_AUX1R, DA732X_AUX_MUTE_SHIFT, | ||
437 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
438 | SOC_SINGLE_TLV("AUX1R Volume", DA732X_REG_AUX1R, | ||
439 | DA732X_AUX_VOL_SHIFT, DA732X_AUX_VOL_VAL_MAX, | ||
440 | DA732X_NO_INVERT, aux_pga_tlv), | ||
441 | |||
442 | /* ADCs */ | ||
443 | SOC_DOUBLE_TLV("ADC1 Volume", DA732X_REG_ADC1_SEL, | ||
444 | DA732X_ADCL_VOL_SHIFT, DA732X_ADCR_VOL_SHIFT, | ||
445 | DA732X_ADC_VOL_VAL_MAX, DA732X_INVERT, adc_pga_tlv), | ||
446 | |||
447 | SOC_DOUBLE_TLV("ADC2 Volume", DA732X_REG_ADC2_SEL, | ||
448 | DA732X_ADCL_VOL_SHIFT, DA732X_ADCR_VOL_SHIFT, | ||
449 | DA732X_ADC_VOL_VAL_MAX, DA732X_INVERT, adc_pga_tlv), | ||
450 | |||
451 | /* DACs */ | ||
452 | SOC_DOUBLE("Digital Playback DAC12 Switch", DA732X_REG_DAC1_SEL, | ||
453 | DA732X_DACL_MUTE_SHIFT, DA732X_DACR_MUTE_SHIFT, | ||
454 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
455 | SOC_DOUBLE_R_TLV("Digital Playback DAC12 Volume", DA732X_REG_DAC1_L_VOL, | ||
456 | DA732X_REG_DAC1_R_VOL, DA732X_DAC_VOL_SHIFT, | ||
457 | DA732X_DAC_VOL_VAL_MAX, DA732X_INVERT, dac_pga_tlv), | ||
458 | SOC_SINGLE("Digital Playback DAC3 Switch", DA732X_REG_DAC2_SEL, | ||
459 | DA732X_DACL_MUTE_SHIFT, DA732X_SWITCH_MAX, DA732X_INVERT), | ||
460 | SOC_SINGLE_TLV("Digital Playback DAC3 Volume", DA732X_REG_DAC2_L_VOL, | ||
461 | DA732X_DAC_VOL_SHIFT, DA732X_DAC_VOL_VAL_MAX, | ||
462 | DA732X_INVERT, dac_pga_tlv), | ||
463 | SOC_SINGLE("Digital Playback DAC4 Switch", DA732X_REG_DAC2_SEL, | ||
464 | DA732X_DACR_MUTE_SHIFT, DA732X_SWITCH_MAX, DA732X_INVERT), | ||
465 | SOC_SINGLE_TLV("Digital Playback DAC4 Volume", DA732X_REG_DAC2_R_VOL, | ||
466 | DA732X_DAC_VOL_SHIFT, DA732X_DAC_VOL_VAL_MAX, | ||
467 | DA732X_INVERT, dac_pga_tlv), | ||
468 | SOC_SINGLE("Digital Playback DAC5 Switch", DA732X_REG_DAC3_SEL, | ||
469 | DA732X_DACL_MUTE_SHIFT, DA732X_SWITCH_MAX, DA732X_INVERT), | ||
470 | SOC_SINGLE_TLV("Digital Playback DAC5 Volume", DA732X_REG_DAC3_VOL, | ||
471 | DA732X_DAC_VOL_SHIFT, DA732X_DAC_VOL_VAL_MAX, | ||
472 | DA732X_INVERT, dac_pga_tlv), | ||
473 | |||
474 | /* High Pass Filters */ | ||
475 | SOC_ENUM_EXT("DAC1 High Pass Filter Mode", | ||
476 | da732x_dac1_hpf_mode_enum, da732x_hpf_get, da732x_hpf_set), | ||
477 | SOC_ENUM("DAC1 High Pass Filter", da732x_dac1_hp_filter_enum), | ||
478 | SOC_ENUM("DAC1 Voice Filter", da732x_dac1_voice_filter_enum), | ||
479 | |||
480 | SOC_ENUM_EXT("DAC2 High Pass Filter Mode", | ||
481 | da732x_dac2_hpf_mode_enum, da732x_hpf_get, da732x_hpf_set), | ||
482 | SOC_ENUM("DAC2 High Pass Filter", da732x_dac2_hp_filter_enum), | ||
483 | SOC_ENUM("DAC2 Voice Filter", da732x_dac2_voice_filter_enum), | ||
484 | |||
485 | SOC_ENUM_EXT("DAC3 High Pass Filter Mode", | ||
486 | da732x_dac3_hpf_mode_enum, da732x_hpf_get, da732x_hpf_set), | ||
487 | SOC_ENUM("DAC3 High Pass Filter", da732x_dac3_hp_filter_enum), | ||
488 | SOC_ENUM("DAC3 Filter Mode", da732x_dac3_voice_filter_enum), | ||
489 | |||
490 | SOC_ENUM_EXT("ADC1 High Pass Filter Mode", | ||
491 | da732x_adc1_hpf_mode_enum, da732x_hpf_get, da732x_hpf_set), | ||
492 | SOC_ENUM("ADC1 High Pass Filter", da732x_adc1_hp_filter_enum), | ||
493 | SOC_ENUM("ADC1 Voice Filter", da732x_adc1_voice_filter_enum), | ||
494 | |||
495 | SOC_ENUM_EXT("ADC2 High Pass Filter Mode", | ||
496 | da732x_adc2_hpf_mode_enum, da732x_hpf_get, da732x_hpf_set), | ||
497 | SOC_ENUM("ADC2 High Pass Filter", da732x_adc2_hp_filter_enum), | ||
498 | SOC_ENUM("ADC2 Voice Filter", da732x_adc2_voice_filter_enum), | ||
499 | |||
500 | /* Equalizers */ | ||
501 | SOC_SINGLE("ADC1 EQ Switch", DA732X_REG_ADC1_EQ5, | ||
502 | DA732X_EQ_EN_SHIFT, DA732X_EQ_EN_MAX, DA732X_NO_INVERT), | ||
503 | SOC_SINGLE_TLV("ADC1 EQ Band 1 Volume", DA732X_REG_ADC1_EQ12, | ||
504 | DA732X_EQ_BAND1_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
505 | DA732X_INVERT, eq_band_pga_tlv), | ||
506 | SOC_SINGLE_TLV("ADC1 EQ Band 2 Volume", DA732X_REG_ADC1_EQ12, | ||
507 | DA732X_EQ_BAND2_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
508 | DA732X_INVERT, eq_band_pga_tlv), | ||
509 | SOC_SINGLE_TLV("ADC1 EQ Band 3 Volume", DA732X_REG_ADC1_EQ34, | ||
510 | DA732X_EQ_BAND3_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
511 | DA732X_INVERT, eq_band_pga_tlv), | ||
512 | SOC_SINGLE_TLV("ADC1 EQ Band 4 Volume", DA732X_REG_ADC1_EQ34, | ||
513 | DA732X_EQ_BAND4_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
514 | DA732X_INVERT, eq_band_pga_tlv), | ||
515 | SOC_SINGLE_TLV("ADC1 EQ Band 5 Volume", DA732X_REG_ADC1_EQ5, | ||
516 | DA732X_EQ_BAND5_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
517 | DA732X_INVERT, eq_band_pga_tlv), | ||
518 | SOC_SINGLE_TLV("ADC1 EQ Overall Volume", DA732X_REG_ADC1_EQ5, | ||
519 | DA732X_EQ_OVERALL_SHIFT, DA732X_EQ_OVERALL_VOL_VAL_MAX, | ||
520 | DA732X_INVERT, eq_overall_tlv), | ||
521 | |||
522 | SOC_SINGLE("ADC2 EQ Switch", DA732X_REG_ADC2_EQ5, | ||
523 | DA732X_EQ_EN_SHIFT, DA732X_EQ_EN_MAX, DA732X_NO_INVERT), | ||
524 | SOC_SINGLE_TLV("ADC2 EQ Band 1 Volume", DA732X_REG_ADC2_EQ12, | ||
525 | DA732X_EQ_BAND1_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
526 | DA732X_INVERT, eq_band_pga_tlv), | ||
527 | SOC_SINGLE_TLV("ADC2 EQ Band 2 Volume", DA732X_REG_ADC2_EQ12, | ||
528 | DA732X_EQ_BAND2_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
529 | DA732X_INVERT, eq_band_pga_tlv), | ||
530 | SOC_SINGLE_TLV("ADC2 EQ Band 3 Volume", DA732X_REG_ADC2_EQ34, | ||
531 | DA732X_EQ_BAND3_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
532 | DA732X_INVERT, eq_band_pga_tlv), | ||
533 | SOC_SINGLE_TLV("ACD2 EQ Band 4 Volume", DA732X_REG_ADC2_EQ34, | ||
534 | DA732X_EQ_BAND4_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
535 | DA732X_INVERT, eq_band_pga_tlv), | ||
536 | SOC_SINGLE_TLV("ACD2 EQ Band 5 Volume", DA732X_REG_ADC2_EQ5, | ||
537 | DA732X_EQ_BAND5_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
538 | DA732X_INVERT, eq_band_pga_tlv), | ||
539 | SOC_SINGLE_TLV("ADC2 EQ Overall Volume", DA732X_REG_ADC1_EQ5, | ||
540 | DA732X_EQ_OVERALL_SHIFT, DA732X_EQ_OVERALL_VOL_VAL_MAX, | ||
541 | DA732X_INVERT, eq_overall_tlv), | ||
542 | |||
543 | SOC_SINGLE("DAC1 EQ Switch", DA732X_REG_DAC1_EQ5, | ||
544 | DA732X_EQ_EN_SHIFT, DA732X_EQ_EN_MAX, DA732X_NO_INVERT), | ||
545 | SOC_SINGLE_TLV("DAC1 EQ Band 1 Volume", DA732X_REG_DAC1_EQ12, | ||
546 | DA732X_EQ_BAND1_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
547 | DA732X_INVERT, eq_band_pga_tlv), | ||
548 | SOC_SINGLE_TLV("DAC1 EQ Band 2 Volume", DA732X_REG_DAC1_EQ12, | ||
549 | DA732X_EQ_BAND2_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
550 | DA732X_INVERT, eq_band_pga_tlv), | ||
551 | SOC_SINGLE_TLV("DAC1 EQ Band 3 Volume", DA732X_REG_DAC1_EQ34, | ||
552 | DA732X_EQ_BAND3_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
553 | DA732X_INVERT, eq_band_pga_tlv), | ||
554 | SOC_SINGLE_TLV("DAC1 EQ Band 4 Volume", DA732X_REG_DAC1_EQ34, | ||
555 | DA732X_EQ_BAND4_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
556 | DA732X_INVERT, eq_band_pga_tlv), | ||
557 | SOC_SINGLE_TLV("DAC1 EQ Band 5 Volume", DA732X_REG_DAC1_EQ5, | ||
558 | DA732X_EQ_BAND5_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
559 | DA732X_INVERT, eq_band_pga_tlv), | ||
560 | |||
561 | SOC_SINGLE("DAC2 EQ Switch", DA732X_REG_DAC2_EQ5, | ||
562 | DA732X_EQ_EN_SHIFT, DA732X_EQ_EN_MAX, DA732X_NO_INVERT), | ||
563 | SOC_SINGLE_TLV("DAC2 EQ Band 1 Volume", DA732X_REG_DAC2_EQ12, | ||
564 | DA732X_EQ_BAND1_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
565 | DA732X_INVERT, eq_band_pga_tlv), | ||
566 | SOC_SINGLE_TLV("DAC2 EQ Band 2 Volume", DA732X_REG_DAC2_EQ12, | ||
567 | DA732X_EQ_BAND2_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
568 | DA732X_INVERT, eq_band_pga_tlv), | ||
569 | SOC_SINGLE_TLV("DAC2 EQ Band 3 Volume", DA732X_REG_DAC2_EQ34, | ||
570 | DA732X_EQ_BAND3_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
571 | DA732X_INVERT, eq_band_pga_tlv), | ||
572 | SOC_SINGLE_TLV("DAC2 EQ Band 4 Volume", DA732X_REG_DAC2_EQ34, | ||
573 | DA732X_EQ_BAND4_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
574 | DA732X_INVERT, eq_band_pga_tlv), | ||
575 | SOC_SINGLE_TLV("DAC2 EQ Band 5 Volume", DA732X_REG_DAC2_EQ5, | ||
576 | DA732X_EQ_BAND5_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
577 | DA732X_INVERT, eq_band_pga_tlv), | ||
578 | |||
579 | SOC_SINGLE("DAC3 EQ Switch", DA732X_REG_DAC3_EQ5, | ||
580 | DA732X_EQ_EN_SHIFT, DA732X_EQ_EN_MAX, DA732X_NO_INVERT), | ||
581 | SOC_SINGLE_TLV("DAC3 EQ Band 1 Volume", DA732X_REG_DAC3_EQ12, | ||
582 | DA732X_EQ_BAND1_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
583 | DA732X_INVERT, eq_band_pga_tlv), | ||
584 | SOC_SINGLE_TLV("DAC3 EQ Band 2 Volume", DA732X_REG_DAC3_EQ12, | ||
585 | DA732X_EQ_BAND2_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
586 | DA732X_INVERT, eq_band_pga_tlv), | ||
587 | SOC_SINGLE_TLV("DAC3 EQ Band 3 Volume", DA732X_REG_DAC3_EQ34, | ||
588 | DA732X_EQ_BAND3_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
589 | DA732X_INVERT, eq_band_pga_tlv), | ||
590 | SOC_SINGLE_TLV("DAC3 EQ Band 4 Volume", DA732X_REG_DAC3_EQ34, | ||
591 | DA732X_EQ_BAND4_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
592 | DA732X_INVERT, eq_band_pga_tlv), | ||
593 | SOC_SINGLE_TLV("DAC3 EQ Band 5 Volume", DA732X_REG_DAC3_EQ5, | ||
594 | DA732X_EQ_BAND5_SHIFT, DA732X_EQ_VOL_VAL_MAX, | ||
595 | DA732X_INVERT, eq_band_pga_tlv), | ||
596 | |||
597 | /* Lineout 2 Reciever*/ | ||
598 | SOC_SINGLE("Lineout 2 Switch", DA732X_REG_LIN2, DA732X_LOUT_MUTE_SHIFT, | ||
599 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
600 | SOC_SINGLE_TLV("Lineout 2 Volume", DA732X_REG_LIN2, | ||
601 | DA732X_LOUT_VOL_SHIFT, DA732X_LOUT_VOL_VAL_MAX, | ||
602 | DA732X_NO_INVERT, lin2_pga_tlv), | ||
603 | |||
604 | /* Lineout 3 SPEAKER*/ | ||
605 | SOC_SINGLE("Lineout 3 Switch", DA732X_REG_LIN3, DA732X_LOUT_MUTE_SHIFT, | ||
606 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
607 | SOC_SINGLE_TLV("Lineout 3 Volume", DA732X_REG_LIN3, | ||
608 | DA732X_LOUT_VOL_SHIFT, DA732X_LOUT_VOL_VAL_MAX, | ||
609 | DA732X_NO_INVERT, lin3_pga_tlv), | ||
610 | |||
611 | /* Lineout 4 */ | ||
612 | SOC_SINGLE("Lineout 4 Switch", DA732X_REG_LIN4, DA732X_LOUT_MUTE_SHIFT, | ||
613 | DA732X_SWITCH_MAX, DA732X_INVERT), | ||
614 | SOC_SINGLE_TLV("Lineout 4 Volume", DA732X_REG_LIN4, | ||
615 | DA732X_LOUT_VOL_SHIFT, DA732X_LOUT_VOL_VAL_MAX, | ||
616 | DA732X_NO_INVERT, lin4_pga_tlv), | ||
617 | |||
618 | /* Headphones */ | ||
619 | SOC_DOUBLE_R("Headphone Switch", DA732X_REG_HPR, DA732X_REG_HPL, | ||
620 | DA732X_HP_MUTE_SHIFT, DA732X_SWITCH_MAX, DA732X_INVERT), | ||
621 | SOC_DOUBLE_R_TLV("Headphone Volume", DA732X_REG_HPL_VOL, | ||
622 | DA732X_REG_HPR_VOL, DA732X_HP_VOL_SHIFT, | ||
623 | DA732X_HP_VOL_VAL_MAX, DA732X_NO_INVERT, hp_pga_tlv), | ||
624 | }; | ||
625 | |||
626 | static int da732x_adc_event(struct snd_soc_dapm_widget *w, | ||
627 | struct snd_kcontrol *kcontrol, int event) | ||
628 | { | ||
629 | struct snd_soc_codec *codec = w->codec; | ||
630 | |||
631 | switch (event) { | ||
632 | case SND_SOC_DAPM_POST_PMU: | ||
633 | switch (w->reg) { | ||
634 | case DA732X_REG_ADC1_PD: | ||
635 | snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, | ||
636 | DA732X_ADCA_BB_CLK_EN, | ||
637 | DA732X_ADCA_BB_CLK_EN); | ||
638 | break; | ||
639 | case DA732X_REG_ADC2_PD: | ||
640 | snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, | ||
641 | DA732X_ADCC_BB_CLK_EN, | ||
642 | DA732X_ADCC_BB_CLK_EN); | ||
643 | break; | ||
644 | default: | ||
645 | return -EINVAL; | ||
646 | } | ||
647 | |||
648 | snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK, | ||
649 | DA732X_ADC_SET_ACT); | ||
650 | snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK, | ||
651 | DA732X_ADC_ON); | ||
652 | break; | ||
653 | case SND_SOC_DAPM_POST_PMD: | ||
654 | snd_soc_update_bits(codec, w->reg, DA732X_ADC_PD_MASK, | ||
655 | DA732X_ADC_OFF); | ||
656 | snd_soc_update_bits(codec, w->reg, DA732X_ADC_RST_MASK, | ||
657 | DA732X_ADC_SET_RST); | ||
658 | |||
659 | switch (w->reg) { | ||
660 | case DA732X_REG_ADC1_PD: | ||
661 | snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, | ||
662 | DA732X_ADCA_BB_CLK_EN, 0); | ||
663 | break; | ||
664 | case DA732X_REG_ADC2_PD: | ||
665 | snd_soc_update_bits(codec, DA732X_REG_CLK_EN3, | ||
666 | DA732X_ADCC_BB_CLK_EN, 0); | ||
667 | break; | ||
668 | default: | ||
669 | return -EINVAL; | ||
670 | } | ||
671 | |||
672 | break; | ||
673 | default: | ||
674 | return -EINVAL; | ||
675 | } | ||
676 | |||
677 | return 0; | ||
678 | } | ||
679 | |||
680 | static int da732x_out_pga_event(struct snd_soc_dapm_widget *w, | ||
681 | struct snd_kcontrol *kcontrol, int event) | ||
682 | { | ||
683 | struct snd_soc_codec *codec = w->codec; | ||
684 | |||
685 | switch (event) { | ||
686 | case SND_SOC_DAPM_POST_PMU: | ||
687 | snd_soc_update_bits(codec, w->reg, | ||
688 | (1 << w->shift) | DA732X_OUT_HIZ_EN, | ||
689 | (1 << w->shift) | DA732X_OUT_HIZ_EN); | ||
690 | break; | ||
691 | case SND_SOC_DAPM_POST_PMD: | ||
692 | snd_soc_update_bits(codec, w->reg, | ||
693 | (1 << w->shift) | DA732X_OUT_HIZ_EN, | ||
694 | (1 << w->shift) | DA732X_OUT_HIZ_DIS); | ||
695 | break; | ||
696 | default: | ||
697 | return -EINVAL; | ||
698 | } | ||
699 | |||
700 | return 0; | ||
701 | } | ||
702 | |||
703 | static const char *adcl_text[] = { | ||
704 | "AUX1L", "MIC1" | ||
705 | }; | ||
706 | |||
707 | static const char *adcr_text[] = { | ||
708 | "AUX1R", "MIC2", "MIC3" | ||
709 | }; | ||
710 | |||
711 | static const char *enable_text[] = { | ||
712 | "Disabled", | ||
713 | "Enabled" | ||
714 | }; | ||
715 | |||
716 | /* ADC1LMUX */ | ||
717 | static const struct soc_enum adc1l_enum = | ||
718 | SOC_ENUM_SINGLE(DA732X_REG_INP_MUX, DA732X_ADC1L_MUX_SEL_SHIFT, | ||
719 | DA732X_ADCL_MUX_MAX, adcl_text); | ||
720 | static const struct snd_kcontrol_new adc1l_mux = | ||
721 | SOC_DAPM_ENUM("ADC Route", adc1l_enum); | ||
722 | |||
723 | /* ADC1RMUX */ | ||
724 | static const struct soc_enum adc1r_enum = | ||
725 | SOC_ENUM_SINGLE(DA732X_REG_INP_MUX, DA732X_ADC1R_MUX_SEL_SHIFT, | ||
726 | DA732X_ADCR_MUX_MAX, adcr_text); | ||
727 | static const struct snd_kcontrol_new adc1r_mux = | ||
728 | SOC_DAPM_ENUM("ADC Route", adc1r_enum); | ||
729 | |||
730 | /* ADC2LMUX */ | ||
731 | static const struct soc_enum adc2l_enum = | ||
732 | SOC_ENUM_SINGLE(DA732X_REG_INP_MUX, DA732X_ADC2L_MUX_SEL_SHIFT, | ||
733 | DA732X_ADCL_MUX_MAX, adcl_text); | ||
734 | static const struct snd_kcontrol_new adc2l_mux = | ||
735 | SOC_DAPM_ENUM("ADC Route", adc2l_enum); | ||
736 | |||
737 | /* ADC2RMUX */ | ||
738 | static const struct soc_enum adc2r_enum = | ||
739 | SOC_ENUM_SINGLE(DA732X_REG_INP_MUX, DA732X_ADC2R_MUX_SEL_SHIFT, | ||
740 | DA732X_ADCR_MUX_MAX, adcr_text); | ||
741 | |||
742 | static const struct snd_kcontrol_new adc2r_mux = | ||
743 | SOC_DAPM_ENUM("ADC Route", adc2r_enum); | ||
744 | |||
745 | static const struct soc_enum da732x_hp_left_output = | ||
746 | SOC_ENUM_SINGLE(DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN_SHIFT, | ||
747 | DA732X_DAC_EN_MAX, enable_text); | ||
748 | |||
749 | static const struct snd_kcontrol_new hpl_mux = | ||
750 | SOC_DAPM_ENUM("HPL Switch", da732x_hp_left_output); | ||
751 | |||
752 | static const struct soc_enum da732x_hp_right_output = | ||
753 | SOC_ENUM_SINGLE(DA732X_REG_HPR, DA732X_HP_OUT_DAC_EN_SHIFT, | ||
754 | DA732X_DAC_EN_MAX, enable_text); | ||
755 | |||
756 | static const struct snd_kcontrol_new hpr_mux = | ||
757 | SOC_DAPM_ENUM("HPR Switch", da732x_hp_right_output); | ||
758 | |||
759 | static const struct soc_enum da732x_speaker_output = | ||
760 | SOC_ENUM_SINGLE(DA732X_REG_LIN3, DA732X_LOUT_DAC_EN_SHIFT, | ||
761 | DA732X_DAC_EN_MAX, enable_text); | ||
762 | |||
763 | static const struct snd_kcontrol_new spk_mux = | ||
764 | SOC_DAPM_ENUM("SPK Switch", da732x_speaker_output); | ||
765 | |||
766 | static const struct soc_enum da732x_lout4_output = | ||
767 | SOC_ENUM_SINGLE(DA732X_REG_LIN4, DA732X_LOUT_DAC_EN_SHIFT, | ||
768 | DA732X_DAC_EN_MAX, enable_text); | ||
769 | |||
770 | static const struct snd_kcontrol_new lout4_mux = | ||
771 | SOC_DAPM_ENUM("LOUT4 Switch", da732x_lout4_output); | ||
772 | |||
773 | static const struct soc_enum da732x_lout2_output = | ||
774 | SOC_ENUM_SINGLE(DA732X_REG_LIN2, DA732X_LOUT_DAC_EN_SHIFT, | ||
775 | DA732X_DAC_EN_MAX, enable_text); | ||
776 | |||
777 | static const struct snd_kcontrol_new lout2_mux = | ||
778 | SOC_DAPM_ENUM("LOUT2 Switch", da732x_lout2_output); | ||
779 | |||
780 | static const struct snd_soc_dapm_widget da732x_dapm_widgets[] = { | ||
781 | /* Supplies */ | ||
782 | SND_SOC_DAPM_SUPPLY("ADC1 Supply", DA732X_REG_ADC1_PD, 0, | ||
783 | DA732X_NO_INVERT, da732x_adc_event, | ||
784 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
785 | SND_SOC_DAPM_SUPPLY("ADC2 Supply", DA732X_REG_ADC2_PD, 0, | ||
786 | DA732X_NO_INVERT, da732x_adc_event, | ||
787 | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD), | ||
788 | SND_SOC_DAPM_SUPPLY("DAC1 CLK", DA732X_REG_CLK_EN4, | ||
789 | DA732X_DACA_BB_CLK_SHIFT, DA732X_NO_INVERT, | ||
790 | NULL, 0), | ||
791 | SND_SOC_DAPM_SUPPLY("DAC2 CLK", DA732X_REG_CLK_EN4, | ||
792 | DA732X_DACC_BB_CLK_SHIFT, DA732X_NO_INVERT, | ||
793 | NULL, 0), | ||
794 | SND_SOC_DAPM_SUPPLY("DAC3 CLK", DA732X_REG_CLK_EN5, | ||
795 | DA732X_DACE_BB_CLK_SHIFT, DA732X_NO_INVERT, | ||
796 | NULL, 0), | ||
797 | |||
798 | /* Micbias */ | ||
799 | SND_SOC_DAPM_SUPPLY("MICBIAS1", DA732X_REG_MICBIAS1, | ||
800 | DA732X_MICBIAS_EN_SHIFT, | ||
801 | DA732X_NO_INVERT, NULL, 0), | ||
802 | SND_SOC_DAPM_SUPPLY("MICBIAS2", DA732X_REG_MICBIAS2, | ||
803 | DA732X_MICBIAS_EN_SHIFT, | ||
804 | DA732X_NO_INVERT, NULL, 0), | ||
805 | |||
806 | /* Inputs */ | ||
807 | SND_SOC_DAPM_INPUT("MIC1"), | ||
808 | SND_SOC_DAPM_INPUT("MIC2"), | ||
809 | SND_SOC_DAPM_INPUT("MIC3"), | ||
810 | SND_SOC_DAPM_INPUT("AUX1L"), | ||
811 | SND_SOC_DAPM_INPUT("AUX1R"), | ||
812 | |||
813 | /* Outputs */ | ||
814 | SND_SOC_DAPM_OUTPUT("HPL"), | ||
815 | SND_SOC_DAPM_OUTPUT("HPR"), | ||
816 | SND_SOC_DAPM_OUTPUT("LOUTL"), | ||
817 | SND_SOC_DAPM_OUTPUT("LOUTR"), | ||
818 | SND_SOC_DAPM_OUTPUT("ClassD"), | ||
819 | |||
820 | /* ADCs */ | ||
821 | SND_SOC_DAPM_ADC("ADC1L", NULL, DA732X_REG_ADC1_SEL, | ||
822 | DA732X_ADCL_EN_SHIFT, DA732X_NO_INVERT), | ||
823 | SND_SOC_DAPM_ADC("ADC1R", NULL, DA732X_REG_ADC1_SEL, | ||
824 | DA732X_ADCR_EN_SHIFT, DA732X_NO_INVERT), | ||
825 | SND_SOC_DAPM_ADC("ADC2L", NULL, DA732X_REG_ADC2_SEL, | ||
826 | DA732X_ADCL_EN_SHIFT, DA732X_NO_INVERT), | ||
827 | SND_SOC_DAPM_ADC("ADC2R", NULL, DA732X_REG_ADC2_SEL, | ||
828 | DA732X_ADCR_EN_SHIFT, DA732X_NO_INVERT), | ||
829 | |||
830 | /* DACs */ | ||
831 | SND_SOC_DAPM_DAC("DAC1L", NULL, DA732X_REG_DAC1_SEL, | ||
832 | DA732X_DACL_EN_SHIFT, DA732X_NO_INVERT), | ||
833 | SND_SOC_DAPM_DAC("DAC1R", NULL, DA732X_REG_DAC1_SEL, | ||
834 | DA732X_DACR_EN_SHIFT, DA732X_NO_INVERT), | ||
835 | SND_SOC_DAPM_DAC("DAC2L", NULL, DA732X_REG_DAC2_SEL, | ||
836 | DA732X_DACL_EN_SHIFT, DA732X_NO_INVERT), | ||
837 | SND_SOC_DAPM_DAC("DAC2R", NULL, DA732X_REG_DAC2_SEL, | ||
838 | DA732X_DACR_EN_SHIFT, DA732X_NO_INVERT), | ||
839 | SND_SOC_DAPM_DAC("DAC3", NULL, DA732X_REG_DAC3_SEL, | ||
840 | DA732X_DACL_EN_SHIFT, DA732X_NO_INVERT), | ||
841 | |||
842 | /* Input Pgas */ | ||
843 | SND_SOC_DAPM_PGA("MIC1 PGA", DA732X_REG_MIC1, DA732X_MIC_EN_SHIFT, | ||
844 | 0, NULL, 0), | ||
845 | SND_SOC_DAPM_PGA("MIC2 PGA", DA732X_REG_MIC2, DA732X_MIC_EN_SHIFT, | ||
846 | 0, NULL, 0), | ||
847 | SND_SOC_DAPM_PGA("MIC3 PGA", DA732X_REG_MIC3, DA732X_MIC_EN_SHIFT, | ||
848 | 0, NULL, 0), | ||
849 | SND_SOC_DAPM_PGA("AUX1L PGA", DA732X_REG_AUX1L, DA732X_AUX_EN_SHIFT, | ||
850 | 0, NULL, 0), | ||
851 | SND_SOC_DAPM_PGA("AUX1R PGA", DA732X_REG_AUX1R, DA732X_AUX_EN_SHIFT, | ||
852 | 0, NULL, 0), | ||
853 | |||
854 | SND_SOC_DAPM_PGA_E("HP Left", DA732X_REG_HPL, DA732X_HP_OUT_EN_SHIFT, | ||
855 | 0, NULL, 0, da732x_out_pga_event, | ||
856 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
857 | SND_SOC_DAPM_PGA_E("HP Right", DA732X_REG_HPR, DA732X_HP_OUT_EN_SHIFT, | ||
858 | 0, NULL, 0, da732x_out_pga_event, | ||
859 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
860 | SND_SOC_DAPM_PGA_E("LIN2", DA732X_REG_LIN2, DA732X_LIN_OUT_EN_SHIFT, | ||
861 | 0, NULL, 0, da732x_out_pga_event, | ||
862 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
863 | SND_SOC_DAPM_PGA_E("LIN3", DA732X_REG_LIN3, DA732X_LIN_OUT_EN_SHIFT, | ||
864 | 0, NULL, 0, da732x_out_pga_event, | ||
865 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
866 | SND_SOC_DAPM_PGA_E("LIN4", DA732X_REG_LIN4, DA732X_LIN_OUT_EN_SHIFT, | ||
867 | 0, NULL, 0, da732x_out_pga_event, | ||
868 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
869 | |||
870 | /* MUXs */ | ||
871 | SND_SOC_DAPM_MUX("ADC1 Left MUX", SND_SOC_NOPM, 0, 0, &adc1l_mux), | ||
872 | SND_SOC_DAPM_MUX("ADC1 Right MUX", SND_SOC_NOPM, 0, 0, &adc1r_mux), | ||
873 | SND_SOC_DAPM_MUX("ADC2 Left MUX", SND_SOC_NOPM, 0, 0, &adc2l_mux), | ||
874 | SND_SOC_DAPM_MUX("ADC2 Right MUX", SND_SOC_NOPM, 0, 0, &adc2r_mux), | ||
875 | |||
876 | SND_SOC_DAPM_MUX("HP Left MUX", SND_SOC_NOPM, 0, 0, &hpl_mux), | ||
877 | SND_SOC_DAPM_MUX("HP Right MUX", SND_SOC_NOPM, 0, 0, &hpr_mux), | ||
878 | SND_SOC_DAPM_MUX("Speaker MUX", SND_SOC_NOPM, 0, 0, &spk_mux), | ||
879 | SND_SOC_DAPM_MUX("LOUT2 MUX", SND_SOC_NOPM, 0, 0, &lout2_mux), | ||
880 | SND_SOC_DAPM_MUX("LOUT4 MUX", SND_SOC_NOPM, 0, 0, &lout4_mux), | ||
881 | |||
882 | /* AIF interfaces */ | ||
883 | SND_SOC_DAPM_AIF_OUT("AIFA Output", "AIFA Capture", 0, DA732X_REG_AIFA3, | ||
884 | DA732X_AIF_EN_SHIFT, 0), | ||
885 | SND_SOC_DAPM_AIF_IN("AIFA Input", "AIFA Playback", 0, DA732X_REG_AIFA3, | ||
886 | DA732X_AIF_EN_SHIFT, 0), | ||
887 | |||
888 | SND_SOC_DAPM_AIF_OUT("AIFB Output", "AIFB Capture", 0, DA732X_REG_AIFB3, | ||
889 | DA732X_AIF_EN_SHIFT, 0), | ||
890 | SND_SOC_DAPM_AIF_IN("AIFB Input", "AIFB Playback", 0, DA732X_REG_AIFB3, | ||
891 | DA732X_AIF_EN_SHIFT, 0), | ||
892 | }; | ||
893 | |||
894 | static const struct snd_soc_dapm_route da732x_dapm_routes[] = { | ||
895 | /* Inputs */ | ||
896 | {"AUX1L PGA", "NULL", "AUX1L"}, | ||
897 | {"AUX1R PGA", "NULL", "AUX1R"}, | ||
898 | {"MIC1 PGA", NULL, "MIC1"}, | ||
899 | {"MIC2 PGA", "NULL", "MIC2"}, | ||
900 | {"MIC3 PGA", "NULL", "MIC3"}, | ||
901 | |||
902 | /* Capture Path */ | ||
903 | {"ADC1 Left MUX", "MIC1", "MIC1 PGA"}, | ||
904 | {"ADC1 Left MUX", "AUX1L", "AUX1L PGA"}, | ||
905 | |||
906 | {"ADC1 Right MUX", "AUX1R", "AUX1R PGA"}, | ||
907 | {"ADC1 Right MUX", "MIC2", "MIC2 PGA"}, | ||
908 | {"ADC1 Right MUX", "MIC3", "MIC3 PGA"}, | ||
909 | |||
910 | {"ADC2 Left MUX", "AUX1L", "AUX1L PGA"}, | ||
911 | {"ADC2 Left MUX", "MIC1", "MIC1 PGA"}, | ||
912 | |||
913 | {"ADC2 Right MUX", "AUX1R", "AUX1R PGA"}, | ||
914 | {"ADC2 Right MUX", "MIC2", "MIC2 PGA"}, | ||
915 | {"ADC2 Right MUX", "MIC3", "MIC3 PGA"}, | ||
916 | |||
917 | {"ADC1L", NULL, "ADC1 Supply"}, | ||
918 | {"ADC1R", NULL, "ADC1 Supply"}, | ||
919 | {"ADC2L", NULL, "ADC2 Supply"}, | ||
920 | {"ADC2R", NULL, "ADC2 Supply"}, | ||
921 | |||
922 | {"ADC1L", NULL, "ADC1 Left MUX"}, | ||
923 | {"ADC1R", NULL, "ADC1 Right MUX"}, | ||
924 | {"ADC2L", NULL, "ADC2 Left MUX"}, | ||
925 | {"ADC2R", NULL, "ADC2 Right MUX"}, | ||
926 | |||
927 | {"AIFA Output", NULL, "ADC1L"}, | ||
928 | {"AIFA Output", NULL, "ADC1R"}, | ||
929 | {"AIFB Output", NULL, "ADC2L"}, | ||
930 | {"AIFB Output", NULL, "ADC2R"}, | ||
931 | |||
932 | {"HP Left MUX", "Enabled", "AIFA Input"}, | ||
933 | {"HP Right MUX", "Enabled", "AIFA Input"}, | ||
934 | {"Speaker MUX", "Enabled", "AIFB Input"}, | ||
935 | {"LOUT2 MUX", "Enabled", "AIFB Input"}, | ||
936 | {"LOUT4 MUX", "Enabled", "AIFB Input"}, | ||
937 | |||
938 | {"DAC1L", NULL, "DAC1 CLK"}, | ||
939 | {"DAC1R", NULL, "DAC1 CLK"}, | ||
940 | {"DAC2L", NULL, "DAC2 CLK"}, | ||
941 | {"DAC2R", NULL, "DAC2 CLK"}, | ||
942 | {"DAC3", NULL, "DAC3 CLK"}, | ||
943 | |||
944 | {"DAC1L", NULL, "HP Left MUX"}, | ||
945 | {"DAC1R", NULL, "HP Right MUX"}, | ||
946 | {"DAC2L", NULL, "Speaker MUX"}, | ||
947 | {"DAC2R", NULL, "LOUT4 MUX"}, | ||
948 | {"DAC3", NULL, "LOUT2 MUX"}, | ||
949 | |||
950 | /* Output Pgas */ | ||
951 | {"HP Left", NULL, "DAC1L"}, | ||
952 | {"HP Right", NULL, "DAC1R"}, | ||
953 | {"LIN3", NULL, "DAC2L"}, | ||
954 | {"LIN4", NULL, "DAC2R"}, | ||
955 | {"LIN2", NULL, "DAC3"}, | ||
956 | |||
957 | /* Outputs */ | ||
958 | {"ClassD", NULL, "LIN3"}, | ||
959 | {"LOUTL", NULL, "LIN2"}, | ||
960 | {"LOUTR", NULL, "LIN4"}, | ||
961 | {"HPL", NULL, "HP Left"}, | ||
962 | {"HPR", NULL, "HP Right"}, | ||
963 | }; | ||
964 | |||
965 | static int da732x_hw_params(struct snd_pcm_substream *substream, | ||
966 | struct snd_pcm_hw_params *params, | ||
967 | struct snd_soc_dai *dai) | ||
968 | { | ||
969 | struct snd_soc_codec *codec = dai->codec; | ||
970 | u32 aif = 0; | ||
971 | u32 reg_aif; | ||
972 | u32 fs; | ||
973 | |||
974 | reg_aif = dai->driver->base; | ||
975 | |||
976 | switch (params_format(params)) { | ||
977 | case SNDRV_PCM_FORMAT_S16_LE: | ||
978 | aif |= DA732X_AIF_WORD_16; | ||
979 | break; | ||
980 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
981 | aif |= DA732X_AIF_WORD_20; | ||
982 | break; | ||
983 | case SNDRV_PCM_FORMAT_S24_LE: | ||
984 | aif |= DA732X_AIF_WORD_24; | ||
985 | break; | ||
986 | case SNDRV_PCM_FORMAT_S32_LE: | ||
987 | aif |= DA732X_AIF_WORD_32; | ||
988 | break; | ||
989 | default: | ||
990 | return -EINVAL; | ||
991 | } | ||
992 | |||
993 | switch (params_rate(params)) { | ||
994 | case 8000: | ||
995 | fs = DA732X_SR_8KHZ; | ||
996 | break; | ||
997 | case 11025: | ||
998 | fs = DA732X_SR_11_025KHZ; | ||
999 | break; | ||
1000 | case 12000: | ||
1001 | fs = DA732X_SR_12KHZ; | ||
1002 | break; | ||
1003 | case 16000: | ||
1004 | fs = DA732X_SR_16KHZ; | ||
1005 | break; | ||
1006 | case 22050: | ||
1007 | fs = DA732X_SR_22_05KHZ; | ||
1008 | break; | ||
1009 | case 24000: | ||
1010 | fs = DA732X_SR_24KHZ; | ||
1011 | break; | ||
1012 | case 32000: | ||
1013 | fs = DA732X_SR_32KHZ; | ||
1014 | break; | ||
1015 | case 44100: | ||
1016 | fs = DA732X_SR_44_1KHZ; | ||
1017 | break; | ||
1018 | case 48000: | ||
1019 | fs = DA732X_SR_48KHZ; | ||
1020 | break; | ||
1021 | case 88100: | ||
1022 | fs = DA732X_SR_88_1KHZ; | ||
1023 | break; | ||
1024 | case 96000: | ||
1025 | fs = DA732X_SR_96KHZ; | ||
1026 | break; | ||
1027 | default: | ||
1028 | return -EINVAL; | ||
1029 | } | ||
1030 | |||
1031 | snd_soc_update_bits(codec, reg_aif, DA732X_AIF_WORD_MASK, aif); | ||
1032 | snd_soc_update_bits(codec, DA732X_REG_CLK_CTRL, DA732X_SR1_MASK, fs); | ||
1033 | |||
1034 | return 0; | ||
1035 | } | ||
1036 | |||
1037 | static int da732x_set_dai_fmt(struct snd_soc_dai *dai, u32 fmt) | ||
1038 | { | ||
1039 | struct snd_soc_codec *codec = dai->codec; | ||
1040 | u32 aif_mclk, pc_count; | ||
1041 | u32 reg_aif1, aif1; | ||
1042 | u32 reg_aif3, aif3; | ||
1043 | |||
1044 | switch (dai->id) { | ||
1045 | case DA732X_DAI_ID1: | ||
1046 | reg_aif1 = DA732X_REG_AIFA1; | ||
1047 | reg_aif3 = DA732X_REG_AIFA3; | ||
1048 | pc_count = DA732X_PC_PULSE_AIFA | DA732X_PC_RESYNC_NOT_AUT | | ||
1049 | DA732X_PC_SAME; | ||
1050 | break; | ||
1051 | case DA732X_DAI_ID2: | ||
1052 | reg_aif1 = DA732X_REG_AIFB1; | ||
1053 | reg_aif3 = DA732X_REG_AIFB3; | ||
1054 | pc_count = DA732X_PC_PULSE_AIFB | DA732X_PC_RESYNC_NOT_AUT | | ||
1055 | DA732X_PC_SAME; | ||
1056 | break; | ||
1057 | default: | ||
1058 | return -EINVAL; | ||
1059 | } | ||
1060 | |||
1061 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
1062 | case SND_SOC_DAIFMT_CBS_CFS: | ||
1063 | aif1 = DA732X_AIF_SLAVE; | ||
1064 | aif_mclk = DA732X_AIFM_FRAME_64 | DA732X_AIFM_SRC_SEL_AIFA; | ||
1065 | break; | ||
1066 | case SND_SOC_DAIFMT_CBM_CFM: | ||
1067 | aif1 = DA732X_AIF_CLK_FROM_SRC; | ||
1068 | aif_mclk = DA732X_CLK_GENERATION_AIF_A; | ||
1069 | break; | ||
1070 | default: | ||
1071 | return -EINVAL; | ||
1072 | } | ||
1073 | |||
1074 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
1075 | case SND_SOC_DAIFMT_I2S: | ||
1076 | aif3 = DA732X_AIF_I2S_MODE; | ||
1077 | break; | ||
1078 | case SND_SOC_DAIFMT_RIGHT_J: | ||
1079 | aif3 = DA732X_AIF_RIGHT_J_MODE; | ||
1080 | break; | ||
1081 | case SND_SOC_DAIFMT_LEFT_J: | ||
1082 | aif3 = DA732X_AIF_LEFT_J_MODE; | ||
1083 | break; | ||
1084 | case SND_SOC_DAIFMT_DSP_B: | ||
1085 | aif3 = DA732X_AIF_DSP_MODE; | ||
1086 | break; | ||
1087 | default: | ||
1088 | return -EINVAL; | ||
1089 | } | ||
1090 | |||
1091 | /* Clock inversion */ | ||
1092 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
1093 | case SND_SOC_DAIFMT_DSP_B: | ||
1094 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
1095 | case SND_SOC_DAIFMT_NB_NF: | ||
1096 | break; | ||
1097 | case SND_SOC_DAIFMT_IB_NF: | ||
1098 | aif3 |= DA732X_AIF_BCLK_INV; | ||
1099 | break; | ||
1100 | default: | ||
1101 | return -EINVAL; | ||
1102 | } | ||
1103 | break; | ||
1104 | case SND_SOC_DAIFMT_I2S: | ||
1105 | case SND_SOC_DAIFMT_RIGHT_J: | ||
1106 | case SND_SOC_DAIFMT_LEFT_J: | ||
1107 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
1108 | case SND_SOC_DAIFMT_NB_NF: | ||
1109 | break; | ||
1110 | case SND_SOC_DAIFMT_IB_IF: | ||
1111 | aif3 |= DA732X_AIF_BCLK_INV | DA732X_AIF_WCLK_INV; | ||
1112 | break; | ||
1113 | case SND_SOC_DAIFMT_IB_NF: | ||
1114 | aif3 |= DA732X_AIF_BCLK_INV; | ||
1115 | break; | ||
1116 | case SND_SOC_DAIFMT_NB_IF: | ||
1117 | aif3 |= DA732X_AIF_WCLK_INV; | ||
1118 | break; | ||
1119 | default: | ||
1120 | return -EINVAL; | ||
1121 | } | ||
1122 | break; | ||
1123 | default: | ||
1124 | return -EINVAL; | ||
1125 | } | ||
1126 | |||
1127 | snd_soc_write(codec, DA732X_REG_AIF_MCLK, aif_mclk); | ||
1128 | snd_soc_update_bits(codec, reg_aif1, DA732X_AIF1_CLK_MASK, aif1); | ||
1129 | snd_soc_update_bits(codec, reg_aif3, DA732X_AIF_BCLK_INV | | ||
1130 | DA732X_AIF_WCLK_INV | DA732X_AIF_MODE_MASK, aif3); | ||
1131 | snd_soc_write(codec, DA732X_REG_PC_CTRL, pc_count); | ||
1132 | |||
1133 | return 0; | ||
1134 | } | ||
1135 | |||
1136 | |||
1137 | |||
1138 | static int da732x_set_dai_pll(struct snd_soc_codec *codec, int pll_id, | ||
1139 | int source, unsigned int freq_in, | ||
1140 | unsigned int freq_out) | ||
1141 | { | ||
1142 | struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); | ||
1143 | int fref, indiv; | ||
1144 | u8 div_lo, div_mid, div_hi; | ||
1145 | u64 frac_div; | ||
1146 | |||
1147 | /* Disable PLL */ | ||
1148 | if (freq_out == 0) { | ||
1149 | snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, | ||
1150 | DA732X_PLL_EN, 0); | ||
1151 | da732x->pll_en = false; | ||
1152 | return 0; | ||
1153 | } | ||
1154 | |||
1155 | if (da732x->pll_en) | ||
1156 | return -EBUSY; | ||
1157 | |||
1158 | if (source == DA732X_SRCCLK_MCLK) { | ||
1159 | /* Validate Sysclk rate */ | ||
1160 | switch (da732x->sysclk) { | ||
1161 | case 11290000: | ||
1162 | case 12288000: | ||
1163 | case 22580000: | ||
1164 | case 24576000: | ||
1165 | case 45160000: | ||
1166 | case 49152000: | ||
1167 | snd_soc_write(codec, DA732X_REG_PLL_CTRL, | ||
1168 | DA732X_PLL_BYPASS); | ||
1169 | return 0; | ||
1170 | default: | ||
1171 | dev_err(codec->dev, | ||
1172 | "Cannot use PLL Bypass, invalid SYSCLK rate\n"); | ||
1173 | return -EINVAL; | ||
1174 | } | ||
1175 | } | ||
1176 | |||
1177 | indiv = da732x_get_input_div(codec, da732x->sysclk); | ||
1178 | if (indiv < 0) | ||
1179 | return indiv; | ||
1180 | |||
1181 | fref = (da732x->sysclk / indiv); | ||
1182 | div_hi = freq_out / fref; | ||
1183 | frac_div = (u64)(freq_out % fref) * 8192ULL; | ||
1184 | do_div(frac_div, fref); | ||
1185 | div_mid = (frac_div >> DA732X_1BYTE_SHIFT) & DA732X_U8_MASK; | ||
1186 | div_lo = (frac_div) & DA732X_U8_MASK; | ||
1187 | |||
1188 | snd_soc_write(codec, DA732X_REG_PLL_DIV_LO, div_lo); | ||
1189 | snd_soc_write(codec, DA732X_REG_PLL_DIV_MID, div_mid); | ||
1190 | snd_soc_write(codec, DA732X_REG_PLL_DIV_HI, div_hi); | ||
1191 | |||
1192 | snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, DA732X_PLL_EN, | ||
1193 | DA732X_PLL_EN); | ||
1194 | |||
1195 | da732x->pll_en = true; | ||
1196 | |||
1197 | return 0; | ||
1198 | } | ||
1199 | |||
1200 | static int da732x_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, | ||
1201 | unsigned int freq, int dir) | ||
1202 | { | ||
1203 | struct snd_soc_codec *codec = dai->codec; | ||
1204 | struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); | ||
1205 | |||
1206 | da732x->sysclk = freq; | ||
1207 | |||
1208 | return 0; | ||
1209 | } | ||
1210 | |||
1211 | #define DA732X_RATES SNDRV_PCM_RATE_8000_96000 | ||
1212 | |||
1213 | #define DA732X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
1214 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
1215 | |||
1216 | static struct snd_soc_dai_ops da732x_dai1_ops = { | ||
1217 | .hw_params = da732x_hw_params, | ||
1218 | .set_fmt = da732x_set_dai_fmt, | ||
1219 | .set_sysclk = da732x_set_dai_sysclk, | ||
1220 | }; | ||
1221 | |||
1222 | static struct snd_soc_dai_ops da732x_dai2_ops = { | ||
1223 | .hw_params = da732x_hw_params, | ||
1224 | .set_fmt = da732x_set_dai_fmt, | ||
1225 | .set_sysclk = da732x_set_dai_sysclk, | ||
1226 | }; | ||
1227 | |||
1228 | static struct snd_soc_dai_driver da732x_dai[] = { | ||
1229 | { | ||
1230 | .name = "DA732X_AIFA", | ||
1231 | .id = DA732X_DAI_ID1, | ||
1232 | .base = DA732X_REG_AIFA1, | ||
1233 | .playback = { | ||
1234 | .stream_name = "AIFA Playback", | ||
1235 | .channels_min = 1, | ||
1236 | .channels_max = 2, | ||
1237 | .rates = DA732X_RATES, | ||
1238 | .formats = DA732X_FORMATS, | ||
1239 | }, | ||
1240 | .capture = { | ||
1241 | .stream_name = "AIFA Capture", | ||
1242 | .channels_min = 1, | ||
1243 | .channels_max = 2, | ||
1244 | .rates = DA732X_RATES, | ||
1245 | .formats = DA732X_FORMATS, | ||
1246 | }, | ||
1247 | .ops = &da732x_dai1_ops, | ||
1248 | }, | ||
1249 | { | ||
1250 | .name = "DA732X_AIFB", | ||
1251 | .id = DA732X_DAI_ID2, | ||
1252 | .base = DA732X_REG_AIFB1, | ||
1253 | .playback = { | ||
1254 | .stream_name = "AIFB Playback", | ||
1255 | .channels_min = 1, | ||
1256 | .channels_max = 2, | ||
1257 | .rates = DA732X_RATES, | ||
1258 | .formats = DA732X_FORMATS, | ||
1259 | }, | ||
1260 | .capture = { | ||
1261 | .stream_name = "AIFB Capture", | ||
1262 | .channels_min = 1, | ||
1263 | .channels_max = 2, | ||
1264 | .rates = DA732X_RATES, | ||
1265 | .formats = DA732X_FORMATS, | ||
1266 | }, | ||
1267 | .ops = &da732x_dai2_ops, | ||
1268 | }, | ||
1269 | }; | ||
1270 | |||
1271 | static const struct regmap_config da732x_regmap = { | ||
1272 | .reg_bits = 8, | ||
1273 | .val_bits = 8, | ||
1274 | |||
1275 | .max_register = DA732X_MAX_REG, | ||
1276 | .reg_defaults = da732x_reg_cache, | ||
1277 | .num_reg_defaults = ARRAY_SIZE(da732x_reg_cache), | ||
1278 | .cache_type = REGCACHE_RBTREE, | ||
1279 | }; | ||
1280 | |||
1281 | |||
1282 | static void da732x_dac_offset_adjust(struct snd_soc_codec *codec) | ||
1283 | { | ||
1284 | u8 offset[DA732X_HP_DACS]; | ||
1285 | u8 sign[DA732X_HP_DACS]; | ||
1286 | u8 step = DA732X_DAC_OFFSET_STEP; | ||
1287 | |||
1288 | /* Initialize DAC offset calibration circuits and registers */ | ||
1289 | snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, | ||
1290 | DA732X_HP_DAC_OFFSET_TRIM_VAL); | ||
1291 | snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, | ||
1292 | DA732X_HP_DAC_OFFSET_TRIM_VAL); | ||
1293 | snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL, | ||
1294 | DA732X_HP_DAC_OFF_CALIBRATION | | ||
1295 | DA732X_HP_DAC_OFF_SCALE_STEPS); | ||
1296 | snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL, | ||
1297 | DA732X_HP_DAC_OFF_CALIBRATION | | ||
1298 | DA732X_HP_DAC_OFF_SCALE_STEPS); | ||
1299 | |||
1300 | /* Wait for voltage stabilization */ | ||
1301 | msleep(DA732X_WAIT_FOR_STABILIZATION); | ||
1302 | |||
1303 | /* Check DAC offset sign */ | ||
1304 | sign[DA732X_HPL_DAC] = (codec->hw_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) & | ||
1305 | DA732X_HP_DAC_OFF_CNTL_COMPO); | ||
1306 | sign[DA732X_HPR_DAC] = (codec->hw_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) & | ||
1307 | DA732X_HP_DAC_OFF_CNTL_COMPO); | ||
1308 | |||
1309 | /* Binary search DAC offset values (both channels at once) */ | ||
1310 | offset[DA732X_HPL_DAC] = sign[DA732X_HPL_DAC] << DA732X_HP_DAC_COMPO_SHIFT; | ||
1311 | offset[DA732X_HPR_DAC] = sign[DA732X_HPR_DAC] << DA732X_HP_DAC_COMPO_SHIFT; | ||
1312 | |||
1313 | do { | ||
1314 | offset[DA732X_HPL_DAC] |= step; | ||
1315 | offset[DA732X_HPR_DAC] |= step; | ||
1316 | snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, | ||
1317 | ~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK); | ||
1318 | snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, | ||
1319 | ~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK); | ||
1320 | |||
1321 | msleep(DA732X_WAIT_FOR_STABILIZATION); | ||
1322 | |||
1323 | if ((codec->hw_read(codec, DA732X_REG_HPL_DAC_OFF_CNTL) & | ||
1324 | DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPL_DAC]) | ||
1325 | offset[DA732X_HPL_DAC] &= ~step; | ||
1326 | if ((codec->hw_read(codec, DA732X_REG_HPR_DAC_OFF_CNTL) & | ||
1327 | DA732X_HP_DAC_OFF_CNTL_COMPO) ^ sign[DA732X_HPR_DAC]) | ||
1328 | offset[DA732X_HPR_DAC] &= ~step; | ||
1329 | |||
1330 | step >>= 1; | ||
1331 | } while (step); | ||
1332 | |||
1333 | /* Write final DAC offsets to registers */ | ||
1334 | snd_soc_write(codec, DA732X_REG_HPL_DAC_OFFSET, | ||
1335 | ~offset[DA732X_HPL_DAC] & DA732X_HP_DAC_OFF_MASK); | ||
1336 | snd_soc_write(codec, DA732X_REG_HPR_DAC_OFFSET, | ||
1337 | ~offset[DA732X_HPR_DAC] & DA732X_HP_DAC_OFF_MASK); | ||
1338 | |||
1339 | /* End DAC calibration mode */ | ||
1340 | snd_soc_write(codec, DA732X_REG_HPL_DAC_OFF_CNTL, | ||
1341 | DA732X_HP_DAC_OFF_SCALE_STEPS); | ||
1342 | snd_soc_write(codec, DA732X_REG_HPR_DAC_OFF_CNTL, | ||
1343 | DA732X_HP_DAC_OFF_SCALE_STEPS); | ||
1344 | } | ||
1345 | |||
1346 | static void da732x_output_offset_adjust(struct snd_soc_codec *codec) | ||
1347 | { | ||
1348 | u8 offset[DA732X_HP_AMPS]; | ||
1349 | u8 sign[DA732X_HP_AMPS]; | ||
1350 | u8 step = DA732X_OUTPUT_OFFSET_STEP; | ||
1351 | |||
1352 | offset[DA732X_HPL_AMP] = DA732X_HP_OUT_TRIM_VAL; | ||
1353 | offset[DA732X_HPR_AMP] = DA732X_HP_OUT_TRIM_VAL; | ||
1354 | |||
1355 | /* Initialize output offset calibration circuits and registers */ | ||
1356 | snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); | ||
1357 | snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, DA732X_HP_OUT_TRIM_VAL); | ||
1358 | snd_soc_write(codec, DA732X_REG_HPL, | ||
1359 | DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN); | ||
1360 | snd_soc_write(codec, DA732X_REG_HPR, | ||
1361 | DA732X_HP_OUT_COMP | DA732X_HP_OUT_EN); | ||
1362 | |||
1363 | /* Wait for voltage stabilization */ | ||
1364 | msleep(DA732X_WAIT_FOR_STABILIZATION); | ||
1365 | |||
1366 | /* Check output offset sign */ | ||
1367 | sign[DA732X_HPL_AMP] = codec->hw_read(codec, DA732X_REG_HPL) & | ||
1368 | DA732X_HP_OUT_COMPO; | ||
1369 | sign[DA732X_HPR_AMP] = codec->hw_read(codec, DA732X_REG_HPR) & | ||
1370 | DA732X_HP_OUT_COMPO; | ||
1371 | |||
1372 | snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_COMP | | ||
1373 | (sign[DA732X_HPL_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) | | ||
1374 | DA732X_HP_OUT_EN); | ||
1375 | snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_COMP | | ||
1376 | (sign[DA732X_HPR_AMP] >> DA732X_HP_OUT_COMPO_SHIFT) | | ||
1377 | DA732X_HP_OUT_EN); | ||
1378 | |||
1379 | /* Binary search output offset values (both channels at once) */ | ||
1380 | do { | ||
1381 | offset[DA732X_HPL_AMP] |= step; | ||
1382 | offset[DA732X_HPR_AMP] |= step; | ||
1383 | snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, | ||
1384 | offset[DA732X_HPL_AMP]); | ||
1385 | snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, | ||
1386 | offset[DA732X_HPR_AMP]); | ||
1387 | |||
1388 | msleep(DA732X_WAIT_FOR_STABILIZATION); | ||
1389 | |||
1390 | if ((codec->hw_read(codec, DA732X_REG_HPL) & | ||
1391 | DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPL_AMP]) | ||
1392 | offset[DA732X_HPL_AMP] &= ~step; | ||
1393 | if ((codec->hw_read(codec, DA732X_REG_HPR) & | ||
1394 | DA732X_HP_OUT_COMPO) ^ sign[DA732X_HPR_AMP]) | ||
1395 | offset[DA732X_HPR_AMP] &= ~step; | ||
1396 | |||
1397 | step >>= 1; | ||
1398 | } while (step); | ||
1399 | |||
1400 | /* Write final DAC offsets to registers */ | ||
1401 | snd_soc_write(codec, DA732X_REG_HPL_OUT_OFFSET, offset[DA732X_HPL_AMP]); | ||
1402 | snd_soc_write(codec, DA732X_REG_HPR_OUT_OFFSET, offset[DA732X_HPR_AMP]); | ||
1403 | } | ||
1404 | |||
1405 | static void da732x_hp_dc_offset_cancellation(struct snd_soc_codec *codec) | ||
1406 | { | ||
1407 | /* Make sure that we have Soft Mute enabled */ | ||
1408 | snd_soc_write(codec, DA732X_REG_DAC1_SOFTMUTE, DA732X_SOFTMUTE_EN | | ||
1409 | DA732X_GAIN_RAMPED | DA732X_16_SAMPLES); | ||
1410 | snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACL_EN | | ||
1411 | DA732X_DACR_EN | DA732X_DACL_SDM | DA732X_DACR_SDM | | ||
1412 | DA732X_DACL_MUTE | DA732X_DACR_MUTE); | ||
1413 | snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_OUT_DAC_EN | | ||
1414 | DA732X_HP_OUT_MUTE | DA732X_HP_OUT_EN); | ||
1415 | snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_OUT_EN | | ||
1416 | DA732X_HP_OUT_MUTE | DA732X_HP_OUT_DAC_EN); | ||
1417 | |||
1418 | da732x_dac_offset_adjust(codec); | ||
1419 | da732x_output_offset_adjust(codec); | ||
1420 | |||
1421 | snd_soc_write(codec, DA732X_REG_DAC1_SEL, DA732X_DACS_DIS); | ||
1422 | snd_soc_write(codec, DA732X_REG_HPL, DA732X_HP_DIS); | ||
1423 | snd_soc_write(codec, DA732X_REG_HPR, DA732X_HP_DIS); | ||
1424 | } | ||
1425 | |||
1426 | static int da732x_set_bias_level(struct snd_soc_codec *codec, | ||
1427 | enum snd_soc_bias_level level) | ||
1428 | { | ||
1429 | struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); | ||
1430 | |||
1431 | switch (level) { | ||
1432 | case SND_SOC_BIAS_ON: | ||
1433 | snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, | ||
1434 | DA732X_BIAS_BOOST_MASK, | ||
1435 | DA732X_BIAS_BOOST_100PC); | ||
1436 | break; | ||
1437 | case SND_SOC_BIAS_PREPARE: | ||
1438 | break; | ||
1439 | case SND_SOC_BIAS_STANDBY: | ||
1440 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | ||
1441 | /* Init Codec */ | ||
1442 | snd_soc_write(codec, DA732X_REG_REF1, | ||
1443 | DA732X_VMID_FASTCHG); | ||
1444 | snd_soc_write(codec, DA732X_REG_BIAS_EN, | ||
1445 | DA732X_BIAS_EN); | ||
1446 | |||
1447 | mdelay(DA732X_STARTUP_DELAY); | ||
1448 | |||
1449 | /* Disable Fast Charge and enable DAC ref voltage */ | ||
1450 | snd_soc_write(codec, DA732X_REG_REF1, | ||
1451 | DA732X_REFBUFX2_EN); | ||
1452 | |||
1453 | /* Enable bypass DSP routing */ | ||
1454 | snd_soc_write(codec, DA732X_REG_DATA_ROUTE, | ||
1455 | DA732X_BYPASS_DSP); | ||
1456 | |||
1457 | /* Enable Digital subsystem */ | ||
1458 | snd_soc_write(codec, DA732X_REG_DSP_CTRL, | ||
1459 | DA732X_DIGITAL_EN); | ||
1460 | |||
1461 | snd_soc_write(codec, DA732X_REG_SPARE1_OUT, | ||
1462 | DA732X_HP_DRIVER_EN | | ||
1463 | DA732X_HP_GATE_LOW | | ||
1464 | DA732X_HP_LOOP_GAIN_CTRL); | ||
1465 | snd_soc_write(codec, DA732X_REG_HP_LIN1_GNDSEL, | ||
1466 | DA732X_HP_OUT_GNDSEL); | ||
1467 | |||
1468 | da732x_set_charge_pump(codec, DA732X_ENABLE_CP); | ||
1469 | |||
1470 | snd_soc_write(codec, DA732X_REG_CLK_EN1, | ||
1471 | DA732X_SYS3_CLK_EN | DA732X_PC_CLK_EN); | ||
1472 | |||
1473 | /* Enable Zero Crossing */ | ||
1474 | snd_soc_write(codec, DA732X_REG_INP_ZC_EN, | ||
1475 | DA732X_MIC1_PRE_ZC_EN | | ||
1476 | DA732X_MIC1_ZC_EN | | ||
1477 | DA732X_MIC2_PRE_ZC_EN | | ||
1478 | DA732X_MIC2_ZC_EN | | ||
1479 | DA732X_AUXL_ZC_EN | | ||
1480 | DA732X_AUXR_ZC_EN | | ||
1481 | DA732X_MIC3_PRE_ZC_EN | | ||
1482 | DA732X_MIC3_ZC_EN); | ||
1483 | snd_soc_write(codec, DA732X_REG_OUT_ZC_EN, | ||
1484 | DA732X_HPL_ZC_EN | DA732X_HPR_ZC_EN | | ||
1485 | DA732X_LIN2_ZC_EN | DA732X_LIN3_ZC_EN | | ||
1486 | DA732X_LIN4_ZC_EN); | ||
1487 | |||
1488 | da732x_hp_dc_offset_cancellation(codec); | ||
1489 | |||
1490 | regcache_cache_only(codec->control_data, false); | ||
1491 | regcache_sync(codec->control_data); | ||
1492 | } else { | ||
1493 | snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, | ||
1494 | DA732X_BIAS_BOOST_MASK, | ||
1495 | DA732X_BIAS_BOOST_50PC); | ||
1496 | snd_soc_update_bits(codec, DA732X_REG_PLL_CTRL, | ||
1497 | DA732X_PLL_EN, 0); | ||
1498 | da732x->pll_en = false; | ||
1499 | } | ||
1500 | break; | ||
1501 | case SND_SOC_BIAS_OFF: | ||
1502 | regcache_cache_only(codec->control_data, true); | ||
1503 | da732x_set_charge_pump(codec, DA732X_DISABLE_CP); | ||
1504 | snd_soc_update_bits(codec, DA732X_REG_BIAS_EN, DA732X_BIAS_EN, | ||
1505 | DA732X_BIAS_DIS); | ||
1506 | da732x->pll_en = false; | ||
1507 | break; | ||
1508 | } | ||
1509 | |||
1510 | codec->dapm.bias_level = level; | ||
1511 | |||
1512 | return 0; | ||
1513 | } | ||
1514 | |||
1515 | static int da732x_probe(struct snd_soc_codec *codec) | ||
1516 | { | ||
1517 | struct da732x_priv *da732x = snd_soc_codec_get_drvdata(codec); | ||
1518 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
1519 | int ret = 0; | ||
1520 | |||
1521 | da732x->codec = codec; | ||
1522 | |||
1523 | dapm->idle_bias_off = false; | ||
1524 | |||
1525 | codec->control_data = da732x->regmap; | ||
1526 | |||
1527 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); | ||
1528 | if (ret != 0) { | ||
1529 | dev_err(codec->dev, "Failed to register codec.\n"); | ||
1530 | goto err; | ||
1531 | } | ||
1532 | |||
1533 | da732x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | ||
1534 | err: | ||
1535 | return ret; | ||
1536 | } | ||
1537 | |||
1538 | static int da732x_remove(struct snd_soc_codec *codec) | ||
1539 | { | ||
1540 | |||
1541 | da732x_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
1542 | |||
1543 | return 0; | ||
1544 | } | ||
1545 | |||
1546 | struct snd_soc_codec_driver soc_codec_dev_da732x = { | ||
1547 | .probe = da732x_probe, | ||
1548 | .remove = da732x_remove, | ||
1549 | .set_bias_level = da732x_set_bias_level, | ||
1550 | .controls = da732x_snd_controls, | ||
1551 | .num_controls = ARRAY_SIZE(da732x_snd_controls), | ||
1552 | .dapm_widgets = da732x_dapm_widgets, | ||
1553 | .num_dapm_widgets = ARRAY_SIZE(da732x_dapm_widgets), | ||
1554 | .dapm_routes = da732x_dapm_routes, | ||
1555 | .num_dapm_routes = ARRAY_SIZE(da732x_dapm_routes), | ||
1556 | .set_pll = da732x_set_dai_pll, | ||
1557 | .reg_cache_size = ARRAY_SIZE(da732x_reg_cache), | ||
1558 | }; | ||
1559 | |||
1560 | static __devinit int da732x_i2c_probe(struct i2c_client *i2c, | ||
1561 | const struct i2c_device_id *id) | ||
1562 | { | ||
1563 | struct da732x_priv *da732x; | ||
1564 | unsigned int reg; | ||
1565 | int ret; | ||
1566 | |||
1567 | da732x = devm_kzalloc(&i2c->dev, sizeof(struct da732x_priv), | ||
1568 | GFP_KERNEL); | ||
1569 | if (!da732x) | ||
1570 | return -ENOMEM; | ||
1571 | |||
1572 | i2c_set_clientdata(i2c, da732x); | ||
1573 | |||
1574 | da732x->regmap = devm_regmap_init_i2c(i2c, &da732x_regmap); | ||
1575 | if (IS_ERR(da732x->regmap)) { | ||
1576 | ret = PTR_ERR(da732x->regmap); | ||
1577 | dev_err(&i2c->dev, "Failed to initialize regmap\n"); | ||
1578 | goto err; | ||
1579 | } | ||
1580 | |||
1581 | ret = regmap_read(da732x->regmap, DA732X_REG_ID, ®); | ||
1582 | if (ret < 0) { | ||
1583 | dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret); | ||
1584 | goto err; | ||
1585 | } | ||
1586 | |||
1587 | dev_info(&i2c->dev, "Revision: %d.%d\n", | ||
1588 | (reg & DA732X_ID_MAJOR_MASK), (reg & DA732X_ID_MINOR_MASK)); | ||
1589 | |||
1590 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_da732x, | ||
1591 | da732x_dai, ARRAY_SIZE(da732x_dai)); | ||
1592 | if (ret != 0) | ||
1593 | dev_err(&i2c->dev, "Failed to register codec.\n"); | ||
1594 | |||
1595 | err: | ||
1596 | return ret; | ||
1597 | } | ||
1598 | |||
1599 | static __devexit int da732x_i2c_remove(struct i2c_client *client) | ||
1600 | { | ||
1601 | snd_soc_unregister_codec(&client->dev); | ||
1602 | |||
1603 | return 0; | ||
1604 | } | ||
1605 | |||
1606 | static const struct i2c_device_id da732x_i2c_id[] = { | ||
1607 | { "da7320", 0}, | ||
1608 | { } | ||
1609 | }; | ||
1610 | MODULE_DEVICE_TABLE(i2c, da732x_i2c_id); | ||
1611 | |||
1612 | static struct i2c_driver da732x_i2c_driver = { | ||
1613 | .driver = { | ||
1614 | .name = "da7320", | ||
1615 | .owner = THIS_MODULE, | ||
1616 | }, | ||
1617 | .probe = da732x_i2c_probe, | ||
1618 | .remove = __devexit_p(da732x_i2c_remove), | ||
1619 | .id_table = da732x_i2c_id, | ||
1620 | }; | ||
1621 | |||
1622 | module_i2c_driver(da732x_i2c_driver); | ||
1623 | |||
1624 | |||
1625 | MODULE_DESCRIPTION("ASoC DA732X driver"); | ||
1626 | MODULE_AUTHOR("Michal Hajduk <michal.hajduk@diasemi.com>"); | ||
1627 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/da732x.h b/sound/soc/codecs/da732x.h new file mode 100644 index 000000000000..c8ce5475de22 --- /dev/null +++ b/sound/soc/codecs/da732x.h | |||
@@ -0,0 +1,133 @@ | |||
1 | /* | ||
2 | * da732x.h -- Dialog DA732X ALSA SoC Audio Driver Header File | ||
3 | * | ||
4 | * Copyright (C) 2012 Dialog Semiconductor GmbH | ||
5 | * | ||
6 | * Author: Michal Hajduk <Michal.Hajduk@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __DA732X_H_ | ||
14 | #define __DA732X_H | ||
15 | |||
16 | #include <sound/soc.h> | ||
17 | |||
18 | /* General */ | ||
19 | #define DA732X_U8_MASK 0xFF | ||
20 | #define DA732X_4BYTES 4 | ||
21 | #define DA732X_3BYTES 3 | ||
22 | #define DA732X_2BYTES 2 | ||
23 | #define DA732X_1BYTE 1 | ||
24 | #define DA732X_1BYTE_SHIFT 8 | ||
25 | #define DA732X_2BYTES_SHIFT 16 | ||
26 | #define DA732X_3BYTES_SHIFT 24 | ||
27 | #define DA732X_4BYTES_SHIFT 32 | ||
28 | |||
29 | #define DA732X_DACS_DIS 0x0 | ||
30 | #define DA732X_HP_DIS 0x0 | ||
31 | #define DA732X_CLEAR_REG 0x0 | ||
32 | |||
33 | /* Calibration */ | ||
34 | #define DA732X_DAC_OFFSET_STEP 0x20 | ||
35 | #define DA732X_OUTPUT_OFFSET_STEP 0x80 | ||
36 | #define DA732X_HP_OUT_TRIM_VAL 0x0 | ||
37 | #define DA732X_WAIT_FOR_STABILIZATION 1 | ||
38 | #define DA732X_HPL_DAC 0 | ||
39 | #define DA732X_HPR_DAC 1 | ||
40 | #define DA732X_HP_DACS 2 | ||
41 | #define DA732X_HPL_AMP 0 | ||
42 | #define DA732X_HPR_AMP 1 | ||
43 | #define DA732X_HP_AMPS 2 | ||
44 | |||
45 | /* Clock settings */ | ||
46 | #define DA732X_STARTUP_DELAY 100 | ||
47 | #define DA732X_PLL_OUT_196608 196608000 | ||
48 | #define DA732X_PLL_OUT_180634 180633600 | ||
49 | #define DA732X_PLL_OUT_SRM 188620800 | ||
50 | #define DA732X_MCLK_10MHZ 10000000 | ||
51 | #define DA732X_MCLK_20MHZ 20000000 | ||
52 | #define DA732X_MCLK_40MHZ 40000000 | ||
53 | #define DA732X_MCLK_54MHZ 54000000 | ||
54 | #define DA732X_MCLK_RET_0_10MHZ 0 | ||
55 | #define DA732X_MCLK_VAL_0_10MHZ 1 | ||
56 | #define DA732X_MCLK_RET_10_20MHZ 1 | ||
57 | #define DA732X_MCLK_VAL_10_20MHZ 2 | ||
58 | #define DA732X_MCLK_RET_20_40MHZ 2 | ||
59 | #define DA732X_MCLK_VAL_20_40MHZ 4 | ||
60 | #define DA732X_MCLK_RET_40_54MHZ 3 | ||
61 | #define DA732X_MCLK_VAL_40_54MHZ 8 | ||
62 | #define DA732X_DAI_ID1 0 | ||
63 | #define DA732X_DAI_ID2 1 | ||
64 | #define DA732X_SRCCLK_PLL 0 | ||
65 | #define DA732X_SRCCLK_MCLK 1 | ||
66 | |||
67 | #define DA732X_LIN_LP_VOL 0x4F | ||
68 | #define DA732X_LP_VOL 0x40 | ||
69 | |||
70 | /* Kcontrols */ | ||
71 | #define DA732X_DAC_EN_MAX 2 | ||
72 | #define DA732X_ADCL_MUX_MAX 2 | ||
73 | #define DA732X_ADCR_MUX_MAX 3 | ||
74 | #define DA732X_HPF_MODE_MAX 3 | ||
75 | #define DA732X_HPF_MODE_SHIFT 4 | ||
76 | #define DA732X_HPF_MUSIC_SHIFT 0 | ||
77 | #define DA732X_HPF_MUSIC_MAX 4 | ||
78 | #define DA732X_HPF_VOICE_SHIFT 4 | ||
79 | #define DA732X_HPF_VOICE_MAX 8 | ||
80 | #define DA732X_EQ_EN_MAX 1 | ||
81 | #define DA732X_HPF_VOICE 1 | ||
82 | #define DA732X_HPF_MUSIC 2 | ||
83 | #define DA732X_HPF_DISABLED 0 | ||
84 | #define DA732X_NO_INVERT 0 | ||
85 | #define DA732X_INVERT 1 | ||
86 | #define DA732X_SWITCH_MAX 1 | ||
87 | #define DA732X_ENABLE_CP 1 | ||
88 | #define DA732X_DISABLE_CP 0 | ||
89 | #define DA732X_DISABLE_ALL_CLKS 0 | ||
90 | #define DA732X_RESET_ADCS 0 | ||
91 | |||
92 | /* dB values */ | ||
93 | #define DA732X_MIC_VOL_DB_MIN 0 | ||
94 | #define DA732X_MIC_VOL_DB_INC 50 | ||
95 | #define DA732X_MIC_PRE_VOL_DB_MIN 0 | ||
96 | #define DA732X_MIC_PRE_VOL_DB_INC 600 | ||
97 | #define DA732X_AUX_VOL_DB_MIN -6000 | ||
98 | #define DA732X_AUX_VOL_DB_INC 150 | ||
99 | #define DA732X_HP_VOL_DB_MIN -2250 | ||
100 | #define DA732X_HP_VOL_DB_INC 150 | ||
101 | #define DA732X_LIN2_VOL_DB_MIN -1650 | ||
102 | #define DA732X_LIN2_VOL_DB_INC 150 | ||
103 | #define DA732X_LIN3_VOL_DB_MIN -1650 | ||
104 | #define DA732X_LIN3_VOL_DB_INC 150 | ||
105 | #define DA732X_LIN4_VOL_DB_MIN -2250 | ||
106 | #define DA732X_LIN4_VOL_DB_INC 150 | ||
107 | #define DA732X_EQ_BAND_VOL_DB_MIN -1050 | ||
108 | #define DA732X_EQ_BAND_VOL_DB_INC 150 | ||
109 | #define DA732X_DAC_VOL_DB_MIN -7725 | ||
110 | #define DA732X_DAC_VOL_DB_INC 75 | ||
111 | #define DA732X_ADC_VOL_DB_MIN 0 | ||
112 | #define DA732X_ADC_VOL_DB_INC -1 | ||
113 | #define DA732X_EQ_OVERALL_VOL_DB_MIN -1800 | ||
114 | #define DA732X_EQ_OVERALL_VOL_DB_INC 600 | ||
115 | |||
116 | #define DA732X_SOC_ENUM_DOUBLE_R(xreg, xrreg, xmax, xtext) \ | ||
117 | {.reg = xreg, .reg2 = xrreg, .max = xmax, .texts = xtext} | ||
118 | |||
119 | enum da732x_sysctl { | ||
120 | DA732X_SR_8KHZ = 0x1, | ||
121 | DA732X_SR_11_025KHZ = 0x2, | ||
122 | DA732X_SR_12KHZ = 0x3, | ||
123 | DA732X_SR_16KHZ = 0x5, | ||
124 | DA732X_SR_22_05KHZ = 0x6, | ||
125 | DA732X_SR_24KHZ = 0x7, | ||
126 | DA732X_SR_32KHZ = 0x9, | ||
127 | DA732X_SR_44_1KHZ = 0xA, | ||
128 | DA732X_SR_48KHZ = 0xB, | ||
129 | DA732X_SR_88_1KHZ = 0xE, | ||
130 | DA732X_SR_96KHZ = 0xF, | ||
131 | }; | ||
132 | |||
133 | #endif /* __DA732X_H_ */ | ||
diff --git a/sound/soc/codecs/da732x_reg.h b/sound/soc/codecs/da732x_reg.h new file mode 100644 index 000000000000..bdd03ca4b2de --- /dev/null +++ b/sound/soc/codecs/da732x_reg.h | |||
@@ -0,0 +1,654 @@ | |||
1 | /* | ||
2 | * da732x_reg.h --- Dialog DA732X ALSA SoC Audio Registers Header File | ||
3 | * | ||
4 | * Copyright (C) 2012 Dialog Semiconductor GmbH | ||
5 | * | ||
6 | * Author: Michal Hajduk <Michal.Hajduk@diasemi.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #ifndef __DA732X_REG_H_ | ||
14 | #define __DA732X_REG_H_ | ||
15 | |||
16 | /* DA732X registers */ | ||
17 | #define DA732X_REG_STATUS_EXT 0x00 | ||
18 | #define DA732X_REG_STATUS 0x01 | ||
19 | #define DA732X_REG_REF1 0x02 | ||
20 | #define DA732X_REG_BIAS_EN 0x03 | ||
21 | #define DA732X_REG_BIAS1 0x04 | ||
22 | #define DA732X_REG_BIAS2 0x05 | ||
23 | #define DA732X_REG_BIAS3 0x06 | ||
24 | #define DA732X_REG_BIAS4 0x07 | ||
25 | #define DA732X_REG_MICBIAS2 0x0F | ||
26 | #define DA732X_REG_MICBIAS1 0x10 | ||
27 | #define DA732X_REG_MICDET 0x11 | ||
28 | #define DA732X_REG_MIC1_PRE 0x12 | ||
29 | #define DA732X_REG_MIC1 0x13 | ||
30 | #define DA732X_REG_MIC2_PRE 0x14 | ||
31 | #define DA732X_REG_MIC2 0x15 | ||
32 | #define DA732X_REG_AUX1L 0x16 | ||
33 | #define DA732X_REG_AUX1R 0x17 | ||
34 | #define DA732X_REG_MIC3_PRE 0x18 | ||
35 | #define DA732X_REG_MIC3 0x19 | ||
36 | #define DA732X_REG_INP_PINBIAS 0x1A | ||
37 | #define DA732X_REG_INP_ZC_EN 0x1B | ||
38 | #define DA732X_REG_INP_MUX 0x1D | ||
39 | #define DA732X_REG_HP_DET 0x20 | ||
40 | #define DA732X_REG_HPL_DAC_OFFSET 0x21 | ||
41 | #define DA732X_REG_HPL_DAC_OFF_CNTL 0x22 | ||
42 | #define DA732X_REG_HPL_OUT_OFFSET 0x23 | ||
43 | #define DA732X_REG_HPL 0x24 | ||
44 | #define DA732X_REG_HPL_VOL 0x25 | ||
45 | #define DA732X_REG_HPR_DAC_OFFSET 0x26 | ||
46 | #define DA732X_REG_HPR_DAC_OFF_CNTL 0x27 | ||
47 | #define DA732X_REG_HPR_OUT_OFFSET 0x28 | ||
48 | #define DA732X_REG_HPR 0x29 | ||
49 | #define DA732X_REG_HPR_VOL 0x2A | ||
50 | #define DA732X_REG_LIN2 0x2B | ||
51 | #define DA732X_REG_LIN3 0x2C | ||
52 | #define DA732X_REG_LIN4 0x2D | ||
53 | #define DA732X_REG_OUT_ZC_EN 0x2E | ||
54 | #define DA732X_REG_HP_LIN1_GNDSEL 0x37 | ||
55 | #define DA732X_REG_CP_HP1 0x3A | ||
56 | #define DA732X_REG_CP_HP2 0x3B | ||
57 | #define DA732X_REG_CP_CTRL1 0x40 | ||
58 | #define DA732X_REG_CP_CTRL2 0x41 | ||
59 | #define DA732X_REG_CP_CTRL3 0x42 | ||
60 | #define DA732X_REG_CP_LEVEL_MASK 0x43 | ||
61 | #define DA732X_REG_CP_DET 0x44 | ||
62 | #define DA732X_REG_CP_STATUS 0x45 | ||
63 | #define DA732X_REG_CP_THRESH1 0x46 | ||
64 | #define DA732X_REG_CP_THRESH2 0x47 | ||
65 | #define DA732X_REG_CP_THRESH3 0x48 | ||
66 | #define DA732X_REG_CP_THRESH4 0x49 | ||
67 | #define DA732X_REG_CP_THRESH5 0x4A | ||
68 | #define DA732X_REG_CP_THRESH6 0x4B | ||
69 | #define DA732X_REG_CP_THRESH7 0x4C | ||
70 | #define DA732X_REG_CP_THRESH8 0x4D | ||
71 | #define DA732X_REG_PLL_DIV_LO 0x50 | ||
72 | #define DA732X_REG_PLL_DIV_MID 0x51 | ||
73 | #define DA732X_REG_PLL_DIV_HI 0x52 | ||
74 | #define DA732X_REG_PLL_CTRL 0x53 | ||
75 | #define DA732X_REG_CLK_CTRL 0x54 | ||
76 | #define DA732X_REG_CLK_DSP 0x5A | ||
77 | #define DA732X_REG_CLK_EN1 0x5B | ||
78 | #define DA732X_REG_CLK_EN2 0x5C | ||
79 | #define DA732X_REG_CLK_EN3 0x5D | ||
80 | #define DA732X_REG_CLK_EN4 0x5E | ||
81 | #define DA732X_REG_CLK_EN5 0x5F | ||
82 | #define DA732X_REG_AIF_MCLK 0x60 | ||
83 | #define DA732X_REG_AIFA1 0x61 | ||
84 | #define DA732X_REG_AIFA2 0x62 | ||
85 | #define DA732X_REG_AIFA3 0x63 | ||
86 | #define DA732X_REG_AIFB1 0x64 | ||
87 | #define DA732X_REG_AIFB2 0x65 | ||
88 | #define DA732X_REG_AIFB3 0x66 | ||
89 | #define DA732X_REG_PC_CTRL 0x6A | ||
90 | #define DA732X_REG_DATA_ROUTE 0x70 | ||
91 | #define DA732X_REG_DSP_CTRL 0x71 | ||
92 | #define DA732X_REG_CIF_CTRL2 0x74 | ||
93 | #define DA732X_REG_HANDSHAKE 0x75 | ||
94 | #define DA732X_REG_MBOX0 0x76 | ||
95 | #define DA732X_REG_MBOX1 0x77 | ||
96 | #define DA732X_REG_MBOX2 0x78 | ||
97 | #define DA732X_REG_MBOX_STATUS 0x79 | ||
98 | #define DA732X_REG_SPARE1_OUT 0x7D | ||
99 | #define DA732X_REG_SPARE2_OUT 0x7E | ||
100 | #define DA732X_REG_SPARE1_IN 0x7F | ||
101 | #define DA732X_REG_ID 0x81 | ||
102 | #define DA732X_REG_ADC1_PD 0x90 | ||
103 | #define DA732X_REG_ADC1_HPF 0x93 | ||
104 | #define DA732X_REG_ADC1_SEL 0x94 | ||
105 | #define DA732X_REG_ADC1_EQ12 0x95 | ||
106 | #define DA732X_REG_ADC1_EQ34 0x96 | ||
107 | #define DA732X_REG_ADC1_EQ5 0x97 | ||
108 | #define DA732X_REG_ADC2_PD 0x98 | ||
109 | #define DA732X_REG_ADC2_HPF 0x9B | ||
110 | #define DA732X_REG_ADC2_SEL 0x9C | ||
111 | #define DA732X_REG_ADC2_EQ12 0x9D | ||
112 | #define DA732X_REG_ADC2_EQ34 0x9E | ||
113 | #define DA732X_REG_ADC2_EQ5 0x9F | ||
114 | #define DA732X_REG_DAC1_HPF 0xA0 | ||
115 | #define DA732X_REG_DAC1_L_VOL 0xA1 | ||
116 | #define DA732X_REG_DAC1_R_VOL 0xA2 | ||
117 | #define DA732X_REG_DAC1_SEL 0xA3 | ||
118 | #define DA732X_REG_DAC1_SOFTMUTE 0xA4 | ||
119 | #define DA732X_REG_DAC1_EQ12 0xA5 | ||
120 | #define DA732X_REG_DAC1_EQ34 0xA6 | ||
121 | #define DA732X_REG_DAC1_EQ5 0xA7 | ||
122 | #define DA732X_REG_DAC2_HPF 0xB0 | ||
123 | #define DA732X_REG_DAC2_L_VOL 0xB1 | ||
124 | #define DA732X_REG_DAC2_R_VOL 0xB2 | ||
125 | #define DA732X_REG_DAC2_SEL 0xB3 | ||
126 | #define DA732X_REG_DAC2_SOFTMUTE 0xB4 | ||
127 | #define DA732X_REG_DAC2_EQ12 0xB5 | ||
128 | #define DA732X_REG_DAC2_EQ34 0xB6 | ||
129 | #define DA732X_REG_DAC2_EQ5 0xB7 | ||
130 | #define DA732X_REG_DAC3_HPF 0xC0 | ||
131 | #define DA732X_REG_DAC3_VOL 0xC1 | ||
132 | #define DA732X_REG_DAC3_SEL 0xC3 | ||
133 | #define DA732X_REG_DAC3_SOFTMUTE 0xC4 | ||
134 | #define DA732X_REG_DAC3_EQ12 0xC5 | ||
135 | #define DA732X_REG_DAC3_EQ34 0xC6 | ||
136 | #define DA732X_REG_DAC3_EQ5 0xC7 | ||
137 | #define DA732X_REG_BIQ_BYP 0xD2 | ||
138 | #define DA732X_REG_DMA_CMD 0xD3 | ||
139 | #define DA732X_REG_DMA_ADDR0 0xD4 | ||
140 | #define DA732X_REG_DMA_ADDR1 0xD5 | ||
141 | #define DA732X_REG_DMA_DATA0 0xD6 | ||
142 | #define DA732X_REG_DMA_DATA1 0xD7 | ||
143 | #define DA732X_REG_DMA_DATA2 0xD8 | ||
144 | #define DA732X_REG_DMA_DATA3 0xD9 | ||
145 | #define DA732X_REG_DMA_STATUS 0xDA | ||
146 | #define DA732X_REG_BROWNOUT 0xDF | ||
147 | #define DA732X_REG_UNLOCK 0xE0 | ||
148 | |||
149 | #define DA732X_MAX_REG DA732X_REG_UNLOCK | ||
150 | /* | ||
151 | * Bits | ||
152 | */ | ||
153 | |||
154 | /* DA732X_REG_STATUS_EXT (addr=0x00) */ | ||
155 | #define DA732X_STATUS_EXT_DSP (1 << 4) | ||
156 | #define DA732X_STATUS_EXT_CLEAR (0 << 0) | ||
157 | |||
158 | /* DA732X_REG_STATUS (addr=0x01) */ | ||
159 | #define DA732X_STATUS_PLL_LOCK (1 << 0) | ||
160 | #define DA732X_STATUS_PLL_MCLK_DET (1 << 1) | ||
161 | #define DA732X_STATUS_HPDET_OUT (1 << 2) | ||
162 | #define DA732X_STATUS_INP_MIXDET_1 (1 << 3) | ||
163 | #define DA732X_STATUS_INP_MIXDET_2 (1 << 4) | ||
164 | #define DA732X_STATUS_BO_STATUS (1 << 5) | ||
165 | |||
166 | /* DA732X_REG_REF1 (addr=0x02) */ | ||
167 | #define DA732X_VMID_FASTCHG (1 << 1) | ||
168 | #define DA732X_VMID_FASTDISCHG (1 << 2) | ||
169 | #define DA732X_REFBUFX2_EN (1 << 6) | ||
170 | #define DA732X_REFBUFX2_DIS (0 << 6) | ||
171 | |||
172 | /* DA732X_REG_BIAS_EN (addr=0x03) */ | ||
173 | #define DA732X_BIAS_BOOST_MASK (3 << 0) | ||
174 | #define DA732X_BIAS_BOOST_100PC (0 << 0) | ||
175 | #define DA732X_BIAS_BOOST_133PC (1 << 0) | ||
176 | #define DA732X_BIAS_BOOST_88PC (2 << 0) | ||
177 | #define DA732X_BIAS_BOOST_50PC (3 << 0) | ||
178 | #define DA732X_BIAS_EN (1 << 7) | ||
179 | #define DA732X_BIAS_DIS (0 << 7) | ||
180 | |||
181 | /* DA732X_REG_BIAS1 (addr=0x04) */ | ||
182 | #define DA732X_BIAS1_HP_DAC_BIAS_MASK (3 << 0) | ||
183 | #define DA732X_BIAS1_HP_DAC_BIAS_100PC (0 << 0) | ||
184 | #define DA732X_BIAS1_HP_DAC_BIAS_150PC (1 << 0) | ||
185 | #define DA732X_BIAS1_HP_DAC_BIAS_50PC (2 << 0) | ||
186 | #define DA732X_BIAS1_HP_DAC_BIAS_75PC (3 << 0) | ||
187 | #define DA732X_BIAS1_HP_OUT_BIAS_MASK (7 << 4) | ||
188 | #define DA732X_BIAS1_HP_OUT_BIAS_100PC (0 << 4) | ||
189 | #define DA732X_BIAS1_HP_OUT_BIAS_125PC (1 << 4) | ||
190 | #define DA732X_BIAS1_HP_OUT_BIAS_150PC (2 << 4) | ||
191 | #define DA732X_BIAS1_HP_OUT_BIAS_175PC (3 << 4) | ||
192 | #define DA732X_BIAS1_HP_OUT_BIAS_200PC (4 << 4) | ||
193 | #define DA732X_BIAS1_HP_OUT_BIAS_250PC (5 << 4) | ||
194 | #define DA732X_BIAS1_HP_OUT_BIAS_300PC (6 << 4) | ||
195 | #define DA732X_BIAS1_HP_OUT_BIAS_350PC (7 << 4) | ||
196 | |||
197 | /* DA732X_REG_BIAS2 (addr=0x05) */ | ||
198 | #define DA732X_BIAS2_LINE2_DAC_BIAS_MASK (3 << 0) | ||
199 | #define DA732X_BIAS2_LINE2_DAC_BIAS_100PC (0 << 0) | ||
200 | #define DA732X_BIAS2_LINE2_DAC_BIAS_150PC (1 << 0) | ||
201 | #define DA732X_BIAS2_LINE2_DAC_BIAS_50PC (2 << 0) | ||
202 | #define DA732X_BIAS2_LINE2_DAC_BIAS_75PC (3 << 0) | ||
203 | #define DA732X_BIAS2_LINE2_OUT_BIAS_MASK (7 << 4) | ||
204 | #define DA732X_BIAS2_LINE2_OUT_BIAS_100PC (0 << 4) | ||
205 | #define DA732X_BIAS2_LINE2_OUT_BIAS_125PC (1 << 4) | ||
206 | #define DA732X_BIAS2_LINE2_OUT_BIAS_150PC (2 << 4) | ||
207 | #define DA732X_BIAS2_LINE2_OUT_BIAS_175PC (3 << 4) | ||
208 | #define DA732X_BIAS2_LINE2_OUT_BIAS_200PC (4 << 4) | ||
209 | #define DA732X_BIAS2_LINE2_OUT_BIAS_250PC (5 << 4) | ||
210 | #define DA732X_BIAS2_LINE2_OUT_BIAS_300PC (6 << 4) | ||
211 | #define DA732X_BIAS2_LINE2_OUT_BIAS_350PC (7 << 4) | ||
212 | |||
213 | /* DA732X_REG_BIAS3 (addr=0x06) */ | ||
214 | #define DA732X_BIAS3_LINE3_DAC_BIAS_MASK (3 << 0) | ||
215 | #define DA732X_BIAS3_LINE3_DAC_BIAS_100PC (0 << 0) | ||
216 | #define DA732X_BIAS3_LINE3_DAC_BIAS_150PC (1 << 0) | ||
217 | #define DA732X_BIAS3_LINE3_DAC_BIAS_50PC (2 << 0) | ||
218 | #define DA732X_BIAS3_LINE3_DAC_BIAS_75PC (3 << 0) | ||
219 | #define DA732X_BIAS3_LINE3_OUT_BIAS_MASK (7 << 4) | ||
220 | #define DA732X_BIAS3_LINE3_OUT_BIAS_100PC (0 << 4) | ||
221 | #define DA732X_BIAS3_LINE3_OUT_BIAS_125PC (1 << 4) | ||
222 | #define DA732X_BIAS3_LINE3_OUT_BIAS_150PC (2 << 4) | ||
223 | #define DA732X_BIAS3_LINE3_OUT_BIAS_175PC (3 << 4) | ||
224 | #define DA732X_BIAS3_LINE3_OUT_BIAS_200PC (4 << 4) | ||
225 | #define DA732X_BIAS3_LINE3_OUT_BIAS_250PC (5 << 4) | ||
226 | #define DA732X_BIAS3_LINE3_OUT_BIAS_300PC (6 << 4) | ||
227 | #define DA732X_BIAS3_LINE3_OUT_BIAS_350PC (7 << 4) | ||
228 | |||
229 | /* DA732X_REG_BIAS4 (addr=0x07) */ | ||
230 | #define DA732X_BIAS4_LINE4_DAC_BIAS_MASK (3 << 0) | ||
231 | #define DA732X_BIAS4_LINE4_DAC_BIAS_100PC (0 << 0) | ||
232 | #define DA732X_BIAS4_LINE4_DAC_BIAS_150PC (1 << 0) | ||
233 | #define DA732X_BIAS4_LINE4_DAC_BIAS_50PC (2 << 0) | ||
234 | #define DA732X_BIAS4_LINE4_DAC_BIAS_75PC (3 << 0) | ||
235 | #define DA732X_BIAS4_LINE4_OUT_BIAS_MASK (7 << 4) | ||
236 | #define DA732X_BIAS4_LINE4_OUT_BIAS_100PC (0 << 4) | ||
237 | #define DA732X_BIAS4_LINE4_OUT_BIAS_125PC (1 << 4) | ||
238 | #define DA732X_BIAS4_LINE4_OUT_BIAS_150PC (2 << 4) | ||
239 | #define DA732X_BIAS4_LINE4_OUT_BIAS_175PC (3 << 4) | ||
240 | #define DA732X_BIAS4_LINE4_OUT_BIAS_200PC (4 << 4) | ||
241 | #define DA732X_BIAS4_LINE4_OUT_BIAS_250PC (5 << 4) | ||
242 | #define DA732X_BIAS4_LINE4_OUT_BIAS_300PC (6 << 4) | ||
243 | #define DA732X_BIAS4_LINE4_OUT_BIAS_350PC (7 << 4) | ||
244 | |||
245 | /* DA732X_REG_SIF_VDD_SEL (addr=0x08) */ | ||
246 | #define DA732X_SIF_VDD_SEL_AIFA_VDD2 (1 << 0) | ||
247 | #define DA732X_SIF_VDD_SEL_AIFB_VDD2 (1 << 1) | ||
248 | #define DA732X_SIF_VDD_SEL_CIFA_VDD2 (1 << 4) | ||
249 | |||
250 | /* DA732X_REG_MICBIAS2/1 (addr=0x0F/0x10) */ | ||
251 | #define DA732X_MICBIAS_VOLTAGE_MASK (0x0F << 0) | ||
252 | #define DA732X_MICBIAS_VOLTAGE_2V (0x00 << 0) | ||
253 | #define DA732X_MICBIAS_VOLTAGE_2V05 (0x01 << 0) | ||
254 | #define DA732X_MICBIAS_VOLTAGE_2V1 (0x02 << 0) | ||
255 | #define DA732X_MICBIAS_VOLTAGE_2V15 (0x03 << 0) | ||
256 | #define DA732X_MICBIAS_VOLTAGE_2V2 (0x04 << 0) | ||
257 | #define DA732X_MICBIAS_VOLTAGE_2V25 (0x05 << 0) | ||
258 | #define DA732X_MICBIAS_VOLTAGE_2V3 (0x06 << 0) | ||
259 | #define DA732X_MICBIAS_VOLTAGE_2V35 (0x07 << 0) | ||
260 | #define DA732X_MICBIAS_VOLTAGE_2V4 (0x08 << 0) | ||
261 | #define DA732X_MICBIAS_VOLTAGE_2V45 (0x09 << 0) | ||
262 | #define DA732X_MICBIAS_VOLTAGE_2V5 (0x0A << 0) | ||
263 | #define DA732X_MICBIAS_EN (1 << 7) | ||
264 | #define DA732X_MICBIAS_EN_SHIFT 7 | ||
265 | #define DA732X_MICBIAS_VOLTAGE_SHIFT 0 | ||
266 | #define DA732X_MICBIAS_VOLTAGE_MAX 0x0B | ||
267 | |||
268 | /* DA732X_REG_MICDET (addr=0x11) */ | ||
269 | #define DA732X_MICDET_INP_MICRES (1 << 0) | ||
270 | #define DA732X_MICDET_INP_MICHOOK (1 << 1) | ||
271 | #define DA732X_MICDET_INP_DEBOUNCE_PRD_8MS (0 << 0) | ||
272 | #define DA732X_MICDET_INP_DEBOUNCE_PRD_16MS (1 << 0) | ||
273 | #define DA732X_MICDET_INP_DEBOUNCE_PRD_32MS (2 << 0) | ||
274 | #define DA732X_MICDET_INP_DEBOUNCE_PRD_64MS (3 << 0) | ||
275 | #define DA732X_MICDET_INP_MICDET_EN (1 << 7) | ||
276 | |||
277 | /* DA732X_REG_MIC1/2/3_PRE (addr=0x11/0x14/0x18) */ | ||
278 | #define DA732X_MICBOOST_MASK 0x7 | ||
279 | #define DA732X_MICBOOST_SHIFT 0 | ||
280 | #define DA732X_MICBOOST_MIN 0x1 | ||
281 | #define DA732X_MICBOOST_MAX DA732X_MICBOOST_MASK | ||
282 | |||
283 | /* DA732X_REG_MIC1/2/3 (addr=0x13/0x15/0x19) */ | ||
284 | #define DA732X_MIC_VOL_SHIFT 0 | ||
285 | #define DA732X_MIC_VOL_VAL_MASK 0x1F | ||
286 | #define DA732X_MIC_MUTE_SHIFT 6 | ||
287 | #define DA732X_MIC_EN_SHIFT 7 | ||
288 | #define DA732X_MIC_VOL_VAL_MIN 0x7 | ||
289 | #define DA732X_MIC_VOL_VAL_MAX DA732X_MIC_VOL_VAL_MASK | ||
290 | |||
291 | /* DA732X_REG_AUX1L/R (addr=0x16/0x17) */ | ||
292 | #define DA732X_AUX_VOL_SHIFT 0 | ||
293 | #define DA732X_AUX_VOL_MASK 0x7 | ||
294 | #define DA732X_AUX_MUTE_SHIFT 6 | ||
295 | #define DA732X_AUX_EN_SHIFT 7 | ||
296 | #define DA732X_AUX_VOL_VAL_MAX DA732X_AUX_VOL_MASK | ||
297 | |||
298 | /* DA732X_REG_INP_PINBIAS (addr=0x1A) */ | ||
299 | #define DA732X_INP_MICL_PINBIAS_EN (1 << 0) | ||
300 | #define DA732X_INP_MICR_PINBIAS_EN (1 << 1) | ||
301 | #define DA732X_INP_AUX1L_PINBIAS_EN (1 << 2) | ||
302 | #define DA732X_INP_AUX1R_PINBIAS_EN (1 << 3) | ||
303 | #define DA732X_INP_AUX2_PINBIAS_EN (1 << 4) | ||
304 | |||
305 | /* DA732X_REG_INP_ZC_EN (addr=0x1B) */ | ||
306 | #define DA732X_MIC1_PRE_ZC_EN (1 << 0) | ||
307 | #define DA732X_MIC1_ZC_EN (1 << 1) | ||
308 | #define DA732X_MIC2_PRE_ZC_EN (1 << 2) | ||
309 | #define DA732X_MIC2_ZC_EN (1 << 3) | ||
310 | #define DA732X_AUXL_ZC_EN (1 << 4) | ||
311 | #define DA732X_AUXR_ZC_EN (1 << 5) | ||
312 | #define DA732X_MIC3_PRE_ZC_EN (1 << 6) | ||
313 | #define DA732X_MIC3_ZC_EN (1 << 7) | ||
314 | |||
315 | /* DA732X_REG_INP_MUX (addr=0x1D) */ | ||
316 | #define DA732X_INP_ADC1L_MUX_SEL_AUX1L (0 << 0) | ||
317 | #define DA732X_INP_ADC1L_MUX_SEL_MIC1 (1 << 0) | ||
318 | #define DA732X_INP_ADC1R_MUX_SEL_MASK (3 << 2) | ||
319 | #define DA732X_INP_ADC1R_MUX_SEL_AUX1R (0 << 2) | ||
320 | #define DA732X_INP_ADC1R_MUX_SEL_MIC2 (1 << 2) | ||
321 | #define DA732X_INP_ADC1R_MUX_SEL_MIC3 (2 << 2) | ||
322 | #define DA732X_INP_ADC2L_MUX_SEL_AUX1L (0 << 4) | ||
323 | #define DA732X_INP_ADC2L_MUX_SEL_MICL (1 << 4) | ||
324 | #define DA732X_INP_ADC2R_MUX_SEL_MASK (3 << 6) | ||
325 | #define DA732X_INP_ADC2R_MUX_SEL_AUX1R (0 << 6) | ||
326 | #define DA732X_INP_ADC2R_MUX_SEL_MICR (1 << 6) | ||
327 | #define DA732X_INP_ADC2R_MUX_SEL_AUX2 (2 << 6) | ||
328 | #define DA732X_ADC1L_MUX_SEL_SHIFT 0 | ||
329 | #define DA732X_ADC1R_MUX_SEL_SHIFT 2 | ||
330 | #define DA732X_ADC2L_MUX_SEL_SHIFT 4 | ||
331 | #define DA732X_ADC2R_MUX_SEL_SHIFT 6 | ||
332 | |||
333 | /* DA732X_REG_HP_DET (addr=0x20) */ | ||
334 | #define DA732X_HP_DET_AZ (1 << 0) | ||
335 | #define DA732X_HP_DET_SEL1 (1 << 1) | ||
336 | #define DA732X_HP_DET_IS_MASK (3 << 2) | ||
337 | #define DA732X_HP_DET_IS_0_5UA (0 << 2) | ||
338 | #define DA732X_HP_DET_IS_1UA (1 << 2) | ||
339 | #define DA732X_HP_DET_IS_2UA (2 << 2) | ||
340 | #define DA732X_HP_DET_IS_4UA (3 << 2) | ||
341 | #define DA732X_HP_DET_RS_MASK (3 << 4) | ||
342 | #define DA732X_HP_DET_RS_INFINITE (0 << 4) | ||
343 | #define DA732X_HP_DET_RS_100KOHM (1 << 4) | ||
344 | #define DA732X_HP_DET_RS_10KOHM (2 << 4) | ||
345 | #define DA732X_HP_DET_RS_1KOHM (3 << 4) | ||
346 | #define DA732X_HP_DET_EN (1 << 7) | ||
347 | |||
348 | /* DA732X_REG_HPL_DAC_OFFSET (addr=0x21/0x26) */ | ||
349 | #define DA732X_HP_DAC_OFFSET_TRIM_MASK (0x3F << 0) | ||
350 | #define DA732X_HP_DAC_OFFSET_DAC_SIGN (1 << 6) | ||
351 | |||
352 | /* DA732X_REG_HPL_DAC_OFF_CNTL (addr=0x22/0x27) */ | ||
353 | #define DA732X_HP_DAC_OFF_CNTL_CONT_MASK (7 << 0) | ||
354 | #define DA732X_HP_DAC_OFF_CNTL_COMPO (1 << 3) | ||
355 | #define DA732X_HP_DAC_OFF_CALIBRATION (1 << 0) | ||
356 | #define DA732X_HP_DAC_OFF_SCALE_STEPS (1 << 1) | ||
357 | #define DA732X_HP_DAC_OFF_MASK 0x7F | ||
358 | #define DA732X_HP_DAC_COMPO_SHIFT 3 | ||
359 | |||
360 | /* DA732X_REG_HPL_OUT_OFFSET (addr=0x23/0x28) */ | ||
361 | #define DA732X_HP_OUT_OFFSET_MASK (0xFF << 0) | ||
362 | #define DA732X_HP_DAC_OFFSET_TRIM_VAL 0x7F | ||
363 | |||
364 | /* DA732X_REG_HPL/R (addr=0x24/0x29) */ | ||
365 | #define DA732X_HP_OUT_SIGN (1 << 0) | ||
366 | #define DA732X_HP_OUT_COMP (1 << 1) | ||
367 | #define DA732X_HP_OUT_RESERVED (1 << 2) | ||
368 | #define DA732X_HP_OUT_COMPO (1 << 3) | ||
369 | #define DA732X_HP_OUT_DAC_EN (1 << 4) | ||
370 | #define DA732X_HP_OUT_HIZ_EN (1 << 5) | ||
371 | #define DA732X_HP_OUT_HIZ_DIS (0 << 5) | ||
372 | #define DA732X_HP_OUT_MUTE (1 << 6) | ||
373 | #define DA732X_HP_OUT_EN (1 << 7) | ||
374 | #define DA732X_HP_OUT_COMPO_SHIFT 3 | ||
375 | #define DA732X_HP_OUT_DAC_EN_SHIFT 4 | ||
376 | #define DA732X_HP_HIZ_SHIFT 5 | ||
377 | #define DA732X_HP_MUTE_SHIFT 6 | ||
378 | #define DA732X_HP_OUT_EN_SHIFT 7 | ||
379 | |||
380 | #define DA732X_OUT_HIZ_EN (1 << 5) | ||
381 | #define DA732X_OUT_HIZ_DIS (0 << 5) | ||
382 | |||
383 | /* DA732X_REG_HPL/R_VOL (addr=0x25/0x2A) */ | ||
384 | #define DA732X_HP_VOL_VAL_MASK 0xF | ||
385 | #define DA732X_HP_VOL_SHIFT 0 | ||
386 | #define DA732X_HP_VOL_VAL_MAX DA732X_HP_VOL_VAL_MASK | ||
387 | |||
388 | /* DA732X_REG_LIN2/3/4 (addr=0x2B/0x2C/0x2D) */ | ||
389 | #define DA732X_LOUT_VOL_SHIFT 0 | ||
390 | #define DA732X_LOUT_VOL_MASK 0x0F | ||
391 | #define DA732X_LOUT_DAC_OFF (0 << 4) | ||
392 | #define DA732X_LOUT_DAC_EN (1 << 4) | ||
393 | #define DA732X_LOUT_HIZ_N_DIS (0 << 5) | ||
394 | #define DA732X_LOUT_HIZ_N_EN (1 << 5) | ||
395 | #define DA732X_LOUT_UNMUTED (0 << 6) | ||
396 | #define DA732X_LOUT_MUTED (1 << 6) | ||
397 | #define DA732X_LOUT_EN (0 << 7) | ||
398 | #define DA732X_LOUT_DIS (1 << 7) | ||
399 | #define DA732X_LOUT_DAC_EN_SHIFT 4 | ||
400 | #define DA732X_LOUT_MUTE_SHIFT 6 | ||
401 | #define DA732X_LIN_OUT_EN_SHIFT 7 | ||
402 | #define DA732X_LOUT_VOL_VAL_MAX DA732X_LOUT_VOL_MASK | ||
403 | |||
404 | /* DA732X_REG_OUT_ZC_EN (addr=0x2E) */ | ||
405 | #define DA732X_HPL_ZC_EN_SHIFT 0 | ||
406 | #define DA732X_HPR_ZC_EN_SHIFT 1 | ||
407 | #define DA732X_HPL_ZC_EN (1 << 0) | ||
408 | #define DA732X_HPL_ZC_DIS (0 << 0) | ||
409 | #define DA732X_HPR_ZC_EN (1 << 1) | ||
410 | #define DA732X_HPR_ZC_DIS (0 << 1) | ||
411 | #define DA732X_LIN2_ZC_EN (1 << 2) | ||
412 | #define DA732X_LIN2_ZC_DIS (0 << 2) | ||
413 | #define DA732X_LIN3_ZC_EN (1 << 3) | ||
414 | #define DA732X_LIN3_ZC_DIS (0 << 3) | ||
415 | #define DA732X_LIN4_ZC_EN (1 << 4) | ||
416 | #define DA732X_LIN4_ZC_DIS (0 << 4) | ||
417 | |||
418 | /* DA732X_REG_HP_LIN1_GNDSEL (addr=0x37) */ | ||
419 | #define DA732X_HP_OUT_GNDSEL (1 << 0) | ||
420 | |||
421 | /* DA732X_REG_CP_HP2 (addr=0x3a) */ | ||
422 | #define DA732X_HP_CP_PULSESKIP (1 << 0) | ||
423 | #define DA732X_HP_CP_REG (1 << 1) | ||
424 | #define DA732X_HP_CP_EN (1 << 3) | ||
425 | #define DA732X_HP_CP_DIS (0 << 3) | ||
426 | |||
427 | /* DA732X_REG_CP_CTRL1 (addr=0x40) */ | ||
428 | #define DA732X_CP_MODE_MASK (7 << 1) | ||
429 | #define DA732X_CP_CTRL_STANDBY (0 << 1) | ||
430 | #define DA732X_CP_CTRL_CPVDD6 (2 << 1) | ||
431 | #define DA732X_CP_CTRL_CPVDD5 (3 << 1) | ||
432 | #define DA732X_CP_CTRL_CPVDD4 (4 << 1) | ||
433 | #define DA732X_CP_CTRL_CPVDD3 (5 << 1) | ||
434 | #define DA732X_CP_CTRL_CPVDD2 (6 << 1) | ||
435 | #define DA732X_CP_CTRL_CPVDD1 (7 << 1) | ||
436 | #define DA723X_CP_DIS (0 << 7) | ||
437 | #define DA732X_CP_EN (1 << 7) | ||
438 | |||
439 | /* DA732X_REG_CP_CTRL2 (addr=0x41) */ | ||
440 | #define DA732X_CP_BOOST (1 << 0) | ||
441 | #define DA732X_CP_MANAGE_MAGNITUDE (2 << 2) | ||
442 | |||
443 | /* DA732X_REG_CP_CTRL3 (addr=0x42) */ | ||
444 | #define DA732X_CP_1MHZ (0 << 0) | ||
445 | #define DA732X_CP_500KHZ (1 << 0) | ||
446 | #define DA732X_CP_250KHZ (2 << 0) | ||
447 | #define DA732X_CP_125KHZ (3 << 0) | ||
448 | #define DA732X_CP_63KHZ (4 << 0) | ||
449 | #define DA732X_CP_0KHZ (5 << 0) | ||
450 | |||
451 | /* DA732X_REG_PLL_CTRL (addr=0x53) */ | ||
452 | #define DA732X_PLL_INDIV_MASK (3 << 0) | ||
453 | #define DA732X_PLL_SRM_EN (1 << 2) | ||
454 | #define DA732X_PLL_EN (1 << 7) | ||
455 | #define DA732X_PLL_BYPASS (0 << 0) | ||
456 | |||
457 | /* DA732X_REG_CLK_CTRL (addr=0x54) */ | ||
458 | #define DA732X_SR1_MASK (0xF) | ||
459 | #define DA732X_SR2_MASK (0xF0) | ||
460 | |||
461 | /* DA732X_REG_CLK_DSP (addr=0x5A) */ | ||
462 | #define DA732X_DSP_FREQ_MASK (7 << 0) | ||
463 | #define DA732X_DSP_FREQ_12MHZ (0 << 0) | ||
464 | #define DA732X_DSP_FREQ_24MHZ (1 << 0) | ||
465 | #define DA732X_DSP_FREQ_36MHZ (2 << 0) | ||
466 | #define DA732X_DSP_FREQ_48MHZ (3 << 0) | ||
467 | #define DA732X_DSP_FREQ_60MHZ (4 << 0) | ||
468 | #define DA732X_DSP_FREQ_72MHZ (5 << 0) | ||
469 | #define DA732X_DSP_FREQ_84MHZ (6 << 0) | ||
470 | #define DA732X_DSP_FREQ_96MHZ (7 << 0) | ||
471 | |||
472 | /* DA732X_REG_CLK_EN1 (addr=0x5B) */ | ||
473 | #define DA732X_DSP_CLK_EN (1 << 0) | ||
474 | #define DA732X_SYS3_CLK_EN (1 << 1) | ||
475 | #define DA732X_DSP12_CLK_EN (1 << 2) | ||
476 | #define DA732X_PC_CLK_EN (1 << 3) | ||
477 | #define DA732X_MCLK_SQR_EN (1 << 7) | ||
478 | |||
479 | /* DA732X_REG_CLK_EN2 (addr=0x5C) */ | ||
480 | #define DA732X_UART_CLK_EN (1 << 1) | ||
481 | #define DA732X_CP_CLK_EN (1 << 2) | ||
482 | #define DA732X_CP_CLK_DIS (0 << 2) | ||
483 | |||
484 | /* DA732X_REG_CLK_EN3 (addr=0x5D) */ | ||
485 | #define DA732X_ADCA_BB_CLK_EN (1 << 0) | ||
486 | #define DA732X_ADCC_BB_CLK_EN (1 << 4) | ||
487 | |||
488 | /* DA732X_REG_CLK_EN4 (addr=0x5E) */ | ||
489 | #define DA732X_DACA_BB_CLK_EN (1 << 0) | ||
490 | #define DA732X_DACC_BB_CLK_EN (1 << 4) | ||
491 | #define DA732X_DACA_BB_CLK_SHIFT 0 | ||
492 | #define DA732X_DACC_BB_CLK_SHIFT 4 | ||
493 | |||
494 | /* DA732X_REG_CLK_EN5 (addr=0x5F) */ | ||
495 | #define DA732X_DACE_BB_CLK_EN (1 << 0) | ||
496 | #define DA732X_DACE_BB_CLK_SHIFT 0 | ||
497 | |||
498 | /* DA732X_REG_AIF_MCLK (addr=0x60) */ | ||
499 | #define DA732X_AIFM_FRAME_64 (1 << 2) | ||
500 | #define DA732X_AIFM_SRC_SEL_AIFA (1 << 6) | ||
501 | #define DA732X_CLK_GENERATION_AIF_A (1 << 4) | ||
502 | #define DA732X_NO_CLK_GENERATION 0x0 | ||
503 | |||
504 | /* DA732X_REG_AIFA1 (addr=0x61) */ | ||
505 | #define DA732X_AIF_WORD_MASK (0x3 << 0) | ||
506 | #define DA732X_AIF_WORD_16 (0 << 0) | ||
507 | #define DA732X_AIF_WORD_20 (1 << 0) | ||
508 | #define DA732X_AIF_WORD_24 (2 << 0) | ||
509 | #define DA732X_AIF_WORD_32 (3 << 0) | ||
510 | #define DA732X_AIF_TDM_MONO_SHIFT (1 << 6) | ||
511 | #define DA732X_AIF1_CLK_MASK (1 << 7) | ||
512 | #define DA732X_AIF_SLAVE (0 << 7) | ||
513 | #define DA732X_AIF_CLK_FROM_SRC (1 << 7) | ||
514 | |||
515 | /* DA732X_REG_AIFA3 (addr=0x63) */ | ||
516 | #define DA732X_AIF_MODE_SHIFT 0 | ||
517 | #define DA732X_AIF_MODE_MASK 0x3 | ||
518 | #define DA732X_AIF_I2S_MODE (0 << 0) | ||
519 | #define DA732X_AIF_LEFT_J_MODE (1 << 0) | ||
520 | #define DA732X_AIF_RIGHT_J_MODE (2 << 0) | ||
521 | #define DA732X_AIF_DSP_MODE (3 << 0) | ||
522 | #define DA732X_AIF_WCLK_INV (1 << 4) | ||
523 | #define DA732X_AIF_BCLK_INV (1 << 5) | ||
524 | #define DA732X_AIF_EN (1 << 7) | ||
525 | #define DA732X_AIF_EN_SHIFT 7 | ||
526 | |||
527 | /* DA732X_REG_PC_CTRL (addr=0x6a) */ | ||
528 | #define DA732X_PC_PULSE_AIFA (0 << 0) | ||
529 | #define DA732X_PC_PULSE_AIFB (1 << 0) | ||
530 | #define DA732X_PC_RESYNC_AUT (1 << 6) | ||
531 | #define DA732X_PC_RESYNC_NOT_AUT (0 << 6) | ||
532 | #define DA732X_PC_SAME (1 << 7) | ||
533 | |||
534 | /* DA732X_REG_DATA_ROUTE (addr=0x70) */ | ||
535 | #define DA732X_ADC1_TO_AIFA (0 << 0) | ||
536 | #define DA732X_DSP_TO_AIFA (1 << 0) | ||
537 | #define DA732X_ADC2_TO_AIFB (0 << 1) | ||
538 | #define DA732X_DSP_TO_AIFB (1 << 1) | ||
539 | #define DA732X_AIFA_TO_DAC1L (0 << 2) | ||
540 | #define DA732X_DSP_TO_DAC1L (1 << 2) | ||
541 | #define DA732X_AIFA_TO_DAC1R (0 << 3) | ||
542 | #define DA732X_DSP_TO_DAC1R (1 << 3) | ||
543 | #define DA732X_AIFB_TO_DAC2L (0 << 4) | ||
544 | #define DA732X_DSP_TO_DAC2L (1 << 4) | ||
545 | #define DA732X_AIFB_TO_DAC2R (0 << 5) | ||
546 | #define DA732X_DSP_TO_DAC2R (1 << 5) | ||
547 | #define DA732X_AIFB_TO_DAC3 (0 << 6) | ||
548 | #define DA732X_DSP_TO_DAC3 (1 << 6) | ||
549 | #define DA732X_BYPASS_DSP (0 << 0) | ||
550 | #define DA732X_ALL_TO_DSP (0x7F << 0) | ||
551 | |||
552 | /* DA732X_REG_DSP_CTRL (addr=0x71) */ | ||
553 | #define DA732X_DIGITAL_EN (1 << 0) | ||
554 | #define DA732X_DIGITAL_RESET (0 << 0) | ||
555 | #define DA732X_DSP_CORE_EN (1 << 1) | ||
556 | #define DA732X_DSP_CORE_RESET (0 << 1) | ||
557 | |||
558 | /* DA732X_REG_SPARE1_OUT (addr=0x7D)*/ | ||
559 | #define DA732X_HP_DRIVER_EN (1 << 0) | ||
560 | #define DA732X_HP_GATE_LOW (1 << 2) | ||
561 | #define DA732X_HP_LOOP_GAIN_CTRL (1 << 3) | ||
562 | |||
563 | /* DA732X_REG_ID (addr=0x81)*/ | ||
564 | #define DA732X_ID_MINOR_MASK (0xF << 0) | ||
565 | #define DA732X_ID_MAJOR_MASK (0xF << 4) | ||
566 | |||
567 | /* DA732X_REG_ADC1/2_PD (addr=0x90/0x98) */ | ||
568 | #define DA732X_ADC_RST_MASK (0x3 << 0) | ||
569 | #define DA732X_ADC_PD_MASK (0x3 << 2) | ||
570 | #define DA732X_ADC_SET_ACT (0x3 << 0) | ||
571 | #define DA732X_ADC_SET_RST (0x0 << 0) | ||
572 | #define DA732X_ADC_ON (0x3 << 2) | ||
573 | #define DA732X_ADC_OFF (0x0 << 2) | ||
574 | |||
575 | /* DA732X_REG_ADC1/2_SEL (addr=0x94/0x9C) */ | ||
576 | #define DA732X_ADC_VOL_VAL_MASK 0x7 | ||
577 | #define DA732X_ADCL_VOL_SHIFT 0 | ||
578 | #define DA732X_ADCR_VOL_SHIFT 4 | ||
579 | #define DA732X_ADCL_EN_SHIFT 2 | ||
580 | #define DA732X_ADCR_EN_SHIFT 3 | ||
581 | #define DA732X_ADCL_EN (1 << 2) | ||
582 | #define DA732X_ADCR_EN (1 << 3) | ||
583 | #define DA732X_ADC_VOL_VAL_MAX DA732X_ADC_VOL_VAL_MASK | ||
584 | |||
585 | /* | ||
586 | * DA732X_REG_ADC1/2_HPF (addr=0x93/0x9b) | ||
587 | * DA732x_REG_DAC1/2/3_HPG (addr=0xA5/0xB5/0xC5) | ||
588 | */ | ||
589 | #define DA732X_HPF_MUSIC_EN (1 << 3) | ||
590 | #define DA732X_HPF_VOICE_EN ((1 << 3) | (1 << 7)) | ||
591 | #define DA732X_HPF_MASK ((1 << 3) | (1 << 7)) | ||
592 | #define DA732X_HPF_DIS ((0 << 3) | (0 << 7)) | ||
593 | |||
594 | /* DA732X_REG_DAC1/2/3_VOL */ | ||
595 | #define DA732X_DAC_VOL_VAL_MASK 0x7F | ||
596 | #define DA732X_DAC_VOL_SHIFT 0 | ||
597 | #define DA732X_DAC_VOL_VAL_MAX DA732X_DAC_VOL_VAL_MASK | ||
598 | |||
599 | /* DA732X_REG_DAC1/2/3_SEL (addr=0xA3/0xB3/0xC3) */ | ||
600 | #define DA732X_DACL_EN_SHIFT 3 | ||
601 | #define DA732X_DACR_EN_SHIFT 7 | ||
602 | #define DA732X_DACL_MUTE_SHIFT 2 | ||
603 | #define DA732X_DACR_MUTE_SHIFT 6 | ||
604 | #define DA732X_DACL_EN (1 << 3) | ||
605 | #define DA732X_DACR_EN (1 << 7) | ||
606 | #define DA732X_DACL_SDM (1 << 0) | ||
607 | #define DA732X_DACR_SDM (1 << 4) | ||
608 | #define DA732X_DACL_MUTE (1 << 2) | ||
609 | #define DA732X_DACR_MUTE (1 << 6) | ||
610 | |||
611 | /* DA732X_REG_DAC_SOFTMUTE (addr=0xA4/0xB4/0xC4) */ | ||
612 | #define DA732X_SOFTMUTE_EN (1 << 7) | ||
613 | #define DA732X_GAIN_RAMPED (1 << 6) | ||
614 | #define DA732X_16_SAMPLES (4 << 0) | ||
615 | #define DA732X_SOFTMUTE_MASK (1 << 7) | ||
616 | #define DA732X_SOFTMUTE_SHIFT 7 | ||
617 | |||
618 | /* | ||
619 | * DA732x_REG_ADC1/2_EQ12 (addr=0x95/0x9D) | ||
620 | * DA732x_REG_ADC1/2_EQ34 (addr=0x96/0x9E) | ||
621 | * DA732x_REG_ADC1/2_EQ5 (addr=0x97/0x9F) | ||
622 | * DA732x_REG_DAC1/2/3_EQ12 (addr=0xA5/0xB5/0xC5) | ||
623 | * DA732x_REG_DAC1/2/3_EQ34 (addr=0xA6/0xB6/0xC6) | ||
624 | * DA732x_REG_DAC1/2/3_EQ5 (addr=0xA7/0xB7/0xB7) | ||
625 | */ | ||
626 | #define DA732X_EQ_VOL_VAL_MASK 0xF | ||
627 | #define DA732X_EQ_BAND1_SHIFT 0 | ||
628 | #define DA732X_EQ_BAND2_SHIFT 4 | ||
629 | #define DA732X_EQ_BAND3_SHIFT 0 | ||
630 | #define DA732X_EQ_BAND4_SHIFT 4 | ||
631 | #define DA732X_EQ_BAND5_SHIFT 0 | ||
632 | #define DA732X_EQ_OVERALL_SHIFT 4 | ||
633 | #define DA732X_EQ_OVERALL_VOL_VAL_MASK 0x3 | ||
634 | #define DA732X_EQ_DIS (0 << 7) | ||
635 | #define DA732X_EQ_EN (1 << 7) | ||
636 | #define DA732X_EQ_EN_SHIFT 7 | ||
637 | #define DA732X_EQ_VOL_VAL_MAX DA732X_EQ_VOL_VAL_MASK | ||
638 | #define DA732X_EQ_OVERALL_VOL_VAL_MAX DA732X_EQ_OVERALL_VOL_VAL_MASK | ||
639 | |||
640 | /* DA732X_REG_DMA_CMD (addr=0xD3) */ | ||
641 | #define DA732X_SEL_DSP_DMA_MASK (3 << 0) | ||
642 | #define DA732X_SEL_DSP_DMA_DIS (0 << 0) | ||
643 | #define DA732X_SEL_DSP_DMA_PMEM (1 << 0) | ||
644 | #define DA732X_SEL_DSP_DMA_XMEM (2 << 0) | ||
645 | #define DA732X_SEL_DSP_DMA_YMEM (3 << 0) | ||
646 | #define DA732X_DSP_RW_MASK (1 << 4) | ||
647 | #define DA732X_DSP_DMA_WRITE (0 << 4) | ||
648 | #define DA732X_DSP_DMA_READ (1 << 4) | ||
649 | |||
650 | /* DA732X_REG_DMA_STATUS (addr=0xDA) */ | ||
651 | #define DA732X_DSP_DMA_FREE (0 << 0) | ||
652 | #define DA732X_DSP_DMA_BUSY (1 << 0) | ||
653 | |||
654 | #endif /* __DA732X_REG_H_ */ | ||