xref: /openbmc/linux/sound/soc/codecs/wm8998.c (revision e6e8c6c2)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * wm8998.c -- ALSA SoC Audio driver for WM8998 codecs
4  *
5  * Copyright 2015 Cirrus Logic, Inc.
6  *
7  * Author: Richard Fitzgerald <rf@opensource.wolfsonmicro.com>
8  */
9 
10 #include <linux/module.h>
11 #include <linux/moduleparam.h>
12 #include <linux/init.h>
13 #include <linux/delay.h>
14 #include <linux/pm.h>
15 #include <linux/pm_runtime.h>
16 #include <linux/regmap.h>
17 #include <linux/slab.h>
18 #include <sound/core.h>
19 #include <sound/pcm.h>
20 #include <sound/pcm_params.h>
21 #include <sound/soc.h>
22 #include <sound/jack.h>
23 #include <sound/initval.h>
24 #include <sound/tlv.h>
25 
26 #include <linux/mfd/arizona/core.h>
27 #include <linux/mfd/arizona/registers.h>
28 
29 #include "arizona.h"
30 #include "wm8998.h"
31 
32 struct wm8998_priv {
33 	struct arizona_priv core;
34 	struct arizona_fll fll[2];
35 };
36 
37 static int wm8998_asrc_ev(struct snd_soc_dapm_widget *w,
38 			  struct snd_kcontrol *kcontrol,
39 			  int event)
40 {
41 	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
42 	unsigned int val;
43 
44 	switch (event) {
45 	case SND_SOC_DAPM_PRE_PMU:
46 		val = snd_soc_component_read(component, ARIZONA_ASRC_RATE1);
47 		val &= ARIZONA_ASRC_RATE1_MASK;
48 		val >>= ARIZONA_ASRC_RATE1_SHIFT;
49 
50 		switch (val) {
51 		case 0:
52 		case 1:
53 		case 2:
54 			val = snd_soc_component_read(component,
55 					   ARIZONA_SAMPLE_RATE_1 + val);
56 			if (val >= 0x11) {
57 				dev_warn(component->dev,
58 					 "Unsupported ASRC rate1 (%s)\n",
59 					 arizona_sample_rate_val_to_name(val));
60 				return -EINVAL;
61 			}
62 			break;
63 		default:
64 			dev_err(component->dev,
65 				"Illegal ASRC rate1 selector (0x%x)\n",
66 				val);
67 			return -EINVAL;
68 		}
69 
70 		val = snd_soc_component_read(component, ARIZONA_ASRC_RATE2);
71 		val &= ARIZONA_ASRC_RATE2_MASK;
72 		val >>= ARIZONA_ASRC_RATE2_SHIFT;
73 
74 		switch (val) {
75 		case 8:
76 		case 9:
77 			val -= 0x8;
78 			val = snd_soc_component_read(component,
79 					   ARIZONA_ASYNC_SAMPLE_RATE_1 + val);
80 			if (val >= 0x11) {
81 				dev_warn(component->dev,
82 					 "Unsupported ASRC rate2 (%s)\n",
83 					 arizona_sample_rate_val_to_name(val));
84 				return -EINVAL;
85 			}
86 			break;
87 		default:
88 			dev_err(component->dev,
89 				"Illegal ASRC rate2 selector (0x%x)\n",
90 				val);
91 			return -EINVAL;
92 		}
93 		break;
94 	default:
95 		return -EINVAL;
96 	}
97 
98 	return 0;
99 }
100 
101 static int wm8998_inmux_put(struct snd_kcontrol *kcontrol,
102 			    struct snd_ctl_elem_value *ucontrol)
103 {
104 	struct snd_soc_component *component = snd_soc_dapm_kcontrol_component(kcontrol);
105 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
106 	struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component);
107 	struct arizona *arizona = wm8998->core.arizona;
108 	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
109 	unsigned int mode_reg, mode_index;
110 	unsigned int mux, inmode, src_val, mode_val;
111 	int change, ret;
112 
113 	mux = ucontrol->value.enumerated.item[0];
114 	if (mux > 1)
115 		return -EINVAL;
116 
117 	switch (e->reg) {
118 	case ARIZONA_ADC_DIGITAL_VOLUME_2L:
119 		mode_reg = ARIZONA_IN2L_CONTROL;
120 		mode_index = 1 + (2 * mux);
121 		break;
122 	default:
123 		mode_reg = ARIZONA_IN1L_CONTROL;
124 		mode_index = (2 * mux);
125 		break;
126 	}
127 
128 	inmode = arizona->pdata.inmode[mode_index];
129 	if (inmode & ARIZONA_INMODE_DMIC)
130 		mode_val = 1 << ARIZONA_IN1_MODE_SHIFT;
131 	else
132 		mode_val = 0;
133 
134 	src_val = mux << ARIZONA_IN1L_SRC_SHIFT;
135 	if (inmode & ARIZONA_INMODE_SE)
136 		src_val |= 1 << ARIZONA_IN1L_SRC_SE_SHIFT;
137 
138 	snd_soc_component_update_bits(component, mode_reg,
139 				      ARIZONA_IN1_MODE_MASK, mode_val);
140 
141 	change = snd_soc_component_update_bits(component, e->reg,
142 					       ARIZONA_IN1L_SRC_MASK |
143 					       ARIZONA_IN1L_SRC_SE_MASK,
144 					       src_val);
145 
146 	ret = snd_soc_dapm_mux_update_power(dapm, kcontrol,
147 					    ucontrol->value.enumerated.item[0],
148 					    e, NULL);
149 	if (ret < 0) {
150 		dev_err(arizona->dev, "Failed to update demux power state: %d\n", ret);
151 		return ret;
152 	}
153 
154 	return change;
155 }
156 
157 static const char * const wm8998_inmux_texts[] = {
158 	"A",
159 	"B",
160 };
161 
162 static SOC_ENUM_SINGLE_DECL(wm8998_in1muxl_enum,
163 			    ARIZONA_ADC_DIGITAL_VOLUME_1L,
164 			    ARIZONA_IN1L_SRC_SHIFT,
165 			    wm8998_inmux_texts);
166 
167 static SOC_ENUM_SINGLE_DECL(wm8998_in1muxr_enum,
168 			    ARIZONA_ADC_DIGITAL_VOLUME_1R,
169 			    ARIZONA_IN1R_SRC_SHIFT,
170 			    wm8998_inmux_texts);
171 
172 static SOC_ENUM_SINGLE_DECL(wm8998_in2mux_enum,
173 			    ARIZONA_ADC_DIGITAL_VOLUME_2L,
174 			    ARIZONA_IN2L_SRC_SHIFT,
175 			    wm8998_inmux_texts);
176 
177 static const struct snd_kcontrol_new wm8998_in1mux[2] = {
178 	SOC_DAPM_ENUM_EXT("IN1L Mux", wm8998_in1muxl_enum,
179 			  snd_soc_dapm_get_enum_double, wm8998_inmux_put),
180 	SOC_DAPM_ENUM_EXT("IN1R Mux", wm8998_in1muxr_enum,
181 			  snd_soc_dapm_get_enum_double, wm8998_inmux_put),
182 };
183 
184 static const struct snd_kcontrol_new wm8998_in2mux =
185 	SOC_DAPM_ENUM_EXT("IN2 Mux", wm8998_in2mux_enum,
186 			  snd_soc_dapm_get_enum_double, wm8998_inmux_put);
187 
188 static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
189 static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
190 static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
191 static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
192 
193 #define WM8998_NG_SRC(name, base) \
194 	SOC_SINGLE(name " NG HPOUTL Switch",  base,  0, 1, 0), \
195 	SOC_SINGLE(name " NG HPOUTR Switch",  base,  1, 1, 0), \
196 	SOC_SINGLE(name " NG LINEOUTL Switch",  base,  2, 1, 0), \
197 	SOC_SINGLE(name " NG LINEOUTR Switch",  base,  3, 1, 0), \
198 	SOC_SINGLE(name " NG EPOUT Switch",   base,  4, 1, 0), \
199 	SOC_SINGLE(name " NG SPKOUTL Switch",  base,  6, 1, 0), \
200 	SOC_SINGLE(name " NG SPKOUTR Switch",  base,  7, 1, 0)
201 
202 static const struct snd_kcontrol_new wm8998_snd_controls[] = {
203 SOC_ENUM("IN1 OSR", arizona_in_dmic_osr[0]),
204 SOC_ENUM("IN2 OSR", arizona_in_dmic_osr[1]),
205 
206 SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL,
207 		     ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
208 SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL,
209 		     ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
210 SOC_SINGLE_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL,
211 		     ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
212 
213 SOC_ENUM("IN HPF Cutoff Frequency", arizona_in_hpf_cut_enum),
214 
215 SOC_SINGLE("IN1L HPF Switch", ARIZONA_IN1L_CONTROL,
216 	   ARIZONA_IN1L_HPF_SHIFT, 1, 0),
217 SOC_SINGLE("IN1R HPF Switch", ARIZONA_IN1R_CONTROL,
218 	   ARIZONA_IN1R_HPF_SHIFT, 1, 0),
219 SOC_SINGLE("IN2 HPF Switch", ARIZONA_IN2L_CONTROL,
220 	   ARIZONA_IN2L_HPF_SHIFT, 1, 0),
221 
222 SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
223 	       ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
224 SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R,
225 	       ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
226 SOC_SINGLE_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
227 	       ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
228 
229 SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
230 SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
231 
232 ARIZONA_GAINMUX_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
233 ARIZONA_GAINMUX_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
234 ARIZONA_GAINMUX_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
235 ARIZONA_GAINMUX_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
236 
237 SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19),
238 SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE_SHIFT, 1, 0),
239 SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
240 	       24, 0, eq_tlv),
241 SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
242 	       24, 0, eq_tlv),
243 SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
244 	       24, 0, eq_tlv),
245 SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
246 	       24, 0, eq_tlv),
247 SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
248 	       24, 0, eq_tlv),
249 
250 SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19),
251 SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE_SHIFT, 1, 0),
252 SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
253 	       24, 0, eq_tlv),
254 SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
255 	       24, 0, eq_tlv),
256 SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
257 	       24, 0, eq_tlv),
258 SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
259 	       24, 0, eq_tlv),
260 SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
261 	       24, 0, eq_tlv),
262 
263 SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19),
264 SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE_SHIFT, 1, 0),
265 SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
266 	       24, 0, eq_tlv),
267 SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
268 	       24, 0, eq_tlv),
269 SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT,
270 	       24, 0, eq_tlv),
271 SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
272 	       24, 0, eq_tlv),
273 SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
274 	       24, 0, eq_tlv),
275 
276 SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19),
277 SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE_SHIFT, 1, 0),
278 SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
279 	       24, 0, eq_tlv),
280 SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
281 	       24, 0, eq_tlv),
282 SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT,
283 	       24, 0, eq_tlv),
284 SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT,
285 	       24, 0, eq_tlv),
286 SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT,
287 	       24, 0, eq_tlv),
288 
289 ARIZONA_GAINMUX_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
290 ARIZONA_GAINMUX_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
291 
292 SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
293 		   ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
294 
295 ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
296 ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
297 ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
298 ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
299 
300 SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
301 SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
302 SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
303 SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
304 
305 SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
306 SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
307 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
308 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
309 
310 SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
311 SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
312 SOC_ENUM("ISRC1 FSH", arizona_isrc_fsh[0]),
313 SOC_ENUM("ISRC2 FSH", arizona_isrc_fsh[1]),
314 SOC_ENUM("ASRC RATE 1", arizona_asrc_rate1),
315 
316 ARIZONA_MIXER_CONTROLS("HPOUTL", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
317 ARIZONA_MIXER_CONTROLS("HPOUTR", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
318 ARIZONA_MIXER_CONTROLS("LINEOUTL", ARIZONA_OUT2LMIX_INPUT_1_SOURCE),
319 ARIZONA_MIXER_CONTROLS("LINEOUTR", ARIZONA_OUT2RMIX_INPUT_1_SOURCE),
320 ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
321 ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
322 ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
323 ARIZONA_MIXER_CONTROLS("SPKDATL", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
324 ARIZONA_MIXER_CONTROLS("SPKDATR", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
325 
326 SOC_DOUBLE_R("HPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
327 	     ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
328 SOC_DOUBLE_R("LINEOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L,
329 	     ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1),
330 SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
331 	   ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
332 SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
333 	     ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
334 SOC_DOUBLE_R("SPKDAT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
335 	     ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
336 
337 SOC_DOUBLE_R_TLV("HPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
338 		 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
339 		 0xbf, 0, digital_tlv),
340 SOC_DOUBLE_R_TLV("LINEOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L,
341 		 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT,
342 		 0xbf, 0, digital_tlv),
343 SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
344 	       ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
345 SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
346 		 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT,
347 		 0xbf, 0, digital_tlv),
348 SOC_DOUBLE_R_TLV("SPKDAT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
349 		 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
350 		 0xbf, 0, digital_tlv),
351 
352 SOC_DOUBLE("SPKDAT Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
353 	   ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
354 
355 SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
356 SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
357 
358 SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL,
359 	   ARIZONA_NGATE_ENA_SHIFT, 1, 0),
360 SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL,
361 	       ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),
362 SOC_ENUM("Noise Gate Hold", arizona_ng_hold),
363 
364 WM8998_NG_SRC("HPOUTL", ARIZONA_NOISE_GATE_SELECT_1L),
365 WM8998_NG_SRC("HPOUTR", ARIZONA_NOISE_GATE_SELECT_1R),
366 WM8998_NG_SRC("LINEOUTL", ARIZONA_NOISE_GATE_SELECT_2L),
367 WM8998_NG_SRC("LINEOUTR", ARIZONA_NOISE_GATE_SELECT_2R),
368 WM8998_NG_SRC("EPOUT",  ARIZONA_NOISE_GATE_SELECT_3L),
369 WM8998_NG_SRC("SPKOUTL", ARIZONA_NOISE_GATE_SELECT_4L),
370 WM8998_NG_SRC("SPKOUTR", ARIZONA_NOISE_GATE_SELECT_4R),
371 WM8998_NG_SRC("SPKDATL", ARIZONA_NOISE_GATE_SELECT_5L),
372 WM8998_NG_SRC("SPKDATR", ARIZONA_NOISE_GATE_SELECT_5R),
373 
374 ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
375 ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
376 ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
377 ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
378 ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
379 ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
380 
381 ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
382 ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
383 ARIZONA_MIXER_CONTROLS("AIF2TX3", ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE),
384 ARIZONA_MIXER_CONTROLS("AIF2TX4", ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE),
385 ARIZONA_MIXER_CONTROLS("AIF2TX5", ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE),
386 ARIZONA_MIXER_CONTROLS("AIF2TX6", ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE),
387 
388 ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
389 ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
390 
391 ARIZONA_GAINMUX_CONTROLS("SLIMTX1", ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE),
392 ARIZONA_GAINMUX_CONTROLS("SLIMTX2", ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE),
393 ARIZONA_GAINMUX_CONTROLS("SLIMTX3", ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE),
394 ARIZONA_GAINMUX_CONTROLS("SLIMTX4", ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE),
395 ARIZONA_GAINMUX_CONTROLS("SLIMTX5", ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE),
396 ARIZONA_GAINMUX_CONTROLS("SLIMTX6", ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE),
397 
398 ARIZONA_GAINMUX_CONTROLS("SPDIFTX1", ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE),
399 ARIZONA_GAINMUX_CONTROLS("SPDIFTX2", ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE),
400 };
401 
402 ARIZONA_MUX_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
403 ARIZONA_MUX_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
404 ARIZONA_MUX_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
405 ARIZONA_MUX_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
406 
407 ARIZONA_MUX_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
408 ARIZONA_MUX_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
409 
410 ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
411 ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
412 ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
413 ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
414 
415 ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
416 ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
417 
418 ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
419 ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
420 ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE);
421 ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE);
422 ARIZONA_MIXER_ENUMS(OUT3,  ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
423 ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
424 ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE);
425 ARIZONA_MIXER_ENUMS(SPKDATL, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
426 ARIZONA_MIXER_ENUMS(SPKDATR, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
427 
428 ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
429 ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
430 ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
431 ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
432 ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
433 ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
434 
435 ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
436 ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
437 ARIZONA_MIXER_ENUMS(AIF2TX3, ARIZONA_AIF2TX3MIX_INPUT_1_SOURCE);
438 ARIZONA_MIXER_ENUMS(AIF2TX4, ARIZONA_AIF2TX4MIX_INPUT_1_SOURCE);
439 ARIZONA_MIXER_ENUMS(AIF2TX5, ARIZONA_AIF2TX5MIX_INPUT_1_SOURCE);
440 ARIZONA_MIXER_ENUMS(AIF2TX6, ARIZONA_AIF2TX6MIX_INPUT_1_SOURCE);
441 
442 ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
443 ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
444 
445 ARIZONA_MUX_ENUMS(SLIMTX1, ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE);
446 ARIZONA_MUX_ENUMS(SLIMTX2, ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE);
447 ARIZONA_MUX_ENUMS(SLIMTX3, ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE);
448 ARIZONA_MUX_ENUMS(SLIMTX4, ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE);
449 ARIZONA_MUX_ENUMS(SLIMTX5, ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE);
450 ARIZONA_MUX_ENUMS(SLIMTX6, ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE);
451 
452 ARIZONA_MUX_ENUMS(SPD1TX1, ARIZONA_SPDIFTX1MIX_INPUT_1_SOURCE);
453 ARIZONA_MUX_ENUMS(SPD1TX2, ARIZONA_SPDIFTX2MIX_INPUT_1_SOURCE);
454 
455 ARIZONA_MUX_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
456 ARIZONA_MUX_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
457 ARIZONA_MUX_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
458 ARIZONA_MUX_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
459 
460 ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE);
461 ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE);
462 ARIZONA_MUX_ENUMS(ISRC1INT3, ARIZONA_ISRC1INT3MIX_INPUT_1_SOURCE);
463 ARIZONA_MUX_ENUMS(ISRC1INT4, ARIZONA_ISRC1INT4MIX_INPUT_1_SOURCE);
464 
465 ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE);
466 ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE);
467 ARIZONA_MUX_ENUMS(ISRC1DEC3, ARIZONA_ISRC1DEC3MIX_INPUT_1_SOURCE);
468 ARIZONA_MUX_ENUMS(ISRC1DEC4, ARIZONA_ISRC1DEC4MIX_INPUT_1_SOURCE);
469 
470 ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE);
471 ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE);
472 
473 ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE);
474 ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE);
475 
476 static const char * const wm8998_aec_loopback_texts[] = {
477 	"HPOUTL", "HPOUTR", "LINEOUTL", "LINEOUTR", "EPOUT",
478 	"SPKOUTL", "SPKOUTR", "SPKDATL", "SPKDATR",
479 };
480 
481 static const unsigned int wm8998_aec_loopback_values[] = {
482 	0, 1, 2, 3, 4, 6, 7, 8, 9,
483 };
484 
485 static SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec1_loopback,
486 				  ARIZONA_DAC_AEC_CONTROL_1,
487 				  ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
488 				  wm8998_aec_loopback_texts,
489 				  wm8998_aec_loopback_values);
490 
491 static SOC_VALUE_ENUM_SINGLE_DECL(wm8998_aec2_loopback,
492 				  ARIZONA_DAC_AEC_CONTROL_2,
493 				  ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
494 				  wm8998_aec_loopback_texts,
495 				  wm8998_aec_loopback_values);
496 
497 static const struct snd_kcontrol_new wm8998_aec_loopback_mux[] = {
498 	SOC_DAPM_ENUM("AEC1 Loopback", wm8998_aec1_loopback),
499 	SOC_DAPM_ENUM("AEC2 Loopback", wm8998_aec2_loopback),
500 };
501 
502 static const struct snd_soc_dapm_widget wm8998_dapm_widgets[] = {
503 SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1,
504 		    ARIZONA_SYSCLK_ENA_SHIFT, 0, arizona_clk_ev,
505 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
506 SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
507 		    ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, arizona_clk_ev,
508 		    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
509 SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
510 		    ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
511 SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
512 		    ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
513 
514 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
515 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0),
516 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
517 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
518 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0),
519 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
520 
521 SND_SOC_DAPM_SIGGEN("TONE"),
522 SND_SOC_DAPM_SIGGEN("HAPTICS"),
523 
524 SND_SOC_DAPM_INPUT("IN1AL"),
525 SND_SOC_DAPM_INPUT("IN1AR"),
526 SND_SOC_DAPM_INPUT("IN1BL"),
527 SND_SOC_DAPM_INPUT("IN1BR"),
528 SND_SOC_DAPM_INPUT("IN2A"),
529 SND_SOC_DAPM_INPUT("IN2B"),
530 
531 SND_SOC_DAPM_MUX("IN1L Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[0]),
532 SND_SOC_DAPM_MUX("IN1R Mux", SND_SOC_NOPM, 0, 0, &wm8998_in1mux[1]),
533 SND_SOC_DAPM_MUX("IN2 Mux", SND_SOC_NOPM, 0, 0, &wm8998_in2mux),
534 
535 SND_SOC_DAPM_OUTPUT("DRC1 Signal Activity"),
536 
537 SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
538 		   0, NULL, 0, arizona_in_ev,
539 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
540 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
541 SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
542 		   0, NULL, 0, arizona_in_ev,
543 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
544 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
545 SND_SOC_DAPM_PGA_E("IN2 PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
546 		   0, NULL, 0, arizona_in_ev,
547 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
548 		   SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
549 
550 SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
551 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
552 SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
553 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
554 SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
555 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
556 
557 SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
558 		 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
559 SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
560 		 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
561 
562 SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
563 SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
564 SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
565 SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
566 
567 SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
568 		 NULL, 0),
569 SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
570 		 NULL, 0),
571 
572 SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
573 		 NULL, 0),
574 SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
575 		 NULL, 0),
576 SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
577 		 NULL, 0),
578 SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
579 		 NULL, 0),
580 
581 SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
582 		 0, NULL, 0),
583 SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
584 		 0, NULL, 0),
585 
586 SND_SOC_DAPM_PGA_E("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
587 		   NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU),
588 SND_SOC_DAPM_PGA_E("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
589 		   NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU),
590 SND_SOC_DAPM_PGA_E("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
591 		   NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU),
592 SND_SOC_DAPM_PGA_E("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
593 		   NULL, 0, wm8998_asrc_ev, SND_SOC_DAPM_PRE_PMU),
594 
595 SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3,
596 		 ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0),
597 SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3,
598 		 ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
599 SND_SOC_DAPM_PGA("ISRC1INT3", ARIZONA_ISRC_1_CTRL_3,
600 		 ARIZONA_ISRC1_INT2_ENA_SHIFT, 0, NULL, 0),
601 SND_SOC_DAPM_PGA("ISRC1INT4", ARIZONA_ISRC_1_CTRL_3,
602 		 ARIZONA_ISRC1_INT3_ENA_SHIFT, 0, NULL, 0),
603 
604 SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3,
605 		 ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0),
606 SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3,
607 		 ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
608 SND_SOC_DAPM_PGA("ISRC1DEC3", ARIZONA_ISRC_1_CTRL_3,
609 		 ARIZONA_ISRC1_DEC2_ENA_SHIFT, 0, NULL, 0),
610 SND_SOC_DAPM_PGA("ISRC1DEC4", ARIZONA_ISRC_1_CTRL_3,
611 		 ARIZONA_ISRC1_DEC3_ENA_SHIFT, 0, NULL, 0),
612 
613 SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3,
614 		 ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0),
615 SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3,
616 		 ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
617 
618 SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3,
619 		 ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0),
620 SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3,
621 		 ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
622 
623 SND_SOC_DAPM_MUX("AEC1 Loopback", ARIZONA_DAC_AEC_CONTROL_1,
624 		 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
625 		 &wm8998_aec_loopback_mux[0]),
626 
627 SND_SOC_DAPM_MUX("AEC2 Loopback", ARIZONA_DAC_AEC_CONTROL_2,
628 		 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
629 		 &wm8998_aec_loopback_mux[1]),
630 
631 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
632 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
633 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 1,
634 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
635 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 2,
636 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
637 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 3,
638 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
639 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 4,
640 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
641 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 5,
642 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
643 
644 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
645 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
646 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 1,
647 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
648 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 2,
649 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
650 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 3,
651 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
652 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 4,
653 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
654 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 5,
655 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
656 
657 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
658 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
659 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 1,
660 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
661 SND_SOC_DAPM_AIF_OUT("AIF2TX3", NULL, 2,
662 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX3_ENA_SHIFT, 0),
663 SND_SOC_DAPM_AIF_OUT("AIF2TX4", NULL, 3,
664 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX4_ENA_SHIFT, 0),
665 SND_SOC_DAPM_AIF_OUT("AIF2TX5", NULL, 4,
666 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX5_ENA_SHIFT, 0),
667 SND_SOC_DAPM_AIF_OUT("AIF2TX6", NULL, 5,
668 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX6_ENA_SHIFT, 0),
669 
670 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
671 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
672 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 1,
673 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
674 SND_SOC_DAPM_AIF_IN("AIF2RX3", NULL, 2,
675 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX3_ENA_SHIFT, 0),
676 SND_SOC_DAPM_AIF_IN("AIF2RX4", NULL, 3,
677 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX4_ENA_SHIFT, 0),
678 SND_SOC_DAPM_AIF_IN("AIF2RX5", NULL, 4,
679 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX5_ENA_SHIFT, 0),
680 SND_SOC_DAPM_AIF_IN("AIF2RX6", NULL, 5,
681 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX6_ENA_SHIFT, 0),
682 
683 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0,
684 		    ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
685 		    ARIZONA_SLIMRX1_ENA_SHIFT, 0),
686 SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 1,
687 		    ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
688 		    ARIZONA_SLIMRX2_ENA_SHIFT, 0),
689 SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 2,
690 		    ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
691 		    ARIZONA_SLIMRX3_ENA_SHIFT, 0),
692 SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 3,
693 		    ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
694 		    ARIZONA_SLIMRX4_ENA_SHIFT, 0),
695 
696 SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0,
697 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
698 		     ARIZONA_SLIMTX1_ENA_SHIFT, 0),
699 SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 1,
700 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
701 		     ARIZONA_SLIMTX2_ENA_SHIFT, 0),
702 SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 2,
703 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
704 		     ARIZONA_SLIMTX3_ENA_SHIFT, 0),
705 SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 3,
706 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
707 		     ARIZONA_SLIMTX4_ENA_SHIFT, 0),
708 SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 4,
709 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
710 		     ARIZONA_SLIMTX5_ENA_SHIFT, 0),
711 SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 5,
712 		     ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
713 		     ARIZONA_SLIMTX6_ENA_SHIFT, 0),
714 
715 SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
716 		     ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
717 SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 1,
718 		     ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
719 
720 SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
721 		    ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
722 SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 1,
723 		    ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
724 
725 SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
726 		   ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
727 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
728 SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
729 		   ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
730 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
731 SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
732 		   ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
733 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
734 SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
735 		   ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
736 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
737 SND_SOC_DAPM_PGA_E("OUT3", ARIZONA_OUTPUT_ENABLES_1,
738 		   ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
739 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
740 SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
741 		   ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
742 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
743 SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
744 		   ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
745 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
746 
747 SND_SOC_DAPM_PGA("SPD1TX1", ARIZONA_SPD1_TX_CONTROL,
748 		 ARIZONA_SPD1_VAL1_SHIFT, 0, NULL, 0),
749 SND_SOC_DAPM_PGA("SPD1TX2", ARIZONA_SPD1_TX_CONTROL,
750 		 ARIZONA_SPD1_VAL2_SHIFT, 0, NULL, 0),
751 SND_SOC_DAPM_OUT_DRV("SPD1", ARIZONA_SPD1_TX_CONTROL,
752 		     ARIZONA_SPD1_ENA_SHIFT, 0, NULL, 0),
753 
754 ARIZONA_MUX_WIDGETS(EQ1, "EQ1"),
755 ARIZONA_MUX_WIDGETS(EQ2, "EQ2"),
756 ARIZONA_MUX_WIDGETS(EQ3, "EQ3"),
757 ARIZONA_MUX_WIDGETS(EQ4, "EQ4"),
758 
759 ARIZONA_MUX_WIDGETS(DRC1L, "DRC1L"),
760 ARIZONA_MUX_WIDGETS(DRC1R, "DRC1R"),
761 
762 ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
763 ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
764 ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
765 ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
766 
767 ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
768 ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
769 
770 ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUTL"),
771 ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUTR"),
772 ARIZONA_MIXER_WIDGETS(OUT2L, "LINEOUTL"),
773 ARIZONA_MIXER_WIDGETS(OUT2R, "LINEOUTR"),
774 ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
775 ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"),
776 ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"),
777 ARIZONA_MIXER_WIDGETS(SPKDATL, "SPKDATL"),
778 ARIZONA_MIXER_WIDGETS(SPKDATR, "SPKDATR"),
779 
780 ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
781 ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
782 ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
783 ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
784 ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
785 ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
786 
787 ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
788 ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
789 ARIZONA_MIXER_WIDGETS(AIF2TX3, "AIF2TX3"),
790 ARIZONA_MIXER_WIDGETS(AIF2TX4, "AIF2TX4"),
791 ARIZONA_MIXER_WIDGETS(AIF2TX5, "AIF2TX5"),
792 ARIZONA_MIXER_WIDGETS(AIF2TX6, "AIF2TX6"),
793 
794 ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
795 ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
796 
797 ARIZONA_MUX_WIDGETS(SLIMTX1, "SLIMTX1"),
798 ARIZONA_MUX_WIDGETS(SLIMTX2, "SLIMTX2"),
799 ARIZONA_MUX_WIDGETS(SLIMTX3, "SLIMTX3"),
800 ARIZONA_MUX_WIDGETS(SLIMTX4, "SLIMTX4"),
801 ARIZONA_MUX_WIDGETS(SLIMTX5, "SLIMTX5"),
802 ARIZONA_MUX_WIDGETS(SLIMTX6, "SLIMTX6"),
803 
804 ARIZONA_MUX_WIDGETS(SPD1TX1, "SPDIFTX1"),
805 ARIZONA_MUX_WIDGETS(SPD1TX2, "SPDIFTX2"),
806 
807 ARIZONA_MUX_WIDGETS(ASRC1L, "ASRC1L"),
808 ARIZONA_MUX_WIDGETS(ASRC1R, "ASRC1R"),
809 ARIZONA_MUX_WIDGETS(ASRC2L, "ASRC2L"),
810 ARIZONA_MUX_WIDGETS(ASRC2R, "ASRC2R"),
811 
812 ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
813 ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
814 ARIZONA_MUX_WIDGETS(ISRC1DEC3, "ISRC1DEC3"),
815 ARIZONA_MUX_WIDGETS(ISRC1DEC4, "ISRC1DEC4"),
816 
817 ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
818 ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
819 ARIZONA_MUX_WIDGETS(ISRC1INT3, "ISRC1INT3"),
820 ARIZONA_MUX_WIDGETS(ISRC1INT4, "ISRC1INT4"),
821 
822 ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
823 ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
824 
825 ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
826 ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
827 
828 SND_SOC_DAPM_OUTPUT("HPOUTL"),
829 SND_SOC_DAPM_OUTPUT("HPOUTR"),
830 SND_SOC_DAPM_OUTPUT("LINEOUTL"),
831 SND_SOC_DAPM_OUTPUT("LINEOUTR"),
832 SND_SOC_DAPM_OUTPUT("EPOUT"),
833 SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
834 SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
835 SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
836 SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
837 SND_SOC_DAPM_OUTPUT("SPKDATL"),
838 SND_SOC_DAPM_OUTPUT("SPKDATR"),
839 SND_SOC_DAPM_OUTPUT("SPDIF"),
840 
841 SND_SOC_DAPM_OUTPUT("MICSUPP"),
842 };
843 
844 #define ARIZONA_MIXER_INPUT_ROUTES(name)	\
845 	{ name, "Tone Generator 1", "Tone Generator 1" }, \
846 	{ name, "Tone Generator 2", "Tone Generator 2" }, \
847 	{ name, "Haptics", "HAPTICS" }, \
848 	{ name, "AEC", "AEC1 Loopback" }, \
849 	{ name, "AEC2", "AEC2 Loopback" }, \
850 	{ name, "IN1L", "IN1L PGA" }, \
851 	{ name, "IN1R", "IN1R PGA" }, \
852 	{ name, "IN2L", "IN2 PGA" }, \
853 	{ name, "AIF1RX1", "AIF1RX1" }, \
854 	{ name, "AIF1RX2", "AIF1RX2" }, \
855 	{ name, "AIF1RX3", "AIF1RX3" }, \
856 	{ name, "AIF1RX4", "AIF1RX4" }, \
857 	{ name, "AIF1RX5", "AIF1RX5" }, \
858 	{ name, "AIF1RX6", "AIF1RX6" }, \
859 	{ name, "AIF2RX1", "AIF2RX1" }, \
860 	{ name, "AIF2RX2", "AIF2RX2" }, \
861 	{ name, "AIF2RX3", "AIF2RX3" }, \
862 	{ name, "AIF2RX4", "AIF2RX4" }, \
863 	{ name, "AIF2RX5", "AIF2RX5" }, \
864 	{ name, "AIF2RX6", "AIF2RX6" }, \
865 	{ name, "AIF3RX1", "AIF3RX1" }, \
866 	{ name, "AIF3RX2", "AIF3RX2" }, \
867 	{ name, "SLIMRX1", "SLIMRX1" }, \
868 	{ name, "SLIMRX2", "SLIMRX2" }, \
869 	{ name, "SLIMRX3", "SLIMRX3" }, \
870 	{ name, "SLIMRX4", "SLIMRX4" }, \
871 	{ name, "EQ1", "EQ1" }, \
872 	{ name, "EQ2", "EQ2" }, \
873 	{ name, "EQ3", "EQ3" }, \
874 	{ name, "EQ4", "EQ4" }, \
875 	{ name, "DRC1L", "DRC1L" }, \
876 	{ name, "DRC1R", "DRC1R" }, \
877 	{ name, "LHPF1", "LHPF1" }, \
878 	{ name, "LHPF2", "LHPF2" }, \
879 	{ name, "LHPF3", "LHPF3" }, \
880 	{ name, "LHPF4", "LHPF4" }, \
881 	{ name, "ASRC1L", "ASRC1L" }, \
882 	{ name, "ASRC1R", "ASRC1R" }, \
883 	{ name, "ASRC2L", "ASRC2L" }, \
884 	{ name, "ASRC2R", "ASRC2R" }, \
885 	{ name, "ISRC1DEC1", "ISRC1DEC1" }, \
886 	{ name, "ISRC1DEC2", "ISRC1DEC2" }, \
887 	{ name, "ISRC1DEC3", "ISRC1DEC3" }, \
888 	{ name, "ISRC1DEC4", "ISRC1DEC4" }, \
889 	{ name, "ISRC1INT1", "ISRC1INT1" }, \
890 	{ name, "ISRC1INT2", "ISRC1INT2" }, \
891 	{ name, "ISRC1INT3", "ISRC1INT3" }, \
892 	{ name, "ISRC1INT4", "ISRC1INT4" }, \
893 	{ name, "ISRC2DEC1", "ISRC2DEC1" }, \
894 	{ name, "ISRC2DEC2", "ISRC2DEC2" }, \
895 	{ name, "ISRC2INT1", "ISRC2INT1" }, \
896 	{ name, "ISRC2INT2", "ISRC2INT2" }
897 
898 static const struct snd_soc_dapm_route wm8998_dapm_routes[] = {
899 	{ "AIF2 Capture", NULL, "DBVDD2" },
900 	{ "AIF2 Playback", NULL, "DBVDD2" },
901 
902 	{ "AIF3 Capture", NULL, "DBVDD3" },
903 	{ "AIF3 Playback", NULL, "DBVDD3" },
904 
905 	{ "OUT1L", NULL, "CPVDD" },
906 	{ "OUT1R", NULL, "CPVDD" },
907 	{ "OUT2L", NULL, "CPVDD" },
908 	{ "OUT2R", NULL, "CPVDD" },
909 	{ "OUT3",  NULL, "CPVDD" },
910 
911 	{ "OUT4L", NULL, "SPKVDDL" },
912 	{ "OUT4R", NULL, "SPKVDDR" },
913 
914 	{ "OUT1L", NULL, "SYSCLK" },
915 	{ "OUT1R", NULL, "SYSCLK" },
916 	{ "OUT2L", NULL, "SYSCLK" },
917 	{ "OUT2R", NULL, "SYSCLK" },
918 	{ "OUT3",  NULL, "SYSCLK" },
919 	{ "OUT4L", NULL, "SYSCLK" },
920 	{ "OUT4R", NULL, "SYSCLK" },
921 	{ "OUT5L", NULL, "SYSCLK" },
922 	{ "OUT5R", NULL, "SYSCLK" },
923 
924 	{ "IN1AL", NULL, "SYSCLK" },
925 	{ "IN1AR", NULL, "SYSCLK" },
926 	{ "IN1BL", NULL, "SYSCLK" },
927 	{ "IN1BR", NULL, "SYSCLK" },
928 	{ "IN2A", NULL, "SYSCLK" },
929 	{ "IN2B", NULL, "SYSCLK" },
930 
931 	{ "ASRC1L", NULL, "SYSCLK" },
932 	{ "ASRC1R", NULL, "SYSCLK" },
933 	{ "ASRC2L", NULL, "SYSCLK" },
934 	{ "ASRC2R", NULL, "SYSCLK" },
935 
936 	{ "ASRC1L", NULL, "ASYNCCLK" },
937 	{ "ASRC1R", NULL, "ASYNCCLK" },
938 	{ "ASRC2L", NULL, "ASYNCCLK" },
939 	{ "ASRC2R", NULL, "ASYNCCLK" },
940 
941 	{ "SPD1", NULL, "SYSCLK" },
942 	{ "SPD1", NULL, "SPD1TX1" },
943 	{ "SPD1", NULL, "SPD1TX2" },
944 
945 	{ "MICBIAS1", NULL, "MICVDD" },
946 	{ "MICBIAS2", NULL, "MICVDD" },
947 	{ "MICBIAS3", NULL, "MICVDD" },
948 
949 	{ "Tone Generator 1", NULL, "SYSCLK" },
950 	{ "Tone Generator 2", NULL, "SYSCLK" },
951 
952 	{ "Tone Generator 1", NULL, "TONE" },
953 	{ "Tone Generator 2", NULL, "TONE" },
954 
955 	{ "AIF1 Capture", NULL, "AIF1TX1" },
956 	{ "AIF1 Capture", NULL, "AIF1TX2" },
957 	{ "AIF1 Capture", NULL, "AIF1TX3" },
958 	{ "AIF1 Capture", NULL, "AIF1TX4" },
959 	{ "AIF1 Capture", NULL, "AIF1TX5" },
960 	{ "AIF1 Capture", NULL, "AIF1TX6" },
961 
962 	{ "AIF1RX1", NULL, "AIF1 Playback" },
963 	{ "AIF1RX2", NULL, "AIF1 Playback" },
964 	{ "AIF1RX3", NULL, "AIF1 Playback" },
965 	{ "AIF1RX4", NULL, "AIF1 Playback" },
966 	{ "AIF1RX5", NULL, "AIF1 Playback" },
967 	{ "AIF1RX6", NULL, "AIF1 Playback" },
968 
969 	{ "AIF2 Capture", NULL, "AIF2TX1" },
970 	{ "AIF2 Capture", NULL, "AIF2TX2" },
971 	{ "AIF2 Capture", NULL, "AIF2TX3" },
972 	{ "AIF2 Capture", NULL, "AIF2TX4" },
973 	{ "AIF2 Capture", NULL, "AIF2TX5" },
974 	{ "AIF2 Capture", NULL, "AIF2TX6" },
975 
976 	{ "AIF2RX1", NULL, "AIF2 Playback" },
977 	{ "AIF2RX2", NULL, "AIF2 Playback" },
978 	{ "AIF2RX3", NULL, "AIF2 Playback" },
979 	{ "AIF2RX4", NULL, "AIF2 Playback" },
980 	{ "AIF2RX5", NULL, "AIF2 Playback" },
981 	{ "AIF2RX6", NULL, "AIF2 Playback" },
982 
983 	{ "AIF3 Capture", NULL, "AIF3TX1" },
984 	{ "AIF3 Capture", NULL, "AIF3TX2" },
985 
986 	{ "AIF3RX1", NULL, "AIF3 Playback" },
987 	{ "AIF3RX2", NULL, "AIF3 Playback" },
988 
989 	{ "Slim1 Capture", NULL, "SLIMTX1" },
990 	{ "Slim1 Capture", NULL, "SLIMTX2" },
991 	{ "Slim1 Capture", NULL, "SLIMTX3" },
992 	{ "Slim1 Capture", NULL, "SLIMTX4" },
993 
994 	{ "Slim2 Capture", NULL, "SLIMTX5" },
995 	{ "Slim2 Capture", NULL, "SLIMTX6" },
996 
997 	{ "SLIMRX1", NULL, "Slim1 Playback" },
998 	{ "SLIMRX2", NULL, "Slim1 Playback" },
999 
1000 	{ "SLIMRX3", NULL, "Slim2 Playback" },
1001 	{ "SLIMRX4", NULL, "Slim2 Playback" },
1002 
1003 	{ "AIF1 Playback", NULL, "SYSCLK" },
1004 	{ "AIF2 Playback", NULL, "SYSCLK" },
1005 	{ "AIF3 Playback", NULL, "SYSCLK" },
1006 	{ "Slim1 Playback", NULL, "SYSCLK" },
1007 	{ "Slim2 Playback", NULL, "SYSCLK" },
1008 
1009 	{ "AIF1 Capture", NULL, "SYSCLK" },
1010 	{ "AIF2 Capture", NULL, "SYSCLK" },
1011 	{ "AIF3 Capture", NULL, "SYSCLK" },
1012 	{ "Slim1 Capture", NULL, "SYSCLK" },
1013 	{ "Slim2 Capture", NULL, "SYSCLK" },
1014 
1015 	{ "IN1L Mux", "A", "IN1AL" },
1016 	{ "IN1R Mux", "A", "IN1AR" },
1017 	{ "IN1L Mux", "B", "IN1BL" },
1018 	{ "IN1R Mux", "B", "IN1BR" },
1019 
1020 	{ "IN2 Mux", "A", "IN2A" },
1021 	{ "IN2 Mux", "B", "IN2B" },
1022 
1023 	{ "IN1L PGA", NULL, "IN1L Mux" },
1024 	{ "IN1R PGA", NULL, "IN1R Mux" },
1025 	{ "IN2 PGA",  NULL, "IN2 Mux" },
1026 
1027 	ARIZONA_MIXER_ROUTES("OUT1L", "HPOUTL"),
1028 	ARIZONA_MIXER_ROUTES("OUT1R", "HPOUTR"),
1029 	ARIZONA_MIXER_ROUTES("OUT2L", "LINEOUTL"),
1030 	ARIZONA_MIXER_ROUTES("OUT2R", "LINEOUTR"),
1031 	ARIZONA_MIXER_ROUTES("OUT3",  "EPOUT"),
1032 
1033 	ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"),
1034 	ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"),
1035 	ARIZONA_MIXER_ROUTES("OUT5L", "SPKDATL"),
1036 	ARIZONA_MIXER_ROUTES("OUT5R", "SPKDATR"),
1037 
1038 	ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
1039 	ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
1040 
1041 	ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
1042 	ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
1043 	ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
1044 	ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
1045 	ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
1046 	ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
1047 
1048 	ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
1049 	ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
1050 	ARIZONA_MIXER_ROUTES("AIF2TX3", "AIF2TX3"),
1051 	ARIZONA_MIXER_ROUTES("AIF2TX4", "AIF2TX4"),
1052 	ARIZONA_MIXER_ROUTES("AIF2TX5", "AIF2TX5"),
1053 	ARIZONA_MIXER_ROUTES("AIF2TX6", "AIF2TX6"),
1054 
1055 	ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
1056 	ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
1057 
1058 	ARIZONA_MUX_ROUTES("SLIMTX1", "SLIMTX1"),
1059 	ARIZONA_MUX_ROUTES("SLIMTX2", "SLIMTX2"),
1060 	ARIZONA_MUX_ROUTES("SLIMTX3", "SLIMTX3"),
1061 	ARIZONA_MUX_ROUTES("SLIMTX4", "SLIMTX4"),
1062 	ARIZONA_MUX_ROUTES("SLIMTX5", "SLIMTX5"),
1063 	ARIZONA_MUX_ROUTES("SLIMTX6", "SLIMTX6"),
1064 
1065 	ARIZONA_MUX_ROUTES("SPD1TX1", "SPDIFTX1"),
1066 	ARIZONA_MUX_ROUTES("SPD1TX2", "SPDIFTX2"),
1067 
1068 	ARIZONA_MUX_ROUTES("EQ1", "EQ1"),
1069 	ARIZONA_MUX_ROUTES("EQ2", "EQ2"),
1070 	ARIZONA_MUX_ROUTES("EQ3", "EQ3"),
1071 	ARIZONA_MUX_ROUTES("EQ4", "EQ4"),
1072 
1073 	ARIZONA_MUX_ROUTES("DRC1L", "DRC1L"),
1074 	ARIZONA_MUX_ROUTES("DRC1R", "DRC1R"),
1075 
1076 	ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
1077 	ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
1078 	ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
1079 	ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
1080 
1081 	ARIZONA_MUX_ROUTES("ASRC1L", "ASRC1L"),
1082 	ARIZONA_MUX_ROUTES("ASRC1R", "ASRC1R"),
1083 	ARIZONA_MUX_ROUTES("ASRC2L", "ASRC2L"),
1084 	ARIZONA_MUX_ROUTES("ASRC2R", "ASRC2R"),
1085 
1086 	ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
1087 	ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
1088 	ARIZONA_MUX_ROUTES("ISRC1INT3", "ISRC1INT3"),
1089 	ARIZONA_MUX_ROUTES("ISRC1INT4", "ISRC1INT4"),
1090 
1091 	ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
1092 	ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
1093 	ARIZONA_MUX_ROUTES("ISRC1DEC3", "ISRC1DEC3"),
1094 	ARIZONA_MUX_ROUTES("ISRC1DEC4", "ISRC1DEC4"),
1095 
1096 	ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
1097 	ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
1098 
1099 	ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
1100 	ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
1101 
1102 	{ "AEC1 Loopback", "HPOUTL", "OUT1L" },
1103 	{ "AEC1 Loopback", "HPOUTR", "OUT1R" },
1104 	{ "AEC2 Loopback", "HPOUTL", "OUT1L" },
1105 	{ "AEC2 Loopback", "HPOUTR", "OUT1R" },
1106 	{ "HPOUTL", NULL, "OUT1L" },
1107 	{ "HPOUTR", NULL, "OUT1R" },
1108 
1109 	{ "AEC1 Loopback", "LINEOUTL", "OUT2L" },
1110 	{ "AEC1 Loopback", "LINEOUTR", "OUT2R" },
1111 	{ "AEC2 Loopback", "LINEOUTL", "OUT2L" },
1112 	{ "AEC2 Loopback", "LINEOUTR", "OUT2R" },
1113 	{ "LINEOUTL", NULL, "OUT2L" },
1114 	{ "LINEOUTR", NULL, "OUT2R" },
1115 
1116 	{ "AEC1 Loopback", "EPOUT", "OUT3" },
1117 	{ "AEC2 Loopback", "EPOUT", "OUT3" },
1118 	{ "EPOUT", NULL, "OUT3" },
1119 
1120 	{ "AEC1 Loopback", "SPKOUTL", "OUT4L" },
1121 	{ "AEC2 Loopback", "SPKOUTL", "OUT4L" },
1122 	{ "SPKOUTLN", NULL, "OUT4L" },
1123 	{ "SPKOUTLP", NULL, "OUT4L" },
1124 
1125 	{ "AEC1 Loopback", "SPKOUTR", "OUT4R" },
1126 	{ "AEC2 Loopback", "SPKOUTR", "OUT4R" },
1127 	{ "SPKOUTRN", NULL, "OUT4R" },
1128 	{ "SPKOUTRP", NULL, "OUT4R" },
1129 
1130 	{ "SPDIF", NULL, "SPD1" },
1131 
1132 	{ "AEC1 Loopback", "SPKDATL", "OUT5L" },
1133 	{ "AEC1 Loopback", "SPKDATR", "OUT5R" },
1134 	{ "AEC2 Loopback", "SPKDATL", "OUT5L" },
1135 	{ "AEC2 Loopback", "SPKDATR", "OUT5R" },
1136 	{ "SPKDATL", NULL, "OUT5L" },
1137 	{ "SPKDATR", NULL, "OUT5R" },
1138 
1139 	{ "MICSUPP", NULL, "SYSCLK" },
1140 
1141 	{ "DRC1 Signal Activity", NULL, "SYSCLK" },
1142 	{ "DRC1 Signal Activity", NULL, "DRC1L" },
1143 	{ "DRC1 Signal Activity", NULL, "DRC1R" },
1144 };
1145 
1146 #define WM8998_RATES SNDRV_PCM_RATE_KNOT
1147 
1148 #define WM8998_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1149 			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1150 
1151 static struct snd_soc_dai_driver wm8998_dai[] = {
1152 	{
1153 		.name = "wm8998-aif1",
1154 		.id = 1,
1155 		.base = ARIZONA_AIF1_BCLK_CTRL,
1156 		.playback = {
1157 			.stream_name = "AIF1 Playback",
1158 			.channels_min = 1,
1159 			.channels_max = 6,
1160 			.rates = WM8998_RATES,
1161 			.formats = WM8998_FORMATS,
1162 		},
1163 		.capture = {
1164 			 .stream_name = "AIF1 Capture",
1165 			 .channels_min = 1,
1166 			 .channels_max = 6,
1167 			 .rates = WM8998_RATES,
1168 			 .formats = WM8998_FORMATS,
1169 		 },
1170 		.ops = &arizona_dai_ops,
1171 		.symmetric_rate = 1,
1172 		.symmetric_sample_bits = 1,
1173 	},
1174 	{
1175 		.name = "wm8998-aif2",
1176 		.id = 2,
1177 		.base = ARIZONA_AIF2_BCLK_CTRL,
1178 		.playback = {
1179 			.stream_name = "AIF2 Playback",
1180 			.channels_min = 1,
1181 			.channels_max = 6,
1182 			.rates = WM8998_RATES,
1183 			.formats = WM8998_FORMATS,
1184 		},
1185 		.capture = {
1186 			 .stream_name = "AIF2 Capture",
1187 			 .channels_min = 1,
1188 			 .channels_max = 6,
1189 			 .rates = WM8998_RATES,
1190 			 .formats = WM8998_FORMATS,
1191 		 },
1192 		.ops = &arizona_dai_ops,
1193 		.symmetric_rate = 1,
1194 		.symmetric_sample_bits = 1,
1195 	},
1196 	{
1197 		.name = "wm8998-aif3",
1198 		.id = 3,
1199 		.base = ARIZONA_AIF3_BCLK_CTRL,
1200 		.playback = {
1201 			.stream_name = "AIF3 Playback",
1202 			.channels_min = 1,
1203 			.channels_max = 2,
1204 			.rates = WM8998_RATES,
1205 			.formats = WM8998_FORMATS,
1206 		},
1207 		.capture = {
1208 			 .stream_name = "AIF3 Capture",
1209 			 .channels_min = 1,
1210 			 .channels_max = 2,
1211 			 .rates = WM8998_RATES,
1212 			 .formats = WM8998_FORMATS,
1213 		 },
1214 		.ops = &arizona_dai_ops,
1215 		.symmetric_rate = 1,
1216 		.symmetric_sample_bits = 1,
1217 	},
1218 	{
1219 		.name = "wm8998-slim1",
1220 		.id = 4,
1221 		.playback = {
1222 			.stream_name = "Slim1 Playback",
1223 			.channels_min = 1,
1224 			.channels_max = 2,
1225 			.rates = WM8998_RATES,
1226 			.formats = WM8998_FORMATS,
1227 		},
1228 		.capture = {
1229 			 .stream_name = "Slim1 Capture",
1230 			 .channels_min = 1,
1231 			 .channels_max = 4,
1232 			 .rates = WM8998_RATES,
1233 			 .formats = WM8998_FORMATS,
1234 		 },
1235 		.ops = &arizona_simple_dai_ops,
1236 	},
1237 	{
1238 		.name = "wm8998-slim2",
1239 		.id = 5,
1240 		.playback = {
1241 			.stream_name = "Slim2 Playback",
1242 			.channels_min = 1,
1243 			.channels_max = 2,
1244 			.rates = WM8998_RATES,
1245 			.formats = WM8998_FORMATS,
1246 		},
1247 		.capture = {
1248 			 .stream_name = "Slim2 Capture",
1249 			 .channels_min = 1,
1250 			 .channels_max = 2,
1251 			 .rates = WM8998_RATES,
1252 			 .formats = WM8998_FORMATS,
1253 		 },
1254 		.ops = &arizona_simple_dai_ops,
1255 	},
1256 };
1257 
1258 static int wm8998_set_fll(struct snd_soc_component *component, int fll_id,
1259 			  int source, unsigned int Fref, unsigned int Fout)
1260 {
1261 	struct wm8998_priv *wm8998 = snd_soc_component_get_drvdata(component);
1262 
1263 	switch (fll_id) {
1264 	case WM8998_FLL1:
1265 		return arizona_set_fll(&wm8998->fll[0], source, Fref, Fout);
1266 	case WM8998_FLL2:
1267 		return arizona_set_fll(&wm8998->fll[1], source, Fref, Fout);
1268 	case WM8998_FLL1_REFCLK:
1269 		return arizona_set_fll_refclk(&wm8998->fll[0], source, Fref,
1270 					      Fout);
1271 	case WM8998_FLL2_REFCLK:
1272 		return arizona_set_fll_refclk(&wm8998->fll[1], source, Fref,
1273 					      Fout);
1274 	default:
1275 		return -EINVAL;
1276 	}
1277 }
1278 
1279 static int wm8998_component_probe(struct snd_soc_component *component)
1280 {
1281 	struct wm8998_priv *priv = snd_soc_component_get_drvdata(component);
1282 	struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
1283 	struct arizona *arizona = priv->core.arizona;
1284 	int ret;
1285 
1286 	arizona->dapm = dapm;
1287 	snd_soc_component_init_regmap(component, arizona->regmap);
1288 
1289 	ret = arizona_init_spk(component);
1290 	if (ret < 0)
1291 		return ret;
1292 
1293 	arizona_init_gpio(component);
1294 
1295 	snd_soc_component_disable_pin(component, "HAPTICS");
1296 
1297 	return 0;
1298 }
1299 
1300 static void wm8998_component_remove(struct snd_soc_component *component)
1301 {
1302 	struct wm8998_priv *priv = snd_soc_component_get_drvdata(component);
1303 
1304 	priv->core.arizona->dapm = NULL;
1305 }
1306 
1307 #define WM8998_DIG_VU 0x0200
1308 
1309 static unsigned int wm8998_digital_vu[] = {
1310 	ARIZONA_DAC_DIGITAL_VOLUME_1L,
1311 	ARIZONA_DAC_DIGITAL_VOLUME_1R,
1312 	ARIZONA_DAC_DIGITAL_VOLUME_2L,
1313 	ARIZONA_DAC_DIGITAL_VOLUME_2R,
1314 	ARIZONA_DAC_DIGITAL_VOLUME_3L,
1315 	ARIZONA_DAC_DIGITAL_VOLUME_4L,
1316 	ARIZONA_DAC_DIGITAL_VOLUME_4R,
1317 	ARIZONA_DAC_DIGITAL_VOLUME_5L,
1318 	ARIZONA_DAC_DIGITAL_VOLUME_5R,
1319 };
1320 
1321 static const struct snd_soc_component_driver soc_component_dev_wm8998 = {
1322 	.probe			= wm8998_component_probe,
1323 	.remove			= wm8998_component_remove,
1324 	.set_sysclk		= arizona_set_sysclk,
1325 	.set_pll		= wm8998_set_fll,
1326 	.set_jack		= arizona_jack_set_jack,
1327 	.controls		= wm8998_snd_controls,
1328 	.num_controls		= ARRAY_SIZE(wm8998_snd_controls),
1329 	.dapm_widgets		= wm8998_dapm_widgets,
1330 	.num_dapm_widgets	= ARRAY_SIZE(wm8998_dapm_widgets),
1331 	.dapm_routes		= wm8998_dapm_routes,
1332 	.num_dapm_routes	= ARRAY_SIZE(wm8998_dapm_routes),
1333 	.use_pmdown_time	= 1,
1334 	.endianness		= 1,
1335 };
1336 
1337 static int wm8998_probe(struct platform_device *pdev)
1338 {
1339 	struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1340 	struct wm8998_priv *wm8998;
1341 	int i, ret;
1342 
1343 	wm8998 = devm_kzalloc(&pdev->dev, sizeof(struct wm8998_priv),
1344 			      GFP_KERNEL);
1345 	if (!wm8998)
1346 		return -ENOMEM;
1347 	platform_set_drvdata(pdev, wm8998);
1348 
1349 	if (IS_ENABLED(CONFIG_OF)) {
1350 		if (!dev_get_platdata(arizona->dev)) {
1351 			ret = arizona_of_get_audio_pdata(arizona);
1352 			if (ret < 0)
1353 				return ret;
1354 		}
1355 	}
1356 
1357 	wm8998->core.arizona = arizona;
1358 	wm8998->core.num_inputs = 3;	/* IN1L, IN1R, IN2 */
1359 
1360 	/* This may return -EPROBE_DEFER, so do this early on */
1361 	ret = arizona_jack_codec_dev_probe(&wm8998->core, &pdev->dev);
1362 	if (ret)
1363 		return ret;
1364 
1365 	for (i = 0; i < ARRAY_SIZE(wm8998->fll); i++)
1366 		wm8998->fll[i].vco_mult = 1;
1367 
1368 	arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
1369 			 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
1370 			 &wm8998->fll[0]);
1371 	arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
1372 			 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
1373 			 &wm8998->fll[1]);
1374 
1375 	for (i = 0; i < ARRAY_SIZE(wm8998_dai); i++)
1376 		arizona_init_dai(&wm8998->core, i);
1377 
1378 	/* Latch volume update bits */
1379 	for (i = 0; i < ARRAY_SIZE(wm8998_digital_vu); i++)
1380 		regmap_update_bits(arizona->regmap, wm8998_digital_vu[i],
1381 				   WM8998_DIG_VU, WM8998_DIG_VU);
1382 
1383 	pm_runtime_enable(&pdev->dev);
1384 	pm_runtime_idle(&pdev->dev);
1385 
1386 	arizona_init_common(arizona);
1387 
1388 	ret = arizona_init_spk_irqs(arizona);
1389 	if (ret < 0)
1390 		goto err_pm_disable;
1391 
1392 	ret = devm_snd_soc_register_component(&pdev->dev,
1393 					      &soc_component_dev_wm8998,
1394 					      wm8998_dai,
1395 					      ARRAY_SIZE(wm8998_dai));
1396 	if (ret < 0) {
1397 		dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
1398 		goto err_spk_irqs;
1399 	}
1400 
1401 	return ret;
1402 
1403 err_spk_irqs:
1404 	arizona_free_spk_irqs(arizona);
1405 err_pm_disable:
1406 	pm_runtime_disable(&pdev->dev);
1407 	arizona_jack_codec_dev_remove(&wm8998->core);
1408 
1409 	return ret;
1410 }
1411 
1412 static int wm8998_remove(struct platform_device *pdev)
1413 {
1414 	struct wm8998_priv *wm8998 = platform_get_drvdata(pdev);
1415 	struct arizona *arizona = wm8998->core.arizona;
1416 
1417 	pm_runtime_disable(&pdev->dev);
1418 
1419 	arizona_free_spk_irqs(arizona);
1420 
1421 	arizona_jack_codec_dev_remove(&wm8998->core);
1422 
1423 	return 0;
1424 }
1425 
1426 static struct platform_driver wm8998_codec_driver = {
1427 	.driver = {
1428 		.name = "wm8998-codec",
1429 	},
1430 	.probe = wm8998_probe,
1431 	.remove = wm8998_remove,
1432 };
1433 
1434 module_platform_driver(wm8998_codec_driver);
1435 
1436 MODULE_DESCRIPTION("ASoC WM8998 driver");
1437 MODULE_AUTHOR("Richard Fitzgerald <rf@opensource.wolfsonmicro.com>");
1438 MODULE_LICENSE("GPL v2");
1439 MODULE_ALIAS("platform:wm8998-codec");
1440