xref: /openbmc/linux/sound/soc/codecs/cs47l35.c (revision 09b35b41)
1 // SPDX-License-Identifier: GPL-2.0-only
2 //
3 // ALSA SoC Audio driver for CS47L35 codec
4 //
5 // Copyright (C) 2015-2019 Cirrus Logic, Inc. and
6 //                         Cirrus Logic International Semiconductor Ltd.
7 //
8 
9 #include <linux/delay.h>
10 #include <linux/device.h>
11 #include <linux/init.h>
12 #include <linux/module.h>
13 #include <linux/moduleparam.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 CS47L35_NUM_ADSP	3
31 #define CS47L35_MONO_OUTPUTS	1
32 
33 #define DRV_NAME "cs47l35-codec"
34 
35 struct cs47l35 {
36 	struct madera_priv core;
37 	struct madera_fll fll;
38 };
39 
40 static const struct wm_adsp_region cs47l35_dsp1_regions[] = {
41 	{ .type = WMFW_ADSP2_PM, .base = 0x080000 },
42 	{ .type = WMFW_ADSP2_ZM, .base = 0x0e0000 },
43 	{ .type = WMFW_ADSP2_XM, .base = 0x0a0000 },
44 	{ .type = WMFW_ADSP2_YM, .base = 0x0c0000 },
45 };
46 
47 static const struct wm_adsp_region cs47l35_dsp2_regions[] = {
48 	{ .type = WMFW_ADSP2_PM, .base = 0x100000 },
49 	{ .type = WMFW_ADSP2_ZM, .base = 0x160000 },
50 	{ .type = WMFW_ADSP2_XM, .base = 0x120000 },
51 	{ .type = WMFW_ADSP2_YM, .base = 0x140000 },
52 };
53 
54 static const struct wm_adsp_region cs47l35_dsp3_regions[] = {
55 	{ .type = WMFW_ADSP2_PM, .base = 0x180000 },
56 	{ .type = WMFW_ADSP2_ZM, .base = 0x1e0000 },
57 	{ .type = WMFW_ADSP2_XM, .base = 0x1a0000 },
58 	{ .type = WMFW_ADSP2_YM, .base = 0x1c0000 },
59 };
60 
61 static const struct wm_adsp_region *cs47l35_dsp_regions[] = {
62 	cs47l35_dsp1_regions,
63 	cs47l35_dsp2_regions,
64 	cs47l35_dsp3_regions,
65 };
66 
67 static const int wm_adsp2_control_bases[] = {
68 	MADERA_DSP1_CONFIG_1,
69 	MADERA_DSP2_CONFIG_1,
70 	MADERA_DSP3_CONFIG_1,
71 };
72 
73 static const char * const cs47l35_outdemux_texts[] = {
74 	"HPOUT",
75 	"EPOUT",
76 };
77 
78 static SOC_ENUM_SINGLE_DECL(cs47l35_outdemux_enum, SND_SOC_NOPM, 0,
79 			    cs47l35_outdemux_texts);
80 
81 static const struct snd_kcontrol_new cs47l35_outdemux =
82 	SOC_DAPM_ENUM_EXT("HPOUT1 Demux", cs47l35_outdemux_enum,
83 			  madera_out1_demux_get, madera_out1_demux_put);
84 
85 static int cs47l35_adsp_power_ev(struct snd_soc_dapm_widget *w,
86 				 struct snd_kcontrol *kcontrol,
87 				 int event)
88 {
89 	struct snd_soc_component *component =
90 		snd_soc_dapm_to_component(w->dapm);
91 	struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component);
92 	struct madera_priv *priv = &cs47l35->core;
93 	struct madera *madera = priv->madera;
94 	unsigned int freq;
95 	int ret;
96 
97 	ret = regmap_read(madera->regmap, MADERA_DSP_CLOCK_1, &freq);
98 	if (ret != 0) {
99 		dev_err(madera->dev,
100 			"Failed to read MADERA_DSP_CLOCK_1: %d\n", ret);
101 		return ret;
102 	}
103 
104 	freq &= MADERA_DSP_CLK_FREQ_LEGACY_MASK;
105 	freq >>= MADERA_DSP_CLK_FREQ_LEGACY_SHIFT;
106 
107 	switch (event) {
108 	case SND_SOC_DAPM_PRE_PMU:
109 		ret = madera_set_adsp_clk(&cs47l35->core, w->shift, freq);
110 		if (ret)
111 			return ret;
112 		break;
113 	default:
114 		break;
115 	}
116 
117 	return wm_adsp_early_event(w, kcontrol, event);
118 }
119 
120 #define CS47L35_NG_SRC(name, base) \
121 	SOC_SINGLE(name " NG HPOUT1L Switch",  base,  0, 1, 0), \
122 	SOC_SINGLE(name " NG HPOUT1R Switch",  base,  1, 1, 0), \
123 	SOC_SINGLE(name " NG SPKOUT Switch",  base,  6, 1, 0), \
124 	SOC_SINGLE(name " NG SPKDAT1L Switch", base,  8, 1, 0), \
125 	SOC_SINGLE(name " NG SPKDAT1R Switch", base,  9, 1, 0)
126 
127 static void cs47l35_hp_post_enable(struct snd_soc_dapm_widget *w)
128 {
129 	struct snd_soc_component *component =
130 		snd_soc_dapm_to_component(w->dapm);
131 	unsigned int val;
132 	int ret;
133 
134 	switch (w->shift) {
135 	case MADERA_OUT1L_ENA_SHIFT:
136 	case MADERA_OUT1R_ENA_SHIFT:
137 		ret = snd_soc_component_read(component, MADERA_OUTPUT_ENABLES_1,
138 					     &val);
139 		if (ret) {
140 			dev_err(component->dev,
141 				"Failed to check output enables: %d\n", ret);
142 			return;
143 		}
144 
145 		val &= (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA);
146 
147 		if (val != (MADERA_OUT1L_ENA | MADERA_OUT1R_ENA))
148 			break;
149 
150 		snd_soc_component_update_bits(component,
151 					      MADERA_EDRE_HP_STEREO_CONTROL,
152 					      0x0001, 1);
153 		break;
154 	default:
155 		break;
156 	}
157 }
158 
159 static void cs47l35_hp_post_disable(struct snd_soc_dapm_widget *w)
160 {
161 	struct snd_soc_component *component =
162 		snd_soc_dapm_to_component(w->dapm);
163 
164 	switch (w->shift) {
165 	case MADERA_OUT1L_ENA_SHIFT:
166 		snd_soc_component_write(component, MADERA_DCS_HP1L_CONTROL,
167 					0x2006);
168 		break;
169 	case MADERA_OUT1R_ENA_SHIFT:
170 		snd_soc_component_write(component, MADERA_DCS_HP1R_CONTROL,
171 					0x2006);
172 		break;
173 	default:
174 		return;
175 	}
176 
177 	/* Only get to here for OUT1L and OUT1R */
178 	snd_soc_component_update_bits(component,
179 				      MADERA_EDRE_HP_STEREO_CONTROL,
180 				      0x0001, 0);
181 }
182 
183 static int cs47l35_hp_ev(struct snd_soc_dapm_widget *w,
184 			 struct snd_kcontrol *kcontrol, int event)
185 {
186 	int ret;
187 
188 	switch (event) {
189 	case SND_SOC_DAPM_PRE_PMU:
190 	case SND_SOC_DAPM_PRE_PMD:
191 		return madera_hp_ev(w, kcontrol, event);
192 	case SND_SOC_DAPM_POST_PMU:
193 		ret = madera_hp_ev(w, kcontrol, event);
194 		if (ret < 0)
195 			return ret;
196 
197 		cs47l35_hp_post_enable(w);
198 		return 0;
199 	case SND_SOC_DAPM_POST_PMD:
200 		ret = madera_hp_ev(w, kcontrol, event);
201 		cs47l35_hp_post_disable(w);
202 		return ret;
203 	default:
204 		return -EINVAL;
205 	}
206 }
207 
208 static const struct snd_kcontrol_new cs47l35_snd_controls[] = {
209 SOC_ENUM("IN1 OSR", madera_in_dmic_osr[0]),
210 SOC_ENUM("IN2 OSR", madera_in_dmic_osr[1]),
211 
212 SOC_SINGLE_RANGE_TLV("IN1L Volume", MADERA_IN1L_CONTROL,
213 		     MADERA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
214 SOC_SINGLE_RANGE_TLV("IN1R Volume", MADERA_IN1R_CONTROL,
215 		     MADERA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
216 SOC_SINGLE_RANGE_TLV("IN2L Volume", MADERA_IN2L_CONTROL,
217 		     MADERA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
218 SOC_SINGLE_RANGE_TLV("IN2R Volume", MADERA_IN2R_CONTROL,
219 		     MADERA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, madera_ana_tlv),
220 
221 SOC_ENUM("IN HPF Cutoff Frequency", madera_in_hpf_cut_enum),
222 
223 SOC_SINGLE("IN1L HPF Switch", MADERA_IN1L_CONTROL,
224 	   MADERA_IN1L_HPF_SHIFT, 1, 0),
225 SOC_SINGLE("IN1R HPF Switch", MADERA_IN1R_CONTROL,
226 	   MADERA_IN1R_HPF_SHIFT, 1, 0),
227 SOC_SINGLE("IN2L HPF Switch", MADERA_IN2L_CONTROL,
228 	   MADERA_IN2L_HPF_SHIFT, 1, 0),
229 SOC_SINGLE("IN2R HPF Switch", MADERA_IN2R_CONTROL,
230 	   MADERA_IN2R_HPF_SHIFT, 1, 0),
231 
232 SOC_SINGLE_TLV("IN1L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1L,
233 	       MADERA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
234 SOC_SINGLE_TLV("IN1R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_1R,
235 	       MADERA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
236 SOC_SINGLE_TLV("IN2L Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2L,
237 	       MADERA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
238 SOC_SINGLE_TLV("IN2R Digital Volume", MADERA_ADC_DIGITAL_VOLUME_2R,
239 	       MADERA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
240 
241 SOC_ENUM("Input Ramp Up", madera_in_vi_ramp),
242 SOC_ENUM("Input Ramp Down", madera_in_vd_ramp),
243 
244 MADERA_MIXER_CONTROLS("EQ1", MADERA_EQ1MIX_INPUT_1_SOURCE),
245 MADERA_MIXER_CONTROLS("EQ2", MADERA_EQ2MIX_INPUT_1_SOURCE),
246 MADERA_MIXER_CONTROLS("EQ3", MADERA_EQ3MIX_INPUT_1_SOURCE),
247 MADERA_MIXER_CONTROLS("EQ4", MADERA_EQ4MIX_INPUT_1_SOURCE),
248 
249 MADERA_EQ_CONTROL("EQ1 Coefficients", MADERA_EQ1_2),
250 SOC_SINGLE_TLV("EQ1 B1 Volume", MADERA_EQ1_1, MADERA_EQ1_B1_GAIN_SHIFT,
251 	       24, 0, madera_eq_tlv),
252 SOC_SINGLE_TLV("EQ1 B2 Volume", MADERA_EQ1_1, MADERA_EQ1_B2_GAIN_SHIFT,
253 	       24, 0, madera_eq_tlv),
254 SOC_SINGLE_TLV("EQ1 B3 Volume", MADERA_EQ1_1, MADERA_EQ1_B3_GAIN_SHIFT,
255 	       24, 0, madera_eq_tlv),
256 SOC_SINGLE_TLV("EQ1 B4 Volume", MADERA_EQ1_2, MADERA_EQ1_B4_GAIN_SHIFT,
257 	       24, 0, madera_eq_tlv),
258 SOC_SINGLE_TLV("EQ1 B5 Volume", MADERA_EQ1_2, MADERA_EQ1_B5_GAIN_SHIFT,
259 	       24, 0, madera_eq_tlv),
260 
261 MADERA_EQ_CONTROL("EQ2 Coefficients", MADERA_EQ2_2),
262 SOC_SINGLE_TLV("EQ2 B1 Volume", MADERA_EQ2_1, MADERA_EQ2_B1_GAIN_SHIFT,
263 	       24, 0, madera_eq_tlv),
264 SOC_SINGLE_TLV("EQ2 B2 Volume", MADERA_EQ2_1, MADERA_EQ2_B2_GAIN_SHIFT,
265 	       24, 0, madera_eq_tlv),
266 SOC_SINGLE_TLV("EQ2 B3 Volume", MADERA_EQ2_1, MADERA_EQ2_B3_GAIN_SHIFT,
267 	       24, 0, madera_eq_tlv),
268 SOC_SINGLE_TLV("EQ2 B4 Volume", MADERA_EQ2_2, MADERA_EQ2_B4_GAIN_SHIFT,
269 	       24, 0, madera_eq_tlv),
270 SOC_SINGLE_TLV("EQ2 B5 Volume", MADERA_EQ2_2, MADERA_EQ2_B5_GAIN_SHIFT,
271 	       24, 0, madera_eq_tlv),
272 
273 MADERA_EQ_CONTROL("EQ3 Coefficients", MADERA_EQ3_2),
274 SOC_SINGLE_TLV("EQ3 B1 Volume", MADERA_EQ3_1, MADERA_EQ3_B1_GAIN_SHIFT,
275 	       24, 0, madera_eq_tlv),
276 SOC_SINGLE_TLV("EQ3 B2 Volume", MADERA_EQ3_1, MADERA_EQ3_B2_GAIN_SHIFT,
277 	       24, 0, madera_eq_tlv),
278 SOC_SINGLE_TLV("EQ3 B3 Volume", MADERA_EQ3_1, MADERA_EQ3_B3_GAIN_SHIFT,
279 	       24, 0, madera_eq_tlv),
280 SOC_SINGLE_TLV("EQ3 B4 Volume", MADERA_EQ3_2, MADERA_EQ3_B4_GAIN_SHIFT,
281 	       24, 0, madera_eq_tlv),
282 SOC_SINGLE_TLV("EQ3 B5 Volume", MADERA_EQ3_2, MADERA_EQ3_B5_GAIN_SHIFT,
283 	       24, 0, madera_eq_tlv),
284 
285 MADERA_EQ_CONTROL("EQ4 Coefficients", MADERA_EQ4_2),
286 SOC_SINGLE_TLV("EQ4 B1 Volume", MADERA_EQ4_1, MADERA_EQ4_B1_GAIN_SHIFT,
287 	       24, 0, madera_eq_tlv),
288 SOC_SINGLE_TLV("EQ4 B2 Volume", MADERA_EQ4_1, MADERA_EQ4_B2_GAIN_SHIFT,
289 	       24, 0, madera_eq_tlv),
290 SOC_SINGLE_TLV("EQ4 B3 Volume", MADERA_EQ4_1, MADERA_EQ4_B3_GAIN_SHIFT,
291 	       24, 0, madera_eq_tlv),
292 SOC_SINGLE_TLV("EQ4 B4 Volume", MADERA_EQ4_2, MADERA_EQ4_B4_GAIN_SHIFT,
293 	       24, 0, madera_eq_tlv),
294 SOC_SINGLE_TLV("EQ4 B5 Volume", MADERA_EQ4_2, MADERA_EQ4_B5_GAIN_SHIFT,
295 	       24, 0, madera_eq_tlv),
296 
297 MADERA_MIXER_CONTROLS("DRC1L", MADERA_DRC1LMIX_INPUT_1_SOURCE),
298 MADERA_MIXER_CONTROLS("DRC1R", MADERA_DRC1RMIX_INPUT_1_SOURCE),
299 MADERA_MIXER_CONTROLS("DRC2L", MADERA_DRC2LMIX_INPUT_1_SOURCE),
300 MADERA_MIXER_CONTROLS("DRC2R", MADERA_DRC2RMIX_INPUT_1_SOURCE),
301 
302 SND_SOC_BYTES_MASK("DRC1", MADERA_DRC1_CTRL1, 5,
303 		   MADERA_DRC1R_ENA | MADERA_DRC1L_ENA),
304 SND_SOC_BYTES_MASK("DRC2", MADERA_DRC2_CTRL1, 5,
305 		   MADERA_DRC2R_ENA | MADERA_DRC2L_ENA),
306 
307 MADERA_MIXER_CONTROLS("LHPF1", MADERA_HPLP1MIX_INPUT_1_SOURCE),
308 MADERA_MIXER_CONTROLS("LHPF2", MADERA_HPLP2MIX_INPUT_1_SOURCE),
309 MADERA_MIXER_CONTROLS("LHPF3", MADERA_HPLP3MIX_INPUT_1_SOURCE),
310 MADERA_MIXER_CONTROLS("LHPF4", MADERA_HPLP4MIX_INPUT_1_SOURCE),
311 
312 MADERA_LHPF_CONTROL("LHPF1 Coefficients", MADERA_HPLPF1_2),
313 MADERA_LHPF_CONTROL("LHPF2 Coefficients", MADERA_HPLPF2_2),
314 MADERA_LHPF_CONTROL("LHPF3 Coefficients", MADERA_HPLPF3_2),
315 MADERA_LHPF_CONTROL("LHPF4 Coefficients", MADERA_HPLPF4_2),
316 
317 SOC_ENUM("LHPF1 Mode", madera_lhpf1_mode),
318 SOC_ENUM("LHPF2 Mode", madera_lhpf2_mode),
319 SOC_ENUM("LHPF3 Mode", madera_lhpf3_mode),
320 SOC_ENUM("LHPF4 Mode", madera_lhpf4_mode),
321 
322 MADERA_RATE_ENUM("ISRC1 FSL", madera_isrc_fsl[0]),
323 MADERA_RATE_ENUM("ISRC2 FSL", madera_isrc_fsl[1]),
324 MADERA_RATE_ENUM("ISRC1 FSH", madera_isrc_fsh[0]),
325 MADERA_RATE_ENUM("ISRC2 FSH", madera_isrc_fsh[1]),
326 
327 WM_ADSP2_PRELOAD_SWITCH("DSP1", 1),
328 WM_ADSP2_PRELOAD_SWITCH("DSP2", 2),
329 WM_ADSP2_PRELOAD_SWITCH("DSP3", 3),
330 
331 MADERA_MIXER_CONTROLS("DSP1L", MADERA_DSP1LMIX_INPUT_1_SOURCE),
332 MADERA_MIXER_CONTROLS("DSP1R", MADERA_DSP1RMIX_INPUT_1_SOURCE),
333 MADERA_MIXER_CONTROLS("DSP2L", MADERA_DSP2LMIX_INPUT_1_SOURCE),
334 MADERA_MIXER_CONTROLS("DSP2R", MADERA_DSP2RMIX_INPUT_1_SOURCE),
335 MADERA_MIXER_CONTROLS("DSP3L", MADERA_DSP3LMIX_INPUT_1_SOURCE),
336 MADERA_MIXER_CONTROLS("DSP3R", MADERA_DSP3RMIX_INPUT_1_SOURCE),
337 
338 SOC_SINGLE_TLV("Noise Generator Volume", MADERA_COMFORT_NOISE_GENERATOR,
339 	       MADERA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, madera_noise_tlv),
340 
341 MADERA_MIXER_CONTROLS("HPOUT1L", MADERA_OUT1LMIX_INPUT_1_SOURCE),
342 MADERA_MIXER_CONTROLS("HPOUT1R", MADERA_OUT1RMIX_INPUT_1_SOURCE),
343 MADERA_MIXER_CONTROLS("SPKOUT", MADERA_OUT4LMIX_INPUT_1_SOURCE),
344 MADERA_MIXER_CONTROLS("SPKDAT1L", MADERA_OUT5LMIX_INPUT_1_SOURCE),
345 MADERA_MIXER_CONTROLS("SPKDAT1R", MADERA_OUT5RMIX_INPUT_1_SOURCE),
346 
347 SOC_SINGLE("HPOUT1 SC Protect Switch", MADERA_HP1_SHORT_CIRCUIT_CTRL,
348 	   MADERA_HP1_SC_ENA_SHIFT, 1, 0),
349 
350 SOC_SINGLE("SPKDAT1 High Performance Switch", MADERA_OUTPUT_PATH_CONFIG_5L,
351 	   MADERA_OUT5_OSR_SHIFT, 1, 0),
352 
353 SOC_DOUBLE_R("HPOUT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_1L,
354 	     MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_MUTE_SHIFT, 1, 1),
355 SOC_SINGLE("Speaker Digital Switch", MADERA_DAC_DIGITAL_VOLUME_4L,
356 	   MADERA_OUT4L_MUTE_SHIFT, 1, 1),
357 SOC_DOUBLE_R("SPKDAT1 Digital Switch", MADERA_DAC_DIGITAL_VOLUME_5L,
358 	     MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_MUTE_SHIFT, 1, 1),
359 
360 SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_1L,
361 		 MADERA_DAC_DIGITAL_VOLUME_1R, MADERA_OUT1L_VOL_SHIFT,
362 		 0xbf, 0, madera_digital_tlv),
363 SOC_SINGLE_TLV("Speaker Digital Volume", MADERA_DAC_DIGITAL_VOLUME_4L,
364 	       MADERA_OUT4L_VOL_SHIFT, 0xbf, 0, madera_digital_tlv),
365 SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", MADERA_DAC_DIGITAL_VOLUME_5L,
366 		 MADERA_DAC_DIGITAL_VOLUME_5R, MADERA_OUT5L_VOL_SHIFT,
367 		 0xbf, 0, madera_digital_tlv),
368 
369 SOC_DOUBLE("SPKDAT1 Switch", MADERA_PDM_SPK1_CTRL_1, MADERA_SPK1L_MUTE_SHIFT,
370 	   MADERA_SPK1R_MUTE_SHIFT, 1, 1),
371 
372 SOC_ENUM("Output Ramp Up", madera_out_vi_ramp),
373 SOC_ENUM("Output Ramp Down", madera_out_vd_ramp),
374 
375 SOC_SINGLE("Noise Gate Switch", MADERA_NOISE_GATE_CONTROL,
376 	   MADERA_NGATE_ENA_SHIFT, 1, 0),
377 SOC_SINGLE_TLV("Noise Gate Threshold Volume", MADERA_NOISE_GATE_CONTROL,
378 	       MADERA_NGATE_THR_SHIFT, 7, 1, madera_ng_tlv),
379 SOC_ENUM("Noise Gate Hold", madera_ng_hold),
380 
381 CS47L35_NG_SRC("HPOUT1L", MADERA_NOISE_GATE_SELECT_1L),
382 CS47L35_NG_SRC("HPOUT1R", MADERA_NOISE_GATE_SELECT_1R),
383 CS47L35_NG_SRC("SPKOUT", MADERA_NOISE_GATE_SELECT_4L),
384 CS47L35_NG_SRC("SPKDAT1L", MADERA_NOISE_GATE_SELECT_5L),
385 CS47L35_NG_SRC("SPKDAT1R", MADERA_NOISE_GATE_SELECT_5R),
386 
387 MADERA_MIXER_CONTROLS("AIF1TX1", MADERA_AIF1TX1MIX_INPUT_1_SOURCE),
388 MADERA_MIXER_CONTROLS("AIF1TX2", MADERA_AIF1TX2MIX_INPUT_1_SOURCE),
389 MADERA_MIXER_CONTROLS("AIF1TX3", MADERA_AIF1TX3MIX_INPUT_1_SOURCE),
390 MADERA_MIXER_CONTROLS("AIF1TX4", MADERA_AIF1TX4MIX_INPUT_1_SOURCE),
391 MADERA_MIXER_CONTROLS("AIF1TX5", MADERA_AIF1TX5MIX_INPUT_1_SOURCE),
392 MADERA_MIXER_CONTROLS("AIF1TX6", MADERA_AIF1TX6MIX_INPUT_1_SOURCE),
393 
394 MADERA_MIXER_CONTROLS("AIF2TX1", MADERA_AIF2TX1MIX_INPUT_1_SOURCE),
395 MADERA_MIXER_CONTROLS("AIF2TX2", MADERA_AIF2TX2MIX_INPUT_1_SOURCE),
396 
397 MADERA_MIXER_CONTROLS("AIF3TX1", MADERA_AIF3TX1MIX_INPUT_1_SOURCE),
398 MADERA_MIXER_CONTROLS("AIF3TX2", MADERA_AIF3TX2MIX_INPUT_1_SOURCE),
399 
400 MADERA_MIXER_CONTROLS("SLIMTX1", MADERA_SLIMTX1MIX_INPUT_1_SOURCE),
401 MADERA_MIXER_CONTROLS("SLIMTX2", MADERA_SLIMTX2MIX_INPUT_1_SOURCE),
402 MADERA_MIXER_CONTROLS("SLIMTX3", MADERA_SLIMTX3MIX_INPUT_1_SOURCE),
403 MADERA_MIXER_CONTROLS("SLIMTX4", MADERA_SLIMTX4MIX_INPUT_1_SOURCE),
404 MADERA_MIXER_CONTROLS("SLIMTX5", MADERA_SLIMTX5MIX_INPUT_1_SOURCE),
405 MADERA_MIXER_CONTROLS("SLIMTX6", MADERA_SLIMTX6MIX_INPUT_1_SOURCE),
406 
407 MADERA_GAINMUX_CONTROLS("SPDIF1TX1", MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE),
408 MADERA_GAINMUX_CONTROLS("SPDIF1TX2", MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE),
409 
410 WM_ADSP_FW_CONTROL("DSP1", 0),
411 WM_ADSP_FW_CONTROL("DSP2", 1),
412 WM_ADSP_FW_CONTROL("DSP3", 2),
413 };
414 
415 MADERA_MIXER_ENUMS(EQ1, MADERA_EQ1MIX_INPUT_1_SOURCE);
416 MADERA_MIXER_ENUMS(EQ2, MADERA_EQ2MIX_INPUT_1_SOURCE);
417 MADERA_MIXER_ENUMS(EQ3, MADERA_EQ3MIX_INPUT_1_SOURCE);
418 MADERA_MIXER_ENUMS(EQ4, MADERA_EQ4MIX_INPUT_1_SOURCE);
419 
420 MADERA_MIXER_ENUMS(DRC1L, MADERA_DRC1LMIX_INPUT_1_SOURCE);
421 MADERA_MIXER_ENUMS(DRC1R, MADERA_DRC1RMIX_INPUT_1_SOURCE);
422 MADERA_MIXER_ENUMS(DRC2L, MADERA_DRC2LMIX_INPUT_1_SOURCE);
423 MADERA_MIXER_ENUMS(DRC2R, MADERA_DRC2RMIX_INPUT_1_SOURCE);
424 
425 MADERA_MIXER_ENUMS(LHPF1, MADERA_HPLP1MIX_INPUT_1_SOURCE);
426 MADERA_MIXER_ENUMS(LHPF2, MADERA_HPLP2MIX_INPUT_1_SOURCE);
427 MADERA_MIXER_ENUMS(LHPF3, MADERA_HPLP3MIX_INPUT_1_SOURCE);
428 MADERA_MIXER_ENUMS(LHPF4, MADERA_HPLP4MIX_INPUT_1_SOURCE);
429 
430 MADERA_MIXER_ENUMS(DSP1L, MADERA_DSP1LMIX_INPUT_1_SOURCE);
431 MADERA_MIXER_ENUMS(DSP1R, MADERA_DSP1RMIX_INPUT_1_SOURCE);
432 MADERA_DSP_AUX_ENUMS(DSP1, MADERA_DSP1AUX1MIX_INPUT_1_SOURCE);
433 
434 MADERA_MIXER_ENUMS(DSP2L, MADERA_DSP2LMIX_INPUT_1_SOURCE);
435 MADERA_MIXER_ENUMS(DSP2R, MADERA_DSP2RMIX_INPUT_1_SOURCE);
436 MADERA_DSP_AUX_ENUMS(DSP2, MADERA_DSP2AUX1MIX_INPUT_1_SOURCE);
437 
438 MADERA_MIXER_ENUMS(DSP3L, MADERA_DSP3LMIX_INPUT_1_SOURCE);
439 MADERA_MIXER_ENUMS(DSP3R, MADERA_DSP3RMIX_INPUT_1_SOURCE);
440 MADERA_DSP_AUX_ENUMS(DSP3, MADERA_DSP3AUX1MIX_INPUT_1_SOURCE);
441 
442 MADERA_MIXER_ENUMS(PWM1, MADERA_PWM1MIX_INPUT_1_SOURCE);
443 MADERA_MIXER_ENUMS(PWM2, MADERA_PWM2MIX_INPUT_1_SOURCE);
444 
445 MADERA_MIXER_ENUMS(OUT1L, MADERA_OUT1LMIX_INPUT_1_SOURCE);
446 MADERA_MIXER_ENUMS(OUT1R, MADERA_OUT1RMIX_INPUT_1_SOURCE);
447 MADERA_MIXER_ENUMS(SPKOUT, MADERA_OUT4LMIX_INPUT_1_SOURCE);
448 MADERA_MIXER_ENUMS(SPKDAT1L, MADERA_OUT5LMIX_INPUT_1_SOURCE);
449 MADERA_MIXER_ENUMS(SPKDAT1R, MADERA_OUT5RMIX_INPUT_1_SOURCE);
450 
451 MADERA_MIXER_ENUMS(AIF1TX1, MADERA_AIF1TX1MIX_INPUT_1_SOURCE);
452 MADERA_MIXER_ENUMS(AIF1TX2, MADERA_AIF1TX2MIX_INPUT_1_SOURCE);
453 MADERA_MIXER_ENUMS(AIF1TX3, MADERA_AIF1TX3MIX_INPUT_1_SOURCE);
454 MADERA_MIXER_ENUMS(AIF1TX4, MADERA_AIF1TX4MIX_INPUT_1_SOURCE);
455 MADERA_MIXER_ENUMS(AIF1TX5, MADERA_AIF1TX5MIX_INPUT_1_SOURCE);
456 MADERA_MIXER_ENUMS(AIF1TX6, MADERA_AIF1TX6MIX_INPUT_1_SOURCE);
457 
458 MADERA_MIXER_ENUMS(AIF2TX1, MADERA_AIF2TX1MIX_INPUT_1_SOURCE);
459 MADERA_MIXER_ENUMS(AIF2TX2, MADERA_AIF2TX2MIX_INPUT_1_SOURCE);
460 
461 MADERA_MIXER_ENUMS(AIF3TX1, MADERA_AIF3TX1MIX_INPUT_1_SOURCE);
462 MADERA_MIXER_ENUMS(AIF3TX2, MADERA_AIF3TX2MIX_INPUT_1_SOURCE);
463 
464 MADERA_MIXER_ENUMS(SLIMTX1, MADERA_SLIMTX1MIX_INPUT_1_SOURCE);
465 MADERA_MIXER_ENUMS(SLIMTX2, MADERA_SLIMTX2MIX_INPUT_1_SOURCE);
466 MADERA_MIXER_ENUMS(SLIMTX3, MADERA_SLIMTX3MIX_INPUT_1_SOURCE);
467 MADERA_MIXER_ENUMS(SLIMTX4, MADERA_SLIMTX4MIX_INPUT_1_SOURCE);
468 MADERA_MIXER_ENUMS(SLIMTX5, MADERA_SLIMTX5MIX_INPUT_1_SOURCE);
469 MADERA_MIXER_ENUMS(SLIMTX6, MADERA_SLIMTX6MIX_INPUT_1_SOURCE);
470 
471 MADERA_MUX_ENUMS(SPD1TX1, MADERA_SPDIF1TX1MIX_INPUT_1_SOURCE);
472 MADERA_MUX_ENUMS(SPD1TX2, MADERA_SPDIF1TX2MIX_INPUT_1_SOURCE);
473 
474 MADERA_MUX_ENUMS(ISRC1INT1, MADERA_ISRC1INT1MIX_INPUT_1_SOURCE);
475 MADERA_MUX_ENUMS(ISRC1INT2, MADERA_ISRC1INT2MIX_INPUT_1_SOURCE);
476 MADERA_MUX_ENUMS(ISRC1INT3, MADERA_ISRC1INT3MIX_INPUT_1_SOURCE);
477 MADERA_MUX_ENUMS(ISRC1INT4, MADERA_ISRC1INT4MIX_INPUT_1_SOURCE);
478 
479 MADERA_MUX_ENUMS(ISRC1DEC1, MADERA_ISRC1DEC1MIX_INPUT_1_SOURCE);
480 MADERA_MUX_ENUMS(ISRC1DEC2, MADERA_ISRC1DEC2MIX_INPUT_1_SOURCE);
481 MADERA_MUX_ENUMS(ISRC1DEC3, MADERA_ISRC1DEC3MIX_INPUT_1_SOURCE);
482 MADERA_MUX_ENUMS(ISRC1DEC4, MADERA_ISRC1DEC4MIX_INPUT_1_SOURCE);
483 
484 MADERA_MUX_ENUMS(ISRC2INT1, MADERA_ISRC2INT1MIX_INPUT_1_SOURCE);
485 MADERA_MUX_ENUMS(ISRC2INT2, MADERA_ISRC2INT2MIX_INPUT_1_SOURCE);
486 MADERA_MUX_ENUMS(ISRC2INT3, MADERA_ISRC2INT3MIX_INPUT_1_SOURCE);
487 MADERA_MUX_ENUMS(ISRC2INT4, MADERA_ISRC2INT4MIX_INPUT_1_SOURCE);
488 
489 MADERA_MUX_ENUMS(ISRC2DEC1, MADERA_ISRC2DEC1MIX_INPUT_1_SOURCE);
490 MADERA_MUX_ENUMS(ISRC2DEC2, MADERA_ISRC2DEC2MIX_INPUT_1_SOURCE);
491 MADERA_MUX_ENUMS(ISRC2DEC3, MADERA_ISRC2DEC3MIX_INPUT_1_SOURCE);
492 MADERA_MUX_ENUMS(ISRC2DEC4, MADERA_ISRC2DEC4MIX_INPUT_1_SOURCE);
493 
494 static const char * const cs47l35_aec_loopback_texts[] = {
495 	"HPOUT1L", "HPOUT1R", "SPKOUT", "SPKDAT1L", "SPKDAT1R",
496 };
497 
498 static const unsigned int cs47l35_aec_loopback_values[] = {
499 	0, 1, 6, 8, 9,
500 };
501 
502 static const struct soc_enum cs47l35_aec1_loopback =
503 	SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_1,
504 			      MADERA_AEC1_LOOPBACK_SRC_SHIFT, 0xf,
505 			      ARRAY_SIZE(cs47l35_aec_loopback_texts),
506 			      cs47l35_aec_loopback_texts,
507 			      cs47l35_aec_loopback_values);
508 
509 static const struct soc_enum cs47l35_aec2_loopback =
510 	SOC_VALUE_ENUM_SINGLE(MADERA_DAC_AEC_CONTROL_2,
511 			      MADERA_AEC2_LOOPBACK_SRC_SHIFT, 0xf,
512 			      ARRAY_SIZE(cs47l35_aec_loopback_texts),
513 			      cs47l35_aec_loopback_texts,
514 			      cs47l35_aec_loopback_values);
515 
516 static const struct snd_kcontrol_new cs47l35_aec_loopback_mux[] = {
517 	SOC_DAPM_ENUM("AEC1 Loopback", cs47l35_aec1_loopback),
518 	SOC_DAPM_ENUM("AEC2 Loopback", cs47l35_aec2_loopback),
519 };
520 
521 static const struct snd_soc_dapm_widget cs47l35_dapm_widgets[] = {
522 SND_SOC_DAPM_SUPPLY("SYSCLK", MADERA_SYSTEM_CLOCK_1, MADERA_SYSCLK_ENA_SHIFT,
523 		    0, madera_sysclk_ev,
524 		    SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
525 SND_SOC_DAPM_SUPPLY("OPCLK", MADERA_OUTPUT_SYSTEM_CLOCK,
526 		    MADERA_OPCLK_ENA_SHIFT, 0, NULL, 0),
527 SND_SOC_DAPM_SUPPLY("DSPCLK", MADERA_DSP_CLOCK_1, MADERA_DSP_CLK_ENA_SHIFT,
528 		    0, NULL, 0),
529 
530 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
531 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD1", 20, 0),
532 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD2", 20, 0),
533 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
534 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
535 
536 SND_SOC_DAPM_SUPPLY("MICBIAS1", MADERA_MIC_BIAS_CTRL_1,
537 		    MADERA_MICB1_ENA_SHIFT, 0, NULL, 0),
538 SND_SOC_DAPM_SUPPLY("MICBIAS2", MADERA_MIC_BIAS_CTRL_2,
539 		    MADERA_MICB1_ENA_SHIFT, 0, NULL, 0),
540 
541 SND_SOC_DAPM_SUPPLY("MICBIAS1A", MADERA_MIC_BIAS_CTRL_5,
542 		    MADERA_MICB1A_ENA_SHIFT, 0, NULL, 0),
543 SND_SOC_DAPM_SUPPLY("MICBIAS1B", MADERA_MIC_BIAS_CTRL_5,
544 		    MADERA_MICB1B_ENA_SHIFT, 0, NULL, 0),
545 SND_SOC_DAPM_SUPPLY("MICBIAS2A", MADERA_MIC_BIAS_CTRL_6,
546 		    MADERA_MICB2A_ENA_SHIFT, 0, NULL, 0),
547 SND_SOC_DAPM_SUPPLY("MICBIAS2B", MADERA_MIC_BIAS_CTRL_6,
548 		    MADERA_MICB2B_ENA_SHIFT, 0, NULL, 0),
549 
550 SND_SOC_DAPM_SUPPLY("FXCLK", SND_SOC_NOPM,
551 		    MADERA_DOM_GRP_FX, 0,
552 		    madera_domain_clk_ev,
553 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
554 SND_SOC_DAPM_SUPPLY("ISRC1CLK", SND_SOC_NOPM,
555 		    MADERA_DOM_GRP_ISRC1, 0,
556 		    madera_domain_clk_ev,
557 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
558 SND_SOC_DAPM_SUPPLY("ISRC2CLK", SND_SOC_NOPM,
559 		    MADERA_DOM_GRP_ISRC2, 0,
560 		    madera_domain_clk_ev,
561 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
562 SND_SOC_DAPM_SUPPLY("OUTCLK", SND_SOC_NOPM,
563 		    MADERA_DOM_GRP_OUT, 0,
564 		    madera_domain_clk_ev,
565 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
566 SND_SOC_DAPM_SUPPLY("SPDCLK", SND_SOC_NOPM,
567 		    MADERA_DOM_GRP_SPD, 0,
568 		    madera_domain_clk_ev,
569 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
570 SND_SOC_DAPM_SUPPLY("DSP1CLK", SND_SOC_NOPM,
571 		    MADERA_DOM_GRP_DSP1, 0,
572 		    madera_domain_clk_ev,
573 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
574 SND_SOC_DAPM_SUPPLY("DSP2CLK", SND_SOC_NOPM,
575 		    MADERA_DOM_GRP_DSP2, 0,
576 		    madera_domain_clk_ev,
577 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
578 SND_SOC_DAPM_SUPPLY("DSP3CLK", SND_SOC_NOPM,
579 		    MADERA_DOM_GRP_DSP3, 0,
580 		    madera_domain_clk_ev,
581 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
582 SND_SOC_DAPM_SUPPLY("AIF1TXCLK", SND_SOC_NOPM,
583 		    MADERA_DOM_GRP_AIF1, 0,
584 		    madera_domain_clk_ev,
585 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
586 SND_SOC_DAPM_SUPPLY("AIF2TXCLK", SND_SOC_NOPM,
587 		    MADERA_DOM_GRP_AIF2, 0,
588 		    madera_domain_clk_ev,
589 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
590 SND_SOC_DAPM_SUPPLY("AIF3TXCLK", SND_SOC_NOPM,
591 		    MADERA_DOM_GRP_AIF3, 0,
592 		    madera_domain_clk_ev,
593 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
594 SND_SOC_DAPM_SUPPLY("SLIMBUSCLK", SND_SOC_NOPM,
595 		    MADERA_DOM_GRP_SLIMBUS, 0,
596 		    madera_domain_clk_ev,
597 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
598 SND_SOC_DAPM_SUPPLY("PWMCLK", SND_SOC_NOPM,
599 		    MADERA_DOM_GRP_PWM, 0,
600 		    madera_domain_clk_ev,
601 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
602 
603 SND_SOC_DAPM_SIGGEN("TONE"),
604 SND_SOC_DAPM_SIGGEN("NOISE"),
605 
606 SND_SOC_DAPM_INPUT("IN1ALN"),
607 SND_SOC_DAPM_INPUT("IN1ALP"),
608 SND_SOC_DAPM_INPUT("IN1BLN"),
609 SND_SOC_DAPM_INPUT("IN1BLP"),
610 SND_SOC_DAPM_INPUT("IN1ARN"),
611 SND_SOC_DAPM_INPUT("IN1ARP"),
612 SND_SOC_DAPM_INPUT("IN1BRN"),
613 SND_SOC_DAPM_INPUT("IN1BRP"),
614 SND_SOC_DAPM_INPUT("IN2LN"),
615 SND_SOC_DAPM_INPUT("IN2LP"),
616 SND_SOC_DAPM_INPUT("IN2RN"),
617 SND_SOC_DAPM_INPUT("IN2RP"),
618 
619 SND_SOC_DAPM_MUX("IN1L Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[0]),
620 SND_SOC_DAPM_MUX("IN1R Analog Mux", SND_SOC_NOPM, 0, 0, &madera_inmux[1]),
621 
622 SND_SOC_DAPM_MUX("IN1L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]),
623 SND_SOC_DAPM_MUX("IN1R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[0]),
624 
625 SND_SOC_DAPM_MUX("IN2L Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]),
626 SND_SOC_DAPM_MUX("IN2R Mode", SND_SOC_NOPM, 0, 0, &madera_inmode[1]),
627 
628 SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
629 SND_SOC_DAPM_OUTPUT("DRC2 Signal Activity"),
630 
631 SND_SOC_DAPM_OUTPUT("DSP Trigger Out"),
632 
633 SND_SOC_DAPM_DEMUX("HPOUT1 Demux", SND_SOC_NOPM, 0, 0, &cs47l35_outdemux),
634 
635 SND_SOC_DAPM_PGA("PWM1 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM1_ENA_SHIFT,
636 		 0, NULL, 0),
637 SND_SOC_DAPM_PGA("PWM2 Driver", MADERA_PWM_DRIVE_1, MADERA_PWM2_ENA_SHIFT,
638 		 0, NULL, 0),
639 
640 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
641 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX1_ENA_SHIFT, 0),
642 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
643 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX2_ENA_SHIFT, 0),
644 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
645 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX3_ENA_SHIFT, 0),
646 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
647 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX4_ENA_SHIFT, 0),
648 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
649 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX5_ENA_SHIFT, 0),
650 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
651 		     MADERA_AIF1_TX_ENABLES, MADERA_AIF1TX6_ENA_SHIFT, 0),
652 
653 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
654 		     MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX1_ENA_SHIFT, 0),
655 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
656 		     MADERA_AIF2_TX_ENABLES, MADERA_AIF2TX2_ENA_SHIFT, 0),
657 
658 SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
659 		     MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX1_ENA_SHIFT, 0),
660 SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
661 		     MADERA_AIF3_TX_ENABLES, MADERA_AIF3TX2_ENA_SHIFT, 0),
662 
663 SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0,
664 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
665 		     MADERA_SLIMTX1_ENA_SHIFT, 0),
666 SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 0,
667 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
668 		     MADERA_SLIMTX2_ENA_SHIFT, 0),
669 SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 0,
670 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
671 		     MADERA_SLIMTX3_ENA_SHIFT, 0),
672 SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 0,
673 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
674 		     MADERA_SLIMTX4_ENA_SHIFT, 0),
675 SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 0,
676 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
677 		     MADERA_SLIMTX5_ENA_SHIFT, 0),
678 SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 0,
679 		     MADERA_SLIMBUS_TX_CHANNEL_ENABLE,
680 		     MADERA_SLIMTX6_ENA_SHIFT, 0),
681 
682 SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
683 		   MADERA_OUT1L_ENA_SHIFT, 0, NULL, 0, cs47l35_hp_ev,
684 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
685 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
686 SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
687 		   MADERA_OUT1R_ENA_SHIFT, 0, NULL, 0, cs47l35_hp_ev,
688 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
689 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
690 SND_SOC_DAPM_PGA_E("OUT4L", SND_SOC_NOPM,
691 		   MADERA_OUT4L_ENA_SHIFT, 0, NULL, 0, madera_spk_ev,
692 		   SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
693 SND_SOC_DAPM_PGA_E("OUT5L", MADERA_OUTPUT_ENABLES_1,
694 		   MADERA_OUT5L_ENA_SHIFT, 0, NULL, 0, madera_out_ev,
695 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
696 SND_SOC_DAPM_PGA_E("OUT5R", MADERA_OUTPUT_ENABLES_1,
697 		   MADERA_OUT5R_ENA_SHIFT, 0, NULL, 0, madera_out_ev,
698 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
699 
700 SND_SOC_DAPM_PGA("SPD1TX1", MADERA_SPD1_TX_CONTROL,
701 		 MADERA_SPD1_VAL1_SHIFT, 0, NULL, 0),
702 SND_SOC_DAPM_PGA("SPD1TX2", MADERA_SPD1_TX_CONTROL,
703 		 MADERA_SPD1_VAL2_SHIFT, 0, NULL, 0),
704 SND_SOC_DAPM_OUT_DRV("SPD1", MADERA_SPD1_TX_CONTROL,
705 		     MADERA_SPD1_ENA_SHIFT, 0, NULL, 0),
706 
707 /*
708  * Input mux widgets arranged in order of sources in MADERA_MIXER_INPUT_ROUTES
709  * to take advantage of cache lookup in DAPM
710  */
711 SND_SOC_DAPM_PGA("Noise Generator", MADERA_COMFORT_NOISE_GENERATOR,
712 		 MADERA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
713 
714 SND_SOC_DAPM_PGA("Tone Generator 1", MADERA_TONE_GENERATOR_1,
715 		 MADERA_TONE1_ENA_SHIFT, 0, NULL, 0),
716 SND_SOC_DAPM_PGA("Tone Generator 2", MADERA_TONE_GENERATOR_1,
717 		 MADERA_TONE2_ENA_SHIFT, 0, NULL, 0),
718 
719 SND_SOC_DAPM_SIGGEN("HAPTICS"),
720 
721 SND_SOC_DAPM_MUX("AEC1 Loopback", MADERA_DAC_AEC_CONTROL_1,
722 		 MADERA_AEC1_LOOPBACK_ENA_SHIFT, 0,
723 		 &cs47l35_aec_loopback_mux[0]),
724 
725 SND_SOC_DAPM_MUX("AEC2 Loopback", MADERA_DAC_AEC_CONTROL_2,
726 		 MADERA_AEC2_LOOPBACK_ENA_SHIFT, 0,
727 		 &cs47l35_aec_loopback_mux[1]),
728 
729 SND_SOC_DAPM_PGA_E("IN1L", MADERA_INPUT_ENABLES, MADERA_IN1L_ENA_SHIFT,
730 		   0, NULL, 0, madera_in_ev,
731 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
732 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
733 SND_SOC_DAPM_PGA_E("IN1R", MADERA_INPUT_ENABLES, MADERA_IN1R_ENA_SHIFT,
734 		   0, NULL, 0, madera_in_ev,
735 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
736 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
737 
738 SND_SOC_DAPM_PGA_E("IN2L", MADERA_INPUT_ENABLES, MADERA_IN2L_ENA_SHIFT,
739 		   0, NULL, 0, madera_in_ev,
740 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
741 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
742 SND_SOC_DAPM_PGA_E("IN2R", MADERA_INPUT_ENABLES, MADERA_IN2R_ENA_SHIFT,
743 		   0, NULL, 0, madera_in_ev,
744 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
745 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
746 
747 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
748 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX1_ENA_SHIFT, 0),
749 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
750 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX2_ENA_SHIFT, 0),
751 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
752 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX3_ENA_SHIFT, 0),
753 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
754 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX4_ENA_SHIFT, 0),
755 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
756 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX5_ENA_SHIFT, 0),
757 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
758 		    MADERA_AIF1_RX_ENABLES, MADERA_AIF1RX6_ENA_SHIFT, 0),
759 
760 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
761 		    MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX1_ENA_SHIFT, 0),
762 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
763 		    MADERA_AIF2_RX_ENABLES, MADERA_AIF2RX2_ENA_SHIFT, 0),
764 
765 SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
766 		    MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX1_ENA_SHIFT, 0),
767 SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
768 		    MADERA_AIF3_RX_ENABLES, MADERA_AIF3RX2_ENA_SHIFT, 0),
769 
770 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0,
771 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
772 		    MADERA_SLIMRX1_ENA_SHIFT, 0),
773 SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 0,
774 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
775 		    MADERA_SLIMRX2_ENA_SHIFT, 0),
776 SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 0,
777 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
778 		    MADERA_SLIMRX3_ENA_SHIFT, 0),
779 SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 0,
780 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
781 		    MADERA_SLIMRX4_ENA_SHIFT, 0),
782 SND_SOC_DAPM_AIF_IN("SLIMRX5", NULL, 0,
783 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
784 		    MADERA_SLIMRX5_ENA_SHIFT, 0),
785 SND_SOC_DAPM_AIF_IN("SLIMRX6", NULL, 0,
786 		    MADERA_SLIMBUS_RX_CHANNEL_ENABLE,
787 		    MADERA_SLIMRX6_ENA_SHIFT, 0),
788 
789 SND_SOC_DAPM_PGA("EQ1", MADERA_EQ1_1, MADERA_EQ1_ENA_SHIFT, 0, NULL, 0),
790 SND_SOC_DAPM_PGA("EQ2", MADERA_EQ2_1, MADERA_EQ2_ENA_SHIFT, 0, NULL, 0),
791 SND_SOC_DAPM_PGA("EQ3", MADERA_EQ3_1, MADERA_EQ3_ENA_SHIFT, 0, NULL, 0),
792 SND_SOC_DAPM_PGA("EQ4", MADERA_EQ4_1, MADERA_EQ4_ENA_SHIFT, 0, NULL, 0),
793 
794 SND_SOC_DAPM_PGA("DRC1L", MADERA_DRC1_CTRL1, MADERA_DRC1L_ENA_SHIFT, 0,
795 		 NULL, 0),
796 SND_SOC_DAPM_PGA("DRC1R", MADERA_DRC1_CTRL1, MADERA_DRC1R_ENA_SHIFT, 0,
797 		 NULL, 0),
798 SND_SOC_DAPM_PGA("DRC2L", MADERA_DRC2_CTRL1, MADERA_DRC2L_ENA_SHIFT, 0,
799 		 NULL, 0),
800 SND_SOC_DAPM_PGA("DRC2R", MADERA_DRC2_CTRL1, MADERA_DRC2R_ENA_SHIFT, 0,
801 		 NULL, 0),
802 
803 SND_SOC_DAPM_PGA("LHPF1", MADERA_HPLPF1_1, MADERA_LHPF1_ENA_SHIFT, 0,
804 		 NULL, 0),
805 SND_SOC_DAPM_PGA("LHPF2", MADERA_HPLPF2_1, MADERA_LHPF2_ENA_SHIFT, 0,
806 		 NULL, 0),
807 SND_SOC_DAPM_PGA("LHPF3", MADERA_HPLPF3_1, MADERA_LHPF3_ENA_SHIFT, 0,
808 		 NULL, 0),
809 SND_SOC_DAPM_PGA("LHPF4", MADERA_HPLPF4_1, MADERA_LHPF4_ENA_SHIFT, 0,
810 		 NULL, 0),
811 
812 SND_SOC_DAPM_PGA("ISRC1DEC1", MADERA_ISRC_1_CTRL_3,
813 		 MADERA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
814 SND_SOC_DAPM_PGA("ISRC1DEC2", MADERA_ISRC_1_CTRL_3,
815 		 MADERA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0),
816 SND_SOC_DAPM_PGA("ISRC1DEC3", MADERA_ISRC_1_CTRL_3,
817 		 MADERA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0),
818 SND_SOC_DAPM_PGA("ISRC1DEC4", MADERA_ISRC_1_CTRL_3,
819 		 MADERA_ISRC1_DEC4_ENA_SHIFT, 0, NULL, 0),
820 
821 SND_SOC_DAPM_PGA("ISRC1INT1", MADERA_ISRC_1_CTRL_3,
822 		 MADERA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
823 SND_SOC_DAPM_PGA("ISRC1INT2", MADERA_ISRC_1_CTRL_3,
824 		 MADERA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0),
825 SND_SOC_DAPM_PGA("ISRC1INT3", MADERA_ISRC_1_CTRL_3,
826 		 MADERA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0),
827 SND_SOC_DAPM_PGA("ISRC1INT4", MADERA_ISRC_1_CTRL_3,
828 		 MADERA_ISRC1_INT4_ENA_SHIFT, 0, NULL, 0),
829 
830 SND_SOC_DAPM_PGA("ISRC2DEC1", MADERA_ISRC_2_CTRL_3,
831 		 MADERA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
832 SND_SOC_DAPM_PGA("ISRC2DEC2", MADERA_ISRC_2_CTRL_3,
833 		 MADERA_ISRC2_DEC2_ENA_SHIFT, 0, NULL, 0),
834 SND_SOC_DAPM_PGA("ISRC2DEC3", MADERA_ISRC_2_CTRL_3,
835 		 MADERA_ISRC2_DEC3_ENA_SHIFT, 0, NULL, 0),
836 SND_SOC_DAPM_PGA("ISRC2DEC4", MADERA_ISRC_2_CTRL_3,
837 		 MADERA_ISRC2_DEC4_ENA_SHIFT, 0, NULL, 0),
838 
839 SND_SOC_DAPM_PGA("ISRC2INT1", MADERA_ISRC_2_CTRL_3,
840 		 MADERA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
841 SND_SOC_DAPM_PGA("ISRC2INT2", MADERA_ISRC_2_CTRL_3,
842 		 MADERA_ISRC2_INT2_ENA_SHIFT, 0, NULL, 0),
843 SND_SOC_DAPM_PGA("ISRC2INT3", MADERA_ISRC_2_CTRL_3,
844 		 MADERA_ISRC2_INT3_ENA_SHIFT, 0, NULL, 0),
845 SND_SOC_DAPM_PGA("ISRC2INT4", MADERA_ISRC_2_CTRL_3,
846 		 MADERA_ISRC2_INT4_ENA_SHIFT, 0, NULL, 0),
847 
848 WM_ADSP2("DSP1", 0, cs47l35_adsp_power_ev),
849 WM_ADSP2("DSP2", 1, cs47l35_adsp_power_ev),
850 WM_ADSP2("DSP3", 2, cs47l35_adsp_power_ev),
851 
852 /* End of ordered input mux widgets */
853 
854 MADERA_MIXER_WIDGETS(EQ1, "EQ1"),
855 MADERA_MIXER_WIDGETS(EQ2, "EQ2"),
856 MADERA_MIXER_WIDGETS(EQ3, "EQ3"),
857 MADERA_MIXER_WIDGETS(EQ4, "EQ4"),
858 
859 MADERA_MIXER_WIDGETS(DRC1L, "DRC1L"),
860 MADERA_MIXER_WIDGETS(DRC1R, "DRC1R"),
861 MADERA_MIXER_WIDGETS(DRC2L, "DRC2L"),
862 MADERA_MIXER_WIDGETS(DRC2R, "DRC2R"),
863 
864 SND_SOC_DAPM_SWITCH("DRC1 Activity Output", SND_SOC_NOPM, 0, 0,
865 		    &madera_drc_activity_output_mux[0]),
866 SND_SOC_DAPM_SWITCH("DRC2 Activity Output", SND_SOC_NOPM, 0, 0,
867 		    &madera_drc_activity_output_mux[1]),
868 
869 MADERA_MIXER_WIDGETS(LHPF1, "LHPF1"),
870 MADERA_MIXER_WIDGETS(LHPF2, "LHPF2"),
871 MADERA_MIXER_WIDGETS(LHPF3, "LHPF3"),
872 MADERA_MIXER_WIDGETS(LHPF4, "LHPF4"),
873 
874 MADERA_MIXER_WIDGETS(PWM1, "PWM1"),
875 MADERA_MIXER_WIDGETS(PWM2, "PWM2"),
876 
877 MADERA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
878 MADERA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
879 MADERA_MIXER_WIDGETS(SPKOUT, "SPKOUT"),
880 MADERA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
881 MADERA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
882 
883 MADERA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
884 MADERA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
885 MADERA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
886 MADERA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
887 MADERA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
888 MADERA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
889 
890 MADERA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
891 MADERA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
892 
893 MADERA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
894 MADERA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
895 
896 MADERA_MIXER_WIDGETS(SLIMTX1, "SLIMTX1"),
897 MADERA_MIXER_WIDGETS(SLIMTX2, "SLIMTX2"),
898 MADERA_MIXER_WIDGETS(SLIMTX3, "SLIMTX3"),
899 MADERA_MIXER_WIDGETS(SLIMTX4, "SLIMTX4"),
900 MADERA_MIXER_WIDGETS(SLIMTX5, "SLIMTX5"),
901 MADERA_MIXER_WIDGETS(SLIMTX6, "SLIMTX6"),
902 
903 MADERA_MUX_WIDGETS(SPD1TX1, "SPDIF1TX1"),
904 MADERA_MUX_WIDGETS(SPD1TX2, "SPDIF1TX2"),
905 
906 MADERA_DSP_WIDGETS(DSP1, "DSP1"),
907 MADERA_DSP_WIDGETS(DSP2, "DSP2"),
908 MADERA_DSP_WIDGETS(DSP3, "DSP3"),
909 
910 SND_SOC_DAPM_SWITCH("DSP1 Trigger Output", SND_SOC_NOPM, 0, 0,
911 		    &madera_dsp_trigger_output_mux[0]),
912 SND_SOC_DAPM_SWITCH("DSP2 Trigger Output", SND_SOC_NOPM, 0, 0,
913 		    &madera_dsp_trigger_output_mux[1]),
914 SND_SOC_DAPM_SWITCH("DSP3 Trigger Output", SND_SOC_NOPM, 0, 0,
915 		    &madera_dsp_trigger_output_mux[2]),
916 
917 MADERA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
918 MADERA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
919 MADERA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"),
920 MADERA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"),
921 
922 MADERA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
923 MADERA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
924 MADERA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"),
925 MADERA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"),
926 
927 MADERA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
928 MADERA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
929 MADERA_MUX_WIDGETS(ISRC2DEC3, "ISRC2DEC3"),
930 MADERA_MUX_WIDGETS(ISRC2DEC4, "ISRC2DEC4"),
931 
932 MADERA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
933 MADERA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
934 MADERA_MUX_WIDGETS(ISRC2INT3, "ISRC2INT3"),
935 MADERA_MUX_WIDGETS(ISRC2INT4, "ISRC2INT4"),
936 
937 SND_SOC_DAPM_OUTPUT("HPOUTL"),
938 SND_SOC_DAPM_OUTPUT("HPOUTR"),
939 SND_SOC_DAPM_OUTPUT("EPOUTP"),
940 SND_SOC_DAPM_OUTPUT("EPOUTN"),
941 SND_SOC_DAPM_OUTPUT("SPKOUTN"),
942 SND_SOC_DAPM_OUTPUT("SPKOUTP"),
943 SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
944 SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
945 SND_SOC_DAPM_OUTPUT("SPDIF1"),
946 
947 SND_SOC_DAPM_OUTPUT("MICSUPP"),
948 };
949 
950 #define MADERA_MIXER_INPUT_ROUTES(name)	\
951 	{ name, "Noise Generator", "Noise Generator" }, \
952 	{ name, "Tone Generator 1", "Tone Generator 1" }, \
953 	{ name, "Tone Generator 2", "Tone Generator 2" }, \
954 	{ name, "Haptics", "HAPTICS" }, \
955 	{ name, "AEC1", "AEC1 Loopback" }, \
956 	{ name, "AEC2", "AEC2 Loopback" }, \
957 	{ name, "IN1L", "IN1L" }, \
958 	{ name, "IN1R", "IN1R" }, \
959 	{ name, "IN2L", "IN2L" }, \
960 	{ name, "IN2R", "IN2R" }, \
961 	{ name, "AIF1RX1", "AIF1RX1" }, \
962 	{ name, "AIF1RX2", "AIF1RX2" }, \
963 	{ name, "AIF1RX3", "AIF1RX3" }, \
964 	{ name, "AIF1RX4", "AIF1RX4" }, \
965 	{ name, "AIF1RX5", "AIF1RX5" }, \
966 	{ name, "AIF1RX6", "AIF1RX6" }, \
967 	{ name, "AIF2RX1", "AIF2RX1" }, \
968 	{ name, "AIF2RX2", "AIF2RX2" }, \
969 	{ name, "AIF3RX1", "AIF3RX1" }, \
970 	{ name, "AIF3RX2", "AIF3RX2" }, \
971 	{ name, "SLIMRX1", "SLIMRX1" }, \
972 	{ name, "SLIMRX2", "SLIMRX2" }, \
973 	{ name, "SLIMRX3", "SLIMRX3" }, \
974 	{ name, "SLIMRX4", "SLIMRX4" }, \
975 	{ name, "SLIMRX5", "SLIMRX5" }, \
976 	{ name, "SLIMRX6", "SLIMRX6" }, \
977 	{ name, "EQ1", "EQ1" }, \
978 	{ name, "EQ2", "EQ2" }, \
979 	{ name, "EQ3", "EQ3" }, \
980 	{ name, "EQ4", "EQ4" }, \
981 	{ name, "DRC1L", "DRC1L" }, \
982 	{ name, "DRC1R", "DRC1R" }, \
983 	{ name, "DRC2L", "DRC2L" }, \
984 	{ name, "DRC2R", "DRC2R" }, \
985 	{ name, "LHPF1", "LHPF1" }, \
986 	{ name, "LHPF2", "LHPF2" }, \
987 	{ name, "LHPF3", "LHPF3" }, \
988 	{ name, "LHPF4", "LHPF4" }, \
989 	{ name, "ISRC1DEC1", "ISRC1DEC1" }, \
990 	{ name, "ISRC1DEC2", "ISRC1DEC2" }, \
991 	{ name, "ISRC1DEC3", "ISRC1DEC3" }, \
992 	{ name, "ISRC1DEC4", "ISRC1DEC4" }, \
993 	{ name, "ISRC1INT1", "ISRC1INT1" }, \
994 	{ name, "ISRC1INT2", "ISRC1INT2" }, \
995 	{ name, "ISRC1INT3", "ISRC1INT3" }, \
996 	{ name, "ISRC1INT4", "ISRC1INT4" }, \
997 	{ name, "ISRC2DEC1", "ISRC2DEC1" }, \
998 	{ name, "ISRC2DEC2", "ISRC2DEC2" }, \
999 	{ name, "ISRC2DEC3", "ISRC2DEC3" }, \
1000 	{ name, "ISRC2DEC4", "ISRC2DEC4" }, \
1001 	{ name, "ISRC2INT1", "ISRC2INT1" }, \
1002 	{ name, "ISRC2INT2", "ISRC2INT2" }, \
1003 	{ name, "ISRC2INT3", "ISRC2INT3" }, \
1004 	{ name, "ISRC2INT4", "ISRC2INT4" }, \
1005 	{ name, "DSP1.1", "DSP1" }, \
1006 	{ name, "DSP1.2", "DSP1" }, \
1007 	{ name, "DSP1.3", "DSP1" }, \
1008 	{ name, "DSP1.4", "DSP1" }, \
1009 	{ name, "DSP1.5", "DSP1" }, \
1010 	{ name, "DSP1.6", "DSP1" }, \
1011 	{ name, "DSP2.1", "DSP2" }, \
1012 	{ name, "DSP2.2", "DSP2" }, \
1013 	{ name, "DSP2.3", "DSP2" }, \
1014 	{ name, "DSP2.4", "DSP2" }, \
1015 	{ name, "DSP2.5", "DSP2" }, \
1016 	{ name, "DSP2.6", "DSP2" }, \
1017 	{ name, "DSP3.1", "DSP3" }, \
1018 	{ name, "DSP3.2", "DSP3" }, \
1019 	{ name, "DSP3.3", "DSP3" }, \
1020 	{ name, "DSP3.4", "DSP3" }, \
1021 	{ name, "DSP3.5", "DSP3" }, \
1022 	{ name, "DSP3.6", "DSP3" }
1023 
1024 static const struct snd_soc_dapm_route cs47l35_dapm_routes[] = {
1025 	/* Internal clock domains */
1026 	{ "EQ1", NULL, "FXCLK" },
1027 	{ "EQ2", NULL, "FXCLK" },
1028 	{ "EQ3", NULL, "FXCLK" },
1029 	{ "EQ4", NULL, "FXCLK" },
1030 	{ "DRC1L", NULL, "FXCLK" },
1031 	{ "DRC1R", NULL, "FXCLK" },
1032 	{ "DRC2L", NULL, "FXCLK" },
1033 	{ "DRC2R", NULL, "FXCLK" },
1034 	{ "LHPF1", NULL, "FXCLK" },
1035 	{ "LHPF2", NULL, "FXCLK" },
1036 	{ "LHPF3", NULL, "FXCLK" },
1037 	{ "LHPF4", NULL, "FXCLK" },
1038 	{ "PWM1 Mixer", NULL, "PWMCLK" },
1039 	{ "PWM2 Mixer", NULL, "PWMCLK" },
1040 	{ "OUT1L", NULL, "OUTCLK" },
1041 	{ "OUT1R", NULL, "OUTCLK" },
1042 	{ "OUT4L", NULL, "OUTCLK" },
1043 	{ "OUT5L", NULL, "OUTCLK" },
1044 	{ "OUT5R", NULL, "OUTCLK" },
1045 	{ "AIF1TX1", NULL, "AIF1TXCLK" },
1046 	{ "AIF1TX2", NULL, "AIF1TXCLK" },
1047 	{ "AIF1TX3", NULL, "AIF1TXCLK" },
1048 	{ "AIF1TX4", NULL, "AIF1TXCLK" },
1049 	{ "AIF1TX5", NULL, "AIF1TXCLK" },
1050 	{ "AIF1TX6", NULL, "AIF1TXCLK" },
1051 	{ "AIF2TX1", NULL, "AIF2TXCLK" },
1052 	{ "AIF2TX2", NULL, "AIF2TXCLK" },
1053 	{ "AIF3TX1", NULL, "AIF3TXCLK" },
1054 	{ "AIF3TX2", NULL, "AIF3TXCLK" },
1055 	{ "SLIMTX1", NULL, "SLIMBUSCLK" },
1056 	{ "SLIMTX2", NULL, "SLIMBUSCLK" },
1057 	{ "SLIMTX3", NULL, "SLIMBUSCLK" },
1058 	{ "SLIMTX4", NULL, "SLIMBUSCLK" },
1059 	{ "SLIMTX5", NULL, "SLIMBUSCLK" },
1060 	{ "SLIMTX6", NULL, "SLIMBUSCLK" },
1061 	{ "SPD1TX1", NULL, "SPDCLK" },
1062 	{ "SPD1TX2", NULL, "SPDCLK" },
1063 	{ "DSP1", NULL, "DSP1CLK" },
1064 	{ "DSP2", NULL, "DSP2CLK" },
1065 	{ "DSP3", NULL, "DSP3CLK" },
1066 	{ "ISRC1DEC1", NULL, "ISRC1CLK" },
1067 	{ "ISRC1DEC2", NULL, "ISRC1CLK" },
1068 	{ "ISRC1DEC3", NULL, "ISRC1CLK" },
1069 	{ "ISRC1DEC4", NULL, "ISRC1CLK" },
1070 	{ "ISRC1INT1", NULL, "ISRC1CLK" },
1071 	{ "ISRC1INT2", NULL, "ISRC1CLK" },
1072 	{ "ISRC1INT3", NULL, "ISRC1CLK" },
1073 	{ "ISRC1INT4", NULL, "ISRC1CLK" },
1074 	{ "ISRC2DEC1", NULL, "ISRC2CLK" },
1075 	{ "ISRC2DEC2", NULL, "ISRC2CLK" },
1076 	{ "ISRC2DEC3", NULL, "ISRC2CLK" },
1077 	{ "ISRC2DEC4", NULL, "ISRC2CLK" },
1078 	{ "ISRC2INT1", NULL, "ISRC2CLK" },
1079 	{ "ISRC2INT2", NULL, "ISRC2CLK" },
1080 	{ "ISRC2INT3", NULL, "ISRC2CLK" },
1081 	{ "ISRC2INT4", NULL, "ISRC2CLK" },
1082 
1083 	{ "AIF2 Capture", NULL, "DBVDD2" },
1084 	{ "AIF2 Playback", NULL, "DBVDD2" },
1085 
1086 	{ "AIF3 Capture", NULL, "DBVDD2" },
1087 	{ "AIF3 Playback", NULL, "DBVDD2" },
1088 
1089 	{ "OUT1L", NULL, "CPVDD1" },
1090 	{ "OUT1R", NULL, "CPVDD1" },
1091 	{ "OUT1L", NULL, "CPVDD2" },
1092 	{ "OUT1R", NULL, "CPVDD2" },
1093 
1094 	{ "OUT4L", NULL, "SPKVDD" },
1095 
1096 	{ "OUT1L", NULL, "SYSCLK" },
1097 	{ "OUT1R", NULL, "SYSCLK" },
1098 	{ "OUT4L", NULL, "SYSCLK" },
1099 	{ "OUT5L", NULL, "SYSCLK" },
1100 	{ "OUT5R", NULL, "SYSCLK" },
1101 
1102 	{ "SPD1", NULL, "SYSCLK" },
1103 	{ "SPD1", NULL, "SPD1TX1" },
1104 	{ "SPD1", NULL, "SPD1TX2" },
1105 
1106 	{ "IN1L", NULL, "SYSCLK" },
1107 	{ "IN1R", NULL, "SYSCLK" },
1108 	{ "IN2L", NULL, "SYSCLK" },
1109 	{ "IN2R", NULL, "SYSCLK" },
1110 
1111 	{ "MICBIAS1", NULL, "MICVDD" },
1112 	{ "MICBIAS2", NULL, "MICVDD" },
1113 
1114 	{ "MICBIAS1A", NULL, "MICBIAS1" },
1115 	{ "MICBIAS1B", NULL, "MICBIAS1" },
1116 	{ "MICBIAS2A", NULL, "MICBIAS2" },
1117 	{ "MICBIAS2B", NULL, "MICBIAS2" },
1118 
1119 	{ "Noise Generator", NULL, "SYSCLK" },
1120 	{ "Tone Generator 1", NULL, "SYSCLK" },
1121 	{ "Tone Generator 2", NULL, "SYSCLK" },
1122 
1123 	{ "Noise Generator", NULL, "NOISE" },
1124 	{ "Tone Generator 1", NULL, "TONE" },
1125 	{ "Tone Generator 2", NULL, "TONE" },
1126 
1127 	{ "AIF1 Capture", NULL, "AIF1TX1" },
1128 	{ "AIF1 Capture", NULL, "AIF1TX2" },
1129 	{ "AIF1 Capture", NULL, "AIF1TX3" },
1130 	{ "AIF1 Capture", NULL, "AIF1TX4" },
1131 	{ "AIF1 Capture", NULL, "AIF1TX5" },
1132 	{ "AIF1 Capture", NULL, "AIF1TX6" },
1133 
1134 	{ "AIF1RX1", NULL, "AIF1 Playback" },
1135 	{ "AIF1RX2", NULL, "AIF1 Playback" },
1136 	{ "AIF1RX3", NULL, "AIF1 Playback" },
1137 	{ "AIF1RX4", NULL, "AIF1 Playback" },
1138 	{ "AIF1RX5", NULL, "AIF1 Playback" },
1139 	{ "AIF1RX6", NULL, "AIF1 Playback" },
1140 
1141 	{ "AIF2 Capture", NULL, "AIF2TX1" },
1142 	{ "AIF2 Capture", NULL, "AIF2TX2" },
1143 
1144 	{ "AIF2RX1", NULL, "AIF2 Playback" },
1145 	{ "AIF2RX2", NULL, "AIF2 Playback" },
1146 
1147 	{ "AIF3 Capture", NULL, "AIF3TX1" },
1148 	{ "AIF3 Capture", NULL, "AIF3TX2" },
1149 
1150 	{ "AIF3RX1", NULL, "AIF3 Playback" },
1151 	{ "AIF3RX2", NULL, "AIF3 Playback" },
1152 
1153 	{ "Slim1 Capture", NULL, "SLIMTX1" },
1154 	{ "Slim1 Capture", NULL, "SLIMTX2" },
1155 	{ "Slim1 Capture", NULL, "SLIMTX3" },
1156 	{ "Slim1 Capture", NULL, "SLIMTX4" },
1157 
1158 	{ "SLIMRX1", NULL, "Slim1 Playback" },
1159 	{ "SLIMRX2", NULL, "Slim1 Playback" },
1160 	{ "SLIMRX3", NULL, "Slim1 Playback" },
1161 	{ "SLIMRX4", NULL, "Slim1 Playback" },
1162 
1163 	{ "Slim2 Capture", NULL, "SLIMTX5" },
1164 	{ "Slim2 Capture", NULL, "SLIMTX6" },
1165 
1166 	{ "SLIMRX5", NULL, "Slim2 Playback" },
1167 	{ "SLIMRX6", NULL, "Slim2 Playback" },
1168 
1169 	{ "AIF1 Playback", NULL, "SYSCLK" },
1170 	{ "AIF2 Playback", NULL, "SYSCLK" },
1171 	{ "AIF3 Playback", NULL, "SYSCLK" },
1172 	{ "Slim1 Playback", NULL, "SYSCLK" },
1173 	{ "Slim2 Playback", NULL, "SYSCLK" },
1174 
1175 	{ "AIF1 Capture", NULL, "SYSCLK" },
1176 	{ "AIF2 Capture", NULL, "SYSCLK" },
1177 	{ "AIF3 Capture", NULL, "SYSCLK" },
1178 	{ "Slim1 Capture", NULL, "SYSCLK" },
1179 	{ "Slim2 Capture", NULL, "SYSCLK" },
1180 
1181 	{ "Voice Control DSP", NULL, "DSP3" },
1182 
1183 	{ "Audio Trace DSP", NULL, "DSP1" },
1184 
1185 	{ "IN1L Analog Mux", "A", "IN1ALN" },
1186 	{ "IN1L Analog Mux", "A", "IN1ALP" },
1187 	{ "IN1L Analog Mux", "B", "IN1BLN" },
1188 	{ "IN1L Analog Mux", "B", "IN1BLP" },
1189 
1190 	{ "IN1R Analog Mux", "A", "IN1ARN" },
1191 	{ "IN1R Analog Mux", "A", "IN1ARP" },
1192 	{ "IN1R Analog Mux", "B", "IN1BRN" },
1193 	{ "IN1R Analog Mux", "B", "IN1BRP" },
1194 
1195 	{ "IN1L Mode", "Analog", "IN1L Analog Mux" },
1196 	{ "IN1R Mode", "Analog", "IN1R Analog Mux" },
1197 
1198 	{ "IN1L Mode", "Digital", "IN1ALN" },
1199 	{ "IN1L Mode", "Digital", "IN1ARN" },
1200 	{ "IN1R Mode", "Digital", "IN1ALN" },
1201 	{ "IN1R Mode", "Digital", "IN1ARN" },
1202 
1203 	{ "IN1L", NULL, "IN1L Mode" },
1204 	{ "IN1R", NULL, "IN1R Mode" },
1205 
1206 	{ "IN2L Mode", "Analog", "IN2LN" },
1207 	{ "IN2L Mode", "Analog", "IN2LP" },
1208 	{ "IN2R Mode", "Analog", "IN2RN" },
1209 	{ "IN2R Mode", "Analog", "IN2RP" },
1210 
1211 	{ "IN2L Mode", "Digital", "IN2LN" },
1212 	{ "IN2L Mode", "Digital", "IN2RN" },
1213 	{ "IN2R Mode", "Digital", "IN2LN" },
1214 	{ "IN2R Mode", "Digital", "IN2RN" },
1215 
1216 	{ "IN2L", NULL, "IN2L Mode" },
1217 	{ "IN2R", NULL, "IN2R Mode" },
1218 
1219 	MADERA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
1220 	MADERA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
1221 
1222 	MADERA_MIXER_ROUTES("OUT4L", "SPKOUT"),
1223 
1224 	MADERA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
1225 	MADERA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
1226 
1227 	MADERA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
1228 	MADERA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
1229 
1230 	MADERA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
1231 	MADERA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
1232 	MADERA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
1233 	MADERA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
1234 	MADERA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
1235 	MADERA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
1236 
1237 	MADERA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
1238 	MADERA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
1239 
1240 	MADERA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
1241 	MADERA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
1242 
1243 	MADERA_MIXER_ROUTES("SLIMTX1", "SLIMTX1"),
1244 	MADERA_MIXER_ROUTES("SLIMTX2", "SLIMTX2"),
1245 	MADERA_MIXER_ROUTES("SLIMTX3", "SLIMTX3"),
1246 	MADERA_MIXER_ROUTES("SLIMTX4", "SLIMTX4"),
1247 	MADERA_MIXER_ROUTES("SLIMTX5", "SLIMTX5"),
1248 	MADERA_MIXER_ROUTES("SLIMTX6", "SLIMTX6"),
1249 
1250 	MADERA_MUX_ROUTES("SPD1TX1", "SPDIF1TX1"),
1251 	MADERA_MUX_ROUTES("SPD1TX2", "SPDIF1TX2"),
1252 
1253 	MADERA_MIXER_ROUTES("EQ1", "EQ1"),
1254 	MADERA_MIXER_ROUTES("EQ2", "EQ2"),
1255 	MADERA_MIXER_ROUTES("EQ3", "EQ3"),
1256 	MADERA_MIXER_ROUTES("EQ4", "EQ4"),
1257 
1258 	MADERA_MIXER_ROUTES("DRC1L", "DRC1L"),
1259 	MADERA_MIXER_ROUTES("DRC1R", "DRC1R"),
1260 	MADERA_MIXER_ROUTES("DRC2L", "DRC2L"),
1261 	MADERA_MIXER_ROUTES("DRC2R", "DRC2R"),
1262 
1263 	MADERA_MIXER_ROUTES("LHPF1", "LHPF1"),
1264 	MADERA_MIXER_ROUTES("LHPF2", "LHPF2"),
1265 	MADERA_MIXER_ROUTES("LHPF3", "LHPF3"),
1266 	MADERA_MIXER_ROUTES("LHPF4", "LHPF4"),
1267 
1268 	MADERA_DSP_ROUTES("DSP1"),
1269 	MADERA_DSP_ROUTES("DSP2"),
1270 	MADERA_DSP_ROUTES("DSP3"),
1271 
1272 	{ "DSP Trigger Out", NULL, "DSP1 Trigger Output" },
1273 	{ "DSP Trigger Out", NULL, "DSP2 Trigger Output" },
1274 	{ "DSP Trigger Out", NULL, "DSP3 Trigger Output" },
1275 
1276 	{ "DSP1 Trigger Output", "Switch", "DSP1" },
1277 	{ "DSP2 Trigger Output", "Switch", "DSP2" },
1278 	{ "DSP3 Trigger Output", "Switch", "DSP3" },
1279 
1280 	MADERA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
1281 	MADERA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
1282 	MADERA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"),
1283 	MADERA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"),
1284 
1285 	MADERA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
1286 	MADERA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
1287 	MADERA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"),
1288 	MADERA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"),
1289 
1290 	MADERA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
1291 	MADERA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
1292 	MADERA_MUX_ROUTES("ISRC2INT3", "ISRC2INT3"),
1293 	MADERA_MUX_ROUTES("ISRC2INT4", "ISRC2INT4"),
1294 
1295 	MADERA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
1296 	MADERA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
1297 	MADERA_MUX_ROUTES("ISRC2DEC3", "ISRC2DEC3"),
1298 	MADERA_MUX_ROUTES("ISRC2DEC4", "ISRC2DEC4"),
1299 
1300 	{ "AEC1 Loopback", "HPOUT1L", "OUT1L" },
1301 	{ "AEC1 Loopback", "HPOUT1R", "OUT1R" },
1302 	{ "AEC2 Loopback", "HPOUT1L", "OUT1L" },
1303 	{ "AEC2 Loopback", "HPOUT1R", "OUT1R" },
1304 	{ "HPOUT1 Demux", NULL, "OUT1L" },
1305 	{ "HPOUT1 Demux", NULL, "OUT1R" },
1306 
1307 	{ "AEC1 Loopback", "SPKOUT", "OUT4L" },
1308 	{ "AEC2 Loopback", "SPKOUT", "OUT4L" },
1309 	{ "SPKOUTN", NULL, "OUT4L" },
1310 	{ "SPKOUTP", NULL, "OUT4L" },
1311 
1312 	{ "HPOUTL", "HPOUT", "HPOUT1 Demux" },
1313 	{ "HPOUTR", "HPOUT", "HPOUT1 Demux" },
1314 	{ "EPOUTP", "EPOUT", "HPOUT1 Demux" },
1315 	{ "EPOUTN", "EPOUT", "HPOUT1 Demux" },
1316 
1317 	{ "AEC1 Loopback", "SPKDAT1L", "OUT5L" },
1318 	{ "AEC1 Loopback", "SPKDAT1R", "OUT5R" },
1319 	{ "AEC2 Loopback", "SPKDAT1L", "OUT5L" },
1320 	{ "AEC2 Loopback", "SPKDAT1R", "OUT5R" },
1321 	{ "SPKDAT1L", NULL, "OUT5L" },
1322 	{ "SPKDAT1R", NULL, "OUT5R" },
1323 
1324 	{ "SPDIF1", NULL, "SPD1" },
1325 
1326 	{ "MICSUPP", NULL, "SYSCLK" },
1327 
1328 	{ "DRC1 Signal Activity", NULL, "DRC1 Activity Output" },
1329 	{ "DRC2 Signal Activity", NULL, "DRC2 Activity Output" },
1330 	{ "DRC1 Activity Output", "Switch", "DRC1L" },
1331 	{ "DRC1 Activity Output", "Switch", "DRC1R" },
1332 	{ "DRC2 Activity Output", "Switch", "DRC2L" },
1333 	{ "DRC2 Activity Output", "Switch", "DRC2R" },
1334 };
1335 
1336 static int cs47l35_set_fll(struct snd_soc_component *component, int fll_id,
1337 			   int source, unsigned int fref, unsigned int fout)
1338 {
1339 	struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component);
1340 
1341 	switch (fll_id) {
1342 	case MADERA_FLL1_REFCLK:
1343 		return madera_set_fll_refclk(&cs47l35->fll, source, fref,
1344 					     fout);
1345 	case MADERA_FLL1_SYNCCLK:
1346 		return madera_set_fll_syncclk(&cs47l35->fll, source, fref,
1347 					      fout);
1348 	default:
1349 		return -EINVAL;
1350 	}
1351 }
1352 
1353 static struct snd_soc_dai_driver cs47l35_dai[] = {
1354 	{
1355 		.name = "cs47l35-aif1",
1356 		.id = 1,
1357 		.base = MADERA_AIF1_BCLK_CTRL,
1358 		.playback = {
1359 			.stream_name = "AIF1 Playback",
1360 			.channels_min = 1,
1361 			.channels_max = 6,
1362 			.rates = MADERA_RATES,
1363 			.formats = MADERA_FORMATS,
1364 		},
1365 		.capture = {
1366 			.stream_name = "AIF1 Capture",
1367 			.channels_min = 1,
1368 			.channels_max = 6,
1369 			.rates = MADERA_RATES,
1370 			.formats = MADERA_FORMATS,
1371 		 },
1372 		.ops = &madera_dai_ops,
1373 		.symmetric_rates = 1,
1374 		.symmetric_samplebits = 1,
1375 	},
1376 	{
1377 		.name = "cs47l35-aif2",
1378 		.id = 2,
1379 		.base = MADERA_AIF2_BCLK_CTRL,
1380 		.playback = {
1381 			.stream_name = "AIF2 Playback",
1382 			.channels_min = 1,
1383 			.channels_max = 2,
1384 			.rates = MADERA_RATES,
1385 			.formats = MADERA_FORMATS,
1386 		},
1387 		.capture = {
1388 			.stream_name = "AIF2 Capture",
1389 			.channels_min = 1,
1390 			.channels_max = 2,
1391 			.rates = MADERA_RATES,
1392 			.formats = MADERA_FORMATS,
1393 		 },
1394 		.ops = &madera_dai_ops,
1395 		.symmetric_rates = 1,
1396 		.symmetric_samplebits = 1,
1397 	},
1398 	{
1399 		.name = "cs47l35-aif3",
1400 		.id = 3,
1401 		.base = MADERA_AIF3_BCLK_CTRL,
1402 		.playback = {
1403 			.stream_name = "AIF3 Playback",
1404 			.channels_min = 1,
1405 			.channels_max = 2,
1406 			.rates = MADERA_RATES,
1407 			.formats = MADERA_FORMATS,
1408 		},
1409 		.capture = {
1410 			.stream_name = "AIF3 Capture",
1411 			.channels_min = 1,
1412 			.channels_max = 2,
1413 			.rates = MADERA_RATES,
1414 			.formats = MADERA_FORMATS,
1415 		 },
1416 		.ops = &madera_dai_ops,
1417 		.symmetric_rates = 1,
1418 		.symmetric_samplebits = 1,
1419 	},
1420 	{
1421 		.name = "cs47l35-slim1",
1422 		.id = 4,
1423 		.playback = {
1424 			.stream_name = "Slim1 Playback",
1425 			.channels_min = 1,
1426 			.channels_max = 4,
1427 			.rates = MADERA_RATES,
1428 			.formats = MADERA_FORMATS,
1429 		},
1430 		.capture = {
1431 			.stream_name = "Slim1 Capture",
1432 			.channels_min = 1,
1433 			.channels_max = 4,
1434 			.rates = MADERA_RATES,
1435 			.formats = MADERA_FORMATS,
1436 		 },
1437 		.ops = &madera_simple_dai_ops,
1438 	},
1439 	{
1440 		.name = "cs47l35-slim2",
1441 		.id = 5,
1442 		.playback = {
1443 			.stream_name = "Slim2 Playback",
1444 			.channels_min = 1,
1445 			.channels_max = 2,
1446 			.rates = MADERA_RATES,
1447 			.formats = MADERA_FORMATS,
1448 		},
1449 		.capture = {
1450 			.stream_name = "Slim2 Capture",
1451 			.channels_min = 1,
1452 			.channels_max = 2,
1453 			.rates = MADERA_RATES,
1454 			.formats = MADERA_FORMATS,
1455 		 },
1456 		.ops = &madera_simple_dai_ops,
1457 	},
1458 	{
1459 		.name = "cs47l35-cpu-voicectrl",
1460 		.capture = {
1461 			.stream_name = "Voice Control CPU",
1462 			.channels_min = 1,
1463 			.channels_max = 1,
1464 			.rates = MADERA_RATES,
1465 			.formats = MADERA_FORMATS,
1466 		},
1467 		.compress_new = &snd_soc_new_compress,
1468 	},
1469 	{
1470 		.name = "cs47l35-dsp-voicectrl",
1471 		.capture = {
1472 			.stream_name = "Voice Control DSP",
1473 			.channels_min = 1,
1474 			.channels_max = 1,
1475 			.rates = MADERA_RATES,
1476 			.formats = MADERA_FORMATS,
1477 		},
1478 	},
1479 	{
1480 		.name = "cs47l35-cpu-trace",
1481 		.capture = {
1482 			.stream_name = "Audio Trace CPU",
1483 			.channels_min = 1,
1484 			.channels_max = 6,
1485 			.rates = MADERA_RATES,
1486 			.formats = MADERA_FORMATS,
1487 		},
1488 		.compress_new = &snd_soc_new_compress,
1489 	},
1490 	{
1491 		.name = "cs47l35-dsp-trace",
1492 		.capture = {
1493 			.stream_name = "Audio Trace DSP",
1494 			.channels_min = 1,
1495 			.channels_max = 6,
1496 			.rates = MADERA_RATES,
1497 			.formats = MADERA_FORMATS,
1498 		},
1499 	},
1500 };
1501 
1502 static int cs47l35_open(struct snd_compr_stream *stream)
1503 {
1504 	struct snd_soc_pcm_runtime *rtd = stream->private_data;
1505 	struct snd_soc_component *component =
1506 		snd_soc_rtdcom_lookup(rtd, DRV_NAME);
1507 	struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component);
1508 	struct madera_priv *priv = &cs47l35->core;
1509 	struct madera *madera = priv->madera;
1510 	int n_adsp;
1511 
1512 	if (strcmp(rtd->codec_dai->name, "cs47l35-dsp-voicectrl") == 0) {
1513 		n_adsp = 2;
1514 	} else if (strcmp(rtd->codec_dai->name, "cs47l35-dsp-trace") == 0) {
1515 		n_adsp = 0;
1516 	} else {
1517 		dev_err(madera->dev,
1518 			"No suitable compressed stream for DAI '%s'\n",
1519 			rtd->codec_dai->name);
1520 		return -EINVAL;
1521 	}
1522 
1523 	return wm_adsp_compr_open(&priv->adsp[n_adsp], stream);
1524 }
1525 
1526 static irqreturn_t cs47l35_adsp2_irq(int irq, void *data)
1527 {
1528 	struct cs47l35 *cs47l35 = data;
1529 	struct madera_priv *priv = &cs47l35->core;
1530 	struct madera *madera = priv->madera;
1531 	struct madera_voice_trigger_info trig_info;
1532 	int serviced = 0;
1533 	int i, ret;
1534 
1535 	for (i = 0; i < CS47L35_NUM_ADSP; ++i) {
1536 		ret = wm_adsp_compr_handle_irq(&priv->adsp[i]);
1537 		if (ret != -ENODEV)
1538 			serviced++;
1539 		if (ret == WM_ADSP_COMPR_VOICE_TRIGGER) {
1540 			trig_info.core_num = i + 1;
1541 			blocking_notifier_call_chain(&madera->notifier,
1542 						MADERA_NOTIFY_VOICE_TRIGGER,
1543 						&trig_info);
1544 		}
1545 	}
1546 
1547 	if (!serviced) {
1548 		dev_err(madera->dev, "Spurious compressed data IRQ\n");
1549 		return IRQ_NONE;
1550 	}
1551 
1552 	return IRQ_HANDLED;
1553 }
1554 
1555 static int cs47l35_component_probe(struct snd_soc_component *component)
1556 {
1557 	struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component);
1558 	struct madera *madera = cs47l35->core.madera;
1559 	int i, ret;
1560 
1561 	snd_soc_component_init_regmap(component, madera->regmap);
1562 
1563 	mutex_lock(&madera->dapm_ptr_lock);
1564 	madera->dapm = snd_soc_component_get_dapm(component);
1565 	mutex_unlock(&madera->dapm_ptr_lock);
1566 
1567 	ret = madera_init_inputs(component);
1568 	if (ret)
1569 		return ret;
1570 
1571 	ret = madera_init_outputs(component, CS47L35_MONO_OUTPUTS);
1572 	if (ret)
1573 		return ret;
1574 
1575 	snd_soc_component_disable_pin(component, "HAPTICS");
1576 
1577 	ret = snd_soc_add_component_controls(component,
1578 					     madera_adsp_rate_controls,
1579 					     CS47L35_NUM_ADSP);
1580 	if (ret)
1581 		return ret;
1582 
1583 	for (i = 0; i < CS47L35_NUM_ADSP; i++)
1584 		wm_adsp2_component_probe(&cs47l35->core.adsp[i], component);
1585 
1586 	return 0;
1587 }
1588 
1589 static void cs47l35_component_remove(struct snd_soc_component *component)
1590 {
1591 	struct cs47l35 *cs47l35 = snd_soc_component_get_drvdata(component);
1592 	struct madera *madera = cs47l35->core.madera;
1593 	int i;
1594 
1595 	mutex_lock(&madera->dapm_ptr_lock);
1596 	madera->dapm = NULL;
1597 	mutex_unlock(&madera->dapm_ptr_lock);
1598 
1599 	for (i = 0; i < CS47L35_NUM_ADSP; i++)
1600 		wm_adsp2_component_remove(&cs47l35->core.adsp[i], component);
1601 }
1602 
1603 #define CS47L35_DIG_VU 0x0200
1604 
1605 static unsigned int cs47l35_digital_vu[] = {
1606 	MADERA_DAC_DIGITAL_VOLUME_1L,
1607 	MADERA_DAC_DIGITAL_VOLUME_1R,
1608 	MADERA_DAC_DIGITAL_VOLUME_4L,
1609 	MADERA_DAC_DIGITAL_VOLUME_5L,
1610 	MADERA_DAC_DIGITAL_VOLUME_5R,
1611 };
1612 
1613 static const struct snd_compr_ops cs47l35_compr_ops = {
1614 	.open = &cs47l35_open,
1615 	.free = &wm_adsp_compr_free,
1616 	.set_params = &wm_adsp_compr_set_params,
1617 	.get_caps = &wm_adsp_compr_get_caps,
1618 	.trigger = &wm_adsp_compr_trigger,
1619 	.pointer = &wm_adsp_compr_pointer,
1620 	.copy = &wm_adsp_compr_copy,
1621 };
1622 
1623 static const struct snd_soc_component_driver soc_component_dev_cs47l35 = {
1624 	.probe			= &cs47l35_component_probe,
1625 	.remove			= &cs47l35_component_remove,
1626 	.set_sysclk		= &madera_set_sysclk,
1627 	.set_pll		= &cs47l35_set_fll,
1628 	.name			= DRV_NAME,
1629 	.compr_ops		= &cs47l35_compr_ops,
1630 	.controls		= cs47l35_snd_controls,
1631 	.num_controls		= ARRAY_SIZE(cs47l35_snd_controls),
1632 	.dapm_widgets		= cs47l35_dapm_widgets,
1633 	.num_dapm_widgets	= ARRAY_SIZE(cs47l35_dapm_widgets),
1634 	.dapm_routes		= cs47l35_dapm_routes,
1635 	.num_dapm_routes	= ARRAY_SIZE(cs47l35_dapm_routes),
1636 	.use_pmdown_time	= 1,
1637 	.endianness		= 1,
1638 	.non_legacy_dai_naming	= 1,
1639 };
1640 
1641 static int cs47l35_probe(struct platform_device *pdev)
1642 {
1643 	struct madera *madera = dev_get_drvdata(pdev->dev.parent);
1644 	struct cs47l35 *cs47l35;
1645 	int i, ret;
1646 
1647 	BUILD_BUG_ON(ARRAY_SIZE(cs47l35_dai) > MADERA_MAX_DAI);
1648 
1649 	/* quick exit if Madera irqchip driver hasn't completed probe */
1650 	if (!madera->irq_dev) {
1651 		dev_dbg(&pdev->dev, "irqchip driver not ready\n");
1652 		return -EPROBE_DEFER;
1653 	}
1654 
1655 	cs47l35 = devm_kzalloc(&pdev->dev, sizeof(struct cs47l35), GFP_KERNEL);
1656 	if (!cs47l35)
1657 		return -ENOMEM;
1658 	platform_set_drvdata(pdev, cs47l35);
1659 
1660 	cs47l35->core.madera = madera;
1661 	cs47l35->core.dev = &pdev->dev;
1662 	cs47l35->core.num_inputs = 4;
1663 
1664 	ret = madera_core_init(&cs47l35->core);
1665 	if (ret)
1666 		return ret;
1667 
1668 	ret = madera_init_overheat(&cs47l35->core);
1669 	if (ret)
1670 		goto error_core;
1671 
1672 	ret = madera_request_irq(madera, MADERA_IRQ_DSP_IRQ1,
1673 				 "ADSP2 Compressed IRQ", cs47l35_adsp2_irq,
1674 				 cs47l35);
1675 	if (ret) {
1676 		dev_err(&pdev->dev, "Failed to request DSP IRQ: %d\n", ret);
1677 		goto error_overheat;
1678 	}
1679 
1680 	ret = madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 1);
1681 	if (ret)
1682 		dev_warn(&pdev->dev, "Failed to set DSP IRQ wake: %d\n", ret);
1683 
1684 	for (i = 0; i < CS47L35_NUM_ADSP; i++) {
1685 		cs47l35->core.adsp[i].part = "cs47l35";
1686 		cs47l35->core.adsp[i].num = i + 1;
1687 		cs47l35->core.adsp[i].type = WMFW_ADSP2;
1688 		cs47l35->core.adsp[i].rev = 1;
1689 		cs47l35->core.adsp[i].dev = madera->dev;
1690 		cs47l35->core.adsp[i].regmap = madera->regmap_32bit;
1691 
1692 		cs47l35->core.adsp[i].base = wm_adsp2_control_bases[i];
1693 		cs47l35->core.adsp[i].mem = cs47l35_dsp_regions[i];
1694 		cs47l35->core.adsp[i].num_mems =
1695 			ARRAY_SIZE(cs47l35_dsp1_regions);
1696 
1697 		ret = wm_adsp2_init(&cs47l35->core.adsp[i]);
1698 		if (ret) {
1699 			for (--i; i >= 0; --i)
1700 				wm_adsp2_remove(&cs47l35->core.adsp[i]);
1701 			goto error_dsp_irq;
1702 		}
1703 	}
1704 
1705 	madera_init_fll(madera, 1, MADERA_FLL1_CONTROL_1 - 1, &cs47l35->fll);
1706 
1707 	for (i = 0; i < ARRAY_SIZE(cs47l35_dai); i++)
1708 		madera_init_dai(&cs47l35->core, i);
1709 
1710 	/* Latch volume update bits */
1711 	for (i = 0; i < ARRAY_SIZE(cs47l35_digital_vu); i++)
1712 		regmap_update_bits(madera->regmap, cs47l35_digital_vu[i],
1713 				   CS47L35_DIG_VU, CS47L35_DIG_VU);
1714 
1715 	pm_runtime_enable(&pdev->dev);
1716 	pm_runtime_idle(&pdev->dev);
1717 
1718 	ret = devm_snd_soc_register_component(&pdev->dev,
1719 					      &soc_component_dev_cs47l35,
1720 					      cs47l35_dai,
1721 					      ARRAY_SIZE(cs47l35_dai));
1722 	if (ret < 0) {
1723 		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
1724 		goto error_pm_runtime;
1725 	}
1726 
1727 	return ret;
1728 
1729 error_pm_runtime:
1730 	pm_runtime_disable(&pdev->dev);
1731 
1732 	for (i = 0; i < CS47L35_NUM_ADSP; i++)
1733 		wm_adsp2_remove(&cs47l35->core.adsp[i]);
1734 error_dsp_irq:
1735 	madera_set_irq_wake(madera, MADERA_IRQ_DSP_IRQ1, 0);
1736 	madera_free_irq(madera, MADERA_IRQ_DSP_IRQ1, cs47l35);
1737 error_overheat:
1738 	madera_free_overheat(&cs47l35->core);
1739 error_core:
1740 	madera_core_free(&cs47l35->core);
1741 
1742 	return ret;
1743 }
1744 
1745 static int cs47l35_remove(struct platform_device *pdev)
1746 {
1747 	struct cs47l35 *cs47l35 = platform_get_drvdata(pdev);
1748 	int i;
1749 
1750 	pm_runtime_disable(&pdev->dev);
1751 
1752 	for (i = 0; i < CS47L35_NUM_ADSP; i++)
1753 		wm_adsp2_remove(&cs47l35->core.adsp[i]);
1754 
1755 	madera_set_irq_wake(cs47l35->core.madera, MADERA_IRQ_DSP_IRQ1, 0);
1756 	madera_free_irq(cs47l35->core.madera, MADERA_IRQ_DSP_IRQ1, cs47l35);
1757 	madera_free_overheat(&cs47l35->core);
1758 	madera_core_free(&cs47l35->core);
1759 
1760 	return 0;
1761 }
1762 
1763 static struct platform_driver cs47l35_codec_driver = {
1764 	.driver = {
1765 		.name = "cs47l35-codec",
1766 	},
1767 	.probe = &cs47l35_probe,
1768 	.remove = &cs47l35_remove,
1769 };
1770 
1771 module_platform_driver(cs47l35_codec_driver);
1772 
1773 MODULE_SOFTDEP("pre: madera irq-madera arizona-micsupp");
1774 MODULE_DESCRIPTION("ASoC CS47L35 driver");
1775 MODULE_AUTHOR("Piotr Stankiewicz <piotrs@opensource.cirrus.com>");
1776 MODULE_LICENSE("GPL v2");
1777 MODULE_ALIAS("platform:cs47l35-codec");
1778