xref: /openbmc/linux/sound/soc/codecs/wm5110.c (revision 15e47304)
1 /*
2  * wm5110.c  --  WM5110 ALSA SoC Audio driver
3  *
4  * Copyright 2012 Wolfson Microelectronics plc
5  *
6  * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11  */
12 
13 #include <linux/module.h>
14 #include <linux/moduleparam.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
17 #include <linux/pm.h>
18 #include <linux/pm_runtime.h>
19 #include <linux/regmap.h>
20 #include <linux/slab.h>
21 #include <sound/core.h>
22 #include <sound/pcm.h>
23 #include <sound/pcm_params.h>
24 #include <sound/soc.h>
25 #include <sound/jack.h>
26 #include <sound/initval.h>
27 #include <sound/tlv.h>
28 
29 #include <linux/mfd/arizona/core.h>
30 #include <linux/mfd/arizona/registers.h>
31 
32 #include "arizona.h"
33 #include "wm5110.h"
34 
35 struct wm5110_priv {
36 	struct arizona_priv core;
37 	struct arizona_fll fll[2];
38 };
39 
40 static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
41 static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
42 static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
43 static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
44 
45 static const struct snd_kcontrol_new wm5110_snd_controls[] = {
46 SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
47 	   ARIZONA_IN1_OSR_SHIFT, 1, 0),
48 SOC_SINGLE("IN2 High Performance Switch", ARIZONA_IN2L_CONTROL,
49 	   ARIZONA_IN2_OSR_SHIFT, 1, 0),
50 SOC_SINGLE("IN3 High Performance Switch", ARIZONA_IN3L_CONTROL,
51 	   ARIZONA_IN3_OSR_SHIFT, 1, 0),
52 SOC_SINGLE("IN4 High Performance Switch", ARIZONA_IN4L_CONTROL,
53 	   ARIZONA_IN4_OSR_SHIFT, 1, 0),
54 
55 SOC_DOUBLE_R_RANGE_TLV("IN1 Volume", ARIZONA_IN1L_CONTROL,
56 		       ARIZONA_IN1R_CONTROL,
57 		       ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
58 SOC_DOUBLE_R_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL,
59 		       ARIZONA_IN2R_CONTROL,
60 		       ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
61 SOC_DOUBLE_R_RANGE_TLV("IN3 Volume", ARIZONA_IN3L_CONTROL,
62 		       ARIZONA_IN3R_CONTROL,
63 		       ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
64 
65 SOC_DOUBLE_R("IN1 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_1L,
66 	     ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_MUTE_SHIFT, 1, 1),
67 SOC_DOUBLE_R("IN2 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_2L,
68 	     ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_MUTE_SHIFT, 1, 1),
69 SOC_DOUBLE_R("IN3 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_3L,
70 	     ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_MUTE_SHIFT, 1, 1),
71 SOC_DOUBLE_R("IN4 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_4L,
72 	     ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_MUTE_SHIFT, 1, 1),
73 
74 SOC_DOUBLE_R_TLV("IN1 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
75 		 ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_DIG_VOL_SHIFT,
76 		 0xbf, 0, digital_tlv),
77 SOC_DOUBLE_R_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
78 		 ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_DIG_VOL_SHIFT,
79 		 0xbf, 0, digital_tlv),
80 SOC_DOUBLE_R_TLV("IN3 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_3L,
81 		 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT,
82 		 0xbf, 0, digital_tlv),
83 SOC_DOUBLE_R_TLV("IN4 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_4L,
84 		 ARIZONA_ADC_DIGITAL_VOLUME_4R, ARIZONA_IN4L_DIG_VOL_SHIFT,
85 		 0xbf, 0, digital_tlv),
86 
87 ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
88 ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
89 ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
90 ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
91 
92 SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
93 	       24, 0, eq_tlv),
94 SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
95 	       24, 0, eq_tlv),
96 SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
97 	       24, 0, eq_tlv),
98 SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
99 	       24, 0, eq_tlv),
100 SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
101 	       24, 0, eq_tlv),
102 
103 SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
104 	       24, 0, eq_tlv),
105 SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
106 	       24, 0, eq_tlv),
107 SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
108 	       24, 0, eq_tlv),
109 SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
110 	       24, 0, eq_tlv),
111 SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
112 	       24, 0, eq_tlv),
113 
114 SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
115 	       24, 0, eq_tlv),
116 SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
117 	       24, 0, eq_tlv),
118 SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT,
119 	       24, 0, eq_tlv),
120 SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
121 	       24, 0, eq_tlv),
122 SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
123 	       24, 0, eq_tlv),
124 
125 SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
126 	       24, 0, eq_tlv),
127 SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
128 	       24, 0, eq_tlv),
129 SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT,
130 	       24, 0, eq_tlv),
131 SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT,
132 	       24, 0, eq_tlv),
133 SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT,
134 	       24, 0, eq_tlv),
135 
136 ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
137 ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
138 ARIZONA_MIXER_CONTROLS("DRC2L", ARIZONA_DRC2LMIX_INPUT_1_SOURCE),
139 ARIZONA_MIXER_CONTROLS("DRC2R", ARIZONA_DRC2RMIX_INPUT_1_SOURCE),
140 
141 SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
142 		   ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
143 SND_SOC_BYTES_MASK("DRC2", ARIZONA_DRC2_CTRL1, 5,
144 		   ARIZONA_DRC2R_ENA | ARIZONA_DRC2L_ENA),
145 
146 ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
147 ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
148 ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
149 ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
150 
151 SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
152 SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
153 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
154 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
155 
156 ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
157 ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
158 
159 SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
160 	       ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
161 
162 ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
163 ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
164 ARIZONA_MIXER_CONTROLS("HPOUT2L", ARIZONA_OUT2LMIX_INPUT_1_SOURCE),
165 ARIZONA_MIXER_CONTROLS("HPOUT2R", ARIZONA_OUT2RMIX_INPUT_1_SOURCE),
166 ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
167 ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
168 ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
169 ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
170 ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
171 ARIZONA_MIXER_CONTROLS("SPKDAT2L", ARIZONA_OUT6LMIX_INPUT_1_SOURCE),
172 ARIZONA_MIXER_CONTROLS("SPKDAT2R", ARIZONA_OUT6RMIX_INPUT_1_SOURCE),
173 
174 SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L,
175 	   ARIZONA_OUT1_OSR_SHIFT, 1, 0),
176 SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L,
177 	   ARIZONA_OUT2_OSR_SHIFT, 1, 0),
178 SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L,
179 	   ARIZONA_OUT3_OSR_SHIFT, 1, 0),
180 SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
181 	   ARIZONA_OUT4_OSR_SHIFT, 1, 0),
182 SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
183 	   ARIZONA_OUT5_OSR_SHIFT, 1, 0),
184 SOC_SINGLE("SPKDAT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_6L,
185 	   ARIZONA_OUT6_OSR_SHIFT, 1, 0),
186 
187 SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
188 	     ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
189 SOC_DOUBLE_R("OUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L,
190 	     ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1),
191 SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
192 	   ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
193 SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
194 	     ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
195 SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
196 	     ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
197 SOC_DOUBLE_R("SPKDAT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_6L,
198 	     ARIZONA_DAC_DIGITAL_VOLUME_6R, ARIZONA_OUT6L_MUTE_SHIFT, 1, 1),
199 
200 SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
201 		 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
202 		 0xbf, 0, digital_tlv),
203 SOC_DOUBLE_R_TLV("OUT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L,
204 		 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT,
205 		 0xbf, 0, digital_tlv),
206 SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
207 	       ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
208 SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
209 		 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT,
210 		 0xbf, 0, digital_tlv),
211 SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
212 		 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
213 		 0xbf, 0, digital_tlv),
214 SOC_DOUBLE_R_TLV("SPKDAT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_6L,
215 		 ARIZONA_DAC_DIGITAL_VOLUME_6R, ARIZONA_OUT6L_VOL_SHIFT,
216 		 0xbf, 0, digital_tlv),
217 
218 SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L,
219 		       ARIZONA_OUTPUT_PATH_CONFIG_1R,
220 		       ARIZONA_OUT1L_PGA_VOL_SHIFT,
221 		       0x34, 0x40, 0, ana_tlv),
222 SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L,
223 		       ARIZONA_OUTPUT_PATH_CONFIG_2R,
224 		       ARIZONA_OUT2L_PGA_VOL_SHIFT,
225 		       0x34, 0x40, 0, ana_tlv),
226 SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L,
227 		     ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv),
228 
229 SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
230 	   ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
231 SOC_DOUBLE("SPKDAT2 Switch", ARIZONA_PDM_SPK2_CTRL_1, ARIZONA_SPK2L_MUTE_SHIFT,
232 	   ARIZONA_SPK2R_MUTE_SHIFT, 1, 1),
233 
234 ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
235 ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
236 ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
237 ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
238 ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
239 ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
240 ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
241 ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
242 
243 ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
244 ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
245 
246 ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
247 ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
248 };
249 
250 ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
251 ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
252 ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
253 ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
254 
255 ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
256 ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
257 ARIZONA_MIXER_ENUMS(DRC2L, ARIZONA_DRC2LMIX_INPUT_1_SOURCE);
258 ARIZONA_MIXER_ENUMS(DRC2R, ARIZONA_DRC2RMIX_INPUT_1_SOURCE);
259 
260 ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
261 ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
262 ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
263 ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
264 
265 ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE);
266 ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE);
267 
268 ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
269 ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
270 
271 ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
272 ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
273 ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE);
274 ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE);
275 ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
276 ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
277 ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE);
278 ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
279 ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
280 ARIZONA_MIXER_ENUMS(SPKDAT2L, ARIZONA_OUT6LMIX_INPUT_1_SOURCE);
281 ARIZONA_MIXER_ENUMS(SPKDAT2R, ARIZONA_OUT6RMIX_INPUT_1_SOURCE);
282 
283 ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
284 ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
285 ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
286 ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
287 ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
288 ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
289 ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
290 ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
291 
292 ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
293 ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
294 
295 ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
296 ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
297 
298 ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
299 ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
300 ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
301 ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
302 
303 static const struct snd_soc_dapm_widget wm5110_dapm_widgets[] = {
304 SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
305 		    0, NULL, 0),
306 SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
307 		    ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
308 
309 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0),
310 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0),
311 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20),
312 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0),
313 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0),
314 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0),
315 
316 SND_SOC_DAPM_SIGGEN("TONE"),
317 SND_SOC_DAPM_SIGGEN("NOISE"),
318 
319 SND_SOC_DAPM_INPUT("IN1L"),
320 SND_SOC_DAPM_INPUT("IN1R"),
321 SND_SOC_DAPM_INPUT("IN2L"),
322 SND_SOC_DAPM_INPUT("IN2R"),
323 SND_SOC_DAPM_INPUT("IN3L"),
324 SND_SOC_DAPM_INPUT("IN3R"),
325 SND_SOC_DAPM_INPUT("IN4L"),
326 SND_SOC_DAPM_INPUT("IN4R"),
327 
328 SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
329 		   0, NULL, 0, arizona_in_ev,
330 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
331 SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
332 		   0, NULL, 0, arizona_in_ev,
333 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
334 SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
335 		   0, NULL, 0, arizona_in_ev,
336 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
337 SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
338 		   0, NULL, 0, arizona_in_ev,
339 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
340 SND_SOC_DAPM_PGA_E("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_ENA_SHIFT,
341 		   0, NULL, 0, arizona_in_ev,
342 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
343 SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
344 		   0, NULL, 0, arizona_in_ev,
345 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
346 SND_SOC_DAPM_PGA_E("IN4L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN4L_ENA_SHIFT,
347 		   0, NULL, 0, arizona_in_ev,
348 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
349 SND_SOC_DAPM_PGA_E("IN4R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN4R_ENA_SHIFT,
350 		   0, NULL, 0, arizona_in_ev,
351 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
352 
353 SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
354 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
355 SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
356 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
357 SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
358 		    ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
359 
360 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
361 		 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
362 
363 SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
364 		 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
365 SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
366 		 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
367 
368 SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1,
369 		 ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0),
370 
371 SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
372 SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
373 SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
374 SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
375 
376 SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
377 		 NULL, 0),
378 SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
379 		 NULL, 0),
380 SND_SOC_DAPM_PGA("DRC2L", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2L_ENA_SHIFT, 0,
381 		 NULL, 0),
382 SND_SOC_DAPM_PGA("DRC2R", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2R_ENA_SHIFT, 0,
383 		 NULL, 0),
384 
385 SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
386 		 NULL, 0),
387 SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
388 		 NULL, 0),
389 SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
390 		 NULL, 0),
391 SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
392 		 NULL, 0),
393 
394 SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
395 		 0, NULL, 0),
396 SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
397 		 0, NULL, 0),
398 
399 SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
400 		 NULL, 0),
401 SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
402 		 NULL, 0),
403 SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
404 		 NULL, 0),
405 SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
406 		 NULL, 0),
407 
408 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
409 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
410 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
411 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
412 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
413 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
414 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
415 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
416 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
417 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
418 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
419 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
420 SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
421 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
422 SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
423 		     ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
424 
425 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
426 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
427 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
428 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
429 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
430 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
431 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
432 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
433 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
434 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
435 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
436 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
437 SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
438 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
439 SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
440 		    ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
441 
442 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
443 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
444 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
445 		     ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
446 
447 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
448 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
449 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
450 		    ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
451 
452 SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
453 		     ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
454 SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
455 		     ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
456 
457 SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
458 		    ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
459 SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
460 		    ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
461 
462 SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1,
463 		   ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
464 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
465 SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1,
466 		   ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
467 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
468 SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
469 		   ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
470 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
471 SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
472 		   ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
473 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
474 SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
475 		   ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
476 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
477 SND_SOC_DAPM_PGA_E("OUT4L", ARIZONA_OUTPUT_ENABLES_1,
478 		   ARIZONA_OUT4L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
479 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
480 SND_SOC_DAPM_PGA_E("OUT4R", ARIZONA_OUTPUT_ENABLES_1,
481 		   ARIZONA_OUT4R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
482 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
483 SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
484 		   ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
485 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
486 SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
487 		   ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
488 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
489 SND_SOC_DAPM_PGA_E("OUT6L", ARIZONA_OUTPUT_ENABLES_1,
490 		   ARIZONA_OUT6L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
491 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
492 SND_SOC_DAPM_PGA_E("OUT6R", ARIZONA_OUTPUT_ENABLES_1,
493 		   ARIZONA_OUT6R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
494 		   SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
495 
496 ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
497 ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
498 ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"),
499 ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"),
500 
501 ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
502 ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
503 ARIZONA_MIXER_WIDGETS(DRC2L, "DRC2L"),
504 ARIZONA_MIXER_WIDGETS(DRC2R, "DRC2R"),
505 
506 ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
507 ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
508 ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
509 ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
510 
511 ARIZONA_MIXER_WIDGETS(Mic, "Mic"),
512 ARIZONA_MIXER_WIDGETS(Noise, "Noise"),
513 
514 ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
515 ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
516 
517 ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
518 ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
519 ARIZONA_MIXER_WIDGETS(OUT2L, "HPOUT2L"),
520 ARIZONA_MIXER_WIDGETS(OUT2R, "HPOUT2R"),
521 ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
522 ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"),
523 ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"),
524 ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
525 ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
526 ARIZONA_MIXER_WIDGETS(SPKDAT2L, "SPKDAT2L"),
527 ARIZONA_MIXER_WIDGETS(SPKDAT2R, "SPKDAT2R"),
528 
529 ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
530 ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
531 ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
532 ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
533 ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
534 ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
535 ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
536 ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
537 
538 ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
539 ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
540 
541 ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
542 ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
543 
544 ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"),
545 ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"),
546 ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"),
547 ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"),
548 
549 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
550 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
551 SND_SOC_DAPM_OUTPUT("HPOUT2L"),
552 SND_SOC_DAPM_OUTPUT("HPOUT2R"),
553 SND_SOC_DAPM_OUTPUT("EPOUTN"),
554 SND_SOC_DAPM_OUTPUT("EPOUTP"),
555 SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
556 SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
557 SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
558 SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
559 SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
560 SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
561 SND_SOC_DAPM_OUTPUT("SPKDAT2L"),
562 SND_SOC_DAPM_OUTPUT("SPKDAT2R"),
563 };
564 
565 #define ARIZONA_MIXER_INPUT_ROUTES(name)	\
566 	{ name, "Noise Generator", "Noise Generator" }, \
567 	{ name, "Tone Generator 1", "Tone Generator 1" }, \
568 	{ name, "Tone Generator 2", "Tone Generator 2" }, \
569 	{ name, "IN1L", "IN1L PGA" }, \
570 	{ name, "IN1R", "IN1R PGA" }, \
571 	{ name, "IN2L", "IN2L PGA" }, \
572 	{ name, "IN2R", "IN2R PGA" }, \
573 	{ name, "IN3L", "IN3L PGA" }, \
574 	{ name, "IN3R", "IN3R PGA" }, \
575 	{ name, "IN4L", "IN4L PGA" }, \
576 	{ name, "IN4R", "IN4R PGA" }, \
577 	{ name, "Mic Mute Mixer", "Mic Mute Mixer" }, \
578 	{ name, "AIF1RX1", "AIF1RX1" }, \
579 	{ name, "AIF1RX2", "AIF1RX2" }, \
580 	{ name, "AIF1RX3", "AIF1RX3" }, \
581 	{ name, "AIF1RX4", "AIF1RX4" }, \
582 	{ name, "AIF1RX5", "AIF1RX5" }, \
583 	{ name, "AIF1RX6", "AIF1RX6" }, \
584 	{ name, "AIF1RX7", "AIF1RX7" }, \
585 	{ name, "AIF1RX8", "AIF1RX8" }, \
586 	{ name, "AIF2RX1", "AIF2RX1" }, \
587 	{ name, "AIF2RX2", "AIF2RX2" }, \
588 	{ name, "AIF3RX1", "AIF3RX1" }, \
589 	{ name, "AIF3RX2", "AIF3RX2" }, \
590 	{ name, "EQ1", "EQ1" }, \
591 	{ name, "EQ2", "EQ2" }, \
592 	{ name, "EQ3", "EQ3" }, \
593 	{ name, "EQ4", "EQ4" }, \
594 	{ name, "DRC1L", "DRC1L" }, \
595 	{ name, "DRC1R", "DRC1R" }, \
596 	{ name, "DRC2L", "DRC2L" }, \
597 	{ name, "DRC2R", "DRC2R" }, \
598 	{ name, "LHPF1", "LHPF1" }, \
599 	{ name, "LHPF2", "LHPF2" }, \
600 	{ name, "LHPF3", "LHPF3" }, \
601 	{ name, "LHPF4", "LHPF4" }, \
602 	{ name, "ASRC1L", "ASRC1L" }, \
603 	{ name, "ASRC1R", "ASRC1R" }, \
604 	{ name, "ASRC2L", "ASRC2L" }, \
605 	{ name, "ASRC2R", "ASRC2R" }
606 
607 static const struct snd_soc_dapm_route wm5110_dapm_routes[] = {
608 	{ "AIF2 Capture", NULL, "DBVDD2" },
609 	{ "AIF2 Playback", NULL, "DBVDD2" },
610 
611 	{ "AIF3 Capture", NULL, "DBVDD3" },
612 	{ "AIF3 Playback", NULL, "DBVDD3" },
613 
614 	{ "OUT1L", NULL, "CPVDD" },
615 	{ "OUT1R", NULL, "CPVDD" },
616 	{ "OUT2L", NULL, "CPVDD" },
617 	{ "OUT2R", NULL, "CPVDD" },
618 	{ "OUT3L", NULL, "CPVDD" },
619 
620 	{ "OUT4L", NULL, "SPKVDDL" },
621 	{ "OUT4R", NULL, "SPKVDDR" },
622 
623 	{ "OUT1L", NULL, "SYSCLK" },
624 	{ "OUT1R", NULL, "SYSCLK" },
625 	{ "OUT2L", NULL, "SYSCLK" },
626 	{ "OUT2R", NULL, "SYSCLK" },
627 	{ "OUT3L", NULL, "SYSCLK" },
628 	{ "OUT4L", NULL, "SYSCLK" },
629 	{ "OUT4R", NULL, "SYSCLK" },
630 	{ "OUT5L", NULL, "SYSCLK" },
631 	{ "OUT5R", NULL, "SYSCLK" },
632 	{ "OUT6L", NULL, "SYSCLK" },
633 	{ "OUT6R", NULL, "SYSCLK" },
634 
635 	{ "MICBIAS1", NULL, "MICVDD" },
636 	{ "MICBIAS2", NULL, "MICVDD" },
637 	{ "MICBIAS3", NULL, "MICVDD" },
638 
639 	{ "Noise Generator", NULL, "NOISE" },
640 	{ "Tone Generator 1", NULL, "TONE" },
641 	{ "Tone Generator 2", NULL, "TONE" },
642 
643 	{ "Mic Mute Mixer", NULL, "Noise Mixer" },
644 	{ "Mic Mute Mixer", NULL, "Mic Mixer" },
645 
646 	{ "AIF1 Capture", NULL, "AIF1TX1" },
647 	{ "AIF1 Capture", NULL, "AIF1TX2" },
648 	{ "AIF1 Capture", NULL, "AIF1TX3" },
649 	{ "AIF1 Capture", NULL, "AIF1TX4" },
650 	{ "AIF1 Capture", NULL, "AIF1TX5" },
651 	{ "AIF1 Capture", NULL, "AIF1TX6" },
652 	{ "AIF1 Capture", NULL, "AIF1TX7" },
653 	{ "AIF1 Capture", NULL, "AIF1TX8" },
654 
655 	{ "AIF1RX1", NULL, "AIF1 Playback" },
656 	{ "AIF1RX2", NULL, "AIF1 Playback" },
657 	{ "AIF1RX3", NULL, "AIF1 Playback" },
658 	{ "AIF1RX4", NULL, "AIF1 Playback" },
659 	{ "AIF1RX5", NULL, "AIF1 Playback" },
660 	{ "AIF1RX6", NULL, "AIF1 Playback" },
661 	{ "AIF1RX7", NULL, "AIF1 Playback" },
662 	{ "AIF1RX8", NULL, "AIF1 Playback" },
663 
664 	{ "AIF2 Capture", NULL, "AIF2TX1" },
665 	{ "AIF2 Capture", NULL, "AIF2TX2" },
666 
667 	{ "AIF2RX1", NULL, "AIF2 Playback" },
668 	{ "AIF2RX2", NULL, "AIF2 Playback" },
669 
670 	{ "AIF3 Capture", NULL, "AIF3TX1" },
671 	{ "AIF3 Capture", NULL, "AIF3TX2" },
672 
673 	{ "AIF3RX1", NULL, "AIF3 Playback" },
674 	{ "AIF3RX2", NULL, "AIF3 Playback" },
675 
676 	{ "AIF1 Playback", NULL, "SYSCLK" },
677 	{ "AIF2 Playback", NULL, "SYSCLK" },
678 	{ "AIF3 Playback", NULL, "SYSCLK" },
679 
680 	{ "AIF1 Capture", NULL, "SYSCLK" },
681 	{ "AIF2 Capture", NULL, "SYSCLK" },
682 	{ "AIF3 Capture", NULL, "SYSCLK" },
683 
684 	{ "IN1L PGA", NULL, "IN1L" },
685 	{ "IN1R PGA", NULL, "IN1R" },
686 
687 	{ "IN2L PGA", NULL, "IN2L" },
688 	{ "IN2R PGA", NULL, "IN2R" },
689 
690 	{ "IN3L PGA", NULL, "IN3L" },
691 	{ "IN3R PGA", NULL, "IN3R" },
692 
693 	{ "IN4L PGA", NULL, "IN4L" },
694 	{ "IN4R PGA", NULL, "IN4R" },
695 
696 	ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
697 	ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
698 	ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"),
699 	ARIZONA_MIXER_ROUTES("OUT2R", "HPOUT2R"),
700 	ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"),
701 
702 	ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"),
703 	ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"),
704 	ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
705 	ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
706 	ARIZONA_MIXER_ROUTES("OUT6L", "SPKDAT2L"),
707 	ARIZONA_MIXER_ROUTES("OUT6R", "SPKDAT2R"),
708 
709 	ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
710 	ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
711 
712 	ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
713 	ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
714 	ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
715 	ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
716 	ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
717 	ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
718 	ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
719 	ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
720 
721 	ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
722 	ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
723 
724 	ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
725 	ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
726 
727 	ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
728 	ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
729 	ARIZONA_MIXER_ROUTES("EQ3", "EQ3"),
730 	ARIZONA_MIXER_ROUTES("EQ4", "EQ4"),
731 
732 	ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
733 	ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
734 	ARIZONA_MIXER_ROUTES("DRC2L", "DRC2L"),
735 	ARIZONA_MIXER_ROUTES("DRC2R", "DRC2R"),
736 
737 	ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
738 	ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
739 	ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
740 	ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
741 
742 	ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"),
743 	ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"),
744 	ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"),
745 	ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"),
746 
747 	{ "HPOUT1L", NULL, "OUT1L" },
748 	{ "HPOUT1R", NULL, "OUT1R" },
749 
750 	{ "HPOUT2L", NULL, "OUT2L" },
751 	{ "HPOUT2R", NULL, "OUT2R" },
752 
753 	{ "EPOUTN", NULL, "OUT3L" },
754 	{ "EPOUTP", NULL, "OUT3L" },
755 
756 	{ "SPKOUTLN", NULL, "OUT4L" },
757 	{ "SPKOUTLP", NULL, "OUT4L" },
758 
759 	{ "SPKOUTRN", NULL, "OUT4R" },
760 	{ "SPKOUTRP", NULL, "OUT4R" },
761 
762 	{ "SPKDAT1L", NULL, "OUT5L" },
763 	{ "SPKDAT1R", NULL, "OUT5R" },
764 
765 	{ "SPKDAT2L", NULL, "OUT6L" },
766 	{ "SPKDAT2R", NULL, "OUT6R" },
767 };
768 
769 static int wm5110_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
770 			  unsigned int Fref, unsigned int Fout)
771 {
772 	struct wm5110_priv *wm5110 = snd_soc_codec_get_drvdata(codec);
773 
774 	switch (fll_id) {
775 	case WM5110_FLL1:
776 		return arizona_set_fll(&wm5110->fll[0], source, Fref, Fout);
777 	case WM5110_FLL2:
778 		return arizona_set_fll(&wm5110->fll[1], source, Fref, Fout);
779 	default:
780 		return -EINVAL;
781 	}
782 }
783 
784 #define WM5110_RATES SNDRV_PCM_RATE_8000_192000
785 
786 #define WM5110_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
787 			SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
788 
789 static struct snd_soc_dai_driver wm5110_dai[] = {
790 	{
791 		.name = "wm5110-aif1",
792 		.id = 1,
793 		.base = ARIZONA_AIF1_BCLK_CTRL,
794 		.playback = {
795 			.stream_name = "AIF1 Playback",
796 			.channels_min = 1,
797 			.channels_max = 8,
798 			.rates = WM5110_RATES,
799 			.formats = WM5110_FORMATS,
800 		},
801 		.capture = {
802 			 .stream_name = "AIF1 Capture",
803 			 .channels_min = 1,
804 			 .channels_max = 8,
805 			 .rates = WM5110_RATES,
806 			 .formats = WM5110_FORMATS,
807 		 },
808 		.ops = &arizona_dai_ops,
809 		.symmetric_rates = 1,
810 	},
811 	{
812 		.name = "wm5110-aif2",
813 		.id = 2,
814 		.base = ARIZONA_AIF2_BCLK_CTRL,
815 		.playback = {
816 			.stream_name = "AIF2 Playback",
817 			.channels_min = 1,
818 			.channels_max = 2,
819 			.rates = WM5110_RATES,
820 			.formats = WM5110_FORMATS,
821 		},
822 		.capture = {
823 			 .stream_name = "AIF2 Capture",
824 			 .channels_min = 1,
825 			 .channels_max = 2,
826 			 .rates = WM5110_RATES,
827 			 .formats = WM5110_FORMATS,
828 		 },
829 		.ops = &arizona_dai_ops,
830 		.symmetric_rates = 1,
831 	},
832 	{
833 		.name = "wm5110-aif3",
834 		.id = 3,
835 		.base = ARIZONA_AIF3_BCLK_CTRL,
836 		.playback = {
837 			.stream_name = "AIF3 Playback",
838 			.channels_min = 1,
839 			.channels_max = 2,
840 			.rates = WM5110_RATES,
841 			.formats = WM5110_FORMATS,
842 		},
843 		.capture = {
844 			 .stream_name = "AIF3 Capture",
845 			 .channels_min = 1,
846 			 .channels_max = 2,
847 			 .rates = WM5110_RATES,
848 			 .formats = WM5110_FORMATS,
849 		 },
850 		.ops = &arizona_dai_ops,
851 		.symmetric_rates = 1,
852 	},
853 };
854 
855 static int wm5110_codec_probe(struct snd_soc_codec *codec)
856 {
857 	struct wm5110_priv *priv = snd_soc_codec_get_drvdata(codec);
858 
859 	codec->control_data = priv->core.arizona->regmap;
860 	return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
861 }
862 
863 #define WM5110_DIG_VU 0x0200
864 
865 static unsigned int wm5110_digital_vu[] = {
866 	ARIZONA_ADC_DIGITAL_VOLUME_1L,
867 	ARIZONA_ADC_DIGITAL_VOLUME_1R,
868 	ARIZONA_ADC_DIGITAL_VOLUME_2L,
869 	ARIZONA_ADC_DIGITAL_VOLUME_2R,
870 	ARIZONA_ADC_DIGITAL_VOLUME_3L,
871 	ARIZONA_ADC_DIGITAL_VOLUME_3R,
872 
873 	ARIZONA_DAC_DIGITAL_VOLUME_1L,
874 	ARIZONA_DAC_DIGITAL_VOLUME_1R,
875 	ARIZONA_DAC_DIGITAL_VOLUME_2L,
876 	ARIZONA_DAC_DIGITAL_VOLUME_2R,
877 	ARIZONA_DAC_DIGITAL_VOLUME_3L,
878 	ARIZONA_DAC_DIGITAL_VOLUME_3R,
879 	ARIZONA_DAC_DIGITAL_VOLUME_4L,
880 	ARIZONA_DAC_DIGITAL_VOLUME_4R,
881 	ARIZONA_DAC_DIGITAL_VOLUME_5L,
882 	ARIZONA_DAC_DIGITAL_VOLUME_5R,
883 };
884 
885 static struct snd_soc_codec_driver soc_codec_dev_wm5110 = {
886 	.probe = wm5110_codec_probe,
887 
888 	.idle_bias_off = true,
889 
890 	.set_sysclk = arizona_set_sysclk,
891 	.set_pll = wm5110_set_fll,
892 
893 	.controls = wm5110_snd_controls,
894 	.num_controls = ARRAY_SIZE(wm5110_snd_controls),
895 	.dapm_widgets = wm5110_dapm_widgets,
896 	.num_dapm_widgets = ARRAY_SIZE(wm5110_dapm_widgets),
897 	.dapm_routes = wm5110_dapm_routes,
898 	.num_dapm_routes = ARRAY_SIZE(wm5110_dapm_routes),
899 };
900 
901 static int __devinit wm5110_probe(struct platform_device *pdev)
902 {
903 	struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
904 	struct wm5110_priv *wm5110;
905 	int i;
906 
907 	wm5110 = devm_kzalloc(&pdev->dev, sizeof(struct wm5110_priv),
908 			      GFP_KERNEL);
909 	if (wm5110 == NULL)
910 		return -ENOMEM;
911 	platform_set_drvdata(pdev, wm5110);
912 
913 	wm5110->core.arizona = arizona;
914 
915 	for (i = 0; i < ARRAY_SIZE(wm5110->fll); i++)
916 		wm5110->fll[i].vco_mult = 3;
917 
918 	arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
919 			 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
920 			 &wm5110->fll[0]);
921 	arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
922 			 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
923 			 &wm5110->fll[1]);
924 
925 	for (i = 0; i < ARRAY_SIZE(wm5110_dai); i++)
926 		arizona_init_dai(&wm5110->core, i);
927 
928 	/* Latch volume update bits */
929 	for (i = 0; i < ARRAY_SIZE(wm5110_digital_vu); i++)
930 		regmap_update_bits(arizona->regmap, wm5110_digital_vu[i],
931 				   WM5110_DIG_VU, WM5110_DIG_VU);
932 
933 	pm_runtime_enable(&pdev->dev);
934 	pm_runtime_idle(&pdev->dev);
935 
936 	return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5110,
937 				      wm5110_dai, ARRAY_SIZE(wm5110_dai));
938 }
939 
940 static int __devexit wm5110_remove(struct platform_device *pdev)
941 {
942 	snd_soc_unregister_codec(&pdev->dev);
943 	pm_runtime_disable(&pdev->dev);
944 
945 	return 0;
946 }
947 
948 static struct platform_driver wm5110_codec_driver = {
949 	.driver = {
950 		.name = "wm5110-codec",
951 		.owner = THIS_MODULE,
952 	},
953 	.probe = wm5110_probe,
954 	.remove = __devexit_p(wm5110_remove),
955 };
956 
957 module_platform_driver(wm5110_codec_driver);
958 
959 MODULE_DESCRIPTION("ASoC WM5110 driver");
960 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
961 MODULE_LICENSE("GPL");
962 MODULE_ALIAS("platform:wm5110-codec");
963