Version:  2.0.40 2.2.26 2.4.37 3.6 3.7 3.8 3.9 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2

Linux/sound/soc/codecs/wm8997.c

  1 /*
  2  * wm8997.c  --  WM8997 ALSA SoC Audio driver
  3  *
  4  * Copyright 2012 Wolfson Microelectronics plc
  5  *
  6  * Author: Charles Keepax <ckeepax@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 "wm8997.h"
 34 
 35 struct wm8997_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, -13200, 600, 0);
 44 static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
 45 
 46 static const struct reg_default wm8997_sysclk_reva_patch[] = {
 47         { 0x301D, 0x7B15 },
 48         { 0x301B, 0x0050 },
 49         { 0x305D, 0x7B17 },
 50         { 0x305B, 0x0050 },
 51         { 0x3001, 0x08FE },
 52         { 0x3003, 0x00F4 },
 53         { 0x3041, 0x08FF },
 54         { 0x3043, 0x0005 },
 55         { 0x3020, 0x0225 },
 56         { 0x3021, 0x0A00 },
 57         { 0x3022, 0xE24D },
 58         { 0x3023, 0x0800 },
 59         { 0x3024, 0xE24D },
 60         { 0x3025, 0xF000 },
 61         { 0x3060, 0x0226 },
 62         { 0x3061, 0x0A00 },
 63         { 0x3062, 0xE252 },
 64         { 0x3063, 0x0800 },
 65         { 0x3064, 0xE252 },
 66         { 0x3065, 0xF000 },
 67         { 0x3116, 0x022B },
 68         { 0x3117, 0xFA00 },
 69         { 0x3110, 0x246C },
 70         { 0x3111, 0x0A03 },
 71         { 0x3112, 0x246E },
 72         { 0x3113, 0x0A03 },
 73         { 0x3114, 0x2470 },
 74         { 0x3115, 0x0A03 },
 75         { 0x3126, 0x246C },
 76         { 0x3127, 0x0A02 },
 77         { 0x3128, 0x246E },
 78         { 0x3129, 0x0A02 },
 79         { 0x312A, 0x2470 },
 80         { 0x312B, 0xFA02 },
 81         { 0x3125, 0x0800 },
 82 };
 83 
 84 static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w,
 85                             struct snd_kcontrol *kcontrol, int event)
 86 {
 87         struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
 88         struct arizona *arizona = dev_get_drvdata(codec->dev->parent);
 89         struct regmap *regmap = arizona->regmap;
 90         const struct reg_default *patch = NULL;
 91         int i, patch_size;
 92 
 93         switch (arizona->rev) {
 94         case 0:
 95                 patch = wm8997_sysclk_reva_patch;
 96                 patch_size = ARRAY_SIZE(wm8997_sysclk_reva_patch);
 97                 break;
 98         default:
 99                 break;
100         }
101 
102         switch (event) {
103         case SND_SOC_DAPM_POST_PMU:
104                 if (patch)
105                         for (i = 0; i < patch_size; i++)
106                                 regmap_write_async(regmap, patch[i].reg,
107                                                    patch[i].def);
108                 break;
109         case SND_SOC_DAPM_PRE_PMD:
110                 break;
111         default:
112                 return 0;
113         }
114 
115         return arizona_dvfs_sysclk_ev(w, kcontrol, event);
116 }
117 
118 static const char *wm8997_osr_text[] = {
119         "Low power", "Normal", "High performance",
120 };
121 
122 static const unsigned int wm8997_osr_val[] = {
123         0x0, 0x3, 0x5,
124 };
125 
126 static const struct soc_enum wm8997_hpout_osr[] = {
127         SOC_VALUE_ENUM_SINGLE(ARIZONA_OUTPUT_PATH_CONFIG_1L,
128                               ARIZONA_OUT1_OSR_SHIFT, 0x7,
129                               ARRAY_SIZE(wm8997_osr_text),
130                               wm8997_osr_text, wm8997_osr_val),
131         SOC_VALUE_ENUM_SINGLE(ARIZONA_OUTPUT_PATH_CONFIG_3L,
132                               ARIZONA_OUT3_OSR_SHIFT, 0x7,
133                               ARRAY_SIZE(wm8997_osr_text),
134                               wm8997_osr_text, wm8997_osr_val),
135 };
136 
137 #define WM8997_NG_SRC(name, base) \
138         SOC_SINGLE(name " NG HPOUT1L Switch",  base, 0, 1, 0), \
139         SOC_SINGLE(name " NG HPOUT1R Switch",  base, 1, 1, 0), \
140         SOC_SINGLE(name " NG EPOUT Switch",    base, 4, 1, 0), \
141         SOC_SINGLE(name " NG SPKOUT Switch",   base, 6, 1, 0), \
142         SOC_SINGLE(name " NG SPKDAT1L Switch", base, 8, 1, 0), \
143         SOC_SINGLE(name " NG SPKDAT1R Switch", base, 9, 1, 0)
144 
145 static const struct snd_kcontrol_new wm8997_snd_controls[] = {
146 SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
147            ARIZONA_IN1_OSR_SHIFT, 1, 0),
148 SOC_SINGLE("IN2 High Performance Switch", ARIZONA_IN2L_CONTROL,
149            ARIZONA_IN2_OSR_SHIFT, 1, 0),
150 
151 SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL,
152                      ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
153 SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL,
154                      ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
155 SOC_SINGLE_RANGE_TLV("IN2L Volume", ARIZONA_IN2L_CONTROL,
156                      ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
157 SOC_SINGLE_RANGE_TLV("IN2R Volume", ARIZONA_IN2R_CONTROL,
158                      ARIZONA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
159 
160 SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
161                ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
162 SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R,
163                ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
164 SOC_SINGLE_TLV("IN2L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
165                ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
166 SOC_SINGLE_TLV("IN2R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2R,
167                ARIZONA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
168 
169 SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
170 SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
171 
172 ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
173 ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
174 ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
175 ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
176 
177 SND_SOC_BYTES("EQ1 Coefficients", ARIZONA_EQ1_3, 19),
178 SOC_SINGLE("EQ1 Mode Switch", ARIZONA_EQ1_2, ARIZONA_EQ1_B1_MODE, 1, 0),
179 SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
180                24, 0, eq_tlv),
181 SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
182                24, 0, eq_tlv),
183 SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
184                24, 0, eq_tlv),
185 SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
186                24, 0, eq_tlv),
187 SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
188                24, 0, eq_tlv),
189 
190 SND_SOC_BYTES("EQ2 Coefficients", ARIZONA_EQ2_3, 19),
191 SOC_SINGLE("EQ2 Mode Switch", ARIZONA_EQ2_2, ARIZONA_EQ2_B1_MODE, 1, 0),
192 SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
193                24, 0, eq_tlv),
194 SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
195                24, 0, eq_tlv),
196 SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
197                24, 0, eq_tlv),
198 SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
199                24, 0, eq_tlv),
200 SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
201                24, 0, eq_tlv),
202 
203 SND_SOC_BYTES("EQ3 Coefficients", ARIZONA_EQ3_3, 19),
204 SOC_SINGLE("EQ3 Mode Switch", ARIZONA_EQ3_2, ARIZONA_EQ3_B1_MODE, 1, 0),
205 SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
206                24, 0, eq_tlv),
207 SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
208                24, 0, eq_tlv),
209 SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT,
210                24, 0, eq_tlv),
211 SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
212                24, 0, eq_tlv),
213 SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
214                24, 0, eq_tlv),
215 
216 SND_SOC_BYTES("EQ4 Coefficients", ARIZONA_EQ4_3, 19),
217 SOC_SINGLE("EQ4 Mode Switch", ARIZONA_EQ4_2, ARIZONA_EQ4_B1_MODE, 1, 0),
218 SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
219                24, 0, eq_tlv),
220 SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
221                24, 0, eq_tlv),
222 SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT,
223                24, 0, eq_tlv),
224 SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT,
225                24, 0, eq_tlv),
226 SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT,
227                24, 0, eq_tlv),
228 
229 ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
230 ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
231 
232 SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
233                    ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
234 
235 ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
236 ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
237 ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
238 ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
239 
240 SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
241 SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
242 SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
243 SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
244 
245 SND_SOC_BYTES("LHPF1 Coefficients", ARIZONA_HPLPF1_2, 1),
246 SND_SOC_BYTES("LHPF2 Coefficients", ARIZONA_HPLPF2_2, 1),
247 SND_SOC_BYTES("LHPF3 Coefficients", ARIZONA_HPLPF3_2, 1),
248 SND_SOC_BYTES("LHPF4 Coefficients", ARIZONA_HPLPF4_2, 1),
249 
250 SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
251 SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
252 
253 ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
254 ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
255 
256 SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
257                ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
258 
259 ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
260 ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
261 ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
262 ARIZONA_MIXER_CONTROLS("SPKOUT", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
263 ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
264 ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
265 
266 SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
267            ARIZONA_OUT4_OSR_SHIFT, 1, 0),
268 SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
269            ARIZONA_OUT5_OSR_SHIFT, 1, 0),
270 
271 SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
272              ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
273 SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
274            ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
275 SOC_SINGLE("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
276            ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
277 SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
278              ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
279 
280 SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
281                  ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
282                  0xbf, 0, digital_tlv),
283 SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
284                ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
285 SOC_SINGLE_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
286                ARIZONA_OUT4L_VOL_SHIFT, 0xbf, 0, digital_tlv),
287 SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
288                  ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
289                  0xbf, 0, digital_tlv),
290 
291 SOC_ENUM("HPOUT1 OSR", wm8997_hpout_osr[0]),
292 SOC_ENUM("EPOUT OSR", wm8997_hpout_osr[1]),
293 
294 SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
295 SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
296 
297 SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
298            ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
299 
300 SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL,
301            ARIZONA_NGATE_ENA_SHIFT, 1, 0),
302 SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL,
303                ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),
304 SOC_ENUM("Noise Gate Hold", arizona_ng_hold),
305 
306 WM8997_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L),
307 WM8997_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R),
308 WM8997_NG_SRC("EPOUT", ARIZONA_NOISE_GATE_SELECT_3L),
309 WM8997_NG_SRC("SPKOUT", ARIZONA_NOISE_GATE_SELECT_4L),
310 WM8997_NG_SRC("SPKDAT1L", ARIZONA_NOISE_GATE_SELECT_5L),
311 WM8997_NG_SRC("SPKDAT1R", ARIZONA_NOISE_GATE_SELECT_5R),
312 
313 ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
314 ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
315 ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
316 ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
317 ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
318 ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
319 ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
320 ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
321 
322 ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
323 ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
324 
325 ARIZONA_MIXER_CONTROLS("SLIMTX1", ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE),
326 ARIZONA_MIXER_CONTROLS("SLIMTX2", ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE),
327 ARIZONA_MIXER_CONTROLS("SLIMTX3", ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE),
328 ARIZONA_MIXER_CONTROLS("SLIMTX4", ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE),
329 ARIZONA_MIXER_CONTROLS("SLIMTX5", ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE),
330 ARIZONA_MIXER_CONTROLS("SLIMTX6", ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE),
331 ARIZONA_MIXER_CONTROLS("SLIMTX7", ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE),
332 ARIZONA_MIXER_CONTROLS("SLIMTX8", ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE),
333 };
334 
335 ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
336 ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
337 ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
338 ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
339 
340 ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
341 ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
342 
343 ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
344 ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
345 ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
346 ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
347 
348 ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE);
349 ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE);
350 
351 ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
352 ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
353 
354 ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
355 ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
356 ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
357 ARIZONA_MIXER_ENUMS(SPKOUT, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
358 ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
359 ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
360 
361 ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
362 ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
363 ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
364 ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
365 ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
366 ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
367 ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
368 ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
369 
370 ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
371 ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
372 
373 ARIZONA_MIXER_ENUMS(SLIMTX1, ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE);
374 ARIZONA_MIXER_ENUMS(SLIMTX2, ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE);
375 ARIZONA_MIXER_ENUMS(SLIMTX3, ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE);
376 ARIZONA_MIXER_ENUMS(SLIMTX4, ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE);
377 ARIZONA_MIXER_ENUMS(SLIMTX5, ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE);
378 ARIZONA_MIXER_ENUMS(SLIMTX6, ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE);
379 ARIZONA_MIXER_ENUMS(SLIMTX7, ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE);
380 ARIZONA_MIXER_ENUMS(SLIMTX8, ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE);
381 
382 ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE);
383 ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE);
384 
385 ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE);
386 ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE);
387 
388 ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE);
389 ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE);
390 
391 ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE);
392 ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE);
393 
394 static const char *wm8997_aec_loopback_texts[] = {
395         "HPOUT1L", "HPOUT1R", "EPOUT", "SPKOUT", "SPKDAT1L", "SPKDAT1R",
396 };
397 
398 static const unsigned int wm8997_aec_loopback_values[] = {
399         0, 1, 4, 6, 8, 9,
400 };
401 
402 static const struct soc_enum wm8997_aec_loopback =
403         SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
404                               ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
405                               ARRAY_SIZE(wm8997_aec_loopback_texts),
406                               wm8997_aec_loopback_texts,
407                               wm8997_aec_loopback_values);
408 
409 static const struct snd_kcontrol_new wm8997_aec_loopback_mux =
410         SOC_DAPM_ENUM("AEC Loopback", wm8997_aec_loopback);
411 
412 static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = {
413 SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
414                     0, wm8997_sysclk_ev,
415                     SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
416 SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
417                     ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
418 SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
419                     ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
420 SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
421                     ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
422 
423 SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
424 SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
425 SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
426 SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
427 
428 SND_SOC_DAPM_SIGGEN("TONE"),
429 SND_SOC_DAPM_SIGGEN("NOISE"),
430 SND_SOC_DAPM_SIGGEN("HAPTICS"),
431 
432 SND_SOC_DAPM_INPUT("IN1L"),
433 SND_SOC_DAPM_INPUT("IN1R"),
434 SND_SOC_DAPM_INPUT("IN2L"),
435 SND_SOC_DAPM_INPUT("IN2R"),
436 
437 SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
438                    0, NULL, 0, arizona_in_ev,
439                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
440                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
441 SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
442                    0, NULL, 0, arizona_in_ev,
443                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
444                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
445 SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
446                    0, NULL, 0, arizona_in_ev,
447                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
448                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
449 SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
450                    0, NULL, 0, arizona_in_ev,
451                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
452                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
453 
454 SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
455                     ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
456 SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
457                     ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
458 SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
459                     ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
460 
461 SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
462                  ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
463 
464 SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
465                  ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
466 SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
467                  ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
468 
469 SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1,
470                  ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0),
471 
472 SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
473 SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
474 SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
475 SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
476 
477 SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
478                  NULL, 0),
479 SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
480                  NULL, 0),
481 
482 SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
483                  NULL, 0),
484 SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
485                  NULL, 0),
486 SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
487                  NULL, 0),
488 SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
489                  NULL, 0),
490 
491 SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
492                  0, NULL, 0),
493 SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
494                  0, NULL, 0),
495 
496 SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3,
497                  ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0),
498 SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3,
499                  ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
500 
501 SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3,
502                  ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0),
503 SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3,
504                  ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
505 
506 SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3,
507                  ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0),
508 SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3,
509                  ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
510 
511 SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3,
512                  ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0),
513 SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3,
514                  ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
515 
516 SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
517                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
518 SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
519                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
520 SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
521                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
522 SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
523                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
524 SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
525                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
526 SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
527                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
528 SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
529                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
530 SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
531                      ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
532 
533 SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
534                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
535 SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
536                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
537 SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
538                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
539 SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
540                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
541 SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
542                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
543 SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
544                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
545 SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
546                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
547 SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
548                     ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
549 
550 SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
551                      ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
552 SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
553                      ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
554 
555 SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
556                     ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
557 SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
558                     ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
559 
560 SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0,
561                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
562                      ARIZONA_SLIMTX1_ENA_SHIFT, 0),
563 SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 0,
564                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
565                      ARIZONA_SLIMTX2_ENA_SHIFT, 0),
566 SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 0,
567                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
568                      ARIZONA_SLIMTX3_ENA_SHIFT, 0),
569 SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 0,
570                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
571                      ARIZONA_SLIMTX4_ENA_SHIFT, 0),
572 SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 0,
573                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
574                      ARIZONA_SLIMTX5_ENA_SHIFT, 0),
575 SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 0,
576                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
577                      ARIZONA_SLIMTX6_ENA_SHIFT, 0),
578 SND_SOC_DAPM_AIF_OUT("SLIMTX7", NULL, 0,
579                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
580                      ARIZONA_SLIMTX7_ENA_SHIFT, 0),
581 SND_SOC_DAPM_AIF_OUT("SLIMTX8", NULL, 0,
582                      ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
583                      ARIZONA_SLIMTX8_ENA_SHIFT, 0),
584 
585 SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0,
586                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
587                     ARIZONA_SLIMRX1_ENA_SHIFT, 0),
588 SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 0,
589                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
590                     ARIZONA_SLIMRX2_ENA_SHIFT, 0),
591 SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 0,
592                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
593                     ARIZONA_SLIMRX3_ENA_SHIFT, 0),
594 SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 0,
595                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
596                     ARIZONA_SLIMRX4_ENA_SHIFT, 0),
597 SND_SOC_DAPM_AIF_IN("SLIMRX5", NULL, 0,
598                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
599                     ARIZONA_SLIMRX5_ENA_SHIFT, 0),
600 SND_SOC_DAPM_AIF_IN("SLIMRX6", NULL, 0,
601                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
602                     ARIZONA_SLIMRX6_ENA_SHIFT, 0),
603 SND_SOC_DAPM_AIF_IN("SLIMRX7", NULL, 0,
604                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
605                     ARIZONA_SLIMRX7_ENA_SHIFT, 0),
606 SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 0,
607                     ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
608                     ARIZONA_SLIMRX8_ENA_SHIFT, 0),
609 
610 SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
611                        ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0,
612                        &wm8997_aec_loopback_mux),
613 
614 SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
615                    ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
616                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
617                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
618 SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
619                    ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
620                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
621                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
622 SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
623                    ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
624                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
625                    SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
626 SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
627                    ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
628                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
629 SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
630                    ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
631                    SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
632 
633 ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
634 ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
635 ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"),
636 ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"),
637 
638 ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
639 ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
640 
641 ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
642 ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
643 ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
644 ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
645 
646 ARIZONA_MIXER_WIDGETS(Mic, "Mic"),
647 ARIZONA_MIXER_WIDGETS(Noise, "Noise"),
648 
649 ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
650 ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
651 
652 ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
653 ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
654 ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
655 ARIZONA_MIXER_WIDGETS(SPKOUT, "SPKOUT"),
656 ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
657 ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
658 
659 ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
660 ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
661 ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
662 ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
663 ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
664 ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
665 ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
666 ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
667 
668 ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
669 ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
670 
671 ARIZONA_MIXER_WIDGETS(SLIMTX1, "SLIMTX1"),
672 ARIZONA_MIXER_WIDGETS(SLIMTX2, "SLIMTX2"),
673 ARIZONA_MIXER_WIDGETS(SLIMTX3, "SLIMTX3"),
674 ARIZONA_MIXER_WIDGETS(SLIMTX4, "SLIMTX4"),
675 ARIZONA_MIXER_WIDGETS(SLIMTX5, "SLIMTX5"),
676 ARIZONA_MIXER_WIDGETS(SLIMTX6, "SLIMTX6"),
677 ARIZONA_MIXER_WIDGETS(SLIMTX7, "SLIMTX7"),
678 ARIZONA_MIXER_WIDGETS(SLIMTX8, "SLIMTX8"),
679 
680 ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
681 ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
682 
683 ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
684 ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
685 
686 ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
687 ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
688 
689 ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
690 ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
691 
692 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
693 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
694 SND_SOC_DAPM_OUTPUT("EPOUTN"),
695 SND_SOC_DAPM_OUTPUT("EPOUTP"),
696 SND_SOC_DAPM_OUTPUT("SPKOUTN"),
697 SND_SOC_DAPM_OUTPUT("SPKOUTP"),
698 SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
699 SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
700 
701 SND_SOC_DAPM_OUTPUT("MICSUPP"),
702 };
703 
704 #define ARIZONA_MIXER_INPUT_ROUTES(name)        \
705         { name, "Noise Generator", "Noise Generator" }, \
706         { name, "Tone Generator 1", "Tone Generator 1" }, \
707         { name, "Tone Generator 2", "Tone Generator 2" }, \
708         { name, "Haptics", "HAPTICS" }, \
709         { name, "AEC", "AEC Loopback" }, \
710         { name, "IN1L", "IN1L PGA" }, \
711         { name, "IN1R", "IN1R PGA" }, \
712         { name, "IN2L", "IN2L PGA" }, \
713         { name, "IN2R", "IN2R PGA" }, \
714         { name, "Mic Mute Mixer", "Mic Mute Mixer" }, \
715         { name, "AIF1RX1", "AIF1RX1" }, \
716         { name, "AIF1RX2", "AIF1RX2" }, \
717         { name, "AIF1RX3", "AIF1RX3" }, \
718         { name, "AIF1RX4", "AIF1RX4" }, \
719         { name, "AIF1RX5", "AIF1RX5" }, \
720         { name, "AIF1RX6", "AIF1RX6" }, \
721         { name, "AIF1RX7", "AIF1RX7" }, \
722         { name, "AIF1RX8", "AIF1RX8" }, \
723         { name, "AIF2RX1", "AIF2RX1" }, \
724         { name, "AIF2RX2", "AIF2RX2" }, \
725         { name, "SLIMRX1", "SLIMRX1" }, \
726         { name, "SLIMRX2", "SLIMRX2" }, \
727         { name, "SLIMRX3", "SLIMRX3" }, \
728         { name, "SLIMRX4", "SLIMRX4" }, \
729         { name, "SLIMRX5", "SLIMRX5" }, \
730         { name, "SLIMRX6", "SLIMRX6" }, \
731         { name, "SLIMRX7", "SLIMRX7" }, \
732         { name, "SLIMRX8", "SLIMRX8" }, \
733         { name, "EQ1", "EQ1" }, \
734         { name, "EQ2", "EQ2" }, \
735         { name, "EQ3", "EQ3" }, \
736         { name, "EQ4", "EQ4" }, \
737         { name, "DRC1L", "DRC1L" }, \
738         { name, "DRC1R", "DRC1R" }, \
739         { name, "LHPF1", "LHPF1" }, \
740         { name, "LHPF2", "LHPF2" }, \
741         { name, "LHPF3", "LHPF3" }, \
742         { name, "LHPF4", "LHPF4" }, \
743         { name, "ISRC1DEC1", "ISRC1DEC1" }, \
744         { name, "ISRC1DEC2", "ISRC1DEC2" }, \
745         { name, "ISRC1INT1", "ISRC1INT1" }, \
746         { name, "ISRC1INT2", "ISRC1INT2" }, \
747         { name, "ISRC2DEC1", "ISRC2DEC1" }, \
748         { name, "ISRC2DEC2", "ISRC2DEC2" }, \
749         { name, "ISRC2INT1", "ISRC2INT1" }, \
750         { name, "ISRC2INT2", "ISRC2INT2" }
751 
752 static const struct snd_soc_dapm_route wm8997_dapm_routes[] = {
753         { "AIF2 Capture", NULL, "DBVDD2" },
754         { "AIF2 Playback", NULL, "DBVDD2" },
755 
756         { "OUT1L", NULL, "CPVDD" },
757         { "OUT1R", NULL, "CPVDD" },
758         { "OUT3L", NULL, "CPVDD" },
759 
760         { "OUT4L", NULL, "SPKVDD" },
761 
762         { "OUT1L", NULL, "SYSCLK" },
763         { "OUT1R", NULL, "SYSCLK" },
764         { "OUT3L", NULL, "SYSCLK" },
765         { "OUT4L", NULL, "SYSCLK" },
766 
767         { "IN1L", NULL, "SYSCLK" },
768         { "IN1R", NULL, "SYSCLK" },
769         { "IN2L", NULL, "SYSCLK" },
770         { "IN2R", NULL, "SYSCLK" },
771 
772         { "MICBIAS1", NULL, "MICVDD" },
773         { "MICBIAS2", NULL, "MICVDD" },
774         { "MICBIAS3", NULL, "MICVDD" },
775 
776         { "Noise Generator", NULL, "SYSCLK" },
777         { "Tone Generator 1", NULL, "SYSCLK" },
778         { "Tone Generator 2", NULL, "SYSCLK" },
779 
780         { "Noise Generator", NULL, "NOISE" },
781         { "Tone Generator 1", NULL, "TONE" },
782         { "Tone Generator 2", NULL, "TONE" },
783 
784         { "AIF1 Capture", NULL, "AIF1TX1" },
785         { "AIF1 Capture", NULL, "AIF1TX2" },
786         { "AIF1 Capture", NULL, "AIF1TX3" },
787         { "AIF1 Capture", NULL, "AIF1TX4" },
788         { "AIF1 Capture", NULL, "AIF1TX5" },
789         { "AIF1 Capture", NULL, "AIF1TX6" },
790         { "AIF1 Capture", NULL, "AIF1TX7" },
791         { "AIF1 Capture", NULL, "AIF1TX8" },
792 
793         { "AIF1RX1", NULL, "AIF1 Playback" },
794         { "AIF1RX2", NULL, "AIF1 Playback" },
795         { "AIF1RX3", NULL, "AIF1 Playback" },
796         { "AIF1RX4", NULL, "AIF1 Playback" },
797         { "AIF1RX5", NULL, "AIF1 Playback" },
798         { "AIF1RX6", NULL, "AIF1 Playback" },
799         { "AIF1RX7", NULL, "AIF1 Playback" },
800         { "AIF1RX8", NULL, "AIF1 Playback" },
801 
802         { "AIF2 Capture", NULL, "AIF2TX1" },
803         { "AIF2 Capture", NULL, "AIF2TX2" },
804 
805         { "AIF2RX1", NULL, "AIF2 Playback" },
806         { "AIF2RX2", NULL, "AIF2 Playback" },
807 
808         { "Slim1 Capture", NULL, "SLIMTX1" },
809         { "Slim1 Capture", NULL, "SLIMTX2" },
810         { "Slim1 Capture", NULL, "SLIMTX3" },
811         { "Slim1 Capture", NULL, "SLIMTX4" },
812 
813         { "SLIMRX1", NULL, "Slim1 Playback" },
814         { "SLIMRX2", NULL, "Slim1 Playback" },
815         { "SLIMRX3", NULL, "Slim1 Playback" },
816         { "SLIMRX4", NULL, "Slim1 Playback" },
817 
818         { "Slim2 Capture", NULL, "SLIMTX5" },
819         { "Slim2 Capture", NULL, "SLIMTX6" },
820 
821         { "SLIMRX5", NULL, "Slim2 Playback" },
822         { "SLIMRX6", NULL, "Slim2 Playback" },
823 
824         { "Slim3 Capture", NULL, "SLIMTX7" },
825         { "Slim3 Capture", NULL, "SLIMTX8" },
826 
827         { "SLIMRX7", NULL, "Slim3 Playback" },
828         { "SLIMRX8", NULL, "Slim3 Playback" },
829 
830         { "AIF1 Playback", NULL, "SYSCLK" },
831         { "AIF2 Playback", NULL, "SYSCLK" },
832         { "Slim1 Playback", NULL, "SYSCLK" },
833         { "Slim2 Playback", NULL, "SYSCLK" },
834         { "Slim3 Playback", NULL, "SYSCLK" },
835 
836         { "AIF1 Capture", NULL, "SYSCLK" },
837         { "AIF2 Capture", NULL, "SYSCLK" },
838         { "Slim1 Capture", NULL, "SYSCLK" },
839         { "Slim2 Capture", NULL, "SYSCLK" },
840         { "Slim3 Capture", NULL, "SYSCLK" },
841 
842         { "IN1L PGA", NULL, "IN1L" },
843         { "IN1R PGA", NULL, "IN1R" },
844 
845         { "IN2L PGA", NULL, "IN2L" },
846         { "IN2R PGA", NULL, "IN2R" },
847 
848         ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
849         ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
850         ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"),
851 
852         ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUT"),
853         ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
854         ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
855 
856         ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
857         ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
858 
859         ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
860         ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
861         ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
862         ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
863         ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
864         ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
865         ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
866         ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
867 
868         ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
869         ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
870 
871         ARIZONA_MIXER_ROUTES("SLIMTX1", "SLIMTX1"),
872         ARIZONA_MIXER_ROUTES("SLIMTX2", "SLIMTX2"),
873         ARIZONA_MIXER_ROUTES("SLIMTX3", "SLIMTX3"),
874         ARIZONA_MIXER_ROUTES("SLIMTX4", "SLIMTX4"),
875         ARIZONA_MIXER_ROUTES("SLIMTX5", "SLIMTX5"),
876         ARIZONA_MIXER_ROUTES("SLIMTX6", "SLIMTX6"),
877         ARIZONA_MIXER_ROUTES("SLIMTX7", "SLIMTX7"),
878         ARIZONA_MIXER_ROUTES("SLIMTX8", "SLIMTX8"),
879 
880         ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
881         ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
882         ARIZONA_MIXER_ROUTES("EQ3", "EQ3"),
883         ARIZONA_MIXER_ROUTES("EQ4", "EQ4"),
884 
885         ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
886         ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
887 
888         ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
889         ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
890         ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
891         ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
892 
893         ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Noise"),
894         ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Mic"),
895 
896         ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
897         ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
898 
899         ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
900         ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
901 
902         ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
903         ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
904 
905         ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
906         ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
907 
908         { "AEC Loopback", "HPOUT1L", "OUT1L" },
909         { "AEC Loopback", "HPOUT1R", "OUT1R" },
910         { "HPOUT1L", NULL, "OUT1L" },
911         { "HPOUT1R", NULL, "OUT1R" },
912 
913         { "AEC Loopback", "EPOUT", "OUT3L" },
914         { "EPOUTN", NULL, "OUT3L" },
915         { "EPOUTP", NULL, "OUT3L" },
916 
917         { "AEC Loopback", "SPKOUT", "OUT4L" },
918         { "SPKOUTN", NULL, "OUT4L" },
919         { "SPKOUTP", NULL, "OUT4L" },
920 
921         { "AEC Loopback", "SPKDAT1L", "OUT5L" },
922         { "AEC Loopback", "SPKDAT1R", "OUT5R" },
923         { "SPKDAT1L", NULL, "OUT5L" },
924         { "SPKDAT1R", NULL, "OUT5R" },
925 
926         { "MICSUPP", NULL, "SYSCLK" },
927 };
928 
929 static int wm8997_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
930                           unsigned int Fref, unsigned int Fout)
931 {
932         struct wm8997_priv *wm8997 = snd_soc_codec_get_drvdata(codec);
933 
934         switch (fll_id) {
935         case WM8997_FLL1:
936                 return arizona_set_fll(&wm8997->fll[0], source, Fref, Fout);
937         case WM8997_FLL2:
938                 return arizona_set_fll(&wm8997->fll[1], source, Fref, Fout);
939         case WM8997_FLL1_REFCLK:
940                 return arizona_set_fll_refclk(&wm8997->fll[0], source, Fref,
941                                               Fout);
942         case WM8997_FLL2_REFCLK:
943                 return arizona_set_fll_refclk(&wm8997->fll[1], source, Fref,
944                                               Fout);
945         default:
946                 return -EINVAL;
947         }
948 }
949 
950 #define WM8997_RATES SNDRV_PCM_RATE_8000_192000
951 
952 #define WM8997_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
953                         SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
954 
955 static struct snd_soc_dai_driver wm8997_dai[] = {
956         {
957                 .name = "wm8997-aif1",
958                 .id = 1,
959                 .base = ARIZONA_AIF1_BCLK_CTRL,
960                 .playback = {
961                         .stream_name = "AIF1 Playback",
962                         .channels_min = 1,
963                         .channels_max = 8,
964                         .rates = WM8997_RATES,
965                         .formats = WM8997_FORMATS,
966                 },
967                 .capture = {
968                          .stream_name = "AIF1 Capture",
969                          .channels_min = 1,
970                          .channels_max = 8,
971                          .rates = WM8997_RATES,
972                          .formats = WM8997_FORMATS,
973                  },
974                 .ops = &arizona_dai_ops,
975                 .symmetric_rates = 1,
976                 .symmetric_samplebits = 1,
977         },
978         {
979                 .name = "wm8997-aif2",
980                 .id = 2,
981                 .base = ARIZONA_AIF2_BCLK_CTRL,
982                 .playback = {
983                         .stream_name = "AIF2 Playback",
984                         .channels_min = 1,
985                         .channels_max = 2,
986                         .rates = WM8997_RATES,
987                         .formats = WM8997_FORMATS,
988                 },
989                 .capture = {
990                          .stream_name = "AIF2 Capture",
991                          .channels_min = 1,
992                          .channels_max = 2,
993                          .rates = WM8997_RATES,
994                          .formats = WM8997_FORMATS,
995                  },
996                 .ops = &arizona_dai_ops,
997                 .symmetric_rates = 1,
998                 .symmetric_samplebits = 1,
999         },
1000         {
1001                 .name = "wm8997-slim1",
1002                 .id = 3,
1003                 .playback = {
1004                         .stream_name = "Slim1 Playback",
1005                         .channels_min = 1,
1006                         .channels_max = 4,
1007                         .rates = WM8997_RATES,
1008                         .formats = WM8997_FORMATS,
1009                 },
1010                 .capture = {
1011                         .stream_name = "Slim1 Capture",
1012                         .channels_min = 1,
1013                         .channels_max = 4,
1014                         .rates = WM8997_RATES,
1015                         .formats = WM8997_FORMATS,
1016                 },
1017                 .ops = &arizona_simple_dai_ops,
1018         },
1019         {
1020                 .name = "wm8997-slim2",
1021                 .id = 4,
1022                 .playback = {
1023                         .stream_name = "Slim2 Playback",
1024                         .channels_min = 1,
1025                         .channels_max = 2,
1026                         .rates = WM8997_RATES,
1027                         .formats = WM8997_FORMATS,
1028                 },
1029                 .capture = {
1030                         .stream_name = "Slim2 Capture",
1031                         .channels_min = 1,
1032                         .channels_max = 2,
1033                         .rates = WM8997_RATES,
1034                         .formats = WM8997_FORMATS,
1035                 },
1036                 .ops = &arizona_simple_dai_ops,
1037         },
1038         {
1039                 .name = "wm8997-slim3",
1040                 .id = 5,
1041                 .playback = {
1042                         .stream_name = "Slim3 Playback",
1043                         .channels_min = 1,
1044                         .channels_max = 2,
1045                         .rates = WM8997_RATES,
1046                         .formats = WM8997_FORMATS,
1047                 },
1048                 .capture = {
1049                         .stream_name = "Slim3 Capture",
1050                         .channels_min = 1,
1051                         .channels_max = 2,
1052                         .rates = WM8997_RATES,
1053                         .formats = WM8997_FORMATS,
1054                 },
1055                 .ops = &arizona_simple_dai_ops,
1056         },
1057 };
1058 
1059 static int wm8997_codec_probe(struct snd_soc_codec *codec)
1060 {
1061         struct snd_soc_dapm_context *dapm = snd_soc_codec_get_dapm(codec);
1062         struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
1063 
1064         arizona_init_spk(codec);
1065 
1066         snd_soc_dapm_disable_pin(dapm, "HAPTICS");
1067 
1068         priv->core.arizona->dapm = dapm;
1069 
1070         return 0;
1071 }
1072 
1073 static int wm8997_codec_remove(struct snd_soc_codec *codec)
1074 {
1075         struct wm8997_priv *priv = snd_soc_codec_get_drvdata(codec);
1076 
1077         priv->core.arizona->dapm = NULL;
1078 
1079         return 0;
1080 }
1081 
1082 #define WM8997_DIG_VU 0x0200
1083 
1084 static unsigned int wm8997_digital_vu[] = {
1085         ARIZONA_DAC_DIGITAL_VOLUME_1L,
1086         ARIZONA_DAC_DIGITAL_VOLUME_1R,
1087         ARIZONA_DAC_DIGITAL_VOLUME_3L,
1088         ARIZONA_DAC_DIGITAL_VOLUME_4L,
1089         ARIZONA_DAC_DIGITAL_VOLUME_5L,
1090         ARIZONA_DAC_DIGITAL_VOLUME_5R,
1091 };
1092 
1093 static struct regmap *wm8997_get_regmap(struct device *dev)
1094 {
1095         struct wm8997_priv *priv = dev_get_drvdata(dev);
1096 
1097         return priv->core.arizona->regmap;
1098 }
1099 
1100 static struct snd_soc_codec_driver soc_codec_dev_wm8997 = {
1101         .probe = wm8997_codec_probe,
1102         .remove = wm8997_codec_remove,
1103         .get_regmap =   wm8997_get_regmap,
1104 
1105         .idle_bias_off = true,
1106 
1107         .set_sysclk = arizona_set_sysclk,
1108         .set_pll = wm8997_set_fll,
1109 
1110         .controls = wm8997_snd_controls,
1111         .num_controls = ARRAY_SIZE(wm8997_snd_controls),
1112         .dapm_widgets = wm8997_dapm_widgets,
1113         .num_dapm_widgets = ARRAY_SIZE(wm8997_dapm_widgets),
1114         .dapm_routes = wm8997_dapm_routes,
1115         .num_dapm_routes = ARRAY_SIZE(wm8997_dapm_routes),
1116 };
1117 
1118 static int wm8997_probe(struct platform_device *pdev)
1119 {
1120         struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1121         struct wm8997_priv *wm8997;
1122         int i;
1123 
1124         wm8997 = devm_kzalloc(&pdev->dev, sizeof(struct wm8997_priv),
1125                               GFP_KERNEL);
1126         if (wm8997 == NULL)
1127                 return -ENOMEM;
1128         platform_set_drvdata(pdev, wm8997);
1129 
1130         wm8997->core.arizona = arizona;
1131         wm8997->core.num_inputs = 4;
1132 
1133         arizona_init_dvfs(&wm8997->core);
1134 
1135         for (i = 0; i < ARRAY_SIZE(wm8997->fll); i++)
1136                 wm8997->fll[i].vco_mult = 1;
1137 
1138         arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
1139                          ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
1140                          &wm8997->fll[0]);
1141         arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
1142                          ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
1143                          &wm8997->fll[1]);
1144 
1145         /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */
1146         regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2,
1147                            ARIZONA_SAMPLE_RATE_2_MASK, 0x11);
1148         regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3,
1149                            ARIZONA_SAMPLE_RATE_3_MASK, 0x12);
1150 
1151         for (i = 0; i < ARRAY_SIZE(wm8997_dai); i++)
1152                 arizona_init_dai(&wm8997->core, i);
1153 
1154         /* Latch volume update bits */
1155         for (i = 0; i < ARRAY_SIZE(wm8997_digital_vu); i++)
1156                 regmap_update_bits(arizona->regmap, wm8997_digital_vu[i],
1157                                    WM8997_DIG_VU, WM8997_DIG_VU);
1158 
1159         pm_runtime_enable(&pdev->dev);
1160         pm_runtime_idle(&pdev->dev);
1161 
1162         return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8997,
1163                                       wm8997_dai, ARRAY_SIZE(wm8997_dai));
1164 }
1165 
1166 static int wm8997_remove(struct platform_device *pdev)
1167 {
1168         snd_soc_unregister_codec(&pdev->dev);
1169         pm_runtime_disable(&pdev->dev);
1170 
1171         return 0;
1172 }
1173 
1174 static struct platform_driver wm8997_codec_driver = {
1175         .driver = {
1176                 .name = "wm8997-codec",
1177         },
1178         .probe = wm8997_probe,
1179         .remove = wm8997_remove,
1180 };
1181 
1182 module_platform_driver(wm8997_codec_driver);
1183 
1184 MODULE_DESCRIPTION("ASoC WM8997 driver");
1185 MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
1186 MODULE_LICENSE("GPL");
1187 MODULE_ALIAS("platform:wm8997-codec");
1188 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us