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