1
2
3
4
5
6
7
8
9
10
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/pm_runtime.h>
19#include <linux/regmap.h>
20#include <linux/slab.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/soc.h>
25#include <sound/jack.h>
26#include <sound/initval.h>
27#include <sound/tlv.h>
28
29#include <linux/mfd/arizona/core.h>
30#include <linux/mfd/arizona/registers.h>
31
32#include "arizona.h"
33#include "wm_adsp.h"
34#include "cs47l24.h"
35
36#define DRV_NAME "cs47l24-codec"
37
38struct cs47l24_priv {
39 struct arizona_priv core;
40 struct arizona_fll fll[2];
41};
42
43static const struct wm_adsp_region cs47l24_dsp2_regions[] = {
44 { .type = WMFW_ADSP2_PM, .base = 0x200000 },
45 { .type = WMFW_ADSP2_ZM, .base = 0x280000 },
46 { .type = WMFW_ADSP2_XM, .base = 0x290000 },
47 { .type = WMFW_ADSP2_YM, .base = 0x2a8000 },
48};
49
50static const struct wm_adsp_region cs47l24_dsp3_regions[] = {
51 { .type = WMFW_ADSP2_PM, .base = 0x300000 },
52 { .type = WMFW_ADSP2_ZM, .base = 0x380000 },
53 { .type = WMFW_ADSP2_XM, .base = 0x390000 },
54 { .type = WMFW_ADSP2_YM, .base = 0x3a8000 },
55};
56
57static const struct wm_adsp_region *cs47l24_dsp_regions[] = {
58 cs47l24_dsp2_regions,
59 cs47l24_dsp3_regions,
60};
61
62static int cs47l24_adsp_power_ev(struct snd_soc_dapm_widget *w,
63 struct snd_kcontrol *kcontrol, int event)
64{
65 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
66 struct arizona *arizona = dev_get_drvdata(component->dev->parent);
67 unsigned int v;
68 int ret;
69
70 ret = regmap_read(arizona->regmap, ARIZONA_SYSTEM_CLOCK_1, &v);
71 if (ret != 0) {
72 dev_err(component->dev, "Failed to read SYSCLK state: %d\n", ret);
73 return ret;
74 }
75
76 v = (v & ARIZONA_SYSCLK_FREQ_MASK) >> ARIZONA_SYSCLK_FREQ_SHIFT;
77
78 return wm_adsp2_early_event(w, kcontrol, event, v);
79}
80
81static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
82static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
83static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
84static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
85
86#define CS47L24_NG_SRC(name, base) \
87 SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \
88 SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \
89 SOC_SINGLE(name " NG SPKOUT Switch", base, 6, 1, 0)
90
91static const struct snd_kcontrol_new cs47l24_snd_controls[] = {
92SOC_ENUM("IN1 OSR", arizona_in_dmic_osr[0]),
93SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]),
94
95SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum),
96
97SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL,
98 ARIZONA_IN1L_HPF_SHIFT, 1, 0),
99SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL,
100 ARIZONA_IN1R_HPF_SHIFT, 1, 0),
101SOC_SINGLE("IN2L HPF Switch", ARIZONA_IN2L_CONTROL,
102 ARIZONA_IN2L_HPF_SHIFT, 1, 0),
103SOC_SINGLE("IN2R HPF Switch", ARIZONA_IN2R_CONTROL,
104 ARIZONA_IN2R_HPF_SHIFT, 1, 0),
105
106SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
107 ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
108SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R,
109 ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
110SOC_SINGLE_TLV("IN2L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
111 ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
112SOC_SINGLE_TLV("IN2R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2R,
113 ARIZONA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
114
115SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
116SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
117
118ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
119ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
120
121ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
122SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
123 24, 0, eq_tlv),
124SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
125 24, 0, eq_tlv),
126SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
127 24, 0, eq_tlv),
128SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
129 24, 0, eq_tlv),
130SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
131 24, 0, eq_tlv),
132
133ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
134SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
135 24, 0, eq_tlv),
136SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
137 24, 0, eq_tlv),
138SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
139 24, 0, eq_tlv),
140SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
141 24, 0, eq_tlv),
142SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
143 24, 0, eq_tlv),
144
145ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
146ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
147ARIZONA_MIXER_CONTROLS("DRC2L", ARIZONA_DRC2LMIX_INPUT_1_SOURCE),
148ARIZONA_MIXER_CONTROLS("DRC2R", ARIZONA_DRC2RMIX_INPUT_1_SOURCE),
149
150SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
151 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
152SND_SOC_BYTES_MASK("DRC2", ARIZONA_DRC2_CTRL1, 5,
153 ARIZONA_DRC2R_ENA | ARIZONA_DRC2L_ENA),
154
155ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
156ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
157ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
158ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
159
160ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
161ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
162ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
163ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
164
165SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
166SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
167SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
168SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
169
170SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
171SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
172SOC_ENUM("ISRC3 FSL", arizona_isrc_fsl[2]),
173SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]),
174SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]),
175SOC_ENUM("ISRC3 FSH", arizona_isrc_fsh[2]),
176SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1),
177
178WM_ADSP2_PRELOAD_SWITCH("DSP2", 2),
179WM_ADSP2_PRELOAD_SWITCH("DSP3", 3),
180
181ARIZONA_MIXER_CONTROLS("DSP2L", ARIZONA_DSP2LMIX_INPUT_1_SOURCE),
182ARIZONA_MIXER_CONTROLS("DSP2R", ARIZONA_DSP2RMIX_INPUT_1_SOURCE),
183ARIZONA_MIXER_CONTROLS("DSP3L", ARIZONA_DSP3LMIX_INPUT_1_SOURCE),
184ARIZONA_MIXER_CONTROLS("DSP3R", ARIZONA_DSP3RMIX_INPUT_1_SOURCE),
185
186SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
187 ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
188
189ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
190ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
191ARIZONA_MIXER_CONTROLS("SPKOUT", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
192
193SOC_SINGLE("HPOUT1 SC Protect Switch", ARIZONA_HP1_SHORT_CIRCUIT_CTRL,
194 ARIZONA_HP1_SC_ENA_SHIFT, 1, 0),
195
196SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
197 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
198SOC_SINGLE("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
199 ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
200
201SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
202 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
203 0xbf, 0, digital_tlv),
204SOC_SINGLE_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
205 ARIZONA_OUT4L_VOL_SHIFT, 0xbf, 0, digital_tlv),
206
207SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
208SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
209
210SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL,
211 ARIZONA_NGATE_ENA_SHIFT, 1, 0),
212SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL,
213 ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),
214SOC_ENUM("Noise Gate Hold", arizona_ng_hold),
215
216CS47L24_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L),
217CS47L24_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R),
218CS47L24_NG_SRC("SPKOUT", ARIZONA_NOISE_GATE_SELECT_4L),
219
220ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
221ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
222ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
223ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
224ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
225ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
226ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
227ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
228
229ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
230ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
231ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE),
232ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE),
233ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE),
234ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE),
235
236ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
237ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
238
239WM_ADSP_FW_CONTROL("DSP2", 1),
240WM_ADSP_FW_CONTROL("DSP3", 2),
241};
242
243ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
244ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
245
246ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
247ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
248ARIZONA_MIXER_ENUMS(DRC2L, ARIZONA_DRC2LMIX_INPUT_1_SOURCE);
249ARIZONA_MIXER_ENUMS(DRC2R, ARIZONA_DRC2RMIX_INPUT_1_SOURCE);
250
251ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
252ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
253ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
254ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
255
256ARIZONA_MIXER_ENUMS(DSP2L, ARIZONA_DSP2LMIX_INPUT_1_SOURCE);
257ARIZONA_MIXER_ENUMS(DSP2R, ARIZONA_DSP2RMIX_INPUT_1_SOURCE);
258ARIZONA_DSP_AUX_ENUMS(DSP2, ARIZONA_DSP2AUX1MIX_INPUT_1_SOURCE);
259
260ARIZONA_MIXER_ENUMS(DSP3L, ARIZONA_DSP3LMIX_INPUT_1_SOURCE);
261ARIZONA_MIXER_ENUMS(DSP3R, ARIZONA_DSP3RMIX_INPUT_1_SOURCE);
262ARIZONA_DSP_AUX_ENUMS(DSP3, ARIZONA_DSP3AUX1MIX_INPUT_1_SOURCE);
263
264ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
265ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
266
267ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
268ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
269ARIZONA_MIXER_ENUMS(SPKOUT, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
270
271ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
272ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
273ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
276ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
277ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
278ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
279
280ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
281ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
282ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE);
283ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE);
284ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE);
285ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE);
286
287ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
288ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
289
290ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
291ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
292ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
293ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
294
295ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE);
296ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE);
297ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE);
298ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE);
299
300ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE);
301ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE);
302ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE);
303ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE);
304
305ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE);
306ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE);
307ARIZONA_MUX_ENUMS(ISRC2INT3, ARIZONA_ISRC2INT3MIX_INPUT_1_SOURCE);
308ARIZONA_MUX_ENUMS(ISRC2INT4, ARIZONA_ISRC2INT4MIX_INPUT_1_SOURCE);
309
310ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE);
311ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE);
312ARIZONA_MUX_ENUMS(ISRC2DEC3, ARIZONA_ISRC2DEC3MIX_INPUT_1_SOURCE);
313ARIZONA_MUX_ENUMS(ISRC2DEC4, ARIZONA_ISRC2DEC4MIX_INPUT_1_SOURCE);
314
315ARIZONA_MUX_ENUMS(ISRC3INT1, ARIZONA_ISRC3INT1MIX_INPUT_1_SOURCE);
316ARIZONA_MUX_ENUMS(ISRC3INT2, ARIZONA_ISRC3INT2MIX_INPUT_1_SOURCE);
317ARIZONA_MUX_ENUMS(ISRC3INT3, ARIZONA_ISRC3INT3MIX_INPUT_1_SOURCE);
318ARIZONA_MUX_ENUMS(ISRC3INT4, ARIZONA_ISRC3INT4MIX_INPUT_1_SOURCE);
319
320ARIZONA_MUX_ENUMS(ISRC3DEC1, ARIZONA_ISRC3DEC1MIX_INPUT_1_SOURCE);
321ARIZONA_MUX_ENUMS(ISRC3DEC2, ARIZONA_ISRC3DEC2MIX_INPUT_1_SOURCE);
322ARIZONA_MUX_ENUMS(ISRC3DEC3, ARIZONA_ISRC3DEC3MIX_INPUT_1_SOURCE);
323ARIZONA_MUX_ENUMS(ISRC3DEC4, ARIZONA_ISRC3DEC4MIX_INPUT_1_SOURCE);
324
325static const char * const cs47l24_aec_loopback_texts[] = {
326 "HPOUT1L", "HPOUT1R", "SPKOUT",
327};
328
329static const unsigned int cs47l24_aec_loopback_values[] = {
330 0, 1, 6,
331};
332
333static const struct soc_enum cs47l24_aec_loopback =
334 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
335 ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
336 ARRAY_SIZE(cs47l24_aec_loopback_texts),
337 cs47l24_aec_loopback_texts,
338 cs47l24_aec_loopback_values);
339
340static const struct snd_kcontrol_new cs47l24_aec_loopback_mux =
341 SOC_DAPM_ENUM("AEC Loopback", cs47l24_aec_loopback);
342
343static const struct snd_soc_dapm_widget cs47l24_dapm_widgets[] = {
344SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1,
345 ARIZONA_SYSCLK_ENA_SHIFT, 0, arizona_clk_ev,
346 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
347SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
348 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, arizona_clk_ev,
349 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
350SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
351 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
352SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
353 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
354
355SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
356SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
357SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
358
359SND_SOC_DAPM_SIGGEN("TONE"),
360SND_SOC_DAPM_SIGGEN("NOISE"),
361SND_SOC_DAPM_SIGGEN("HAPTICS"),
362
363SND_SOC_DAPM_INPUT("IN1L"),
364SND_SOC_DAPM_INPUT("IN1R"),
365SND_SOC_DAPM_INPUT("IN2L"),
366SND_SOC_DAPM_INPUT("IN2R"),
367
368SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
369SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"),
370
371SND_SOC_DAPM_OUTPUT("DSP Voice Trigger"),
372
373SND_SOC_DAPM_SWITCH("DSP3 Voice Trigger", SND_SOC_NOPM, 2, 0,
374 &arizona_voice_trigger_switch[2]),
375
376SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
377 0, NULL, 0, arizona_in_ev,
378 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
379 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
380SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
381 0, NULL, 0, arizona_in_ev,
382 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
383 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
384SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
385 0, NULL, 0, arizona_in_ev,
386 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
387 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
388SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
389 0, NULL, 0, arizona_in_ev,
390 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
391 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
392
393SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
394 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
395SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
396 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
397
398SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
399 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
400
401SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
402 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
403SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
404 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
405
406SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
407SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
408
409SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
410 NULL, 0),
411SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
412 NULL, 0),
413SND_SOC_DAPM_PGA("DRC2L", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2L_ENA_SHIFT, 0,
414 NULL, 0),
415SND_SOC_DAPM_PGA("DRC2R", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2R_ENA_SHIFT, 0,
416 NULL, 0),
417
418SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
419 NULL, 0),
420SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
421 NULL, 0),
422SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
423 NULL, 0),
424SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
425 NULL, 0),
426
427SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
428 0, NULL, 0),
429SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
430 0, NULL, 0),
431
432SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
433 NULL, 0),
434SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
435 NULL, 0),
436SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
437 NULL, 0),
438SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
439 NULL, 0),
440
441WM_ADSP2("DSP2", 1, cs47l24_adsp_power_ev),
442WM_ADSP2("DSP3", 2, cs47l24_adsp_power_ev),
443
444SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3,
445 ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0),
446SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3,
447 ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
448SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3,
449 ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0),
450SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3,
451 ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0),
452
453SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3,
454 ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0),
455SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3,
456 ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
457SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3,
458 ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0),
459SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3,
460 ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0),
461
462SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3,
463 ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0),
464SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3,
465 ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
466SND_SOC_DAPM_PGA("ISRC2INT3", ARIZONA_ISRC_2_CTRL_3,
467 ARIZONA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0),
468SND_SOC_DAPM_PGA("ISRC2INT4", ARIZONA_ISRC_2_CTRL_3,
469 ARIZONA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0),
470
471SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3,
472 ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0),
473SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3,
474 ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
475SND_SOC_DAPM_PGA("ISRC2DEC3", ARIZONA_ISRC_2_CTRL_3,
476 ARIZONA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0),
477SND_SOC_DAPM_PGA("ISRC2DEC4", ARIZONA_ISRC_2_CTRL_3,
478 ARIZONA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0),
479
480SND_SOC_DAPM_PGA("ISRC3INT1", ARIZONA_ISRC_3_CTRL_3,
481 ARIZONA_ISRC3_INT0_ENA_SHIFT, 0, NULL, 0),
482SND_SOC_DAPM_PGA("ISRC3INT2", ARIZONA_ISRC_3_CTRL_3,
483 ARIZONA_ISRC3_INT1_ENA_SHIFT, 0, NULL, 0),
484SND_SOC_DAPM_PGA("ISRC3INT3", ARIZONA_ISRC_3_CTRL_3,
485 ARIZONA_ISRC3_INT2_ENA_SHIFT, 0, NULL, 0),
486SND_SOC_DAPM_PGA("ISRC3INT4", ARIZONA_ISRC_3_CTRL_3,
487 ARIZONA_ISRC3_INT3_ENA_SHIFT, 0, NULL, 0),
488
489SND_SOC_DAPM_PGA("ISRC3DEC1", ARIZONA_ISRC_3_CTRL_3,
490 ARIZONA_ISRC3_DEC0_ENA_SHIFT, 0, NULL, 0),
491SND_SOC_DAPM_PGA("ISRC3DEC2", ARIZONA_ISRC_3_CTRL_3,
492 ARIZONA_ISRC3_DEC1_ENA_SHIFT, 0, NULL, 0),
493SND_SOC_DAPM_PGA("ISRC3DEC3", ARIZONA_ISRC_3_CTRL_3,
494 ARIZONA_ISRC3_DEC2_ENA_SHIFT, 0, NULL, 0),
495SND_SOC_DAPM_PGA("ISRC3DEC4", ARIZONA_ISRC_3_CTRL_3,
496 ARIZONA_ISRC3_DEC3_ENA_SHIFT, 0, NULL, 0),
497
498SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
499 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &cs47l24_aec_loopback_mux),
500
501SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
502 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
503SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
504 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
505SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
506 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
507SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
508 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
509SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
510 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
511SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
512 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
513SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
514 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
515SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
516 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
517
518SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
519 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
520SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
521 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
522SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
523 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
524SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
525 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
526SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
527 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
528SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
529 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
530SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
531 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
532SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
533 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
534
535SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
536 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
537SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
538 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
539SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0,
540 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0),
541SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0,
542 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0),
543SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 0,
544 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0),
545SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 0,
546 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0),
547
548SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
549 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
550SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
551 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
552SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0,
553 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0),
554SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0,
555 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0),
556SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 0,
557 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0),
558SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 0,
559 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0),
560
561SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
562 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
563SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
564 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
565
566SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
567 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
568SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
569 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
570
571SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
572 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
573 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
574 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
575SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
576 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
577 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
578 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
579
580ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
581ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
582
583ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
584ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
585ARIZONA_MIXER_WIDGETS(DRC2L, "DRC2L"),
586ARIZONA_MIXER_WIDGETS(DRC2R, "DRC2R"),
587
588ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
589ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
590ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
591ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
592
593ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
594ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
595
596ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
597ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
598ARIZONA_MIXER_WIDGETS(SPKOUT, "SPKOUT"),
599
600ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
601ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
602ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
603ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
604ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
605ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
606ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
607ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
608
609ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
610ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
611ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"),
612ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"),
613ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"),
614ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"),
615
616ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
617ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
618
619ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
620ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
621ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
622ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
623
624ARIZONA_DSP_WIDGETS(DSP2, "DSP2"),
625ARIZONA_DSP_WIDGETS(DSP3, "DSP3"),
626
627ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
628ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
629ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"),
630ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"),
631
632ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
633ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
634ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"),
635ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"),
636
637ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
638ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
639ARIZONA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"),
640ARIZONA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"),
641
642ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
643ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
644ARIZONA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"),
645ARIZONA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"),
646
647ARIZONA_MUX_WIDGETS(ISRC3DEC1, "ISRC3DEC1"),
648ARIZONA_MUX_WIDGETS(ISRC3DEC2, "ISRC3DEC2"),
649ARIZONA_MUX_WIDGETS(ISRC3DEC3, "ISRC3DEC3"),
650ARIZONA_MUX_WIDGETS(ISRC3DEC4, "ISRC3DEC4"),
651
652ARIZONA_MUX_WIDGETS(ISRC3INT1, "ISRC3INT1"),
653ARIZONA_MUX_WIDGETS(ISRC3INT2, "ISRC3INT2"),
654ARIZONA_MUX_WIDGETS(ISRC3INT3, "ISRC3INT3"),
655ARIZONA_MUX_WIDGETS(ISRC3INT4, "ISRC3INT4"),
656
657SND_SOC_DAPM_OUTPUT("HPOUT1L"),
658SND_SOC_DAPM_OUTPUT("HPOUT1R"),
659SND_SOC_DAPM_OUTPUT("SPKOUTN"),
660SND_SOC_DAPM_OUTPUT("SPKOUTP"),
661
662SND_SOC_DAPM_OUTPUT("MICSUPP"),
663};
664
665#define ARIZONA_MIXER_INPUT_ROUTES(name) \
666 { name, "Noise Generator", "Noise Generator" }, \
667 { name, "Tone Generator 1", "Tone Generator 1" }, \
668 { name, "Tone Generator 2", "Tone Generator 2" }, \
669 { name, "Haptics", "HAPTICS" }, \
670 { name, "AEC", "AEC Loopback" }, \
671 { name, "IN1L", "IN1L PGA" }, \
672 { name, "IN1R", "IN1R PGA" }, \
673 { name, "IN2L", "IN2L PGA" }, \
674 { name, "IN2R", "IN2R PGA" }, \
675 { name, "AIF1RX1", "AIF1RX1" }, \
676 { name, "AIF1RX2", "AIF1RX2" }, \
677 { name, "AIF1RX3", "AIF1RX3" }, \
678 { name, "AIF1RX4", "AIF1RX4" }, \
679 { name, "AIF1RX5", "AIF1RX5" }, \
680 { name, "AIF1RX6", "AIF1RX6" }, \
681 { name, "AIF1RX7", "AIF1RX7" }, \
682 { name, "AIF1RX8", "AIF1RX8" }, \
683 { name, "AIF2RX1", "AIF2RX1" }, \
684 { name, "AIF2RX2", "AIF2RX2" }, \
685 { name, "AIF2RX3", "AIF2RX3" }, \
686 { name, "AIF2RX4", "AIF2RX4" }, \
687 { name, "AIF2RX5", "AIF2RX5" }, \
688 { name, "AIF2RX6", "AIF2RX6" }, \
689 { name, "AIF3RX1", "AIF3RX1" }, \
690 { name, "AIF3RX2", "AIF3RX2" }, \
691 { name, "EQ1", "EQ1" }, \
692 { name, "EQ2", "EQ2" }, \
693 { name, "DRC1L", "DRC1L" }, \
694 { name, "DRC1R", "DRC1R" }, \
695 { name, "DRC2L", "DRC2L" }, \
696 { name, "DRC2R", "DRC2R" }, \
697 { name, "LHPF1", "LHPF1" }, \
698 { name, "LHPF2", "LHPF2" }, \
699 { name, "LHPF3", "LHPF3" }, \
700 { name, "LHPF4", "LHPF4" }, \
701 { name, "ASRC1L", "ASRC1L" }, \
702 { name, "ASRC1R", "ASRC1R" }, \
703 { name, "ASRC2L", "ASRC2L" }, \
704 { name, "ASRC2R", "ASRC2R" }, \
705 { name, "ISRC1DEC1", "ISRC1DEC1" }, \
706 { name, "ISRC1DEC2", "ISRC1DEC2" }, \
707 { name, "ISRC1DEC3", "ISRC1DEC3" }, \
708 { name, "ISRC1DEC4", "ISRC1DEC4" }, \
709 { name, "ISRC1INT1", "ISRC1INT1" }, \
710 { name, "ISRC1INT2", "ISRC1INT2" }, \
711 { name, "ISRC1INT3", "ISRC1INT3" }, \
712 { name, "ISRC1INT4", "ISRC1INT4" }, \
713 { name, "ISRC2DEC1", "ISRC2DEC1" }, \
714 { name, "ISRC2DEC2", "ISRC2DEC2" }, \
715 { name, "ISRC2DEC3", "ISRC2DEC3" }, \
716 { name, "ISRC2DEC4", "ISRC2DEC4" }, \
717 { name, "ISRC2INT1", "ISRC2INT1" }, \
718 { name, "ISRC2INT2", "ISRC2INT2" }, \
719 { name, "ISRC2INT3", "ISRC2INT3" }, \
720 { name, "ISRC2INT4", "ISRC2INT4" }, \
721 { name, "ISRC3DEC1", "ISRC3DEC1" }, \
722 { name, "ISRC3DEC2", "ISRC3DEC2" }, \
723 { name, "ISRC3DEC3", "ISRC3DEC3" }, \
724 { name, "ISRC3DEC4", "ISRC3DEC4" }, \
725 { name, "ISRC3INT1", "ISRC3INT1" }, \
726 { name, "ISRC3INT2", "ISRC3INT2" }, \
727 { name, "ISRC3INT3", "ISRC3INT3" }, \
728 { name, "ISRC3INT4", "ISRC3INT4" }, \
729 { name, "DSP2.1", "DSP2" }, \
730 { name, "DSP2.2", "DSP2" }, \
731 { name, "DSP2.3", "DSP2" }, \
732 { name, "DSP2.4", "DSP2" }, \
733 { name, "DSP2.5", "DSP2" }, \
734 { name, "DSP2.6", "DSP2" }, \
735 { name, "DSP3.1", "DSP3" }, \
736 { name, "DSP3.2", "DSP3" }, \
737 { name, "DSP3.3", "DSP3" }, \
738 { name, "DSP3.4", "DSP3" }, \
739 { name, "DSP3.5", "DSP3" }, \
740 { name, "DSP3.6", "DSP3" }
741
742static const struct snd_soc_dapm_route cs47l24_dapm_routes[] = {
743 { "OUT1L", NULL, "CPVDD" },
744 { "OUT1R", NULL, "CPVDD" },
745
746 { "OUT4L", NULL, "SPKVDD" },
747
748 { "OUT1L", NULL, "SYSCLK" },
749 { "OUT1R", NULL, "SYSCLK" },
750 { "OUT4L", NULL, "SYSCLK" },
751
752 { "IN1L", NULL, "SYSCLK" },
753 { "IN1R", NULL, "SYSCLK" },
754 { "IN2L", NULL, "SYSCLK" },
755 { "IN2R", NULL, "SYSCLK" },
756
757 { "ASRC1L", NULL, "SYSCLK" },
758 { "ASRC1R", NULL, "SYSCLK" },
759 { "ASRC2L", NULL, "SYSCLK" },
760 { "ASRC2R", NULL, "SYSCLK" },
761
762 { "ASRC1L", NULL, "ASYNCCLK" },
763 { "ASRC1R", NULL, "ASYNCCLK" },
764 { "ASRC2L", NULL, "ASYNCCLK" },
765 { "ASRC2R", NULL, "ASYNCCLK" },
766
767 { "MICBIAS1", NULL, "MICVDD" },
768 { "MICBIAS2", NULL, "MICVDD" },
769
770 { "Noise Generator", NULL, "SYSCLK" },
771 { "Tone Generator 1", NULL, "SYSCLK" },
772 { "Tone Generator 2", NULL, "SYSCLK" },
773
774 { "Noise Generator", NULL, "NOISE" },
775 { "Tone Generator 1", NULL, "TONE" },
776 { "Tone Generator 2", NULL, "TONE" },
777
778 { "AIF1 Capture", NULL, "AIF1TX1" },
779 { "AIF1 Capture", NULL, "AIF1TX2" },
780 { "AIF1 Capture", NULL, "AIF1TX3" },
781 { "AIF1 Capture", NULL, "AIF1TX4" },
782 { "AIF1 Capture", NULL, "AIF1TX5" },
783 { "AIF1 Capture", NULL, "AIF1TX6" },
784 { "AIF1 Capture", NULL, "AIF1TX7" },
785 { "AIF1 Capture", NULL, "AIF1TX8" },
786
787 { "AIF1RX1", NULL, "AIF1 Playback" },
788 { "AIF1RX2", NULL, "AIF1 Playback" },
789 { "AIF1RX3", NULL, "AIF1 Playback" },
790 { "AIF1RX4", NULL, "AIF1 Playback" },
791 { "AIF1RX5", NULL, "AIF1 Playback" },
792 { "AIF1RX6", NULL, "AIF1 Playback" },
793 { "AIF1RX7", NULL, "AIF1 Playback" },
794 { "AIF1RX8", NULL, "AIF1 Playback" },
795
796 { "AIF2 Capture", NULL, "AIF2TX1" },
797 { "AIF2 Capture", NULL, "AIF2TX2" },
798 { "AIF2 Capture", NULL, "AIF2TX3" },
799 { "AIF2 Capture", NULL, "AIF2TX4" },
800 { "AIF2 Capture", NULL, "AIF2TX5" },
801 { "AIF2 Capture", NULL, "AIF2TX6" },
802
803 { "AIF2RX1", NULL, "AIF2 Playback" },
804 { "AIF2RX2", NULL, "AIF2 Playback" },
805 { "AIF2RX3", NULL, "AIF2 Playback" },
806 { "AIF2RX4", NULL, "AIF2 Playback" },
807 { "AIF2RX5", NULL, "AIF2 Playback" },
808 { "AIF2RX6", NULL, "AIF2 Playback" },
809
810 { "AIF3 Capture", NULL, "AIF3TX1" },
811 { "AIF3 Capture", NULL, "AIF3TX2" },
812
813 { "AIF3RX1", NULL, "AIF3 Playback" },
814 { "AIF3RX2", NULL, "AIF3 Playback" },
815
816 { "AIF1 Playback", NULL, "SYSCLK" },
817 { "AIF2 Playback", NULL, "SYSCLK" },
818 { "AIF3 Playback", NULL, "SYSCLK" },
819
820 { "AIF1 Capture", NULL, "SYSCLK" },
821 { "AIF2 Capture", NULL, "SYSCLK" },
822 { "AIF3 Capture", NULL, "SYSCLK" },
823
824 { "Voice Control DSP", NULL, "DSP3" },
825
826 { "IN1L PGA", NULL, "IN1L" },
827 { "IN1R PGA", NULL, "IN1R" },
828
829 { "IN2L PGA", NULL, "IN2L" },
830 { "IN2R PGA", NULL, "IN2R" },
831
832 { "Audio Trace DSP", NULL, "DSP2" },
833
834 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
835 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
836
837 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUT"),
838
839 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
840 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
841
842 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
843 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
844 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
845 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
846 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
847 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
848 ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
849 ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
850
851 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
852 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
853 ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"),
854 ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"),
855 ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"),
856 ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"),
857
858 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
859 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
860
861 ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
862 ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
863
864 ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
865 ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
866 ARIZONA_MIXER_ROUTES("DRC2L", "DRC2L"),
867 ARIZONA_MIXER_ROUTES("DRC2R", "DRC2R"),
868
869 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
870 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
871 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
872 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
873
874 ARIZONA_MUX_ROUTES("ASRC1L", "ASRC1L"),
875 ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"),
876 ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"),
877 ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"),
878
879 ARIZONA_DSP_ROUTES("DSP2"),
880 ARIZONA_DSP_ROUTES("DSP3"),
881
882 ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
883 ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
884 ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"),
885 ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"),
886
887 ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
888 ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
889 ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"),
890 ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"),
891
892 ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
893 ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
894 ARIZONA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"),
895 ARIZONA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"),
896
897 ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
898 ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
899 ARIZONA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"),
900 ARIZONA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"),
901
902 ARIZONA_MUX_ROUTES("ISRC3INT1", "ISRC3INT1"),
903 ARIZONA_MUX_ROUTES("ISRC3INT2", "ISRC3INT2"),
904 ARIZONA_MUX_ROUTES("ISRC3INT3", "ISRC3INT3"),
905 ARIZONA_MUX_ROUTES("ISRC3INT4", "ISRC3INT4"),
906
907 ARIZONA_MUX_ROUTES("ISRC3DEC1", "ISRC3DEC1"),
908 ARIZONA_MUX_ROUTES("ISRC3DEC2", "ISRC3DEC2"),
909 ARIZONA_MUX_ROUTES("ISRC3DEC3", "ISRC3DEC3"),
910 ARIZONA_MUX_ROUTES("ISRC3DEC4", "ISRC3DEC4"),
911
912 { "AEC Loopback", "HPOUT1L", "OUT1L" },
913 { "AEC Loopback", "HPOUT1R", "OUT1R" },
914 { "HPOUT1L", NULL, "OUT1L" },
915 { "HPOUT1R", NULL, "OUT1R" },
916
917 { "AEC Loopback", "SPKOUT", "OUT4L" },
918 { "SPKOUTN", NULL, "OUT4L" },
919 { "SPKOUTP", NULL, "OUT4L" },
920
921 { "MICSUPP", NULL, "SYSCLK" },
922
923 { "DRC1 Signal Activity", NULL, "SYSCLK" },
924 { "DRC2 Signal Activity", NULL, "SYSCLK" },
925 { "DRC1 Signal Activity", NULL, "DRC1L" },
926 { "DRC1 Signal Activity", NULL, "DRC1R" },
927 { "DRC2 Signal Activity", NULL, "DRC2L" },
928 { "DRC2 Signal Activity", NULL, "DRC2R" },
929
930 { "DSP Voice Trigger", NULL, "SYSCLK" },
931 { "DSP Voice Trigger", NULL, "DSP3 Voice Trigger" },
932 { "DSP3 Voice Trigger", "Switch", "DSP3" },
933};
934
935static int cs47l24_set_fll(struct snd_soc_component *component, int fll_id,
936 int source, unsigned int Fref, unsigned int Fout)
937{
938 struct cs47l24_priv *cs47l24 = snd_soc_component_get_drvdata(component);
939
940 switch (fll_id) {
941 case CS47L24_FLL1:
942 return arizona_set_fll(&cs47l24->fll[0], source, Fref, Fout);
943 case CS47L24_FLL2:
944 return arizona_set_fll(&cs47l24->fll[1], source, Fref, Fout);
945 case CS47L24_FLL1_REFCLK:
946 return arizona_set_fll_refclk(&cs47l24->fll[0], source, Fref,
947 Fout);
948 case CS47L24_FLL2_REFCLK:
949 return arizona_set_fll_refclk(&cs47l24->fll[1], source, Fref,
950 Fout);
951 default:
952 return -EINVAL;
953 }
954}
955
956#define CS47L24_RATES SNDRV_PCM_RATE_KNOT
957
958#define CS47L24_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
959 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
960
961static struct snd_soc_dai_driver cs47l24_dai[] = {
962 {
963 .name = "cs47l24-aif1",
964 .id = 1,
965 .base = ARIZONA_AIF1_BCLK_CTRL,
966 .playback = {
967 .stream_name = "AIF1 Playback",
968 .channels_min = 1,
969 .channels_max = 8,
970 .rates = CS47L24_RATES,
971 .formats = CS47L24_FORMATS,
972 },
973 .capture = {
974 .stream_name = "AIF1 Capture",
975 .channels_min = 1,
976 .channels_max = 8,
977 .rates = CS47L24_RATES,
978 .formats = CS47L24_FORMATS,
979 },
980 .ops = &arizona_dai_ops,
981 .symmetric_rates = 1,
982 .symmetric_samplebits = 1,
983 },
984 {
985 .name = "cs47l24-aif2",
986 .id = 2,
987 .base = ARIZONA_AIF2_BCLK_CTRL,
988 .playback = {
989 .stream_name = "AIF2 Playback",
990 .channels_min = 1,
991 .channels_max = 6,
992 .rates = CS47L24_RATES,
993 .formats = CS47L24_FORMATS,
994 },
995 .capture = {
996 .stream_name = "AIF2 Capture",
997 .channels_min = 1,
998 .channels_max = 6,
999 .rates = CS47L24_RATES,
1000 .formats = CS47L24_FORMATS,
1001 },
1002 .ops = &arizona_dai_ops,
1003 .symmetric_rates = 1,
1004 .symmetric_samplebits = 1,
1005 },
1006 {
1007 .name = "cs47l24-aif3",
1008 .id = 3,
1009 .base = ARIZONA_AIF3_BCLK_CTRL,
1010 .playback = {
1011 .stream_name = "AIF3 Playback",
1012 .channels_min = 1,
1013 .channels_max = 2,
1014 .rates = CS47L24_RATES,
1015 .formats = CS47L24_FORMATS,
1016 },
1017 .capture = {
1018 .stream_name = "AIF3 Capture",
1019 .channels_min = 1,
1020 .channels_max = 2,
1021 .rates = CS47L24_RATES,
1022 .formats = CS47L24_FORMATS,
1023 },
1024 .ops = &arizona_dai_ops,
1025 .symmetric_rates = 1,
1026 .symmetric_samplebits = 1,
1027 },
1028 {
1029 .name = "cs47l24-cpu-voicectrl",
1030 .capture = {
1031 .stream_name = "Voice Control CPU",
1032 .channels_min = 1,
1033 .channels_max = 1,
1034 .rates = CS47L24_RATES,
1035 .formats = CS47L24_FORMATS,
1036 },
1037 .compress_new = snd_soc_new_compress,
1038 },
1039 {
1040 .name = "cs47l24-dsp-voicectrl",
1041 .capture = {
1042 .stream_name = "Voice Control DSP",
1043 .channels_min = 1,
1044 .channels_max = 1,
1045 .rates = CS47L24_RATES,
1046 .formats = CS47L24_FORMATS,
1047 },
1048 },
1049 {
1050 .name = "cs47l24-cpu-trace",
1051 .capture = {
1052 .stream_name = "Audio Trace CPU",
1053 .channels_min = 1,
1054 .channels_max = 6,
1055 .rates = CS47L24_RATES,
1056 .formats = CS47L24_FORMATS,
1057 },
1058 .compress_new = snd_soc_new_compress,
1059 },
1060 {
1061 .name = "cs47l24-dsp-trace",
1062 .capture = {
1063 .stream_name = "Audio Trace DSP",
1064 .channels_min = 1,
1065 .channels_max = 6,
1066 .rates = CS47L24_RATES,
1067 .formats = CS47L24_FORMATS,
1068 },
1069 },
1070};
1071
1072static int cs47l24_open(struct snd_compr_stream *stream)
1073{
1074 struct snd_soc_pcm_runtime *rtd = stream->private_data;
1075 struct snd_soc_component *component = snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1076 struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component);
1077 struct arizona *arizona = priv->core.arizona;
1078 int n_adsp;
1079
1080 if (strcmp(rtd->codec_dai->name, "cs47l24-dsp-voicectrl") == 0) {
1081 n_adsp = 2;
1082 } else if (strcmp(rtd->codec_dai->name, "cs47l24-dsp-trace") == 0) {
1083 n_adsp = 1;
1084 } else {
1085 dev_err(arizona->dev,
1086 "No suitable compressed stream for DAI '%s'\n",
1087 rtd->codec_dai->name);
1088 return -EINVAL;
1089 }
1090
1091 return wm_adsp_compr_open(&priv->core.adsp[n_adsp], stream);
1092}
1093
1094static irqreturn_t cs47l24_adsp2_irq(int irq, void *data)
1095{
1096 struct cs47l24_priv *priv = data;
1097 struct arizona *arizona = priv->core.arizona;
1098 struct arizona_voice_trigger_info info;
1099 int serviced = 0;
1100 int i, ret;
1101
1102 for (i = 1; i <= 2; ++i) {
1103 ret = wm_adsp_compr_handle_irq(&priv->core.adsp[i]);
1104 if (ret != -ENODEV)
1105 serviced++;
1106 if (ret == WM_ADSP_COMPR_VOICE_TRIGGER) {
1107 info.core = i;
1108 arizona_call_notifiers(arizona,
1109 ARIZONA_NOTIFY_VOICE_TRIGGER,
1110 &info);
1111 }
1112 }
1113
1114 if (!serviced) {
1115 dev_err(arizona->dev, "Spurious compressed data IRQ\n");
1116 return IRQ_NONE;
1117 }
1118
1119 return IRQ_HANDLED;
1120}
1121
1122static int cs47l24_component_probe(struct snd_soc_component *component)
1123{
1124 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
1125 struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component);
1126 struct arizona *arizona = priv->core.arizona;
1127 int ret;
1128
1129 arizona->dapm = dapm;
1130 snd_soc_component_init_regmap(component, arizona->regmap);
1131
1132 ret = arizona_init_spk(component);
1133 if (ret < 0)
1134 return ret;
1135
1136 arizona_init_gpio(component);
1137 arizona_init_mono(component);
1138
1139 ret = wm_adsp2_component_probe(&priv->core.adsp[1], component);
1140 if (ret)
1141 goto err_adsp2_codec_probe;
1142
1143 ret = wm_adsp2_component_probe(&priv->core.adsp[2], component);
1144 if (ret)
1145 goto err_adsp2_codec_probe;
1146
1147 ret = snd_soc_add_component_controls(component,
1148 &arizona_adsp2_rate_controls[1],
1149 2);
1150 if (ret)
1151 goto err_adsp2_codec_probe;
1152
1153 snd_soc_component_disable_pin(component, "HAPTICS");
1154
1155 return 0;
1156
1157err_adsp2_codec_probe:
1158 wm_adsp2_component_remove(&priv->core.adsp[1], component);
1159 wm_adsp2_component_remove(&priv->core.adsp[2], component);
1160
1161 return ret;
1162}
1163
1164static void cs47l24_component_remove(struct snd_soc_component *component)
1165{
1166 struct cs47l24_priv *priv = snd_soc_component_get_drvdata(component);
1167
1168 wm_adsp2_component_remove(&priv->core.adsp[1], component);
1169 wm_adsp2_component_remove(&priv->core.adsp[2], component);
1170
1171 priv->core.arizona->dapm = NULL;
1172}
1173
1174#define CS47L24_DIG_VU 0x0200
1175
1176static unsigned int cs47l24_digital_vu[] = {
1177 ARIZONA_DAC_DIGITAL_VOLUME_1L,
1178 ARIZONA_DAC_DIGITAL_VOLUME_1R,
1179 ARIZONA_DAC_DIGITAL_VOLUME_4L,
1180};
1181
1182static struct snd_compr_ops cs47l24_compr_ops = {
1183 .open = cs47l24_open,
1184 .free = wm_adsp_compr_free,
1185 .set_params = wm_adsp_compr_set_params,
1186 .get_caps = wm_adsp_compr_get_caps,
1187 .trigger = wm_adsp_compr_trigger,
1188 .pointer = wm_adsp_compr_pointer,
1189 .copy = wm_adsp_compr_copy,
1190};
1191
1192static const struct snd_soc_component_driver soc_component_dev_cs47l24 = {
1193 .probe = cs47l24_component_probe,
1194 .remove = cs47l24_component_remove,
1195 .set_sysclk = arizona_set_sysclk,
1196 .set_pll = cs47l24_set_fll,
1197 .name = DRV_NAME,
1198 .compr_ops = &cs47l24_compr_ops,
1199 .controls = cs47l24_snd_controls,
1200 .num_controls = ARRAY_SIZE(cs47l24_snd_controls),
1201 .dapm_widgets = cs47l24_dapm_widgets,
1202 .num_dapm_widgets = ARRAY_SIZE(cs47l24_dapm_widgets),
1203 .dapm_routes = cs47l24_dapm_routes,
1204 .num_dapm_routes = ARRAY_SIZE(cs47l24_dapm_routes),
1205 .use_pmdown_time = 1,
1206 .endianness = 1,
1207 .non_legacy_dai_naming = 1,
1208};
1209
1210static int cs47l24_probe(struct platform_device *pdev)
1211{
1212 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1213 struct cs47l24_priv *cs47l24;
1214 int i, ret;
1215
1216 BUILD_BUG_ON(ARRAY_SIZE(cs47l24_dai) > ARIZONA_MAX_DAI);
1217
1218 cs47l24 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l24_priv),
1219 GFP_KERNEL);
1220 if (!cs47l24)
1221 return -ENOMEM;
1222
1223 if (IS_ENABLED(CONFIG_OF)) {
1224 if (!dev_get_platdata(arizona->dev)) {
1225 ret = arizona_of_get_audio_pdata(arizona);
1226 if (ret < 0)
1227 return ret;
1228 }
1229 }
1230
1231 platform_set_drvdata(pdev, cs47l24);
1232
1233 cs47l24->core.arizona = arizona;
1234 cs47l24->core.num_inputs = 4;
1235
1236 for (i = 1; i <= 2; i++) {
1237 cs47l24->core.adsp[i].part = "cs47l24";
1238 cs47l24->core.adsp[i].num = i + 1;
1239 cs47l24->core.adsp[i].type = WMFW_ADSP2;
1240 cs47l24->core.adsp[i].dev = arizona->dev;
1241 cs47l24->core.adsp[i].regmap = arizona->regmap;
1242
1243 cs47l24->core.adsp[i].base = ARIZONA_DSP1_CONTROL_1 +
1244 (0x100 * i);
1245 cs47l24->core.adsp[i].mem = cs47l24_dsp_regions[i - 1];
1246 cs47l24->core.adsp[i].num_mems =
1247 ARRAY_SIZE(cs47l24_dsp2_regions);
1248
1249 ret = wm_adsp2_init(&cs47l24->core.adsp[i]);
1250 if (ret != 0)
1251 return ret;
1252 }
1253
1254 for (i = 0; i < ARRAY_SIZE(cs47l24->fll); i++)
1255 cs47l24->fll[i].vco_mult = 3;
1256
1257 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
1258 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
1259 &cs47l24->fll[0]);
1260 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
1261 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
1262 &cs47l24->fll[1]);
1263
1264
1265 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2,
1266 ARIZONA_SAMPLE_RATE_2_MASK, 0x11);
1267 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3,
1268 ARIZONA_SAMPLE_RATE_3_MASK, 0x12);
1269
1270 for (i = 0; i < ARRAY_SIZE(cs47l24_dai); i++)
1271 arizona_init_dai(&cs47l24->core, i);
1272
1273
1274 for (i = 0; i < ARRAY_SIZE(cs47l24_digital_vu); i++)
1275 regmap_update_bits(arizona->regmap, cs47l24_digital_vu[i],
1276 CS47L24_DIG_VU, CS47L24_DIG_VU);
1277
1278 pm_runtime_enable(&pdev->dev);
1279 pm_runtime_idle(&pdev->dev);
1280
1281 ret = arizona_request_irq(arizona, ARIZONA_IRQ_DSP_IRQ1,
1282 "ADSP2 Compressed IRQ", cs47l24_adsp2_irq,
1283 cs47l24);
1284 if (ret != 0) {
1285 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
1286 return ret;
1287 }
1288
1289 ret = arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 1);
1290 if (ret != 0)
1291 dev_warn(&pdev->dev,
1292 "Failed to set compressed IRQ as a wake source: %d\n",
1293 ret);
1294
1295 arizona_init_common(arizona);
1296
1297 ret = arizona_init_vol_limit(arizona);
1298 if (ret < 0)
1299 goto err_dsp_irq;
1300 ret = arizona_init_spk_irqs(arizona);
1301 if (ret < 0)
1302 goto err_dsp_irq;
1303
1304 ret = devm_snd_soc_register_component(&pdev->dev,
1305 &soc_component_dev_cs47l24,
1306 cs47l24_dai,
1307 ARRAY_SIZE(cs47l24_dai));
1308 if (ret < 0) {
1309 dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
1310 goto err_spk_irqs;
1311 }
1312
1313 return ret;
1314
1315err_spk_irqs:
1316 arizona_free_spk_irqs(arizona);
1317err_dsp_irq:
1318 arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
1319 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, cs47l24);
1320
1321 return ret;
1322}
1323
1324static int cs47l24_remove(struct platform_device *pdev)
1325{
1326 struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev);
1327 struct arizona *arizona = cs47l24->core.arizona;
1328
1329 pm_runtime_disable(&pdev->dev);
1330
1331 wm_adsp2_remove(&cs47l24->core.adsp[1]);
1332 wm_adsp2_remove(&cs47l24->core.adsp[2]);
1333
1334 arizona_free_spk_irqs(arizona);
1335
1336 arizona_set_irq_wake(arizona, ARIZONA_IRQ_DSP_IRQ1, 0);
1337 arizona_free_irq(arizona, ARIZONA_IRQ_DSP_IRQ1, cs47l24);
1338
1339 return 0;
1340}
1341
1342static struct platform_driver cs47l24_codec_driver = {
1343 .driver = {
1344 .name = "cs47l24-codec",
1345 },
1346 .probe = cs47l24_probe,
1347 .remove = cs47l24_remove,
1348};
1349
1350module_platform_driver(cs47l24_codec_driver);
1351
1352MODULE_DESCRIPTION("ASoC CS47L24 driver");
1353MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.wolfsonmicro.com>");
1354MODULE_LICENSE("GPL v2");
1355MODULE_ALIAS("platform:cs47l24-codec");
1356