blob: 38ef631d1a1ff825a60064e822464d389e32aaa9 [file] [log] [blame]
Thomas Gleixnerd2912cb2019-06-04 10:11:33 +02001// SPDX-License-Identifier: GPL-2.0-only
Charles Keepax40843ae2013-08-12 23:46:55 +01002/*
3 * wm8997.c -- WM8997 ALSA SoC Audio driver
4 *
5 * Copyright 2012 Wolfson Microelectronics plc
6 *
7 * Author: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Charles Keepax40843ae2013-08-12 23:46:55 +01008 */
9
10#include <linux/module.h>
11#include <linux/moduleparam.h>
12#include <linux/init.h>
13#include <linux/delay.h>
14#include <linux/pm.h>
15#include <linux/pm_runtime.h>
16#include <linux/regmap.h>
17#include <linux/slab.h>
18#include <sound/core.h>
19#include <sound/pcm.h>
20#include <sound/pcm_params.h>
21#include <sound/soc.h>
22#include <sound/jack.h>
23#include <sound/initval.h>
24#include <sound/tlv.h>
25
26#include <linux/mfd/arizona/core.h>
27#include <linux/mfd/arizona/registers.h>
28
29#include "arizona.h"
30#include "wm8997.h"
31
32struct wm8997_priv {
33 struct arizona_priv core;
34 struct arizona_fll fll[2];
35};
36
37static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
38static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
39static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
Richard Fitzgerald15575ed2015-05-28 14:28:12 +010040static DECLARE_TLV_DB_SCALE(noise_tlv, -13200, 600, 0);
Charles Keepax40843ae2013-08-12 23:46:55 +010041static DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
42
43static const struct reg_default wm8997_sysclk_reva_patch[] = {
44 { 0x301D, 0x7B15 },
45 { 0x301B, 0x0050 },
46 { 0x305D, 0x7B17 },
47 { 0x305B, 0x0050 },
48 { 0x3001, 0x08FE },
49 { 0x3003, 0x00F4 },
50 { 0x3041, 0x08FF },
51 { 0x3043, 0x0005 },
52 { 0x3020, 0x0225 },
53 { 0x3021, 0x0A00 },
54 { 0x3022, 0xE24D },
55 { 0x3023, 0x0800 },
56 { 0x3024, 0xE24D },
57 { 0x3025, 0xF000 },
58 { 0x3060, 0x0226 },
59 { 0x3061, 0x0A00 },
60 { 0x3062, 0xE252 },
61 { 0x3063, 0x0800 },
62 { 0x3064, 0xE252 },
63 { 0x3065, 0xF000 },
64 { 0x3116, 0x022B },
65 { 0x3117, 0xFA00 },
66 { 0x3110, 0x246C },
67 { 0x3111, 0x0A03 },
68 { 0x3112, 0x246E },
69 { 0x3113, 0x0A03 },
70 { 0x3114, 0x2470 },
71 { 0x3115, 0x0A03 },
72 { 0x3126, 0x246C },
73 { 0x3127, 0x0A02 },
74 { 0x3128, 0x246E },
75 { 0x3129, 0x0A02 },
76 { 0x312A, 0x2470 },
77 { 0x312B, 0xFA02 },
78 { 0x3125, 0x0800 },
79};
80
81static int wm8997_sysclk_ev(struct snd_soc_dapm_widget *w,
82 struct snd_kcontrol *kcontrol, int event)
83{
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +000084 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
85 struct arizona *arizona = dev_get_drvdata(component->dev->parent);
Lars-Peter Clausen055bbe22014-03-01 13:45:32 +010086 struct regmap *regmap = arizona->regmap;
Charles Keepax40843ae2013-08-12 23:46:55 +010087 const struct reg_default *patch = NULL;
88 int i, patch_size;
89
90 switch (arizona->rev) {
91 case 0:
92 patch = wm8997_sysclk_reva_patch;
93 patch_size = ARRAY_SIZE(wm8997_sysclk_reva_patch);
94 break;
95 default:
96 break;
97 }
98
99 switch (event) {
100 case SND_SOC_DAPM_POST_PMU:
101 if (patch)
102 for (i = 0; i < patch_size; i++)
Mark Brown1f4fe272013-12-12 00:50:04 +0000103 regmap_write_async(regmap, patch[i].reg,
104 patch[i].def);
Charles Keepax40843ae2013-08-12 23:46:55 +0100105 break;
Richard Fitzgerald346d9682015-06-02 11:53:33 +0100106 case SND_SOC_DAPM_PRE_PMD:
Charles Keepax40843ae2013-08-12 23:46:55 +0100107 break;
Charles Keepax7a4413d2016-10-21 14:15:57 +0100108 case SND_SOC_DAPM_PRE_PMU:
109 case SND_SOC_DAPM_POST_PMD:
110 return arizona_clk_ev(w, kcontrol, event);
Richard Fitzgerald346d9682015-06-02 11:53:33 +0100111 default:
112 return 0;
Charles Keepax40843ae2013-08-12 23:46:55 +0100113 }
114
Richard Fitzgerald346d9682015-06-02 11:53:33 +0100115 return arizona_dvfs_sysclk_ev(w, kcontrol, event);
Charles Keepax40843ae2013-08-12 23:46:55 +0100116}
117
Charles Keepax7dd0f7c2018-02-20 16:08:11 +0000118static const char * const wm8997_osr_text[] = {
Charles Keepax40843ae2013-08-12 23:46:55 +0100119 "Low power", "Normal", "High performance",
120};
121
122static const unsigned int wm8997_osr_val[] = {
123 0x0, 0x3, 0x5,
124};
125
126static const struct soc_enum wm8997_hpout_osr[] = {
127 SOC_VALUE_ENUM_SINGLE(ARIZONA_OUTPUT_PATH_CONFIG_1L,
Takashi Iwai347e5512014-02-18 11:49:56 +0100128 ARIZONA_OUT1_OSR_SHIFT, 0x7,
129 ARRAY_SIZE(wm8997_osr_text),
Charles Keepax40843ae2013-08-12 23:46:55 +0100130 wm8997_osr_text, wm8997_osr_val),
131 SOC_VALUE_ENUM_SINGLE(ARIZONA_OUTPUT_PATH_CONFIG_3L,
Takashi Iwai347e5512014-02-18 11:49:56 +0100132 ARIZONA_OUT3_OSR_SHIFT, 0x7,
133 ARRAY_SIZE(wm8997_osr_text),
Charles Keepax40843ae2013-08-12 23:46:55 +0100134 wm8997_osr_text, wm8997_osr_val),
135};
136
137#define WM8997_NG_SRC(name, base) \
138 SOC_SINGLE(name " NG HPOUT1L Switch", base, 0, 1, 0), \
139 SOC_SINGLE(name " NG HPOUT1R Switch", base, 1, 1, 0), \
140 SOC_SINGLE(name " NG EPOUT Switch", base, 4, 1, 0), \
141 SOC_SINGLE(name " NG SPKOUT Switch", base, 6, 1, 0), \
142 SOC_SINGLE(name " NG SPKDAT1L Switch", base, 8, 1, 0), \
143 SOC_SINGLE(name " NG SPKDAT1R Switch", base, 9, 1, 0)
144
145static const struct snd_kcontrol_new wm8997_snd_controls[] = {
146SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
147 ARIZONA_IN1_OSR_SHIFT, 1, 0),
148SOC_SINGLE("IN2 High Performance Switch", ARIZONA_IN2L_CONTROL,
149 ARIZONA_IN2_OSR_SHIFT, 1, 0),
150
151SOC_SINGLE_RANGE_TLV("IN1L Volume", ARIZONA_IN1L_CONTROL,
152 ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
153SOC_SINGLE_RANGE_TLV("IN1R Volume", ARIZONA_IN1R_CONTROL,
154 ARIZONA_IN1R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
155SOC_SINGLE_RANGE_TLV("IN2L Volume", ARIZONA_IN2L_CONTROL,
156 ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
157SOC_SINGLE_RANGE_TLV("IN2R Volume", ARIZONA_IN2R_CONTROL,
158 ARIZONA_IN2R_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
159
160SOC_SINGLE_TLV("IN1L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
161 ARIZONA_IN1L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
162SOC_SINGLE_TLV("IN1R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1R,
163 ARIZONA_IN1R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
164SOC_SINGLE_TLV("IN2L Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
165 ARIZONA_IN2L_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
166SOC_SINGLE_TLV("IN2R Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2R,
167 ARIZONA_IN2R_DIG_VOL_SHIFT, 0xbf, 0, digital_tlv),
168
169SOC_ENUM("Input Ramp Up", arizona_in_vi_ramp),
170SOC_ENUM("Input Ramp Down", arizona_in_vd_ramp),
171
172ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
173ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
174ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
175ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
176
Charles Keepaxc05d9a82015-06-25 09:35:11 +0100177ARIZONA_EQ_CONTROL("EQ1 Coefficients", ARIZONA_EQ1_2),
Charles Keepax40843ae2013-08-12 23:46:55 +0100178SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
179 24, 0, eq_tlv),
180SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
181 24, 0, eq_tlv),
182SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
183 24, 0, eq_tlv),
184SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
185 24, 0, eq_tlv),
186SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
187 24, 0, eq_tlv),
188
Charles Keepaxc05d9a82015-06-25 09:35:11 +0100189ARIZONA_EQ_CONTROL("EQ2 Coefficients", ARIZONA_EQ2_2),
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 Keepaxc05d9a82015-06-25 09:35:11 +0100201ARIZONA_EQ_CONTROL("EQ3 Coefficients", ARIZONA_EQ3_2),
Charles Keepax40843ae2013-08-12 23:46:55 +0100202SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
203 24, 0, eq_tlv),
204SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
205 24, 0, eq_tlv),
206SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT,
207 24, 0, eq_tlv),
208SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
209 24, 0, eq_tlv),
210SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
211 24, 0, eq_tlv),
212
Charles Keepaxc05d9a82015-06-25 09:35:11 +0100213ARIZONA_EQ_CONTROL("EQ4 Coefficients", ARIZONA_EQ4_2),
Charles Keepax40843ae2013-08-12 23:46:55 +0100214SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
215 24, 0, eq_tlv),
216SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
217 24, 0, eq_tlv),
218SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT,
219 24, 0, eq_tlv),
220SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT,
221 24, 0, eq_tlv),
222SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT,
223 24, 0, eq_tlv),
224
225ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
226ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
227
228SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
229 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
230
231ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
232ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
233ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
234ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
235
236SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
237SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
238SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
239SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
240
Charles Keepax5f8e6712015-06-25 09:35:12 +0100241ARIZONA_LHPF_CONTROL("LHPF1 Coefficients", ARIZONA_HPLPF1_2),
242ARIZONA_LHPF_CONTROL("LHPF2 Coefficients", ARIZONA_HPLPF2_2),
243ARIZONA_LHPF_CONTROL("LHPF3 Coefficients", ARIZONA_HPLPF3_2),
244ARIZONA_LHPF_CONTROL("LHPF4 Coefficients", ARIZONA_HPLPF4_2),
Charles Keepax40843ae2013-08-12 23:46:55 +0100245
Lars-Peter Clausen9de98da2014-04-15 07:46:05 +0200246SOC_ENUM("ISRC1 FSL", arizona_isrc_fsl[0]),
247SOC_ENUM("ISRC2 FSL", arizona_isrc_fsl[1]),
Charles Keepax40843ae2013-08-12 23:46:55 +0100248
249ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
250ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
251
252SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
253 ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
254
255ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
256ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
257ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
258ARIZONA_MIXER_CONTROLS("SPKOUT", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
259ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
260ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
261
262SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
263 ARIZONA_OUT4_OSR_SHIFT, 1, 0),
264SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
265 ARIZONA_OUT5_OSR_SHIFT, 1, 0),
266
267SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
268 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
269SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
270 ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
271SOC_SINGLE("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
272 ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
273SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
274 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
275
276SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
277 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
278 0xbf, 0, digital_tlv),
279SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
280 ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
281SOC_SINGLE_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
282 ARIZONA_OUT4L_VOL_SHIFT, 0xbf, 0, digital_tlv),
283SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
284 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
285 0xbf, 0, digital_tlv),
286
Lars-Peter Clausen9de98da2014-04-15 07:46:05 +0200287SOC_ENUM("HPOUT1 OSR", wm8997_hpout_osr[0]),
288SOC_ENUM("EPOUT OSR", wm8997_hpout_osr[1]),
Charles Keepax40843ae2013-08-12 23:46:55 +0100289
290SOC_ENUM("Output Ramp Up", arizona_out_vi_ramp),
291SOC_ENUM("Output Ramp Down", arizona_out_vd_ramp),
292
293SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
294 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
295
296SOC_SINGLE("Noise Gate Switch", ARIZONA_NOISE_GATE_CONTROL,
297 ARIZONA_NGATE_ENA_SHIFT, 1, 0),
298SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL,
299 ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv),
300SOC_ENUM("Noise Gate Hold", arizona_ng_hold),
301
302WM8997_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L),
303WM8997_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R),
304WM8997_NG_SRC("EPOUT", ARIZONA_NOISE_GATE_SELECT_3L),
305WM8997_NG_SRC("SPKOUT", ARIZONA_NOISE_GATE_SELECT_4L),
306WM8997_NG_SRC("SPKDAT1L", ARIZONA_NOISE_GATE_SELECT_5L),
307WM8997_NG_SRC("SPKDAT1R", ARIZONA_NOISE_GATE_SELECT_5R),
308
309ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
310ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
311ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
312ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
313ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
314ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
315ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
316ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
317
318ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
319ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
320
321ARIZONA_MIXER_CONTROLS("SLIMTX1", ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE),
322ARIZONA_MIXER_CONTROLS("SLIMTX2", ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE),
323ARIZONA_MIXER_CONTROLS("SLIMTX3", ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE),
324ARIZONA_MIXER_CONTROLS("SLIMTX4", ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE),
325ARIZONA_MIXER_CONTROLS("SLIMTX5", ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE),
326ARIZONA_MIXER_CONTROLS("SLIMTX6", ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE),
327ARIZONA_MIXER_CONTROLS("SLIMTX7", ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE),
328ARIZONA_MIXER_CONTROLS("SLIMTX8", ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE),
329};
330
331ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
332ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
333ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
334ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
335
336ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
337ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
338
339ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
340ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
341ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
342ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
343
344ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE);
345ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE);
346
347ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
348ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
349
350ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
351ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
352ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
353ARIZONA_MIXER_ENUMS(SPKOUT, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
354ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
355ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
356
357ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
358ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
359ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
360ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
361ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
362ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
363ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
364ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
365
366ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
367ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
368
369ARIZONA_MIXER_ENUMS(SLIMTX1, ARIZONA_SLIMTX1MIX_INPUT_1_SOURCE);
370ARIZONA_MIXER_ENUMS(SLIMTX2, ARIZONA_SLIMTX2MIX_INPUT_1_SOURCE);
371ARIZONA_MIXER_ENUMS(SLIMTX3, ARIZONA_SLIMTX3MIX_INPUT_1_SOURCE);
372ARIZONA_MIXER_ENUMS(SLIMTX4, ARIZONA_SLIMTX4MIX_INPUT_1_SOURCE);
373ARIZONA_MIXER_ENUMS(SLIMTX5, ARIZONA_SLIMTX5MIX_INPUT_1_SOURCE);
374ARIZONA_MIXER_ENUMS(SLIMTX6, ARIZONA_SLIMTX6MIX_INPUT_1_SOURCE);
375ARIZONA_MIXER_ENUMS(SLIMTX7, ARIZONA_SLIMTX7MIX_INPUT_1_SOURCE);
376ARIZONA_MIXER_ENUMS(SLIMTX8, ARIZONA_SLIMTX8MIX_INPUT_1_SOURCE);
377
378ARIZONA_MUX_ENUMS(ISRC1INT1, ARIZONA_ISRC1INT1MIX_INPUT_1_SOURCE);
379ARIZONA_MUX_ENUMS(ISRC1INT2, ARIZONA_ISRC1INT2MIX_INPUT_1_SOURCE);
380
381ARIZONA_MUX_ENUMS(ISRC1DEC1, ARIZONA_ISRC1DEC1MIX_INPUT_1_SOURCE);
382ARIZONA_MUX_ENUMS(ISRC1DEC2, ARIZONA_ISRC1DEC2MIX_INPUT_1_SOURCE);
383
384ARIZONA_MUX_ENUMS(ISRC2INT1, ARIZONA_ISRC2INT1MIX_INPUT_1_SOURCE);
385ARIZONA_MUX_ENUMS(ISRC2INT2, ARIZONA_ISRC2INT2MIX_INPUT_1_SOURCE);
386
387ARIZONA_MUX_ENUMS(ISRC2DEC1, ARIZONA_ISRC2DEC1MIX_INPUT_1_SOURCE);
388ARIZONA_MUX_ENUMS(ISRC2DEC2, ARIZONA_ISRC2DEC2MIX_INPUT_1_SOURCE);
389
390static const char *wm8997_aec_loopback_texts[] = {
391 "HPOUT1L", "HPOUT1R", "EPOUT", "SPKOUT", "SPKDAT1L", "SPKDAT1R",
392};
393
394static const unsigned int wm8997_aec_loopback_values[] = {
395 0, 1, 4, 6, 8, 9,
396};
397
398static const struct soc_enum wm8997_aec_loopback =
399 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
400 ARIZONA_AEC_LOOPBACK_SRC_SHIFT, 0xf,
401 ARRAY_SIZE(wm8997_aec_loopback_texts),
402 wm8997_aec_loopback_texts,
403 wm8997_aec_loopback_values);
404
405static const struct snd_kcontrol_new wm8997_aec_loopback_mux =
Lars-Peter Clausene13dd8c2014-04-14 21:31:11 +0200406 SOC_DAPM_ENUM("AEC Loopback", wm8997_aec_loopback);
Charles Keepax40843ae2013-08-12 23:46:55 +0100407
408static const struct snd_soc_dapm_widget wm8997_dapm_widgets[] = {
409SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
Richard Fitzgerald346d9682015-06-02 11:53:33 +0100410 0, wm8997_sysclk_ev,
Charles Keepax7a4413d2016-10-21 14:15:57 +0100411 SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD |
412 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
Charles Keepax40843ae2013-08-12 23:46:55 +0100413SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
Charles Keepax7a4413d2016-10-21 14:15:57 +0100414 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, arizona_clk_ev,
415 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
Charles Keepax40843ae2013-08-12 23:46:55 +0100416SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
417 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
418SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
419 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
420
421SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
422SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
423SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
424SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDD", 0, 0),
425
426SND_SOC_DAPM_SIGGEN("TONE"),
427SND_SOC_DAPM_SIGGEN("NOISE"),
428SND_SOC_DAPM_SIGGEN("HAPTICS"),
429
430SND_SOC_DAPM_INPUT("IN1L"),
431SND_SOC_DAPM_INPUT("IN1R"),
432SND_SOC_DAPM_INPUT("IN2L"),
433SND_SOC_DAPM_INPUT("IN2R"),
434
435SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
436 0, NULL, 0, arizona_in_ev,
437 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
438 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
439SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
440 0, NULL, 0, arizona_in_ev,
441 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
442 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
443SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
444 0, NULL, 0, arizona_in_ev,
445 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
446 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
447SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
448 0, NULL, 0, arizona_in_ev,
449 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
450 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
451
452SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
453 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
454SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
455 ARIZONA_MICB2_ENA_SHIFT, 0, NULL, 0),
456SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
457 ARIZONA_MICB3_ENA_SHIFT, 0, NULL, 0),
458
459SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
460 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
461
462SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
463 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
464SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
465 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
466
467SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1,
468 ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0),
469
470SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
471SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
472SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
473SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
474
475SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
476 NULL, 0),
477SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
478 NULL, 0),
479
480SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
481 NULL, 0),
482SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
483 NULL, 0),
484SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
485 NULL, 0),
486SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
487 NULL, 0),
488
489SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
490 0, NULL, 0),
491SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
492 0, NULL, 0),
493
494SND_SOC_DAPM_PGA("ISRC1INT1", ARIZONA_ISRC_1_CTRL_3,
495 ARIZONA_ISRC1_INT0_ENA_SHIFT, 0, NULL, 0),
496SND_SOC_DAPM_PGA("ISRC1INT2", ARIZONA_ISRC_1_CTRL_3,
497 ARIZONA_ISRC1_INT1_ENA_SHIFT, 0, NULL, 0),
498
499SND_SOC_DAPM_PGA("ISRC1DEC1", ARIZONA_ISRC_1_CTRL_3,
500 ARIZONA_ISRC1_DEC0_ENA_SHIFT, 0, NULL, 0),
501SND_SOC_DAPM_PGA("ISRC1DEC2", ARIZONA_ISRC_1_CTRL_3,
502 ARIZONA_ISRC1_DEC1_ENA_SHIFT, 0, NULL, 0),
503
504SND_SOC_DAPM_PGA("ISRC2INT1", ARIZONA_ISRC_2_CTRL_3,
505 ARIZONA_ISRC2_INT0_ENA_SHIFT, 0, NULL, 0),
506SND_SOC_DAPM_PGA("ISRC2INT2", ARIZONA_ISRC_2_CTRL_3,
507 ARIZONA_ISRC2_INT1_ENA_SHIFT, 0, NULL, 0),
508
509SND_SOC_DAPM_PGA("ISRC2DEC1", ARIZONA_ISRC_2_CTRL_3,
510 ARIZONA_ISRC2_DEC0_ENA_SHIFT, 0, NULL, 0),
511SND_SOC_DAPM_PGA("ISRC2DEC2", ARIZONA_ISRC_2_CTRL_3,
512 ARIZONA_ISRC2_DEC1_ENA_SHIFT, 0, NULL, 0),
513
514SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
515 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000516SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100517 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000518SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 2,
Charles Keepax40843ae2013-08-12 23:46:55 +0100519 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000520SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 3,
Charles Keepax40843ae2013-08-12 23:46:55 +0100521 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000522SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 4,
Charles Keepax40843ae2013-08-12 23:46:55 +0100523 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000524SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 5,
Charles Keepax40843ae2013-08-12 23:46:55 +0100525 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000526SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 6,
Charles Keepax40843ae2013-08-12 23:46:55 +0100527 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000528SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 7,
Charles Keepax40843ae2013-08-12 23:46:55 +0100529 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
530
531SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
532 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000533SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100534 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000535SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 2,
Charles Keepax40843ae2013-08-12 23:46:55 +0100536 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000537SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 3,
Charles Keepax40843ae2013-08-12 23:46:55 +0100538 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000539SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 4,
Charles Keepax40843ae2013-08-12 23:46:55 +0100540 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000541SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 5,
Charles Keepax40843ae2013-08-12 23:46:55 +0100542 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000543SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 6,
Charles Keepax40843ae2013-08-12 23:46:55 +0100544 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000545SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 7,
Charles Keepax40843ae2013-08-12 23:46:55 +0100546 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
547
548SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
549 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000550SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100551 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
552
553SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
554 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000555SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100556 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
557
558SND_SOC_DAPM_AIF_OUT("SLIMTX1", NULL, 0,
559 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
560 ARIZONA_SLIMTX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000561SND_SOC_DAPM_AIF_OUT("SLIMTX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100562 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
563 ARIZONA_SLIMTX2_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000564SND_SOC_DAPM_AIF_OUT("SLIMTX3", NULL, 2,
Charles Keepax40843ae2013-08-12 23:46:55 +0100565 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
566 ARIZONA_SLIMTX3_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000567SND_SOC_DAPM_AIF_OUT("SLIMTX4", NULL, 3,
Charles Keepax40843ae2013-08-12 23:46:55 +0100568 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
569 ARIZONA_SLIMTX4_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000570SND_SOC_DAPM_AIF_OUT("SLIMTX5", NULL, 4,
Charles Keepax40843ae2013-08-12 23:46:55 +0100571 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
572 ARIZONA_SLIMTX5_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000573SND_SOC_DAPM_AIF_OUT("SLIMTX6", NULL, 5,
Charles Keepax40843ae2013-08-12 23:46:55 +0100574 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
575 ARIZONA_SLIMTX6_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000576SND_SOC_DAPM_AIF_OUT("SLIMTX7", NULL, 6,
Charles Keepax40843ae2013-08-12 23:46:55 +0100577 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
578 ARIZONA_SLIMTX7_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000579SND_SOC_DAPM_AIF_OUT("SLIMTX8", NULL, 7,
Charles Keepax40843ae2013-08-12 23:46:55 +0100580 ARIZONA_SLIMBUS_TX_CHANNEL_ENABLE,
581 ARIZONA_SLIMTX8_ENA_SHIFT, 0),
582
583SND_SOC_DAPM_AIF_IN("SLIMRX1", NULL, 0,
584 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
585 ARIZONA_SLIMRX1_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000586SND_SOC_DAPM_AIF_IN("SLIMRX2", NULL, 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100587 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
588 ARIZONA_SLIMRX2_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000589SND_SOC_DAPM_AIF_IN("SLIMRX3", NULL, 2,
Charles Keepax40843ae2013-08-12 23:46:55 +0100590 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
591 ARIZONA_SLIMRX3_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000592SND_SOC_DAPM_AIF_IN("SLIMRX4", NULL, 3,
Charles Keepax40843ae2013-08-12 23:46:55 +0100593 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
594 ARIZONA_SLIMRX4_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000595SND_SOC_DAPM_AIF_IN("SLIMRX5", NULL, 4,
Charles Keepax40843ae2013-08-12 23:46:55 +0100596 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
597 ARIZONA_SLIMRX5_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000598SND_SOC_DAPM_AIF_IN("SLIMRX6", NULL, 5,
Charles Keepax40843ae2013-08-12 23:46:55 +0100599 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
600 ARIZONA_SLIMRX6_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000601SND_SOC_DAPM_AIF_IN("SLIMRX7", NULL, 6,
Charles Keepax40843ae2013-08-12 23:46:55 +0100602 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
603 ARIZONA_SLIMRX7_ENA_SHIFT, 0),
Charles Keepax909d74e2019-01-31 13:30:19 +0000604SND_SOC_DAPM_AIF_IN("SLIMRX8", NULL, 7,
Charles Keepax40843ae2013-08-12 23:46:55 +0100605 ARIZONA_SLIMBUS_RX_CHANNEL_ENABLE,
606 ARIZONA_SLIMRX8_ENA_SHIFT, 0),
607
Lars-Peter Clausene13dd8c2014-04-14 21:31:11 +0200608SND_SOC_DAPM_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
Charles Keepax7dd0f7c2018-02-20 16:08:11 +0000609 ARIZONA_AEC_LOOPBACK_ENA_SHIFT, 0, &wm8997_aec_loopback_mux),
Charles Keepax40843ae2013-08-12 23:46:55 +0100610
611SND_SOC_DAPM_PGA_E("OUT1L", SND_SOC_NOPM,
612 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_hp_ev,
Charles Keepax054e1b42015-01-20 16:31:50 +0000613 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD |
Charles Keepaxe1ae5fb2015-01-20 16:31:51 +0000614 SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU),
Charles Keepax40843ae2013-08-12 23:46:55 +0100615SND_SOC_DAPM_PGA_E("OUT1R", SND_SOC_NOPM,
616 ARIZONA_OUT1R_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("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
620 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_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("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
624 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
625 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
626SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
627 ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
628 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
629
630ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
631ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
632ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"),
633ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"),
634
635ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
636ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
637
638ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
639ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
640ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
641ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
642
643ARIZONA_MIXER_WIDGETS(Mic, "Mic"),
644ARIZONA_MIXER_WIDGETS(Noise, "Noise"),
645
646ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
647ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
648
649ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
650ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
651ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
652ARIZONA_MIXER_WIDGETS(SPKOUT, "SPKOUT"),
653ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
654ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
655
656ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
657ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
658ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
659ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
660ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
661ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
662ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
663ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
664
665ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
666ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
667
668ARIZONA_MIXER_WIDGETS(SLIMTX1, "SLIMTX1"),
669ARIZONA_MIXER_WIDGETS(SLIMTX2, "SLIMTX2"),
670ARIZONA_MIXER_WIDGETS(SLIMTX3, "SLIMTX3"),
671ARIZONA_MIXER_WIDGETS(SLIMTX4, "SLIMTX4"),
672ARIZONA_MIXER_WIDGETS(SLIMTX5, "SLIMTX5"),
673ARIZONA_MIXER_WIDGETS(SLIMTX6, "SLIMTX6"),
674ARIZONA_MIXER_WIDGETS(SLIMTX7, "SLIMTX7"),
675ARIZONA_MIXER_WIDGETS(SLIMTX8, "SLIMTX8"),
676
677ARIZONA_MUX_WIDGETS(ISRC1DEC1, "ISRC1DEC1"),
678ARIZONA_MUX_WIDGETS(ISRC1DEC2, "ISRC1DEC2"),
679
680ARIZONA_MUX_WIDGETS(ISRC1INT1, "ISRC1INT1"),
681ARIZONA_MUX_WIDGETS(ISRC1INT2, "ISRC1INT2"),
682
683ARIZONA_MUX_WIDGETS(ISRC2DEC1, "ISRC2DEC1"),
684ARIZONA_MUX_WIDGETS(ISRC2DEC2, "ISRC2DEC2"),
685
686ARIZONA_MUX_WIDGETS(ISRC2INT1, "ISRC2INT1"),
687ARIZONA_MUX_WIDGETS(ISRC2INT2, "ISRC2INT2"),
688
689SND_SOC_DAPM_OUTPUT("HPOUT1L"),
690SND_SOC_DAPM_OUTPUT("HPOUT1R"),
691SND_SOC_DAPM_OUTPUT("EPOUTN"),
692SND_SOC_DAPM_OUTPUT("EPOUTP"),
693SND_SOC_DAPM_OUTPUT("SPKOUTN"),
694SND_SOC_DAPM_OUTPUT("SPKOUTP"),
695SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
696SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
697
698SND_SOC_DAPM_OUTPUT("MICSUPP"),
699};
700
701#define ARIZONA_MIXER_INPUT_ROUTES(name) \
702 { name, "Noise Generator", "Noise Generator" }, \
703 { name, "Tone Generator 1", "Tone Generator 1" }, \
704 { name, "Tone Generator 2", "Tone Generator 2" }, \
705 { name, "Haptics", "HAPTICS" }, \
706 { name, "AEC", "AEC Loopback" }, \
707 { name, "IN1L", "IN1L PGA" }, \
708 { name, "IN1R", "IN1R PGA" }, \
709 { name, "IN2L", "IN2L PGA" }, \
710 { name, "IN2R", "IN2R PGA" }, \
711 { name, "Mic Mute Mixer", "Mic Mute Mixer" }, \
712 { name, "AIF1RX1", "AIF1RX1" }, \
713 { name, "AIF1RX2", "AIF1RX2" }, \
714 { name, "AIF1RX3", "AIF1RX3" }, \
715 { name, "AIF1RX4", "AIF1RX4" }, \
716 { name, "AIF1RX5", "AIF1RX5" }, \
717 { name, "AIF1RX6", "AIF1RX6" }, \
718 { name, "AIF1RX7", "AIF1RX7" }, \
719 { name, "AIF1RX8", "AIF1RX8" }, \
720 { name, "AIF2RX1", "AIF2RX1" }, \
721 { name, "AIF2RX2", "AIF2RX2" }, \
722 { name, "SLIMRX1", "SLIMRX1" }, \
723 { name, "SLIMRX2", "SLIMRX2" }, \
724 { name, "SLIMRX3", "SLIMRX3" }, \
725 { name, "SLIMRX4", "SLIMRX4" }, \
726 { name, "SLIMRX5", "SLIMRX5" }, \
727 { name, "SLIMRX6", "SLIMRX6" }, \
728 { name, "SLIMRX7", "SLIMRX7" }, \
729 { name, "SLIMRX8", "SLIMRX8" }, \
730 { name, "EQ1", "EQ1" }, \
731 { name, "EQ2", "EQ2" }, \
732 { name, "EQ3", "EQ3" }, \
733 { name, "EQ4", "EQ4" }, \
734 { name, "DRC1L", "DRC1L" }, \
735 { name, "DRC1R", "DRC1R" }, \
736 { name, "LHPF1", "LHPF1" }, \
737 { name, "LHPF2", "LHPF2" }, \
738 { name, "LHPF3", "LHPF3" }, \
739 { name, "LHPF4", "LHPF4" }, \
740 { name, "ISRC1DEC1", "ISRC1DEC1" }, \
741 { name, "ISRC1DEC2", "ISRC1DEC2" }, \
742 { name, "ISRC1INT1", "ISRC1INT1" }, \
743 { name, "ISRC1INT2", "ISRC1INT2" }, \
744 { name, "ISRC2DEC1", "ISRC2DEC1" }, \
745 { name, "ISRC2DEC2", "ISRC2DEC2" }, \
746 { name, "ISRC2INT1", "ISRC2INT1" }, \
747 { name, "ISRC2INT2", "ISRC2INT2" }
748
749static const struct snd_soc_dapm_route wm8997_dapm_routes[] = {
750 { "AIF2 Capture", NULL, "DBVDD2" },
751 { "AIF2 Playback", NULL, "DBVDD2" },
752
753 { "OUT1L", NULL, "CPVDD" },
754 { "OUT1R", NULL, "CPVDD" },
755 { "OUT3L", NULL, "CPVDD" },
756
757 { "OUT4L", NULL, "SPKVDD" },
758
759 { "OUT1L", NULL, "SYSCLK" },
760 { "OUT1R", NULL, "SYSCLK" },
761 { "OUT3L", NULL, "SYSCLK" },
762 { "OUT4L", NULL, "SYSCLK" },
763
764 { "IN1L", NULL, "SYSCLK" },
765 { "IN1R", NULL, "SYSCLK" },
766 { "IN2L", NULL, "SYSCLK" },
767 { "IN2R", NULL, "SYSCLK" },
768
769 { "MICBIAS1", NULL, "MICVDD" },
770 { "MICBIAS2", NULL, "MICVDD" },
771 { "MICBIAS3", NULL, "MICVDD" },
772
773 { "Noise Generator", NULL, "SYSCLK" },
774 { "Tone Generator 1", NULL, "SYSCLK" },
775 { "Tone Generator 2", NULL, "SYSCLK" },
776
777 { "Noise Generator", NULL, "NOISE" },
778 { "Tone Generator 1", NULL, "TONE" },
779 { "Tone Generator 2", NULL, "TONE" },
780
Charles Keepax40843ae2013-08-12 23:46:55 +0100781 { "AIF1 Capture", NULL, "AIF1TX1" },
782 { "AIF1 Capture", NULL, "AIF1TX2" },
783 { "AIF1 Capture", NULL, "AIF1TX3" },
784 { "AIF1 Capture", NULL, "AIF1TX4" },
785 { "AIF1 Capture", NULL, "AIF1TX5" },
786 { "AIF1 Capture", NULL, "AIF1TX6" },
787 { "AIF1 Capture", NULL, "AIF1TX7" },
788 { "AIF1 Capture", NULL, "AIF1TX8" },
789
790 { "AIF1RX1", NULL, "AIF1 Playback" },
791 { "AIF1RX2", NULL, "AIF1 Playback" },
792 { "AIF1RX3", NULL, "AIF1 Playback" },
793 { "AIF1RX4", NULL, "AIF1 Playback" },
794 { "AIF1RX5", NULL, "AIF1 Playback" },
795 { "AIF1RX6", NULL, "AIF1 Playback" },
796 { "AIF1RX7", NULL, "AIF1 Playback" },
797 { "AIF1RX8", NULL, "AIF1 Playback" },
798
799 { "AIF2 Capture", NULL, "AIF2TX1" },
800 { "AIF2 Capture", NULL, "AIF2TX2" },
801
802 { "AIF2RX1", NULL, "AIF2 Playback" },
803 { "AIF2RX2", NULL, "AIF2 Playback" },
804
805 { "Slim1 Capture", NULL, "SLIMTX1" },
806 { "Slim1 Capture", NULL, "SLIMTX2" },
807 { "Slim1 Capture", NULL, "SLIMTX3" },
808 { "Slim1 Capture", NULL, "SLIMTX4" },
809
810 { "SLIMRX1", NULL, "Slim1 Playback" },
811 { "SLIMRX2", NULL, "Slim1 Playback" },
812 { "SLIMRX3", NULL, "Slim1 Playback" },
813 { "SLIMRX4", NULL, "Slim1 Playback" },
814
815 { "Slim2 Capture", NULL, "SLIMTX5" },
816 { "Slim2 Capture", NULL, "SLIMTX6" },
817
818 { "SLIMRX5", NULL, "Slim2 Playback" },
819 { "SLIMRX6", NULL, "Slim2 Playback" },
820
821 { "Slim3 Capture", NULL, "SLIMTX7" },
822 { "Slim3 Capture", NULL, "SLIMTX8" },
823
824 { "SLIMRX7", NULL, "Slim3 Playback" },
825 { "SLIMRX8", NULL, "Slim3 Playback" },
826
827 { "AIF1 Playback", NULL, "SYSCLK" },
828 { "AIF2 Playback", NULL, "SYSCLK" },
829 { "Slim1 Playback", NULL, "SYSCLK" },
830 { "Slim2 Playback", NULL, "SYSCLK" },
831 { "Slim3 Playback", NULL, "SYSCLK" },
832
833 { "AIF1 Capture", NULL, "SYSCLK" },
834 { "AIF2 Capture", NULL, "SYSCLK" },
835 { "Slim1 Capture", NULL, "SYSCLK" },
836 { "Slim2 Capture", NULL, "SYSCLK" },
837 { "Slim3 Capture", NULL, "SYSCLK" },
838
839 { "IN1L PGA", NULL, "IN1L" },
840 { "IN1R PGA", NULL, "IN1R" },
841
842 { "IN2L PGA", NULL, "IN2L" },
843 { "IN2R PGA", NULL, "IN2R" },
844
845 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
846 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
847 ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"),
848
849 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUT"),
850 ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
851 ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
852
853 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
854 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
855
856 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
857 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
858 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
859 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
860 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
861 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
862 ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
863 ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
864
865 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
866 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
867
868 ARIZONA_MIXER_ROUTES("SLIMTX1", "SLIMTX1"),
869 ARIZONA_MIXER_ROUTES("SLIMTX2", "SLIMTX2"),
870 ARIZONA_MIXER_ROUTES("SLIMTX3", "SLIMTX3"),
871 ARIZONA_MIXER_ROUTES("SLIMTX4", "SLIMTX4"),
872 ARIZONA_MIXER_ROUTES("SLIMTX5", "SLIMTX5"),
873 ARIZONA_MIXER_ROUTES("SLIMTX6", "SLIMTX6"),
874 ARIZONA_MIXER_ROUTES("SLIMTX7", "SLIMTX7"),
875 ARIZONA_MIXER_ROUTES("SLIMTX8", "SLIMTX8"),
876
877 ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
878 ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
879 ARIZONA_MIXER_ROUTES("EQ3", "EQ3"),
880 ARIZONA_MIXER_ROUTES("EQ4", "EQ4"),
881
882 ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
883 ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
884
885 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
886 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
887 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
888 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
889
Mark Brownc5efb382013-08-12 23:59:19 +0100890 ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Noise"),
891 ARIZONA_MIXER_ROUTES("Mic Mute Mixer", "Mic"),
892
Charles Keepax40843ae2013-08-12 23:46:55 +0100893 ARIZONA_MUX_ROUTES("ISRC1INT1", "ISRC1INT1"),
Charles Keepaxf4cdb6b2013-11-12 10:52:10 +0000894 ARIZONA_MUX_ROUTES("ISRC1INT2", "ISRC1INT2"),
Charles Keepax40843ae2013-08-12 23:46:55 +0100895
896 ARIZONA_MUX_ROUTES("ISRC1DEC1", "ISRC1DEC1"),
897 ARIZONA_MUX_ROUTES("ISRC1DEC2", "ISRC1DEC2"),
898
899 ARIZONA_MUX_ROUTES("ISRC2INT1", "ISRC2INT1"),
900 ARIZONA_MUX_ROUTES("ISRC2INT2", "ISRC2INT2"),
901
902 ARIZONA_MUX_ROUTES("ISRC2DEC1", "ISRC2DEC1"),
903 ARIZONA_MUX_ROUTES("ISRC2DEC2", "ISRC2DEC2"),
904
905 { "AEC Loopback", "HPOUT1L", "OUT1L" },
906 { "AEC Loopback", "HPOUT1R", "OUT1R" },
907 { "HPOUT1L", NULL, "OUT1L" },
908 { "HPOUT1R", NULL, "OUT1R" },
909
910 { "AEC Loopback", "EPOUT", "OUT3L" },
911 { "EPOUTN", NULL, "OUT3L" },
912 { "EPOUTP", NULL, "OUT3L" },
913
914 { "AEC Loopback", "SPKOUT", "OUT4L" },
915 { "SPKOUTN", NULL, "OUT4L" },
916 { "SPKOUTP", NULL, "OUT4L" },
917
918 { "AEC Loopback", "SPKDAT1L", "OUT5L" },
919 { "AEC Loopback", "SPKDAT1R", "OUT5R" },
920 { "SPKDAT1L", NULL, "OUT5L" },
921 { "SPKDAT1R", NULL, "OUT5R" },
922
923 { "MICSUPP", NULL, "SYSCLK" },
924};
925
Charles Keepax7dd0f7c2018-02-20 16:08:11 +0000926static int wm8997_set_fll(struct snd_soc_component *component, int fll_id,
927 int source, unsigned int Fref, unsigned int Fout)
Charles Keepax40843ae2013-08-12 23:46:55 +0100928{
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +0000929 struct wm8997_priv *wm8997 = snd_soc_component_get_drvdata(component);
Charles Keepax40843ae2013-08-12 23:46:55 +0100930
931 switch (fll_id) {
932 case WM8997_FLL1:
933 return arizona_set_fll(&wm8997->fll[0], source, Fref, Fout);
934 case WM8997_FLL2:
935 return arizona_set_fll(&wm8997->fll[1], source, Fref, Fout);
936 case WM8997_FLL1_REFCLK:
937 return arizona_set_fll_refclk(&wm8997->fll[0], source, Fref,
938 Fout);
939 case WM8997_FLL2_REFCLK:
940 return arizona_set_fll_refclk(&wm8997->fll[1], source, Fref,
941 Fout);
942 default:
943 return -EINVAL;
944 }
945}
946
Charles Keepaxd81221f2016-02-04 16:29:01 +0000947#define WM8997_RATES SNDRV_PCM_RATE_KNOT
Charles Keepax40843ae2013-08-12 23:46:55 +0100948
949#define WM8997_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
950 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
951
952static struct snd_soc_dai_driver wm8997_dai[] = {
953 {
954 .name = "wm8997-aif1",
955 .id = 1,
956 .base = ARIZONA_AIF1_BCLK_CTRL,
957 .playback = {
958 .stream_name = "AIF1 Playback",
959 .channels_min = 1,
960 .channels_max = 8,
961 .rates = WM8997_RATES,
962 .formats = WM8997_FORMATS,
963 },
964 .capture = {
965 .stream_name = "AIF1 Capture",
966 .channels_min = 1,
967 .channels_max = 8,
968 .rates = WM8997_RATES,
969 .formats = WM8997_FORMATS,
970 },
971 .ops = &arizona_dai_ops,
Kuninori Morimoto07695752021-01-15 13:54:13 +0900972 .symmetric_rate = 1,
973 .symmetric_sample_bits = 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100974 },
975 {
976 .name = "wm8997-aif2",
977 .id = 2,
978 .base = ARIZONA_AIF2_BCLK_CTRL,
979 .playback = {
980 .stream_name = "AIF2 Playback",
981 .channels_min = 1,
982 .channels_max = 2,
983 .rates = WM8997_RATES,
984 .formats = WM8997_FORMATS,
985 },
986 .capture = {
987 .stream_name = "AIF2 Capture",
988 .channels_min = 1,
989 .channels_max = 2,
990 .rates = WM8997_RATES,
991 .formats = WM8997_FORMATS,
992 },
993 .ops = &arizona_dai_ops,
Kuninori Morimoto07695752021-01-15 13:54:13 +0900994 .symmetric_rate = 1,
995 .symmetric_sample_bits = 1,
Charles Keepax40843ae2013-08-12 23:46:55 +0100996 },
997 {
998 .name = "wm8997-slim1",
999 .id = 3,
1000 .playback = {
1001 .stream_name = "Slim1 Playback",
1002 .channels_min = 1,
1003 .channels_max = 4,
1004 .rates = WM8997_RATES,
1005 .formats = WM8997_FORMATS,
1006 },
1007 .capture = {
1008 .stream_name = "Slim1 Capture",
1009 .channels_min = 1,
1010 .channels_max = 4,
1011 .rates = WM8997_RATES,
1012 .formats = WM8997_FORMATS,
1013 },
1014 .ops = &arizona_simple_dai_ops,
1015 },
1016 {
1017 .name = "wm8997-slim2",
1018 .id = 4,
1019 .playback = {
1020 .stream_name = "Slim2 Playback",
1021 .channels_min = 1,
1022 .channels_max = 2,
1023 .rates = WM8997_RATES,
1024 .formats = WM8997_FORMATS,
1025 },
1026 .capture = {
1027 .stream_name = "Slim2 Capture",
1028 .channels_min = 1,
1029 .channels_max = 2,
1030 .rates = WM8997_RATES,
1031 .formats = WM8997_FORMATS,
1032 },
1033 .ops = &arizona_simple_dai_ops,
1034 },
1035 {
1036 .name = "wm8997-slim3",
1037 .id = 5,
1038 .playback = {
1039 .stream_name = "Slim3 Playback",
1040 .channels_min = 1,
1041 .channels_max = 2,
1042 .rates = WM8997_RATES,
1043 .formats = WM8997_FORMATS,
1044 },
1045 .capture = {
1046 .stream_name = "Slim3 Capture",
1047 .channels_min = 1,
1048 .channels_max = 2,
1049 .rates = WM8997_RATES,
1050 .formats = WM8997_FORMATS,
1051 },
1052 .ops = &arizona_simple_dai_ops,
1053 },
1054};
1055
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001056static int wm8997_component_probe(struct snd_soc_component *component)
Charles Keepax40843ae2013-08-12 23:46:55 +01001057{
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001058 struct snd_soc_dapm_context *dapm = snd_soc_component_get_dapm(component);
1059 struct wm8997_priv *priv = snd_soc_component_get_drvdata(component);
Kuninori Morimoto1e4a36a2017-11-28 06:03:48 +00001060 struct arizona *arizona = priv->core.arizona;
Charles Keepaxacff07d2017-01-18 15:27:05 +00001061 int ret;
Charles Keepax40843ae2013-08-12 23:46:55 +01001062
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001063 snd_soc_component_init_regmap(component, arizona->regmap);
Kuninori Morimoto1e4a36a2017-11-28 06:03:48 +00001064
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001065 ret = arizona_init_spk(component);
Charles Keepaxacff07d2017-01-18 15:27:05 +00001066 if (ret < 0)
1067 return ret;
1068
Richard Fitzgerald35f44032016-11-29 15:44:39 +00001069 snd_soc_component_disable_pin(component, "HAPTICS");
Charles Keepax40843ae2013-08-12 23:46:55 +01001070
Lars-Peter Clausen8383dfd2015-06-01 10:11:03 +02001071 priv->core.arizona->dapm = dapm;
Charles Keepax40843ae2013-08-12 23:46:55 +01001072
1073 return 0;
1074}
1075
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001076static void wm8997_component_remove(struct snd_soc_component *component)
Charles Keepax40843ae2013-08-12 23:46:55 +01001077{
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001078 struct wm8997_priv *priv = snd_soc_component_get_drvdata(component);
Charles Keepax40843ae2013-08-12 23:46:55 +01001079
1080 priv->core.arizona->dapm = NULL;
Charles Keepax40843ae2013-08-12 23:46:55 +01001081}
1082
1083#define WM8997_DIG_VU 0x0200
1084
1085static unsigned int wm8997_digital_vu[] = {
1086 ARIZONA_DAC_DIGITAL_VOLUME_1L,
1087 ARIZONA_DAC_DIGITAL_VOLUME_1R,
1088 ARIZONA_DAC_DIGITAL_VOLUME_3L,
1089 ARIZONA_DAC_DIGITAL_VOLUME_4L,
1090 ARIZONA_DAC_DIGITAL_VOLUME_5L,
1091 ARIZONA_DAC_DIGITAL_VOLUME_5R,
1092};
1093
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001094static const struct snd_soc_component_driver soc_component_dev_wm8997 = {
1095 .probe = wm8997_component_probe,
1096 .remove = wm8997_component_remove,
1097 .set_sysclk = arizona_set_sysclk,
1098 .set_pll = wm8997_set_fll,
Hans de Goede37dbabf2021-03-07 16:18:06 +01001099 .set_jack = arizona_jack_set_jack,
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001100 .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 .use_pmdown_time = 1,
1107 .endianness = 1,
1108 .non_legacy_dai_naming = 1,
Charles Keepax40843ae2013-08-12 23:46:55 +01001109};
1110
1111static int wm8997_probe(struct platform_device *pdev)
1112{
1113 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
1114 struct wm8997_priv *wm8997;
Charles Keepax31833ea2016-10-26 10:59:57 +01001115 int i, ret;
Charles Keepax40843ae2013-08-12 23:46:55 +01001116
1117 wm8997 = devm_kzalloc(&pdev->dev, sizeof(struct wm8997_priv),
1118 GFP_KERNEL);
1119 if (wm8997 == NULL)
1120 return -ENOMEM;
1121 platform_set_drvdata(pdev, wm8997);
1122
Charles Keepax0a229b12017-09-04 16:41:49 +01001123 if (IS_ENABLED(CONFIG_OF)) {
1124 if (!dev_get_platdata(arizona->dev)) {
1125 ret = arizona_of_get_audio_pdata(arizona);
1126 if (ret < 0)
1127 return ret;
1128 }
1129 }
1130
Charles Keepax40843ae2013-08-12 23:46:55 +01001131 wm8997->core.arizona = arizona;
1132 wm8997->core.num_inputs = 4;
1133
Richard Fitzgerald346d9682015-06-02 11:53:33 +01001134 arizona_init_dvfs(&wm8997->core);
1135
Hans de Goede37dbabf2021-03-07 16:18:06 +01001136 /* This may return -EPROBE_DEFER, so do this early on */
1137 ret = arizona_jack_codec_dev_probe(&wm8997->core, &pdev->dev);
1138 if (ret)
1139 return ret;
1140
Charles Keepax40843ae2013-08-12 23:46:55 +01001141 for (i = 0; i < ARRAY_SIZE(wm8997->fll); i++)
1142 wm8997->fll[i].vco_mult = 1;
1143
1144 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
1145 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
1146 &wm8997->fll[0]);
1147 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
1148 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
1149 &wm8997->fll[1]);
1150
1151 /* SR2 fixed at 8kHz, SR3 fixed at 16kHz */
1152 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_2,
1153 ARIZONA_SAMPLE_RATE_2_MASK, 0x11);
1154 regmap_update_bits(arizona->regmap, ARIZONA_SAMPLE_RATE_3,
1155 ARIZONA_SAMPLE_RATE_3_MASK, 0x12);
1156
1157 for (i = 0; i < ARRAY_SIZE(wm8997_dai); i++)
1158 arizona_init_dai(&wm8997->core, i);
1159
1160 /* Latch volume update bits */
1161 for (i = 0; i < ARRAY_SIZE(wm8997_digital_vu); i++)
1162 regmap_update_bits(arizona->regmap, wm8997_digital_vu[i],
1163 WM8997_DIG_VU, WM8997_DIG_VU);
1164
1165 pm_runtime_enable(&pdev->dev);
1166 pm_runtime_idle(&pdev->dev);
1167
Charles Keepax9e3f9f32017-09-04 16:41:48 +01001168 arizona_init_common(arizona);
1169
Charles Keepax85e7dd32017-09-04 16:41:53 +01001170 ret = arizona_init_vol_limit(arizona);
1171 if (ret < 0)
Hans de Goede37dbabf2021-03-07 16:18:06 +01001172 goto err_jack_codec_dev;
Charles Keepax31833ea2016-10-26 10:59:57 +01001173 ret = arizona_init_spk_irqs(arizona);
1174 if (ret < 0)
Hans de Goede37dbabf2021-03-07 16:18:06 +01001175 goto err_jack_codec_dev;
Charles Keepax31833ea2016-10-26 10:59:57 +01001176
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001177 ret = devm_snd_soc_register_component(&pdev->dev,
Charles Keepax7dd0f7c2018-02-20 16:08:11 +00001178 &soc_component_dev_wm8997,
1179 wm8997_dai,
1180 ARRAY_SIZE(wm8997_dai));
Charles Keepax31833ea2016-10-26 10:59:57 +01001181 if (ret < 0) {
Kuninori Morimoto0fe1daa2018-02-13 02:03:12 +00001182 dev_err(&pdev->dev, "Failed to register component: %d\n", ret);
Charles Keepax31833ea2016-10-26 10:59:57 +01001183 goto err_spk_irqs;
1184 }
1185
Zhang Qilong5e7aace2020-11-11 21:09:20 +08001186 return ret;
1187
Charles Keepax31833ea2016-10-26 10:59:57 +01001188err_spk_irqs:
1189 arizona_free_spk_irqs(arizona);
Hans de Goede37dbabf2021-03-07 16:18:06 +01001190err_jack_codec_dev:
1191 arizona_jack_codec_dev_remove(&wm8997->core);
Charles Keepax31833ea2016-10-26 10:59:57 +01001192
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 pm_runtime_disable(&pdev->dev);
1202
Charles Keepax31833ea2016-10-26 10:59:57 +01001203 arizona_free_spk_irqs(arizona);
1204
Hans de Goede37dbabf2021-03-07 16:18:06 +01001205 arizona_jack_codec_dev_remove(&wm8997->core);
1206
Charles Keepax40843ae2013-08-12 23:46:55 +01001207 return 0;
1208}
1209
1210static struct platform_driver wm8997_codec_driver = {
1211 .driver = {
1212 .name = "wm8997-codec",
Charles Keepax40843ae2013-08-12 23:46:55 +01001213 },
1214 .probe = wm8997_probe,
1215 .remove = wm8997_remove,
1216};
1217
1218module_platform_driver(wm8997_codec_driver);
1219
1220MODULE_DESCRIPTION("ASoC WM8997 driver");
1221MODULE_AUTHOR("Charles Keepax <ckeepax@opensource.wolfsonmicro.com>");
1222MODULE_LICENSE("GPL");
1223MODULE_ALIAS("platform:wm8997-codec");