1
2
3
4
5
6
7
8
9#include <linux/module.h>
10#include <linux/moduleparam.h>
11#include <linux/device.h>
12#include <linux/delay.h>
13#include <linux/init.h>
14#include <linux/pm.h>
15#include <linux/pm_runtime.h>
16#include <linux/regmap.h>
17#include <sound/core.h>
18#include <sound/pcm.h>
19#include <sound/pcm_params.h>
20#include <sound/soc.h>
21#include <sound/tlv.h>
22
23#include <linux/irqchip/irq-madera.h>
24#include <linux/mfd/madera/core.h>
25#include <linux/mfd/madera/registers.h>
26
27#include "madera.h"
28#include "wm_adsp.h"
29
30#define CS47L15_NUM_ADSP 1
31#define CS47L15_MONO_OUTPUTS 1
32
33
34#define CS47L15_ADC_INT_BIAS_MASK 0x3800
35#define CS47L15_ADC_INT_BIAS_SHIFT 11
36#define CS47L15_PGA_BIAS_SEL_MASK 0x03
37#define CS47L15_PGA_BIAS_SEL_SHIFT 0
38
39#define DRV_NAME "cs47l15-codec"
40
41struct cs47l15 {
42 struct madera_priv core;
43 struct madera_fll fll[2];
44
45 bool in1_lp_mode;
46};
47
48static const struct wm_adsp_region cs47l15_dsp1_regions[] = {
49 { .type = WMFW_ADSP2_PM, .base = 0x080000 },
50 { .type = WMFW_ADSP2_ZM, .base = 0x0e0000 },
51 { .type = WMFW_ADSP2_XM, .base = 0x0a0000 },
52 { .type = WMFW_ADSP2_YM, .base = 0x0c0000 },
53};
54
55static const char * const cs47l15_outdemux_texts[] = {
56 "HPOUT",
57 "EPOUT",
58};
59
60static SOC_ENUM_SINGLE_DECL(cs47l15_outdemux_enum, SND_SOC_NOPM, 0,
61 cs47l15_outdemux_texts);
62
63static const struct snd_kcontrol_new cs47l15_outdemux =
64 SOC_DAPM_ENUM_EXT("HPOUT1 Demux", cs47l15_outdemux_enum,
65 madera_out1_demux_get, madera_out1_demux_put);
66
67static int cs47l15_adsp_power_ev(struct snd_soc_dapm_widget *w,
68 struct snd_kcontrol *kcontrol,
69 int event)
70{
71 struct snd_soc_component *component =
72 snd_soc_dapm_to_component(w->dapm);
73 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
74 struct madera_priv *priv = &cs47l15->core;
75 struct madera *madera = priv->madera;
76 unsigned int freq;
77 int ret;
78
79 ret = regmap_read(madera->regmap, MADERA_DSP_CLOCK_2, &freq);
80 if (ret != 0) {
81 dev_err(madera->dev,
82 "Failed to read MADERA_DSP_CLOCK_2: %d\n", ret);
83 return ret;
84 }
85
86 switch (event) {
87 case SND_SOC_DAPM_PRE_PMU:
88 ret = madera_set_adsp_clk(&cs47l15->core, w->shift, freq);
89 if (ret)
90 return ret;
91 break;
92 default:
93 break;
94 }
95
96 return wm_adsp_early_event(w, kcontrol, event);
97}
98
99#define CS47L15_NG_SRC(name, base) \
100 SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \
101 SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \
102 SOC_SINGLE(name " NG SPKOUTL Switch", base, 6, 1, 0), \
103 SOC_SINGLE(name " NG SPKDAT1L Switch", base, 8, 1, 0), \
104 SOC_SINGLE(name " NG SPKDAT1R Switch", base, 9, 1, 0)
105
106static int cs47l15_in1_adc_get(struct snd_kcontrol *kcontrol,
107 struct snd_ctl_elem_value *ucontrol)
108{
109 struct snd_soc_component *component =
110 snd_soc_kcontrol_component(kcontrol);
111 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
112
113 ucontrol->value.integer.value[0] = !!cs47l15->in1_lp_mode;
114
115 return 0;
116}
117
118static int cs47l15_in1_adc_put(struct snd_kcontrol *kcontrol,
119 struct snd_ctl_elem_value *ucontrol)
120{
121 struct snd_soc_component *component =
122 snd_soc_kcontrol_component(kcontrol);
123 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
124
125 switch (ucontrol->value.integer.value[0]) {
126 case 0:
127
128 snd_soc_component_update_bits(component, MADERA_DMIC1L_CONTROL,
129 MADERA_IN1_OSR_MASK,
130 5 << MADERA_IN1_OSR_SHIFT);
131 snd_soc_component_update_bits(component, CS47L15_ADC_INT_BIAS,
132 CS47L15_ADC_INT_BIAS_MASK,
133 4 << CS47L15_ADC_INT_BIAS_SHIFT);
134 snd_soc_component_update_bits(component, CS47L15_PGA_BIAS_SEL,
135 CS47L15_PGA_BIAS_SEL_MASK, 0);
136 cs47l15->in1_lp_mode = false;
137 break;
138 default:
139
140 snd_soc_component_update_bits(component, MADERA_DMIC1L_CONTROL,
141 MADERA_IN1_OSR_MASK,
142 4 << MADERA_IN1_OSR_SHIFT);
143 snd_soc_component_update_bits(component, CS47L15_ADC_INT_BIAS,
144 CS47L15_ADC_INT_BIAS_MASK,
145 1 << CS47L15_ADC_INT_BIAS_SHIFT);
146 snd_soc_component_update_bits(component, CS47L15_PGA_BIAS_SEL,
147 CS47L15_PGA_BIAS_SEL_MASK,
148 3 << CS47L15_PGA_BIAS_SEL_SHIFT);
149 cs47l15->in1_lp_mode = true;
150 break;
151 }
152
153 return 0;
154}
155
156static const struct snd_kcontrol_new cs47l15_snd_controls[] = {
157SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]),
158SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]),
159
160SOC_SINGLE_RANGE_TLV("IN1L Volume", MADERA_IN1L_CONTROL,
161 MADERA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
162SOC_SINGLE_RANGE_TLV("IN1R Volume", MADERA_IN1R_CONTROL,
163 MADERA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
164
165SOC_ENUM("IN HPF Cutoff Frequency", madera_in_hpf_cut_enum),
166
167SOC_SINGLE("IN1L HPF Switch", MADERA_IN1L_CONTROL, MADERA_IN1L_HPF_SHIFT, 1, 0),
168SOC_SINGLE("IN1R HPF Switch", MADERA_IN1R_CONTROL, MADERA_IN1R_HPF_SHIFT, 1, 0),
169SOC_SINGLE("IN2L HPF Switch", MADERA_IN2L_CONTROL, MADERA_IN2L_HPF_SHIFT, 1, 0),
170SOC_SINGLE("IN2R HPF Switch", MADERA_IN2R_CONTROL, MADERA_IN2R_HPF_SHIFT, 1, 0),
171
172SOC_SINGLE_TLV("IN1L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1L,
173 MADERA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
174SOC_SINGLE_TLV("IN1R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1R,
175 MADERA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
176SOC_SINGLE_TLV("IN2L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2L,
177 MADERA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
178SOC_SINGLE_TLV("IN2R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2R,
179 MADERA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
180
181SOC_ENUM("Input Ramp Up", madera_in_vi_ramp),
182SOC_ENUM("Input Ramp Down", madera_in_vd_ramp),
183
184MADERA_MIXER_CONTROLS("EQ1", MADERA_EQ1MIX_INPUT_1_SOURCE),
185MADERA_MIXER_CONTROLS("EQ2", MADERA_EQ2MIX_INPUT_1_SOURCE),
186MADERA_MIXER_CONTROLS("EQ3", MADERA_EQ3MIX_INPUT_1_SOURCE),
187MADERA_MIXER_CONTROLS("EQ4", MADERA_EQ4MIX_INPUT_1_SOURCE),
188
189MADERA_EQ_CONTROL("EQ1 Coefficients", MADERA_EQ1_2),
190SOC_SINGLE_TLV("EQ1 B1 Volume", MADERA_EQ1_1, MADERA_EQ1_B1_GAIN_SHIFT,
191 24, 0, madera_eq_tlv),
192SOC_SINGLE_TLV("EQ1 B2 Volume", MADERA_EQ1_1, MADERA_EQ1_B2_GAIN_SHIFT,
193 24, 0, madera_eq_tlv),
194SOC_SINGLE_TLV("EQ1 B3 Volume", MADERA_EQ1_1, MADERA_EQ1_B3_GAIN_SHIFT,
195 24, 0, madera_eq_tlv),
196SOC_SINGLE_TLV("EQ1 B4 Volume", MADERA_EQ1_2, MADERA_EQ1_B4_GAIN_SHIFT,
197 24, 0, madera_eq_tlv),
198SOC_SINGLE_TLV("EQ1 B5 Volume", MADERA_EQ1_2, MADERA_EQ1_B5_GAIN_SHIFT,
199 24, 0, madera_eq_tlv),
200
201MADERA_EQ_CONTROL("EQ2 Coefficients", MADERA_EQ2_2),
202SOC_SINGLE_TLV("EQ2 B1 Volume", MADERA_EQ2_1, MADERA_EQ2_B1_GAIN_SHIFT,
203 24, 0, madera_eq_tlv),
204SOC_SINGLE_TLV("EQ2 B2 Volume", MADERA_EQ2_1, MADERA_EQ2_B2_GAIN_SHIFT,
205 24, 0, madera_eq_tlv),
206SOC_SINGLE_TLV("EQ2 B3 Volume", MADERA_EQ2_1, MADERA_EQ2_B3_GAIN_SHIFT,
207 24, 0, madera_eq_tlv),
208SOC_SINGLE_TLV("EQ2 B4 Volume", MADERA_EQ2_2, MADERA_EQ2_B4_GAIN_SHIFT,
209 24, 0, madera_eq_tlv),
210SOC_SINGLE_TLV("EQ2 B5 Volume", MADERA_EQ2_2, MADERA_EQ2_B5_GAIN_SHIFT,
211 24, 0, madera_eq_tlv),
212
213MADERA_EQ_CONTROL("EQ3 Coefficients", MADERA_EQ3_2),
214SOC_SINGLE_TLV("EQ3 B1 Volume", MADERA_EQ3_1, MADERA_EQ3_B1_GAIN_SHIFT,
215 24, 0, madera_eq_tlv),
216SOC_SINGLE_TLV("EQ3 B2 Volume", MADERA_EQ3_1, MADERA_EQ3_B2_GAIN_SHIFT,
217 24, 0, madera_eq_tlv),
218SOC_SINGLE_TLV("EQ3 B3 Volume", MADERA_EQ3_1, MADERA_EQ3_B3_GAIN_SHIFT,
219 24, 0, madera_eq_tlv),
220SOC_SINGLE_TLV("EQ3 B4 Volume", MADERA_EQ3_2, MADERA_EQ3_B4_GAIN_SHIFT,
221 24, 0, madera_eq_tlv),
222SOC_SINGLE_TLV("EQ3 B5 Volume", MADERA_EQ3_2, MADERA_EQ3_B5_GAIN_SHIFT,
223 24, 0, madera_eq_tlv),
224
225MADERA_EQ_CONTROL("EQ4 Coefficients", MADERA_EQ4_2),
226SOC_SINGLE_TLV("EQ4 B1 Volume", MADERA_EQ4_1, MADERA_EQ4_B1_GAIN_SHIFT,
227 24, 0, madera_eq_tlv),
228SOC_SINGLE_TLV("EQ4 B2 Volume", MADERA_EQ4_1, MADERA_EQ4_B2_GAIN_SHIFT,
229 24, 0, madera_eq_tlv),
230SOC_SINGLE_TLV("EQ4 B3 Volume", MADERA_EQ4_1, MADERA_EQ4_B3_GAIN_SHIFT,
231 24, 0, madera_eq_tlv),
232SOC_SINGLE_TLV("EQ4 B4 Volume", MADERA_EQ4_2, MADERA_EQ4_B4_GAIN_SHIFT,
233 24, 0, madera_eq_tlv),
234SOC_SINGLE_TLV("EQ4 B5 Volume", MADERA_EQ4_2, MADERA_EQ4_B5_GAIN_SHIFT,
235 24, 0, madera_eq_tlv),
236
237MADERA_MIXER_CONTROLS("DRC1L", MADERA_DRC1LMIX_INPUT_1_SOURCE),
238MADERA_MIXER_CONTROLS("DRC1R", MADERA_DRC1RMIX_INPUT_1_SOURCE),
239MADERA_MIXER_CONTROLS("DRC2L", MADERA_DRC2LMIX_INPUT_1_SOURCE),
240MADERA_MIXER_CONTROLS("DRC2R", MADERA_DRC2RMIX_INPUT_1_SOURCE),
241
242SND_SOC_BYTES_MASK("DRC1", MADERA_DRC1_CTRL1, 5,
243 MADERA_DRC1R_ENA | MADERA_DRC1L_ENA),
244SND_SOC_BYTES_MASK("DRC2", MADERA_DRC2_CTRL1, 5,
245 MADERA_DRC2R_ENA | MADERA_DRC2L_ENA),
246
247MADERA_MIXER_CONTROLS("LHPF1", MADERA_HPLP1MIX_INPUT_1_SOURCE),
248MADERA_MIXER_CONTROLS("LHPF2", MADERA_HPLP2MIX_INPUT_1_SOURCE),
249MADERA_MIXER_CONTROLS("LHPF3", MADERA_HPLP3MIX_INPUT_1_SOURCE),
250MADERA_MIXER_CONTROLS("LHPF4", MADERA_HPLP4MIX_INPUT_1_SOURCE),
251
252MADERA_LHPF_CONTROL("LHPF1 Coefficients", MADERA_HPLPF1_2),
253MADERA_LHPF_CONTROL("LHPF2 Coefficients", MADERA_HPLPF2_2),
254MADERA_LHPF_CONTROL("LHPF3 Coefficients", MADERA_HPLPF3_2),
255MADERA_LHPF_CONTROL("LHPF4 Coefficients", MADERA_HPLPF4_2),
256
257SOC_ENUM("LHPF1 Mode", madera_lhpf1_mode),
258SOC_ENUM("LHPF2 Mode", madera_lhpf2_mode),
259SOC_ENUM("LHPF3 Mode", madera_lhpf3_mode),
260SOC_ENUM("LHPF4 Mode", madera_lhpf4_mode),
261
262MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]),
263MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]),
264MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]),
265MADERA_RATE_ENUM("ISRC2 FSH", madera_isrc_fsh[1]),
266
267WM_ADSP2_PRELOAD_SWITCH("DSP1", 1),
268
269MADERA_MIXER_CONTROLS("DSP1L", MADERA_DSP1LMIX_INPUT_1_SOURCE),
270MADERA_MIXER_CONTROLS("DSP1R", MADERA_DSP1RMIX_INPUT_1_SOURCE),
271
272SOC_SINGLE_TLV("Noise Generator Volume", MADERA_COMFORT_NOISE_GENERATOR,
273 MADERA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, madera_noise_tlv),
274
275MADERA_MIXER_CONTROLS("HPOUT1L", MADERA_OUT1LMIX_INPUT_1_SOURCE),
276MADERA_MIXER_CONTROLS("HPOUT1R", MADERA_OUT1RMIX_INPUT_1_SOURCE),
277MADERA_MIXER_CONTROLS("SPKOUTL", MADERA_OUT4LMIX_INPUT_1_SOURCE),
278MADERA_MIXER_CONTROLS("SPKDAT1L", MADERA_OUT5LMIX_INPUT_1_SOURCE),
279MADERA_MIXER_CONTROLS("SPKDAT1R", MADERA_OUT5RMIX_INPUT_1_SOURCE),
280
281SOC_SINGLE("HPOUT1 SC Protect Switch", MADERA_HP1_SHORT_CIRCUIT_CTRL,
282 MADERA_HP1_SC_ENA_SHIFT, 1, 0),
283
284SOC_SINGLE("SPKDAT1 High Performance Switch", MADERA_OUTPUT_PATH_CONFIG_5L,
285 MADERA_OUT5_OSR_SHIFT, 1, 0),
286
287SOC_DOUBLE_R("HPOUT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_1L,
288 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_MUTE_SHIFT, 1, 1),
289SOC_SINGLE("Speaker Digital Switch", MADERA_DAC_DIGITAL_VOLUME_4L,
290 MADERA_OUT4L_MUTE_SHIFT, 1, 1),
291SOC_DOUBLE_R("SPKDAT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_5L,
292 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_MUTE_SHIFT, 1, 1),
293
294SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_1L,
295 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_VOL_SHIFT,
296 0xbf, 0, madera_digital_tlv),
297SOC_SINGLE_TLV("Speaker Digital Volume", MADERA_DAC_DIGITAL_VOLUME_4L,
298 MADERA_OUT4L_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
299SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_5L,
300 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_VOL_SHIFT,
301 0xbf, 0, madera_digital_tlv),
302
303SOC_DOUBLE("SPKDAT1 Switch", MADERA_PDM_SPK1_CTRL_1, MADERA_SPK1L_MUTE_SHIFT,
304 MADERA_SPK1R_MUTE_SHIFT, 1, 1),
305
306SOC_ENUM("Output Ramp Up", madera_out_vi_ramp),
307SOC_ENUM("Output Ramp Down", madera_out_vd_ramp),
308
309SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL,
310 MADERA_NGATE_ENA_SHIFT, 1, 0),
311SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL,
312 MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv),
313SOC_ENUM("Noise Gate Hold", madera_ng_hold),
314
315SOC_SINGLE_BOOL_EXT("IN1 LP Mode Switch", 0,
316 cs47l15_in1_adc_get, cs47l15_in1_adc_put),
317
318CS47L15_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L),
319CS47L15_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R),
320CS47L15_NG_SRC("SPKOUTL", MADERA_NOISE_GATE_SELECT_4L),
321CS47L15_NG_SRC("SPKDAT1L", MADERA_NOISE_GATE_SELECT_5L),
322CS47L15_NG_SRC("SPKDAT1R", MADERA_NOISE_GATE_SELECT_5R),
323
324MADERA_MIXER_CONTROLS("AIF1TX1", MADERA_AIF1TX1MIX_INPUT_1_SOURCE),
325MADERA_MIXER_CONTROLS("AIF1TX2", MADERA_AIF1TX2MIX_INPUT_1_SOURCE),
326MADERA_MIXER_CONTROLS("AIF1TX3", MADERA_AIF1TX3MIX_INPUT_1_SOURCE),
327MADERA_MIXER_CONTROLS("AIF1TX4", MADERA_AIF1TX4MIX_INPUT_1_SOURCE),
328MADERA_MIXER_CONTROLS("AIF1TX5", MADERA_AIF1TX5MIX_INPUT_1_SOURCE),
329MADERA_MIXER_CONTROLS("AIF1TX6", MADERA_AIF1TX6MIX_INPUT_1_SOURCE),
330
331MADERA_MIXER_CONTROLS("AIF2TX1", MADERA_AIF2TX1MIX_INPUT_1_SOURCE),
332MADERA_MIXER_CONTROLS("AIF2TX2", MADERA_AIF2TX2MIX_INPUT_1_SOURCE),
333MADERA_MIXER_CONTROLS("AIF2TX3", MADERA_AIF2TX3MIX_INPUT_1_SOURCE),
334MADERA_MIXER_CONTROLS("AIF2TX4", MADERA_AIF2TX4MIX_INPUT_1_SOURCE),
335
336MADERA_MIXER_CONTROLS("AIF3TX1", MADERA_AIF3TX1MIX_INPUT_1_SOURCE),
337MADERA_MIXER_CONTROLS("AIF3TX2", MADERA_AIF3TX2MIX_INPUT_1_SOURCE),
338
339MADERA_GAINMUX_CONTROLS("SPDIF1TX1", MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE),
340MADERA_GAINMUX_CONTROLS("SPDIF1TX2", MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE),
341
342WM_ADSP_FW_CONTROL("DSP1", 0),
343};
344
345MADERA_MIXER_ENUMS(EQ1, MADERA_EQ1MIX_INPUT_1_SOURCE);
346MADERA_MIXER_ENUMS(EQ2, MADERA_EQ2MIX_INPUT_1_SOURCE);
347MADERA_MIXER_ENUMS(EQ3, MADERA_EQ3MIX_INPUT_1_SOURCE);
348MADERA_MIXER_ENUMS(EQ4, MADERA_EQ4MIX_INPUT_1_SOURCE);
349
350MADERA_MIXER_ENUMS(DRC1L, MADERA_DRC1LMIX_INPUT_1_SOURCE);
351MADERA_MIXER_ENUMS(DRC1R, MADERA_DRC1RMIX_INPUT_1_SOURCE);
352MADERA_MIXER_ENUMS(DRC2L, MADERA_DRC2LMIX_INPUT_1_SOURCE);
353MADERA_MIXER_ENUMS(DRC2R, MADERA_DRC2RMIX_INPUT_1_SOURCE);
354
355MADERA_MIXER_ENUMS(LHPF1, MADERA_HPLP1MIX_INPUT_1_SOURCE);
356MADERA_MIXER_ENUMS(LHPF2, MADERA_HPLP2MIX_INPUT_1_SOURCE);
357MADERA_MIXER_ENUMS(LHPF3, MADERA_HPLP3MIX_INPUT_1_SOURCE);
358MADERA_MIXER_ENUMS(LHPF4, MADERA_HPLP4MIX_INPUT_1_SOURCE);
359
360MADERA_MIXER_ENUMS(DSP1L, MADERA_DSP1LMIX_INPUT_1_SOURCE);
361MADERA_MIXER_ENUMS(DSP1R, MADERA_DSP1RMIX_INPUT_1_SOURCE);
362MADERA_DSP_AUX_ENUMS(DSP1, MADERA_DSP1AUX1MIX_INPUT_1_SOURCE);
363
364MADERA_MIXER_ENUMS(PWM1, MADERA_PWM1MIX_INPUT_1_SOURCE);
365MADERA_MIXER_ENUMS(PWM2, MADERA_PWM2MIX_INPUT_1_SOURCE);
366
367MADERA_MIXER_ENUMS(OUT1L, MADERA_OUT1LMIX_INPUT_1_SOURCE);
368MADERA_MIXER_ENUMS(OUT1R, MADERA_OUT1RMIX_INPUT_1_SOURCE);
369MADERA_MIXER_ENUMS(SPKOUTL, MADERA_OUT4LMIX_INPUT_1_SOURCE);
370MADERA_MIXER_ENUMS(SPKDAT1L, MADERA_OUT5LMIX_INPUT_1_SOURCE);
371MADERA_MIXER_ENUMS(SPKDAT1R, MADERA_OUT5RMIX_INPUT_1_SOURCE);
372
373MADERA_MIXER_ENUMS(AIF1TX1, MADERA_AIF1TX1MIX_INPUT_1_SOURCE);
374MADERA_MIXER_ENUMS(AIF1TX2, MADERA_AIF1TX2MIX_INPUT_1_SOURCE);
375MADERA_MIXER_ENUMS(AIF1TX3, MADERA_AIF1TX3MIX_INPUT_1_SOURCE);
376MADERA_MIXER_ENUMS(AIF1TX4, MADERA_AIF1TX4MIX_INPUT_1_SOURCE);
377MADERA_MIXER_ENUMS(AIF1TX5, MADERA_AIF1TX5MIX_INPUT_1_SOURCE);
378MADERA_MIXER_ENUMS(AIF1TX6, MADERA_AIF1TX6MIX_INPUT_1_SOURCE);
379
380MADERA_MIXER_ENUMS(AIF2TX1, MADERA_AIF2TX1MIX_INPUT_1_SOURCE);
381MADERA_MIXER_ENUMS(AIF2TX2, MADERA_AIF2TX2MIX_INPUT_1_SOURCE);
382MADERA_MIXER_ENUMS(AIF2TX3, MADERA_AIF2TX3MIX_INPUT_1_SOURCE);
383MADERA_MIXER_ENUMS(AIF2TX4, MADERA_AIF2TX4MIX_INPUT_1_SOURCE);
384
385MADERA_MIXER_ENUMS(AIF3TX1, MADERA_AIF3TX1MIX_INPUT_1_SOURCE);
386MADERA_MIXER_ENUMS(AIF3TX2, MADERA_AIF3TX2MIX_INPUT_1_SOURCE);
387
388MADERA_MUX_ENUMS(SPD1TX1, MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE);
389MADERA_MUX_ENUMS(SPD1TX2, MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE);
390
391MADERA_MUX_ENUMS(ISRC1INT1, MADERA_ISRC1INT1MIX_INPUT_1_SOURCE);
392MADERA_MUX_ENUMS(ISRC1INT2, MADERA_ISRC1INT2MIX_INPUT_1_SOURCE);
393MADERA_MUX_ENUMS(ISRC1INT3, MADERA_ISRC1INT3MIX_INPUT_1_SOURCE);
394MADERA_MUX_ENUMS(ISRC1INT4, MADERA_ISRC1INT4MIX_INPUT_1_SOURCE);
395
396MADERA_MUX_ENUMS(ISRC1DEC1, MADERA_ISRC1DEC1MIX_INPUT_1_SOURCE);
397MADERA_MUX_ENUMS(ISRC1DEC2, MADERA_ISRC1DEC2MIX_INPUT_1_SOURCE);
398MADERA_MUX_ENUMS(ISRC1DEC3, MADERA_ISRC1DEC3MIX_INPUT_1_SOURCE);
399MADERA_MUX_ENUMS(ISRC1DEC4, MADERA_ISRC1DEC4MIX_INPUT_1_SOURCE);
400
401MADERA_MUX_ENUMS(ISRC2INT1, MADERA_ISRC2INT1MIX_INPUT_1_SOURCE);
402MADERA_MUX_ENUMS(ISRC2INT2, MADERA_ISRC2INT2MIX_INPUT_1_SOURCE);
403MADERA_MUX_ENUMS(ISRC2INT3, MADERA_ISRC2INT3MIX_INPUT_1_SOURCE);
404MADERA_MUX_ENUMS(ISRC2INT4, MADERA_ISRC2INT4MIX_INPUT_1_SOURCE);
405
406MADERA_MUX_ENUMS(ISRC2DEC1, MADERA_ISRC2DEC1MIX_INPUT_1_SOURCE);
407MADERA_MUX_ENUMS(ISRC2DEC2, MADERA_ISRC2DEC2MIX_INPUT_1_SOURCE);
408MADERA_MUX_ENUMS(ISRC2DEC3, MADERA_ISRC2DEC3MIX_INPUT_1_SOURCE);
409MADERA_MUX_ENUMS(ISRC2DEC4, MADERA_ISRC2DEC4MIX_INPUT_1_SOURCE);
410
411static const char * const cs47l15_aec_loopback_texts[] = {
412 "HPOUT1L", "HPOUT1R", "SPKOUTL", "SPKDAT1L", "SPKDAT1R",
413};
414
415static const unsigned int cs47l15_aec_loopback_values[] = {
416 0, 1, 6, 8, 9,
417};
418
419static const struct soc_enum cs47l15_aec1_loopback =
420 SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_1,
421 MADERA_AEC1_LOOPBACK_SRC_SHIFT, 0xf,
422 ARRAY_SIZE(cs47l15_aec_loopback_texts),
423 cs47l15_aec_loopback_texts,
424 cs47l15_aec_loopback_values);
425
426static const struct soc_enum cs47l15_aec2_loopback =
427 SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_2,
428 MADERA_AEC2_LOOPBACK_SRC_SHIFT, 0xf,
429 ARRAY_SIZE(cs47l15_aec_loopback_texts),
430 cs47l15_aec_loopback_texts,
431 cs47l15_aec_loopback_values);
432
433static const struct snd_kcontrol_new cs47l15_aec_loopback_mux[] = {
434 SOC_DAPM_ENUM("AEC1 Loopback", cs47l15_aec1_loopback),
435 SOC_DAPM_ENUM("AEC2 Loopback", cs47l15_aec2_loopback),
436};
437
438static const struct snd_soc_dapm_widget cs47l15_dapm_widgets[] = {
439SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT,
440 0, madera_sysclk_ev,
441 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
442SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK,
443 MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0),
444SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1,
445 MADERA_DSP_CLK_ENA_SHIFT, 0, NULL, 0),
446
447SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0),
448SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
449SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
450
451SND_SOC_DAPM_SUPPLY("MICBIAS1", MADERA_MIC_BIAS_CTRL_1,
452 MADERA_MICB1_ENA_SHIFT, 0, NULL, 0),
453
454SND_SOC_DAPM_SUPPLY("MICBIAS1A", MADERA_MIC_BIAS_CTRL_5,
455 MADERA_MICB1A_ENA_SHIFT, 0, NULL, 0),
456SND_SOC_DAPM_SUPPLY("MICBIAS1B", MADERA_MIC_BIAS_CTRL_5,
457 MADERA_MICB1B_ENA_SHIFT, 0, NULL, 0),
458SND_SOC_DAPM_SUPPLY("MICBIAS1C", MADERA_MIC_BIAS_CTRL_5,
459 MADERA_MICB1C_ENA_SHIFT, 0, NULL, 0),
460
461SND_SOC_DAPM_SUPPLY("FXCLK", SND_SOC_NOPM,
462 MADERA_DOM_GRP_FX, 0,
463 madera_domain_clk_ev,
464 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
465SND_SOC_DAPM_SUPPLY("ISRC1CLK", SND_SOC_NOPM,
466 MADERA_DOM_GRP_ISRC1, 0,
467 madera_domain_clk_ev,
468 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
469SND_SOC_DAPM_SUPPLY("ISRC2CLK", SND_SOC_NOPM,
470 MADERA_DOM_GRP_ISRC2, 0,
471 madera_domain_clk_ev,
472 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
473SND_SOC_DAPM_SUPPLY("OUTCLK", SND_SOC_NOPM,
474 MADERA_DOM_GRP_OUT, 0,
475 madera_domain_clk_ev,
476 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
477SND_SOC_DAPM_SUPPLY("SPDCLK", SND_SOC_NOPM,
478 MADERA_DOM_GRP_SPD, 0,
479 madera_domain_clk_ev,
480 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
481SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM,
482 MADERA_DOM_GRP_DSP1, 0,
483 madera_domain_clk_ev,
484 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
485SND_SOC_DAPM_SUPPLY("AIF1TXCLK", SND_SOC_NOPM,
486 MADERA_DOM_GRP_AIF1, 0,
487 madera_domain_clk_ev,
488 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
489SND_SOC_DAPM_SUPPLY("AIF2TXCLK", SND_SOC_NOPM,
490 MADERA_DOM_GRP_AIF2, 0,
491 madera_domain_clk_ev,
492 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
493SND_SOC_DAPM_SUPPLY("AIF3TXCLK", SND_SOC_NOPM,
494 MADERA_DOM_GRP_AIF3, 0,
495 madera_domain_clk_ev,
496 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
497SND_SOC_DAPM_SUPPLY("PWMCLK", SND_SOC_NOPM,
498 MADERA_DOM_GRP_PWM, 0,
499 madera_domain_clk_ev,
500 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
501
502SND_SOC_DAPM_SIGGEN("TONE"),
503SND_SOC_DAPM_SIGGEN("NOISE"),
504
505SND_SOC_DAPM_INPUT("IN1ALN"),
506SND_SOC_DAPM_INPUT("IN1ALP"),
507SND_SOC_DAPM_INPUT("IN1BLN"),
508SND_SOC_DAPM_INPUT("IN1BLP"),
509SND_SOC_DAPM_INPUT("IN1ARN"),
510SND_SOC_DAPM_INPUT("IN1ARP"),
511SND_SOC_DAPM_INPUT("IN1BRN"),
512SND_SOC_DAPM_INPUT("IN1BRP"),
513SND_SOC_DAPM_INPUT("IN2N"),
514SND_SOC_DAPM_INPUT("IN2P"),
515SND_SOC_DAPM_INPUT("SPKRXDAT"),
516
517SND_SOC_DAPM_MUX("IN1L Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[0]),
518SND_SOC_DAPM_MUX("IN1R Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[1]),
519
520SND_SOC_DAPM_MUX("IN1L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]),
521SND_SOC_DAPM_MUX("IN1R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]),
522
523SND_SOC_DAPM_MUX("IN2L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]),
524SND_SOC_DAPM_MUX("IN2R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]),
525
526SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
527SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"),
528
529SND_SOC_DAPM_OUTPUT("DSP Trigger Out"),
530
531SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l15_outdemux),
532
533SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT,
534 0, NULL, 0),
535SND_SOC_DAPM_PGA("PWM2 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM2_ENA_SHIFT,
536 0, NULL, 0),
537
538SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
539 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX1_ENA_SHIFT, 0),
540SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
541 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX2_ENA_SHIFT, 0),
542SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
543 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX3_ENA_SHIFT, 0),
544SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
545 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX4_ENA_SHIFT, 0),
546SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
547 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX5_ENA_SHIFT, 0),
548SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
549 MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX6_ENA_SHIFT, 0),
550
551SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
552 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX1_ENA_SHIFT, 0),
553SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
554 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX2_ENA_SHIFT, 0),
555SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 0,
556 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX3_ENA_SHIFT, 0),
557SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 0,
558 MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX4_ENA_SHIFT, 0),
559
560SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
561 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX1_ENA_SHIFT, 0),
562SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
563 MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX2_ENA_SHIFT, 0),
564
565SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
566 MADERA_OUT1L_ENA_SHIFT, 0, NULL, 0, madera_hp_ev,
567 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
568 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
569SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
570 MADERA_OUT1R_ENA_SHIFT, 0, NULL, 0, madera_hp_ev,
571 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
572 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
573SND_SOC_DAPM_PGA_E("OUT4L", SND_SOC_NOPM,
574 MADERA_OUT4L_ENA_SHIFT, 0, NULL, 0, madera_spk_ev,
575 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
576SND_SOC_DAPM_PGA_E("OUT5L", MADERA_OUTPUT_ENABLES_1,
577 MADERA_OUT5L_ENA_SHIFT, 0, NULL, 0, madera_out_ev,
578 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
579SND_SOC_DAPM_PGA_E("OUT5R", MADERA_OUTPUT_ENABLES_1,
580 MADERA_OUT5R_ENA_SHIFT, 0, NULL, 0, madera_out_ev,
581 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
582
583SND_SOC_DAPM_PGA("SPD1TX1", MADERA_SPD1_TX_CONTROL,
584 MADERA_SPD1_VAL1_SHIFT, 0, NULL, 0),
585SND_SOC_DAPM_PGA("SPD1TX2", MADERA_SPD1_TX_CONTROL,
586 MADERA_SPD1_VAL2_SHIFT, 0, NULL, 0),
587SND_SOC_DAPM_OUT_DRV("SPD1", MADERA_SPD1_TX_CONTROL,
588 MADERA_SPD1_ENA_SHIFT, 0, NULL, 0),
589
590
591
592
593
594
595SND_SOC_DAPM_PGA("Noise Generator", MADERA_COMFORT_NOISE_GENERATOR,
596 MADERA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
597
598SND_SOC_DAPM_PGA("Tone Generator 1", MADERA_TONE_GENERATOR_1,
599 MADERA_TONE1_ENA_SHIFT, 0, NULL, 0),
600SND_SOC_DAPM_PGA("Tone Generator 2", MADERA_TONE_GENERATOR_1,
601 MADERA_TONE2_ENA_SHIFT, 0, NULL, 0),
602
603SND_SOC_DAPM_SIGGEN("HAPTICS"),
604
605SND_SOC_DAPM_MUX("AEC1 Loopback", MADERA_DAC_AEC_CONTROL_1,
606 MADERA_AEC1_LOOPBACK_ENA_SHIFT, 0,
607 &cs47l15_aec_loopback_mux[0]),
608SND_SOC_DAPM_MUX("AEC2 Loopback", MADERA_DAC_AEC_CONTROL_2,
609 MADERA_AEC2_LOOPBACK_ENA_SHIFT, 0,
610 &cs47l15_aec_loopback_mux[1]),
611
612SND_SOC_DAPM_PGA_E("IN1L", MADERA_INPUT_ENABLES, MADERA_IN1L_ENA_SHIFT,
613 0, NULL, 0, madera_in_ev,
614 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
615 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
616SND_SOC_DAPM_PGA_E("IN1R", MADERA_INPUT_ENABLES, MADERA_IN1R_ENA_SHIFT,
617 0, NULL, 0, madera_in_ev,
618 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
619 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
620SND_SOC_DAPM_PGA_E("IN2L", MADERA_INPUT_ENABLES, MADERA_IN2L_ENA_SHIFT,
621 0, NULL, 0, madera_in_ev,
622 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
623 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
624SND_SOC_DAPM_PGA_E("IN2R", MADERA_INPUT_ENABLES, MADERA_IN2R_ENA_SHIFT,
625 0, NULL, 0, madera_in_ev,
626 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
627 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
628
629SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
630 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX1_ENA_SHIFT, 0),
631SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
632 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX2_ENA_SHIFT, 0),
633SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
634 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX3_ENA_SHIFT, 0),
635SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
636 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX4_ENA_SHIFT, 0),
637SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
638 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX5_ENA_SHIFT, 0),
639SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
640 MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX6_ENA_SHIFT, 0),
641
642SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
643 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX1_ENA_SHIFT, 0),
644SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
645 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX2_ENA_SHIFT, 0),
646SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 0,
647 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX3_ENA_SHIFT, 0),
648SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 0,
649 MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX4_ENA_SHIFT, 0),
650
651SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
652 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX1_ENA_SHIFT, 0),
653SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
654 MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX2_ENA_SHIFT, 0),
655
656SND_SOC_DAPM_PGA("EQ1", MADERA_EQ1_1, MADERA_EQ1_ENA_SHIFT, 0, NULL, 0),
657SND_SOC_DAPM_PGA("EQ2", MADERA_EQ2_1, MADERA_EQ2_ENA_SHIFT, 0, NULL, 0),
658SND_SOC_DAPM_PGA("EQ3", MADERA_EQ3_1, MADERA_EQ3_ENA_SHIFT, 0, NULL, 0),
659SND_SOC_DAPM_PGA("EQ4", MADERA_EQ4_1, MADERA_EQ4_ENA_SHIFT, 0, NULL, 0),
660
661SND_SOC_DAPM_PGA("DRC1L", MADERA_DRC1_CTRL1, MADERA_DRC1L_ENA_SHIFT, 0,
662 NULL, 0),
663SND_SOC_DAPM_PGA("DRC1R", MADERA_DRC1_CTRL1, MADERA_DRC1R_ENA_SHIFT, 0,
664 NULL, 0),
665SND_SOC_DAPM_PGA("DRC2L", MADERA_DRC2_CTRL1, MADERA_DRC2L_ENA_SHIFT, 0,
666 NULL, 0),
667SND_SOC_DAPM_PGA("DRC2R", MADERA_DRC2_CTRL1, MADERA_DRC2R_ENA_SHIFT, 0,
668 NULL, 0),
669
670SND_SOC_DAPM_PGA("LHPF1", MADERA_HPLPF1_1, MADERA_LHPF1_ENA_SHIFT, 0, NULL, 0),
671SND_SOC_DAPM_PGA("LHPF2", MADERA_HPLPF2_1, MADERA_LHPF2_ENA_SHIFT, 0, NULL, 0),
672SND_SOC_DAPM_PGA("LHPF3", MADERA_HPLPF3_1, MADERA_LHPF3_ENA_SHIFT, 0, NULL, 0),
673SND_SOC_DAPM_PGA("LHPF4", MADERA_HPLPF4_1, MADERA_LHPF4_ENA_SHIFT, 0, NULL, 0),
674
675SND_SOC_DAPM_PGA("ISRC1DEC1", MADERA_ISRC_1_CTRL_3,
676 MADERA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
677SND_SOC_DAPM_PGA("ISRC1DEC2", MADERA_ISRC_1_CTRL_3,
678 MADERA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0),
679SND_SOC_DAPM_PGA("ISRC1DEC3", MADERA_ISRC_1_CTRL_3,
680 MADERA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0),
681SND_SOC_DAPM_PGA("ISRC1DEC4", MADERA_ISRC_1_CTRL_3,
682 MADERA_ISRC1_DEC4_ENA_SHIFT, 0, NULL, 0),
683
684SND_SOC_DAPM_PGA("ISRC1INT1", MADERA_ISRC_1_CTRL_3,
685 MADERA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
686SND_SOC_DAPM_PGA("ISRC1INT2", MADERA_ISRC_1_CTRL_3,
687 MADERA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0),
688SND_SOC_DAPM_PGA("ISRC1INT3", MADERA_ISRC_1_CTRL_3,
689 MADERA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0),
690SND_SOC_DAPM_PGA("ISRC1INT4", MADERA_ISRC_1_CTRL_3,
691 MADERA_ISRC1_INT4_ENA_SHIFT, 0, NULL, 0),
692
693SND_SOC_DAPM_PGA("ISRC2DEC1", MADERA_ISRC_2_CTRL_3,
694 MADERA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
695SND_SOC_DAPM_PGA("ISRC2DEC2", MADERA_ISRC_2_CTRL_3,
696 MADERA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0),
697SND_SOC_DAPM_PGA("ISRC2DEC3", MADERA_ISRC_2_CTRL_3,
698 MADERA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0),
699SND_SOC_DAPM_PGA("ISRC2DEC4", MADERA_ISRC_2_CTRL_3,
700 MADERA_ISRC2_DEC4_ENA_SHIFT, 0, NULL, 0),
701
702SND_SOC_DAPM_PGA("ISRC2INT1", MADERA_ISRC_2_CTRL_3,
703 MADERA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
704SND_SOC_DAPM_PGA("ISRC2INT2", MADERA_ISRC_2_CTRL_3,
705 MADERA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0),
706SND_SOC_DAPM_PGA("ISRC2INT3", MADERA_ISRC_2_CTRL_3,
707 MADERA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0),
708SND_SOC_DAPM_PGA("ISRC2INT4", MADERA_ISRC_2_CTRL_3,
709 MADERA_ISRC2_INT4_ENA_SHIFT, 0, NULL, 0),
710
711WM_ADSP2("DSP1", 0, cs47l15_adsp_power_ev),
712
713
714
715MADERA_MIXER_WIDGETS(EQ1, "EQ1"),
716MADERA_MIXER_WIDGETS(EQ2, "EQ2"),
717MADERA_MIXER_WIDGETS(EQ3, "EQ3"),
718MADERA_MIXER_WIDGETS(EQ4, "EQ4"),
719
720MADERA_MIXER_WIDGETS(DRC1L, "DRC1L"),
721MADERA_MIXER_WIDGETS(DRC1R, "DRC1R"),
722MADERA_MIXER_WIDGETS(DRC2L, "DRC2L"),
723MADERA_MIXER_WIDGETS(DRC2R, "DRC2R"),
724
725SND_SOC_DAPM_SWITCH("DRC1 Activity Output", SND_SOC_NOPM, 0, 0,
726 &madera_drc_activity_output_mux[0]),
727SND_SOC_DAPM_SWITCH("DRC2 Activity Output", SND_SOC_NOPM, 0, 0,
728 &madera_drc_activity_output_mux[1]),
729
730MADERA_MIXER_WIDGETS(LHPF1, "LHPF1"),
731MADERA_MIXER_WIDGETS(LHPF2, "LHPF2"),
732MADERA_MIXER_WIDGETS(LHPF3, "LHPF3"),
733MADERA_MIXER_WIDGETS(LHPF4, "LHPF4"),
734
735MADERA_MIXER_WIDGETS(PWM1, "PWM1"),
736MADERA_MIXER_WIDGETS(PWM2, "PWM2"),
737
738MADERA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
739MADERA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
740MADERA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"),
741MADERA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
742MADERA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
743
744MADERA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
745MADERA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
746MADERA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
747MADERA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
748MADERA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
749MADERA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
750
751MADERA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
752MADERA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
753MADERA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"),
754MADERA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"),
755
756MADERA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
757MADERA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
758
759MADERA_MUX_WIDGETS(SPD1TX1, "SPDIF1TX1"),
760MADERA_MUX_WIDGETS(SPD1TX2, "SPDIF1TX2"),
761
762MADERA_DSP_WIDGETS(DSP1, "DSP1"),
763
764SND_SOC_DAPM_SWITCH("DSP1 Trigger Output", SND_SOC_NOPM, 0, 0,
765 &madera_dsp_trigger_output_mux[0]),
766
767MADERA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
768MADERA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
769MADERA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"),
770MADERA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"),
771
772MADERA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
773MADERA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
774MADERA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"),
775MADERA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"),
776
777MADERA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
778MADERA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
779MADERA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"),
780MADERA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"),
781
782MADERA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
783MADERA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
784MADERA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"),
785MADERA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"),
786
787SND_SOC_DAPM_OUTPUT("HPOUTL"),
788SND_SOC_DAPM_OUTPUT("HPOUTR"),
789SND_SOC_DAPM_OUTPUT("EPOUTP"),
790SND_SOC_DAPM_OUTPUT("EPOUTN"),
791SND_SOC_DAPM_OUTPUT("SPKOUTN"),
792SND_SOC_DAPM_OUTPUT("SPKOUTP"),
793SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
794SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
795SND_SOC_DAPM_OUTPUT("SPDIF1"),
796
797SND_SOC_DAPM_OUTPUT("MICSUPP"),
798};
799
800#define MADERA_MIXER_INPUT_ROUTES(name) \
801 { name, "Noise Generator", "Noise Generator" }, \
802 { name, "Tone Generator 1", "Tone Generator 1" }, \
803 { name, "Tone Generator 2", "Tone Generator 2" }, \
804 { name, "Haptics", "HAPTICS" }, \
805 { name, "AEC1", "AEC1 Loopback" }, \
806 { name, "AEC2", "AEC2 Loopback" }, \
807 { name, "IN1L", "IN1L" }, \
808 { name, "IN1R", "IN1R" }, \
809 { name, "IN2L", "IN2L" }, \
810 { name, "IN2R", "IN2R" }, \
811 { name, "AIF1RX1", "AIF1RX1" }, \
812 { name, "AIF1RX2", "AIF1RX2" }, \
813 { name, "AIF1RX3", "AIF1RX3" }, \
814 { name, "AIF1RX4", "AIF1RX4" }, \
815 { name, "AIF1RX5", "AIF1RX5" }, \
816 { name, "AIF1RX6", "AIF1RX6" }, \
817 { name, "AIF2RX1", "AIF2RX1" }, \
818 { name, "AIF2RX2", "AIF2RX2" }, \
819 { name, "AIF2RX3", "AIF2RX3" }, \
820 { name, "AIF2RX4", "AIF2RX4" }, \
821 { name, "AIF3RX1", "AIF3RX1" }, \
822 { name, "AIF3RX2", "AIF3RX2" }, \
823 { name, "EQ1", "EQ1" }, \
824 { name, "EQ2", "EQ2" }, \
825 { name, "EQ3", "EQ3" }, \
826 { name, "EQ4", "EQ4" }, \
827 { name, "DRC1L", "DRC1L" }, \
828 { name, "DRC1R", "DRC1R" }, \
829 { name, "DRC2L", "DRC2L" }, \
830 { name, "DRC2R", "DRC2R" }, \
831 { name, "LHPF1", "LHPF1" }, \
832 { name, "LHPF2", "LHPF2" }, \
833 { name, "LHPF3", "LHPF3" }, \
834 { name, "LHPF4", "LHPF4" }, \
835 { name, "ISRC1DEC1", "ISRC1DEC1" }, \
836 { name, "ISRC1DEC2", "ISRC1DEC2" }, \
837 { name, "ISRC1DEC3", "ISRC1DEC3" }, \
838 { name, "ISRC1DEC4", "ISRC1DEC4" }, \
839 { name, "ISRC1INT1", "ISRC1INT1" }, \
840 { name, "ISRC1INT2", "ISRC1INT2" }, \
841 { name, "ISRC1INT3", "ISRC1INT3" }, \
842 { name, "ISRC1INT4", "ISRC1INT4" }, \
843 { name, "ISRC2DEC1", "ISRC2DEC1" }, \
844 { name, "ISRC2DEC2", "ISRC2DEC2" }, \
845 { name, "ISRC2DEC3", "ISRC2DEC3" }, \
846 { name, "ISRC2DEC4", "ISRC2DEC4" }, \
847 { name, "ISRC2INT1", "ISRC2INT1" }, \
848 { name, "ISRC2INT2", "ISRC2INT2" }, \
849 { name, "ISRC2INT3", "ISRC2INT3" }, \
850 { name, "ISRC2INT4", "ISRC2INT4" }, \
851 { name, "DSP1.1", "DSP1" }, \
852 { name, "DSP1.2", "DSP1" }, \
853 { name, "DSP1.3", "DSP1" }, \
854 { name, "DSP1.4", "DSP1" }, \
855 { name, "DSP1.5", "DSP1" }, \
856 { name, "DSP1.6", "DSP1" }
857
858static const struct snd_soc_dapm_route cs47l15_dapm_routes[] = {
859
860 { "EQ1", NULL, "FXCLK" },
861 { "EQ2", NULL, "FXCLK" },
862 { "EQ3", NULL, "FXCLK" },
863 { "EQ4", NULL, "FXCLK" },
864 { "DRC1L", NULL, "FXCLK" },
865 { "DRC1R", NULL, "FXCLK" },
866 { "DRC2L", NULL, "FXCLK" },
867 { "DRC2R", NULL, "FXCLK" },
868 { "LHPF1", NULL, "FXCLK" },
869 { "LHPF2", NULL, "FXCLK" },
870 { "LHPF3", NULL, "FXCLK" },
871 { "LHPF4", NULL, "FXCLK" },
872 { "PWM1 Mixer", NULL, "PWMCLK" },
873 { "PWM2 Mixer", NULL, "PWMCLK" },
874 { "OUT1L", NULL, "OUTCLK" },
875 { "OUT1R", NULL, "OUTCLK" },
876 { "OUT4L", NULL, "OUTCLK" },
877 { "OUT5L", NULL, "OUTCLK" },
878 { "OUT5R", NULL, "OUTCLK" },
879 { "AIF1TX1", NULL, "AIF1TXCLK" },
880 { "AIF1TX2", NULL, "AIF1TXCLK" },
881 { "AIF1TX3", NULL, "AIF1TXCLK" },
882 { "AIF1TX4", NULL, "AIF1TXCLK" },
883 { "AIF1TX5", NULL, "AIF1TXCLK" },
884 { "AIF1TX6", NULL, "AIF1TXCLK" },
885 { "AIF2TX1", NULL, "AIF2TXCLK" },
886 { "AIF2TX2", NULL, "AIF2TXCLK" },
887 { "AIF2TX3", NULL, "AIF2TXCLK" },
888 { "AIF2TX4", NULL, "AIF2TXCLK" },
889 { "AIF3TX1", NULL, "AIF3TXCLK" },
890 { "AIF3TX2", NULL, "AIF3TXCLK" },
891 { "SPD1TX1", NULL, "SPDCLK" },
892 { "SPD1TX2", NULL, "SPDCLK" },
893 { "DSP1", NULL, "DSP1CLK" },
894 { "ISRC1DEC1", NULL, "ISRC1CLK" },
895 { "ISRC1DEC2", NULL, "ISRC1CLK" },
896 { "ISRC1DEC3", NULL, "ISRC1CLK" },
897 { "ISRC1DEC4", NULL, "ISRC1CLK" },
898 { "ISRC1INT1", NULL, "ISRC1CLK" },
899 { "ISRC1INT2", NULL, "ISRC1CLK" },
900 { "ISRC1INT3", NULL, "ISRC1CLK" },
901 { "ISRC1INT4", NULL, "ISRC1CLK" },
902 { "ISRC2DEC1", NULL, "ISRC2CLK" },
903 { "ISRC2DEC2", NULL, "ISRC2CLK" },
904 { "ISRC2DEC3", NULL, "ISRC2CLK" },
905 { "ISRC2DEC4", NULL, "ISRC2CLK" },
906 { "ISRC2INT1", NULL, "ISRC2CLK" },
907 { "ISRC2INT2", NULL, "ISRC2CLK" },
908 { "ISRC2INT3", NULL, "ISRC2CLK" },
909 { "ISRC2INT4", NULL, "ISRC2CLK" },
910
911 { "OUT1L", NULL, "CPVDD1" },
912 { "OUT1R", NULL, "CPVDD1" },
913 { "OUT4L", NULL, "SPKVDD" },
914
915 { "OUT1L", NULL, "SYSCLK" },
916 { "OUT1R", NULL, "SYSCLK" },
917 { "OUT4L", NULL, "SYSCLK" },
918 { "OUT5L", NULL, "SYSCLK" },
919 { "OUT5R", NULL, "SYSCLK" },
920
921 { "SPD1", NULL, "SYSCLK" },
922 { "SPD1", NULL, "SPD1TX1" },
923 { "SPD1", NULL, "SPD1TX2" },
924
925 { "IN1L", NULL, "SYSCLK" },
926 { "IN1R", NULL, "SYSCLK" },
927 { "IN2L", NULL, "SYSCLK" },
928 { "IN2R", NULL, "SYSCLK" },
929
930 { "MICBIAS1", NULL, "MICVDD" },
931
932 { "MICBIAS1A", NULL, "MICBIAS1" },
933 { "MICBIAS1B", NULL, "MICBIAS1" },
934 { "MICBIAS1C", NULL, "MICBIAS1" },
935
936 { "Noise Generator", NULL, "SYSCLK" },
937 { "Tone Generator 1", NULL, "SYSCLK" },
938 { "Tone Generator 2", NULL, "SYSCLK" },
939
940 { "Noise Generator", NULL, "NOISE" },
941 { "Tone Generator 1", NULL, "TONE" },
942 { "Tone Generator 2", NULL, "TONE" },
943
944 { "AIF1 Capture", NULL, "AIF1TX1" },
945 { "AIF1 Capture", NULL, "AIF1TX2" },
946 { "AIF1 Capture", NULL, "AIF1TX3" },
947 { "AIF1 Capture", NULL, "AIF1TX4" },
948 { "AIF1 Capture", NULL, "AIF1TX5" },
949 { "AIF1 Capture", NULL, "AIF1TX6" },
950
951 { "AIF1RX1", NULL, "AIF1 Playback" },
952 { "AIF1RX2", NULL, "AIF1 Playback" },
953 { "AIF1RX3", NULL, "AIF1 Playback" },
954 { "AIF1RX4", NULL, "AIF1 Playback" },
955 { "AIF1RX5", NULL, "AIF1 Playback" },
956 { "AIF1RX6", NULL, "AIF1 Playback" },
957
958 { "AIF2 Capture", NULL, "AIF2TX1" },
959 { "AIF2 Capture", NULL, "AIF2TX2" },
960 { "AIF2 Capture", NULL, "AIF2TX3" },
961 { "AIF2 Capture", NULL, "AIF2TX4" },
962
963 { "AIF2RX1", NULL, "AIF2 Playback" },
964 { "AIF2RX2", NULL, "AIF2 Playback" },
965 { "AIF2RX3", NULL, "AIF2 Playback" },
966 { "AIF2RX4", NULL, "AIF2 Playback" },
967
968 { "AIF3 Capture", NULL, "AIF3TX1" },
969 { "AIF3 Capture", NULL, "AIF3TX2" },
970
971 { "AIF3RX1", NULL, "AIF3 Playback" },
972 { "AIF3RX2", NULL, "AIF3 Playback" },
973
974 { "AIF1 Playback", NULL, "SYSCLK" },
975 { "AIF2 Playback", NULL, "SYSCLK" },
976 { "AIF3 Playback", NULL, "SYSCLK" },
977
978 { "AIF1 Capture", NULL, "SYSCLK" },
979 { "AIF2 Capture", NULL, "SYSCLK" },
980 { "AIF3 Capture", NULL, "SYSCLK" },
981
982 { "Audio Trace DSP", NULL, "DSP1" },
983
984 { "IN1L Analog Mux", "A", "IN1ALN" },
985 { "IN1L Analog Mux", "A", "IN1ALP" },
986 { "IN1L Analog Mux", "B", "IN1BLN" },
987 { "IN1L Analog Mux", "B", "IN1BLP" },
988 { "IN1R Analog Mux", "A", "IN1ARN" },
989 { "IN1R Analog Mux", "A", "IN1ARP" },
990 { "IN1R Analog Mux", "B", "IN1BRN" },
991 { "IN1R Analog Mux", "B", "IN1BRP" },
992
993 { "IN1L Mode", "Analog", "IN1L Analog Mux" },
994 { "IN1R Mode", "Analog", "IN1R Analog Mux" },
995
996 { "IN1L Mode", "Digital", "IN1ALN" },
997 { "IN1L Mode", "Digital", "IN1ALP" },
998 { "IN1R Mode", "Digital", "IN1ALN" },
999 { "IN1R Mode", "Digital", "IN1ALP" },
1000
1001 { "IN1L", NULL, "IN1L Mode" },
1002 { "IN1R", NULL, "IN1R Mode" },
1003
1004 { "IN2L Mode", "Analog", "IN2N" },
1005 { "IN2L Mode", "Analog", "IN2P" },
1006
1007 { "IN2L Mode", "Digital", "SPKRXDAT" },
1008 { "IN2R Mode", "Digital", "SPKRXDAT" },
1009
1010 { "IN2L", NULL, "IN2L Mode" },
1011 { "IN2R", NULL, "IN2R Mode" },
1012
1013 MADERA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
1014 MADERA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
1015 MADERA_MIXER_ROUTES("OUT4L", "SPKOUTL"),
1016 MADERA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
1017 MADERA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
1018
1019 MADERA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
1020 MADERA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
1021
1022 MADERA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
1023 MADERA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
1024 MADERA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
1025 MADERA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
1026 MADERA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
1027 MADERA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
1028
1029 MADERA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
1030 MADERA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
1031 MADERA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"),
1032 MADERA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"),
1033
1034 MADERA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
1035 MADERA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
1036
1037 MADERA_MUX_ROUTES("SPD1TX1", "SPDIF1TX1"),
1038 MADERA_MUX_ROUTES("SPD1TX2", "SPDIF1TX2"),
1039
1040 MADERA_MIXER_ROUTES("EQ1", "EQ1"),
1041 MADERA_MIXER_ROUTES("EQ2", "EQ2"),
1042 MADERA_MIXER_ROUTES("EQ3", "EQ3"),
1043 MADERA_MIXER_ROUTES("EQ4", "EQ4"),
1044
1045 MADERA_MIXER_ROUTES("DRC1L", "DRC1L"),
1046 MADERA_MIXER_ROUTES("DRC1R", "DRC1R"),
1047 MADERA_MIXER_ROUTES("DRC2L", "DRC2L"),
1048 MADERA_MIXER_ROUTES("DRC2R", "DRC2R"),
1049
1050 MADERA_MIXER_ROUTES("LHPF1", "LHPF1"),
1051 MADERA_MIXER_ROUTES("LHPF2", "LHPF2"),
1052 MADERA_MIXER_ROUTES("LHPF3", "LHPF3"),
1053 MADERA_MIXER_ROUTES("LHPF4", "LHPF4"),
1054
1055 MADERA_DSP_ROUTES("DSP1"),
1056
1057 { "DSP Trigger Out", NULL, "DSP1 Trigger Output" },
1058
1059 { "DSP1 Trigger Output", "Switch", "DSP1" },
1060
1061 MADERA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
1062 MADERA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
1063 MADERA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"),
1064 MADERA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"),
1065
1066 MADERA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
1067 MADERA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
1068 MADERA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"),
1069 MADERA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"),
1070
1071 MADERA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
1072 MADERA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
1073 MADERA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"),
1074 MADERA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"),
1075
1076 MADERA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
1077 MADERA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
1078 MADERA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"),
1079 MADERA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"),
1080
1081 { "AEC1 Loopback", "HPOUT1L", "OUT1L" },
1082 { "AEC1 Loopback", "HPOUT1R", "OUT1R" },
1083 { "AEC2 Loopback", "HPOUT1L", "OUT1L" },
1084 { "AEC2 Loopback", "HPOUT1R", "OUT1R" },
1085 { "HPOUT1 Demux", NULL, "OUT1L" },
1086 { "HPOUT1 Demux", NULL, "OUT1R" },
1087 { "HPOUTL", "HPOUT", "HPOUT1 Demux" },
1088 { "HPOUTR", "HPOUT", "HPOUT1 Demux" },
1089 { "EPOUTP", "EPOUT", "HPOUT1 Demux" },
1090 { "EPOUTN", "EPOUT", "HPOUT1 Demux" },
1091
1092 { "AEC1 Loopback", "SPKOUTL", "OUT4L" },
1093 { "AEC2 Loopback", "SPKOUTL", "OUT4L" },
1094 { "SPKOUTN", NULL, "OUT4L" },
1095 { "SPKOUTP", NULL, "OUT4L" },
1096
1097 { "AEC1 Loopback", "SPKDAT1L", "OUT5L" },
1098 { "AEC1 Loopback", "SPKDAT1R", "OUT5R" },
1099 { "AEC2 Loopback", "SPKDAT1L", "OUT5L" },
1100 { "AEC2 Loopback", "SPKDAT1R", "OUT5R" },
1101 { "SPKDAT1L", NULL, "OUT5L" },
1102 { "SPKDAT1R", NULL, "OUT5R" },
1103
1104 { "SPDIF1", NULL, "SPD1" },
1105
1106 { "MICSUPP", NULL, "SYSCLK" },
1107
1108 { "DRC1 Signal Activity", NULL, "DRC1 Activity Output" },
1109 { "DRC2 Signal Activity", NULL, "DRC2 Activity Output" },
1110 { "DRC1 Activity Output", "Switch", "DRC1L" },
1111 { "DRC1 Activity Output", "Switch", "DRC1R" },
1112 { "DRC2 Activity Output", "Switch", "DRC2L" },
1113 { "DRC2 Activity Output", "Switch", "DRC2R" },
1114};
1115
1116static int cs47l15_set_fll(struct snd_soc_component *component, int fll_id,
1117 int source, unsigned int fref, unsigned int fout)
1118{
1119 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
1120
1121 switch (fll_id) {
1122 case MADERA_FLL1_REFCLK:
1123 return madera_set_fll_refclk(&cs47l15->fll[0], source, fref,
1124 fout);
1125 case MADERA_FLLAO_REFCLK:
1126 return madera_set_fll_ao_refclk(&cs47l15->fll[1], source, fref,
1127 fout);
1128 case MADERA_FLL1_SYNCCLK:
1129 return madera_set_fll_syncclk(&cs47l15->fll[0], source, fref,
1130 fout);
1131 default:
1132 return -EINVAL;
1133 }
1134}
1135
1136static struct snd_soc_dai_driver cs47l15_dai[] = {
1137 {
1138 .name = "cs47l15-aif1",
1139 .id = 1,
1140 .base = MADERA_AIF1_BCLK_CTRL,
1141 .playback = {
1142 .stream_name = "AIF1 Playback",
1143 .channels_min = 1,
1144 .channels_max = 6,
1145 .rates = MADERA_RATES,
1146 .formats = MADERA_FORMATS,
1147 },
1148 .capture = {
1149 .stream_name = "AIF1 Capture",
1150 .channels_min = 1,
1151 .channels_max = 6,
1152 .rates = MADERA_RATES,
1153 .formats = MADERA_FORMATS,
1154 },
1155 .ops = &madera_dai_ops,
1156 .symmetric_rates = 1,
1157 .symmetric_samplebits = 1,
1158 },
1159 {
1160 .name = "cs47l15-aif2",
1161 .id = 2,
1162 .base = MADERA_AIF2_BCLK_CTRL,
1163 .playback = {
1164 .stream_name = "AIF2 Playback",
1165 .channels_min = 1,
1166 .channels_max = 4,
1167 .rates = MADERA_RATES,
1168 .formats = MADERA_FORMATS,
1169 },
1170 .capture = {
1171 .stream_name = "AIF2 Capture",
1172 .channels_min = 1,
1173 .channels_max = 4,
1174 .rates = MADERA_RATES,
1175 .formats = MADERA_FORMATS,
1176 },
1177 .ops = &madera_dai_ops,
1178 .symmetric_rates = 1,
1179 .symmetric_samplebits = 1,
1180 },
1181 {
1182 .name = "cs47l15-aif3",
1183 .id = 3,
1184 .base = MADERA_AIF3_BCLK_CTRL,
1185 .playback = {
1186 .stream_name = "AIF3 Playback",
1187 .channels_min = 1,
1188 .channels_max = 2,
1189 .rates = MADERA_RATES,
1190 .formats = MADERA_FORMATS,
1191 },
1192 .capture = {
1193 .stream_name = "AIF3 Capture",
1194 .channels_min = 1,
1195 .channels_max = 2,
1196 .rates = MADERA_RATES,
1197 .formats = MADERA_FORMATS,
1198 },
1199 .ops = &madera_dai_ops,
1200 .symmetric_rates = 1,
1201 .symmetric_samplebits = 1,
1202 },
1203 {
1204 .name = "cs47l15-cpu-trace",
1205 .capture = {
1206 .stream_name = "Audio Trace CPU",
1207 .channels_min = 1,
1208 .channels_max = 6,
1209 .rates = MADERA_RATES,
1210 .formats = MADERA_FORMATS,
1211 },
1212 .compress_new = snd_soc_new_compress,
1213 },
1214 {
1215 .name = "cs47l15-dsp-trace",
1216 .capture = {
1217 .stream_name = "Audio Trace DSP",
1218 .channels_min = 1,
1219 .channels_max = 6,
1220 .rates = MADERA_RATES,
1221 .formats = MADERA_FORMATS,
1222 },
1223 },
1224};
1225
1226static int cs47l15_open(struct snd_compr_stream *stream)
1227{
1228 struct snd_soc_pcm_runtime *rtd = stream->private_data;
1229 struct snd_soc_component *component =
1230 snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1231 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
1232 struct madera_priv *priv = &cs47l15->core;
1233 struct madera *madera = priv->madera;
1234 int n_adsp;
1235
1236 if (strcmp(rtd->codec_dai->name, "cs47l15-dsp-trace") == 0) {
1237 n_adsp = 0;
1238 } else {
1239 dev_err(madera->dev,
1240 "No suitable compressed stream for DAI '%s'\n",
1241 rtd->codec_dai->name);
1242 return -EINVAL;
1243 }
1244
1245 return wm_adsp_compr_open(&priv->adsp[n_adsp], stream);
1246}
1247
1248static irqreturn_t cs47l15_adsp2_irq(int irq, void *data)
1249{
1250 struct cs47l15 *cs47l15 = data;
1251 struct madera_priv *priv = &cs47l15->core;
1252 struct madera *madera = priv->madera;
1253 int ret;
1254
1255 ret = wm_adsp_compr_handle_irq(&priv->adsp[0]);
1256 if (ret == -ENODEV) {
1257 dev_err(madera->dev, "Spurious compressed data IRQ\n");
1258 return IRQ_NONE;
1259 }
1260
1261 return IRQ_HANDLED;
1262}
1263
1264static int cs47l15_component_probe(struct snd_soc_component *component)
1265{
1266 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
1267 struct madera *madera = cs47l15->core.madera;
1268 int ret;
1269
1270 snd_soc_component_init_regmap(component, madera->regmap);
1271
1272 mutex_lock(&madera->dapm_ptr_lock);
1273 madera->dapm = snd_soc_component_get_dapm(component);
1274 mutex_unlock(&madera->dapm_ptr_lock);
1275
1276 ret = madera_init_inputs(component);
1277 if (ret)
1278 return ret;
1279
1280 ret = madera_init_outputs(component, CS47L15_MONO_OUTPUTS);
1281 if (ret)
1282 return ret;
1283
1284 snd_soc_component_disable_pin(component, "HAPTICS");
1285
1286 ret = snd_soc_add_component_controls(component,
1287 madera_adsp_rate_controls,
1288 CS47L15_NUM_ADSP);
1289 if (ret)
1290 return ret;
1291
1292 wm_adsp2_component_probe(&cs47l15->core.adsp[0], component);
1293
1294 return 0;
1295}
1296
1297static void cs47l15_component_remove(struct snd_soc_component *component)
1298{
1299 struct cs47l15 *cs47l15 = snd_soc_component_get_drvdata(component);
1300 struct madera *madera = cs47l15->core.madera;
1301
1302 mutex_lock(&madera->dapm_ptr_lock);
1303 madera->dapm = NULL;
1304 mutex_unlock(&madera->dapm_ptr_lock);
1305
1306 wm_adsp2_component_remove(&cs47l15->core.adsp[0], component);
1307}
1308
1309#define CS47L15_DIG_VU 0x0200
1310
1311static unsigned int cs47l15_digital_vu[] = {
1312 MADERA_DAC_DIGITAL_VOLUME_1L,
1313 MADERA_DAC_DIGITAL_VOLUME_1R,
1314 MADERA_DAC_DIGITAL_VOLUME_4L,
1315 MADERA_DAC_DIGITAL_VOLUME_5L,
1316 MADERA_DAC_DIGITAL_VOLUME_5R,
1317};
1318
1319static const struct snd_compr_ops cs47l15_compr_ops = {
1320 .open = &cs47l15_open,
1321 .free = &wm_adsp_compr_free,
1322 .set_params = &wm_adsp_compr_set_params,
1323 .get_caps = &wm_adsp_compr_get_caps,
1324 .trigger = &wm_adsp_compr_trigger,
1325 .pointer = &wm_adsp_compr_pointer,
1326 .copy = &wm_adsp_compr_copy,
1327};
1328
1329static const struct snd_soc_component_driver soc_component_dev_cs47l15 = {
1330 .probe = &cs47l15_component_probe,
1331 .remove = &cs47l15_component_remove,
1332 .set_sysclk = &madera_set_sysclk,
1333 .set_pll = &cs47l15_set_fll,
1334 .name = DRV_NAME,
1335 .compr_ops = &cs47l15_compr_ops,
1336 .controls = cs47l15_snd_controls,
1337 .num_controls = ARRAY_SIZE(cs47l15_snd_controls),
1338 .dapm_widgets = cs47l15_dapm_widgets,
1339 .num_dapm_widgets = ARRAY_SIZE(cs47l15_dapm_widgets),
1340 .dapm_routes = cs47l15_dapm_routes,
1341 .num_dapm_routes = ARRAY_SIZE(cs47l15_dapm_routes),
1342 .use_pmdown_time = 1,
1343 .endianness = 1,
1344 .non_legacy_dai_naming = 1,
1345};
1346
1347static int cs47l15_probe(struct platform_device *pdev)
1348{
1349 struct madera *madera = dev_get_drvdata(pdev->dev.parent);
1350 struct cs47l15 *cs47l15;
1351 int i, ret;
1352
1353 BUILD_BUG_ON(ARRAY_SIZE(cs47l15_dai) > MADERA_MAX_DAI);
1354
1355
1356 if (!madera->irq_dev) {
1357 dev_dbg(&pdev->dev, "irqchip driver not ready\n");
1358 return -EPROBE_DEFER;
1359 }
1360
1361 cs47l15 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l15),
1362 GFP_KERNEL);
1363 if (!cs47l15)
1364 return -ENOMEM;
1365
1366 platform_set_drvdata(pdev, cs47l15);
1367
1368 cs47l15->core.madera = madera;
1369 cs47l15->core.dev = &pdev->dev;
1370 cs47l15->core.num_inputs = 4;
1371
1372 ret = madera_core_init(&cs47l15->core);
1373 if (ret)
1374 return ret;
1375
1376 ret = madera_init_overheat(&cs47l15->core);
1377 if (ret)
1378 goto error_core;
1379
1380 ret = madera_request_irq(madera, MADERA_IRQ_DSP_IRQ1,
1381 "ADSP2 Compressed IRQ", cs47l15_adsp2_irq,
1382 cs47l15);
1383 if (ret != 0) {
1384 dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
1385 goto error_overheat;
1386 }
1387
1388 ret = madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 1);
1389 if (ret)
1390 dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret);
1391
1392 cs47l15->core.adsp[0].part = "cs47l15";
1393 cs47l15->core.adsp[0].num = 1;
1394 cs47l15->core.adsp[0].type = WMFW_ADSP2;
1395 cs47l15->core.adsp[0].rev = 2;
1396 cs47l15->core.adsp[0].dev = madera->dev;
1397 cs47l15->core.adsp[0].regmap = madera->regmap_32bit;
1398
1399 cs47l15->core.adsp[0].base = MADERA_DSP1_CONFIG_1;
1400 cs47l15->core.adsp[0].mem = cs47l15_dsp1_regions;
1401 cs47l15->core.adsp[0].num_mems = ARRAY_SIZE(cs47l15_dsp1_regions);
1402
1403 cs47l15->core.adsp[0].lock_regions =
1404 WM_ADSP2_REGION_1 | WM_ADSP2_REGION_2 | WM_ADSP2_REGION_3;
1405
1406 ret = wm_adsp2_init(&cs47l15->core.adsp[0]);
1407 if (ret != 0)
1408 goto error_dsp_irq;
1409
1410 ret = madera_init_bus_error_irq(&cs47l15->core, 0, wm_adsp2_bus_error);
1411 if (ret)
1412 goto error_adsp;
1413
1414 madera_init_fll(madera, 1, MADERA_FLL1_CONTROL_1 - 1,
1415 &cs47l15->fll[0]);
1416 madera_init_fll(madera, 4, MADERA_FLLAO_CONTROL_1 - 1,
1417 &cs47l15->fll[1]);
1418
1419 for (i = 0; i < ARRAY_SIZE(cs47l15_dai); i++)
1420 madera_init_dai(&cs47l15->core, i);
1421
1422
1423 for (i = 0; i < ARRAY_SIZE(cs47l15_digital_vu); i++)
1424 regmap_update_bits(madera->regmap, cs47l15_digital_vu[i],
1425 CS47L15_DIG_VU, CS47L15_DIG_VU);
1426
1427 pm_runtime_enable(&pdev->dev);
1428 pm_runtime_idle(&pdev->dev);
1429
1430 ret = devm_snd_soc_register_component(&pdev->dev,
1431 &soc_component_dev_cs47l15,
1432 cs47l15_dai,
1433 ARRAY_SIZE(cs47l15_dai));
1434 if (ret < 0) {
1435 dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
1436 goto error_pm_runtime;
1437 }
1438
1439 return ret;
1440
1441error_pm_runtime:
1442 pm_runtime_disable(&pdev->dev);
1443 madera_free_bus_error_irq(&cs47l15->core, 0);
1444error_adsp:
1445 wm_adsp2_remove(&cs47l15->core.adsp[0]);
1446error_dsp_irq:
1447 madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 0);
1448 madera_free_irq(madera, MADERA_IRQ_DSP_IRQ1, cs47l15);
1449error_overheat:
1450 madera_free_overheat(&cs47l15->core);
1451error_core:
1452 madera_core_free(&cs47l15->core);
1453
1454 return ret;
1455}
1456
1457static int cs47l15_remove(struct platform_device *pdev)
1458{
1459 struct cs47l15 *cs47l15 = platform_get_drvdata(pdev);
1460
1461 pm_runtime_disable(&pdev->dev);
1462
1463 madera_free_bus_error_irq(&cs47l15->core, 0);
1464
1465 wm_adsp2_remove(&cs47l15->core.adsp[0]);
1466
1467 madera_set_irq_wake(cs47l15->core.madera, MADERA_IRQ_DSP_IRQ1, 0);
1468 madera_free_irq(cs47l15->core.madera, MADERA_IRQ_DSP_IRQ1, cs47l15);
1469 madera_free_overheat(&cs47l15->core);
1470 madera_core_free(&cs47l15->core);
1471
1472 return 0;
1473}
1474
1475static struct platform_driver cs47l15_codec_driver = {
1476 .driver = {
1477 .name = "cs47l15-codec",
1478 },
1479 .probe = &cs47l15_probe,
1480 .remove = &cs47l15_remove,
1481};
1482
1483module_platform_driver(cs47l15_codec_driver);
1484
1485MODULE_SOFTDEP("pre: madera irq-madera arizona-micsupp");
1486MODULE_DESCRIPTION("ASoC CS47L15 driver");
1487MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.cirrus.com>");
1488MODULE_AUTHOR("Jaswinder Jassal <jjassal@opensource.cirrus.com>");
1489MODULE_LICENSE("GPL v2");
1490MODULE_ALIAS("platform:cs47l15-codec");
1491