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