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