blob: 2e6f1ffc9fd44676d0cf9bcd6ad6cae6fa0a418a [file] [log] [blame]
Mark Brown93e87912012-06-19 16:38:15 +01001/*
2 * wm5102.c -- WM5102 ALSA SoC Audio driver
3 *
4 * Copyright 2012 Wolfson Microelectronics plc
5 *
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#include <linux/module.h>
14#include <linux/moduleparam.h>
15#include <linux/init.h>
16#include <linux/delay.h>
17#include <linux/pm.h>
18#include <linux/pm_runtime.h>
19#include <linux/regmap.h>
20#include <linux/slab.h>
21#include <sound/core.h>
22#include <sound/pcm.h>
23#include <sound/pcm_params.h>
24#include <sound/soc.h>
25#include <sound/jack.h>
26#include <sound/initval.h>
27#include <sound/tlv.h>
Mark Brown93e87912012-06-19 16:38:15 +010028
29#include <linux/mfd/arizona/core.h>
30#include <linux/mfd/arizona/registers.h>
31
32#include "arizona.h"
33#include "wm5102.h"
34
35struct wm5102_priv {
36 struct arizona_priv core;
37 struct arizona_fll fll[2];
38};
39
40static DECLARE_TLV_DB_SCALE(ana_tlv, 0, 100, 0);
41static DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
42static DECLARE_TLV_DB_SCALE(digital_tlv, -6400, 50, 0);
43static DECLARE_TLV_DB_SCALE(noise_tlv, 0, 600, 0);
44
45static const struct snd_kcontrol_new wm5102_snd_controls[] = {
46SOC_SINGLE("IN1 High Performance Switch", ARIZONA_IN1L_CONTROL,
47 ARIZONA_IN1_OSR_SHIFT, 1, 0),
48SOC_SINGLE("IN2 High Performance Switch", ARIZONA_IN2L_CONTROL,
49 ARIZONA_IN2_OSR_SHIFT, 1, 0),
50SOC_SINGLE("IN3 High Performance Switch", ARIZONA_IN3L_CONTROL,
51 ARIZONA_IN3_OSR_SHIFT, 1, 0),
52
53SOC_DOUBLE_R_RANGE_TLV("IN1 Volume", ARIZONA_IN1L_CONTROL,
54 ARIZONA_IN1R_CONTROL,
55 ARIZONA_IN1L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
56SOC_DOUBLE_R_RANGE_TLV("IN2 Volume", ARIZONA_IN2L_CONTROL,
57 ARIZONA_IN2R_CONTROL,
58 ARIZONA_IN2L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
59SOC_DOUBLE_R_RANGE_TLV("IN3 Volume", ARIZONA_IN3L_CONTROL,
60 ARIZONA_IN3R_CONTROL,
61 ARIZONA_IN3L_PGA_VOL_SHIFT, 0x40, 0x5f, 0, ana_tlv),
62
63SOC_DOUBLE_R("IN1 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_1L,
64 ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_MUTE_SHIFT, 1, 1),
65SOC_DOUBLE_R("IN2 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_2L,
66 ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_MUTE_SHIFT, 1, 1),
67SOC_DOUBLE_R("IN3 Digital Switch", ARIZONA_ADC_DIGITAL_VOLUME_3L,
68 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_MUTE_SHIFT, 1, 1),
69
70SOC_DOUBLE_R_TLV("IN1 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_1L,
Mark Brownbc9dce52012-07-09 19:08:23 +010071 ARIZONA_ADC_DIGITAL_VOLUME_1R, ARIZONA_IN1L_DIG_VOL_SHIFT,
Mark Brown93e87912012-06-19 16:38:15 +010072 0xbf, 0, digital_tlv),
73SOC_DOUBLE_R_TLV("IN2 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_2L,
Mark Brownbc9dce52012-07-09 19:08:23 +010074 ARIZONA_ADC_DIGITAL_VOLUME_2R, ARIZONA_IN2L_DIG_VOL_SHIFT,
Mark Brown93e87912012-06-19 16:38:15 +010075 0xbf, 0, digital_tlv),
76SOC_DOUBLE_R_TLV("IN3 Digital Volume", ARIZONA_ADC_DIGITAL_VOLUME_3L,
Mark Brownbc9dce52012-07-09 19:08:23 +010077 ARIZONA_ADC_DIGITAL_VOLUME_3R, ARIZONA_IN3L_DIG_VOL_SHIFT,
Mark Brown93e87912012-06-19 16:38:15 +010078 0xbf, 0, digital_tlv),
79
80ARIZONA_MIXER_CONTROLS("EQ1", ARIZONA_EQ1MIX_INPUT_1_SOURCE),
81ARIZONA_MIXER_CONTROLS("EQ2", ARIZONA_EQ2MIX_INPUT_1_SOURCE),
82ARIZONA_MIXER_CONTROLS("EQ3", ARIZONA_EQ3MIX_INPUT_1_SOURCE),
83ARIZONA_MIXER_CONTROLS("EQ4", ARIZONA_EQ4MIX_INPUT_1_SOURCE),
84
85SOC_SINGLE_TLV("EQ1 B1 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B1_GAIN_SHIFT,
86 24, 0, eq_tlv),
87SOC_SINGLE_TLV("EQ1 B2 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B2_GAIN_SHIFT,
88 24, 0, eq_tlv),
89SOC_SINGLE_TLV("EQ1 B3 Volume", ARIZONA_EQ1_1, ARIZONA_EQ1_B3_GAIN_SHIFT,
90 24, 0, eq_tlv),
91SOC_SINGLE_TLV("EQ1 B4 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B4_GAIN_SHIFT,
92 24, 0, eq_tlv),
93SOC_SINGLE_TLV("EQ1 B5 Volume", ARIZONA_EQ1_2, ARIZONA_EQ1_B5_GAIN_SHIFT,
94 24, 0, eq_tlv),
95
96SOC_SINGLE_TLV("EQ2 B1 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B1_GAIN_SHIFT,
97 24, 0, eq_tlv),
98SOC_SINGLE_TLV("EQ2 B2 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B2_GAIN_SHIFT,
99 24, 0, eq_tlv),
100SOC_SINGLE_TLV("EQ2 B3 Volume", ARIZONA_EQ2_1, ARIZONA_EQ2_B3_GAIN_SHIFT,
101 24, 0, eq_tlv),
102SOC_SINGLE_TLV("EQ2 B4 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B4_GAIN_SHIFT,
103 24, 0, eq_tlv),
104SOC_SINGLE_TLV("EQ2 B5 Volume", ARIZONA_EQ2_2, ARIZONA_EQ2_B5_GAIN_SHIFT,
105 24, 0, eq_tlv),
106
107SOC_SINGLE_TLV("EQ3 B1 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B1_GAIN_SHIFT,
108 24, 0, eq_tlv),
109SOC_SINGLE_TLV("EQ3 B2 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B2_GAIN_SHIFT,
110 24, 0, eq_tlv),
111SOC_SINGLE_TLV("EQ3 B3 Volume", ARIZONA_EQ3_1, ARIZONA_EQ3_B3_GAIN_SHIFT,
112 24, 0, eq_tlv),
113SOC_SINGLE_TLV("EQ3 B4 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B4_GAIN_SHIFT,
114 24, 0, eq_tlv),
115SOC_SINGLE_TLV("EQ3 B5 Volume", ARIZONA_EQ3_2, ARIZONA_EQ3_B5_GAIN_SHIFT,
116 24, 0, eq_tlv),
117
118SOC_SINGLE_TLV("EQ4 B1 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B1_GAIN_SHIFT,
119 24, 0, eq_tlv),
120SOC_SINGLE_TLV("EQ4 B2 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B2_GAIN_SHIFT,
121 24, 0, eq_tlv),
122SOC_SINGLE_TLV("EQ4 B3 Volume", ARIZONA_EQ4_1, ARIZONA_EQ4_B3_GAIN_SHIFT,
123 24, 0, eq_tlv),
124SOC_SINGLE_TLV("EQ4 B4 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B4_GAIN_SHIFT,
125 24, 0, eq_tlv),
126SOC_SINGLE_TLV("EQ4 B5 Volume", ARIZONA_EQ4_2, ARIZONA_EQ4_B5_GAIN_SHIFT,
127 24, 0, eq_tlv),
128
129ARIZONA_MIXER_CONTROLS("DRC1L", ARIZONA_DRC1LMIX_INPUT_1_SOURCE),
130ARIZONA_MIXER_CONTROLS("DRC1R", ARIZONA_DRC1RMIX_INPUT_1_SOURCE),
131ARIZONA_MIXER_CONTROLS("DRC2L", ARIZONA_DRC2LMIX_INPUT_1_SOURCE),
132ARIZONA_MIXER_CONTROLS("DRC2R", ARIZONA_DRC2RMIX_INPUT_1_SOURCE),
133
134SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
135 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
136SND_SOC_BYTES_MASK("DRC2", ARIZONA_DRC2_CTRL1, 5,
137 ARIZONA_DRC2R_ENA | ARIZONA_DRC2L_ENA),
138
139ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
140ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
141ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
142ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
143
144SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
145SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
146SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
147SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
148
149ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
150ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
151
152SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
153 ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
154
155ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
156ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
157ARIZONA_MIXER_CONTROLS("HPOUT2L", ARIZONA_OUT2LMIX_INPUT_1_SOURCE),
158ARIZONA_MIXER_CONTROLS("HPOUT2R", ARIZONA_OUT2RMIX_INPUT_1_SOURCE),
159ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
160ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
161ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
162ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
163ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
164
165SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L,
166 ARIZONA_OUT1_OSR_SHIFT, 1, 0),
167SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L,
168 ARIZONA_OUT2_OSR_SHIFT, 1, 0),
169SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L,
170 ARIZONA_OUT3_OSR_SHIFT, 1, 0),
171SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
172 ARIZONA_OUT4_OSR_SHIFT, 1, 0),
173SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
174 ARIZONA_OUT5_OSR_SHIFT, 1, 0),
175
176SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
177 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
178SOC_DOUBLE_R("OUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L,
179 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1),
180SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
181 ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
182SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
183 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
184SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
185 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
186
187SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
188 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
189 0xbf, 0, digital_tlv),
190SOC_DOUBLE_R_TLV("OUT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L,
191 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT,
192 0xbf, 0, digital_tlv),
193SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
194 ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
195SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
196 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT,
197 0xbf, 0, digital_tlv),
198SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
199 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
200 0xbf, 0, digital_tlv),
201
202SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L,
203 ARIZONA_OUTPUT_PATH_CONFIG_1R,
204 ARIZONA_OUT1L_PGA_VOL_SHIFT,
205 0x34, 0x40, 0, ana_tlv),
206SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L,
207 ARIZONA_OUTPUT_PATH_CONFIG_2R,
208 ARIZONA_OUT2L_PGA_VOL_SHIFT,
209 0x34, 0x40, 0, ana_tlv),
210SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L,
211 ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv),
212
213SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
214 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
215
216ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
217ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
218ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
219ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
220ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
221ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
222ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
223ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
224
225ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
226ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
227
228ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
229ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
230};
231
232ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
233ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
234ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
235ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
236
237ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
238ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
239ARIZONA_MIXER_ENUMS(DRC2L, ARIZONA_DRC2LMIX_INPUT_1_SOURCE);
240ARIZONA_MIXER_ENUMS(DRC2R, ARIZONA_DRC2RMIX_INPUT_1_SOURCE);
241
242ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
243ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
244ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
245ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
246
247ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE);
248ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE);
249
250ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
251ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
252
253ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
254ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
255ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE);
256ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE);
257ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
258ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
259ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE);
260ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
261ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
262
263ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
264ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
265ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
266ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
267ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
268ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
269ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
270ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
271
272ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
273ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
274
275ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
276ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
277
Mark Brown94988222012-07-04 20:07:03 +0100278ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
279ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
280ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
281ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
282
Mark Browna3150f02012-08-16 20:28:18 +0100283
284static const char *wm5102_aec_loopback_texts[] = {
285 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT",
286 "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R",
287};
288
289static const unsigned int wm5102_aec_loopback_values[] = {
290 0, 1, 2, 3, 4, 6, 7, 8, 9,
291};
292
293static const struct soc_enum wm5102_aec_loopback =
294 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
295 ARIZONA_AEC_LOOPBACK_SRC_SHIFT,
296 ARIZONA_AEC_LOOPBACK_SRC_MASK,
297 ARRAY_SIZE(wm5102_aec_loopback_texts),
298 wm5102_aec_loopback_texts,
299 wm5102_aec_loopback_values);
300
301static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
302 SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5102_aec_loopback);
303
Mark Brown93e87912012-06-19 16:38:15 +0100304static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
305SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
306 0, NULL, 0),
307SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
308 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
Mark Brownc665d1a2012-08-08 17:53:01 +0100309SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
310 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
311SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
312 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
Mark Brown93e87912012-06-19 16:38:15 +0100313
314SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0),
315SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0),
316SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20),
317SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0),
318SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0),
319SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0),
320
321SND_SOC_DAPM_SIGGEN("TONE"),
322SND_SOC_DAPM_SIGGEN("NOISE"),
323
324SND_SOC_DAPM_INPUT("IN1L"),
325SND_SOC_DAPM_INPUT("IN1R"),
326SND_SOC_DAPM_INPUT("IN2L"),
327SND_SOC_DAPM_INPUT("IN2R"),
328SND_SOC_DAPM_INPUT("IN3L"),
329SND_SOC_DAPM_INPUT("IN3R"),
330
331SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
332 0, NULL, 0, arizona_in_ev,
333 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
334SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
335 0, NULL, 0, arizona_in_ev,
336 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
337SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_ENA_SHIFT,
338 0, NULL, 0, arizona_in_ev,
339 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
340SND_SOC_DAPM_PGA_E("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_ENA_SHIFT,
341 0, NULL, 0, arizona_in_ev,
342 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
343SND_SOC_DAPM_PGA_E("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_ENA_SHIFT,
344 0, NULL, 0, arizona_in_ev,
345 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
346SND_SOC_DAPM_PGA_E("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
347 0, NULL, 0, arizona_in_ev,
348 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
349
350SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
351 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
352SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
353 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
354SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
355 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
356
357SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
358 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
359
360SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
361 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
362SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
363 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
364
365SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1,
366 ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0),
367
368SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
369SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
370SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
371SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
372
373SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
374 NULL, 0),
375SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
376 NULL, 0),
377SND_SOC_DAPM_PGA("DRC2L", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2L_ENA_SHIFT, 0,
378 NULL, 0),
379SND_SOC_DAPM_PGA("DRC2R", ARIZONA_DRC2_CTRL1, ARIZONA_DRC2R_ENA_SHIFT, 0,
380 NULL, 0),
381
382SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
383 NULL, 0),
384SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
385 NULL, 0),
386SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
387 NULL, 0),
388SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
389 NULL, 0),
390
391SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
392 0, NULL, 0),
393SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
394 0, NULL, 0),
395
Mark Brown94988222012-07-04 20:07:03 +0100396SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
397 NULL, 0),
398SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
399 NULL, 0),
400SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
401 NULL, 0),
402SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
403 NULL, 0),
404
Mark Brown93e87912012-06-19 16:38:15 +0100405SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
406 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
407SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
408 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
409SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
410 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
411SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
412 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
413SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
414 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
415SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
416 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
417SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
418 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
419SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
420 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
421
422SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
423 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
424SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
425 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
426SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
427 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
428SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
429 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
430SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
431 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
432SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
433 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
434SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
435 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
436SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
437 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
438
439SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
440 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
441SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
442 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
443
444SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
445 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
446SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
447 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
448
449SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
450 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
451SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
452 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
453
454SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
455 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
456SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
457 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
458
Mark Browna3150f02012-08-16 20:28:18 +0100459SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
460 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux),
461
Mark Brown93e87912012-06-19 16:38:15 +0100462SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1,
463 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
464 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
465SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1,
466 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
467 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
468SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
469 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
470 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
471SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
472 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
473 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
474SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
475 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
476 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
477SND_SOC_DAPM_PGA_E("OUT4L", ARIZONA_OUTPUT_ENABLES_1,
478 ARIZONA_OUT4L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
479 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
480SND_SOC_DAPM_PGA_E("OUT4R", ARIZONA_OUTPUT_ENABLES_1,
481 ARIZONA_OUT4R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
482 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
483SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
484 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
485 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
486SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
487 ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
488 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
489
490ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
491ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
492ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"),
493ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"),
494
495ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
496ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
497ARIZONA_MIXER_WIDGETS(DRC2L, "DRC2L"),
498ARIZONA_MIXER_WIDGETS(DRC2R, "DRC2R"),
499
500ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
501ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
502ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
503ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
504
505ARIZONA_MIXER_WIDGETS(Mic, "Mic"),
506ARIZONA_MIXER_WIDGETS(Noise, "Noise"),
507
508ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
509ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
510
511ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
512ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
513ARIZONA_MIXER_WIDGETS(OUT2L, "HPOUT2L"),
514ARIZONA_MIXER_WIDGETS(OUT2R, "HPOUT2R"),
515ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
516ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"),
517ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"),
518ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
519ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
520
521ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
522ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
523ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
524ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
525ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
526ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
527ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
528ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
529
530ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
531ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
532
533ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
534ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
535
Mark Brown94988222012-07-04 20:07:03 +0100536ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"),
537ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"),
538ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"),
539ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"),
540
Mark Brown93e87912012-06-19 16:38:15 +0100541SND_SOC_DAPM_OUTPUT("HPOUT1L"),
542SND_SOC_DAPM_OUTPUT("HPOUT1R"),
543SND_SOC_DAPM_OUTPUT("HPOUT2L"),
544SND_SOC_DAPM_OUTPUT("HPOUT2R"),
545SND_SOC_DAPM_OUTPUT("EPOUTN"),
546SND_SOC_DAPM_OUTPUT("EPOUTP"),
547SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
548SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
549SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
550SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
551SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
552SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
553};
554
555#define ARIZONA_MIXER_INPUT_ROUTES(name) \
556 { name, "Noise Generator", "Noise Generator" }, \
557 { name, "Tone Generator 1", "Tone Generator 1" }, \
558 { name, "Tone Generator 2", "Tone Generator 2" }, \
Mark Browna3150f02012-08-16 20:28:18 +0100559 { name, "AEC", "AEC Loopback" }, \
Mark Brown93e87912012-06-19 16:38:15 +0100560 { name, "IN1L", "IN1L PGA" }, \
561 { name, "IN1R", "IN1R PGA" }, \
562 { name, "IN2L", "IN2L PGA" }, \
563 { name, "IN2R", "IN2R PGA" }, \
564 { name, "IN3L", "IN3L PGA" }, \
565 { name, "IN3R", "IN3R PGA" }, \
566 { name, "Mic Mute Mixer", "Mic Mute Mixer" }, \
567 { name, "AIF1RX1", "AIF1RX1" }, \
568 { name, "AIF1RX2", "AIF1RX2" }, \
569 { name, "AIF1RX3", "AIF1RX3" }, \
570 { name, "AIF1RX4", "AIF1RX4" }, \
571 { name, "AIF1RX5", "AIF1RX5" }, \
572 { name, "AIF1RX6", "AIF1RX6" }, \
573 { name, "AIF1RX7", "AIF1RX7" }, \
574 { name, "AIF1RX8", "AIF1RX8" }, \
575 { name, "AIF2RX1", "AIF2RX1" }, \
576 { name, "AIF2RX2", "AIF2RX2" }, \
577 { name, "AIF3RX1", "AIF3RX1" }, \
578 { name, "AIF3RX2", "AIF3RX2" }, \
579 { name, "EQ1", "EQ1" }, \
580 { name, "EQ2", "EQ2" }, \
581 { name, "EQ3", "EQ3" }, \
582 { name, "EQ4", "EQ4" }, \
583 { name, "DRC1L", "DRC1L" }, \
584 { name, "DRC1R", "DRC1R" }, \
585 { name, "DRC2L", "DRC2L" }, \
586 { name, "DRC2R", "DRC2R" }, \
587 { name, "LHPF1", "LHPF1" }, \
588 { name, "LHPF2", "LHPF2" }, \
589 { name, "LHPF3", "LHPF3" }, \
Mark Brown94988222012-07-04 20:07:03 +0100590 { name, "LHPF4", "LHPF4" }, \
591 { name, "ASRC1L", "ASRC1L" }, \
592 { name, "ASRC1R", "ASRC1R" }, \
593 { name, "ASRC2L", "ASRC2L" }, \
594 { name, "ASRC2R", "ASRC2R" }
Mark Brown93e87912012-06-19 16:38:15 +0100595
596static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
597 { "AIF2 Capture", NULL, "DBVDD2" },
598 { "AIF2 Playback", NULL, "DBVDD2" },
599
600 { "AIF3 Capture", NULL, "DBVDD3" },
601 { "AIF3 Playback", NULL, "DBVDD3" },
602
603 { "OUT1L", NULL, "CPVDD" },
604 { "OUT1R", NULL, "CPVDD" },
605 { "OUT2L", NULL, "CPVDD" },
606 { "OUT2R", NULL, "CPVDD" },
607 { "OUT3L", NULL, "CPVDD" },
608
609 { "OUT4L", NULL, "SPKVDDL" },
610 { "OUT4R", NULL, "SPKVDDR" },
611
612 { "OUT1L", NULL, "SYSCLK" },
613 { "OUT1R", NULL, "SYSCLK" },
614 { "OUT2L", NULL, "SYSCLK" },
615 { "OUT2R", NULL, "SYSCLK" },
616 { "OUT3L", NULL, "SYSCLK" },
617 { "OUT4L", NULL, "SYSCLK" },
618 { "OUT4R", NULL, "SYSCLK" },
619 { "OUT5L", NULL, "SYSCLK" },
620 { "OUT5R", NULL, "SYSCLK" },
621
622 { "MICBIAS1", NULL, "MICVDD" },
623 { "MICBIAS2", NULL, "MICVDD" },
624 { "MICBIAS3", NULL, "MICVDD" },
625
626 { "Noise Generator", NULL, "NOISE" },
627 { "Tone Generator 1", NULL, "TONE" },
628 { "Tone Generator 2", NULL, "TONE" },
629
630 { "Mic Mute Mixer", NULL, "Noise Mixer" },
631 { "Mic Mute Mixer", NULL, "Mic Mixer" },
632
633 { "AIF1 Capture", NULL, "AIF1TX1" },
634 { "AIF1 Capture", NULL, "AIF1TX2" },
635 { "AIF1 Capture", NULL, "AIF1TX3" },
636 { "AIF1 Capture", NULL, "AIF1TX4" },
637 { "AIF1 Capture", NULL, "AIF1TX5" },
638 { "AIF1 Capture", NULL, "AIF1TX6" },
639 { "AIF1 Capture", NULL, "AIF1TX7" },
640 { "AIF1 Capture", NULL, "AIF1TX8" },
641
642 { "AIF1RX1", NULL, "AIF1 Playback" },
643 { "AIF1RX2", NULL, "AIF1 Playback" },
644 { "AIF1RX3", NULL, "AIF1 Playback" },
645 { "AIF1RX4", NULL, "AIF1 Playback" },
646 { "AIF1RX5", NULL, "AIF1 Playback" },
647 { "AIF1RX6", NULL, "AIF1 Playback" },
648 { "AIF1RX7", NULL, "AIF1 Playback" },
649 { "AIF1RX8", NULL, "AIF1 Playback" },
650
651 { "AIF2 Capture", NULL, "AIF2TX1" },
652 { "AIF2 Capture", NULL, "AIF2TX2" },
653
654 { "AIF2RX1", NULL, "AIF2 Playback" },
655 { "AIF2RX2", NULL, "AIF2 Playback" },
656
657 { "AIF3 Capture", NULL, "AIF3TX1" },
658 { "AIF3 Capture", NULL, "AIF3TX2" },
659
660 { "AIF3RX1", NULL, "AIF3 Playback" },
661 { "AIF3RX2", NULL, "AIF3 Playback" },
662
663 { "AIF1 Playback", NULL, "SYSCLK" },
664 { "AIF2 Playback", NULL, "SYSCLK" },
665 { "AIF3 Playback", NULL, "SYSCLK" },
666
667 { "AIF1 Capture", NULL, "SYSCLK" },
668 { "AIF2 Capture", NULL, "SYSCLK" },
669 { "AIF3 Capture", NULL, "SYSCLK" },
670
671 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
672 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
673 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"),
674 ARIZONA_MIXER_ROUTES("OUT2R", "HPOUT2R"),
675 ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"),
676
677 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"),
678 ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"),
679 ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
680 ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
681
682 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
683 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
684
685 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
686 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
687 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
688 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
689 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
690 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
691 ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
692 ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
693
694 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
695 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
696
697 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
698 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
699
700 ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
701 ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
702 ARIZONA_MIXER_ROUTES("EQ3", "EQ3"),
703 ARIZONA_MIXER_ROUTES("EQ4", "EQ4"),
704
705 ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
706 ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
707 ARIZONA_MIXER_ROUTES("DRC2L", "DRC2L"),
708 ARIZONA_MIXER_ROUTES("DRC2R", "DRC2R"),
709
710 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
711 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
712 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
713 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
714
Mark Brown94988222012-07-04 20:07:03 +0100715 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"),
716 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"),
717 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"),
718 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"),
719
Mark Browna3150f02012-08-16 20:28:18 +0100720 { "AEC Loopback", "HPOUT1L", "OUT1L" },
721 { "AEC Loopback", "HPOUT1R", "OUT1R" },
Mark Brown93e87912012-06-19 16:38:15 +0100722 { "HPOUT1L", NULL, "OUT1L" },
723 { "HPOUT1R", NULL, "OUT1R" },
724
Mark Browna3150f02012-08-16 20:28:18 +0100725 { "AEC Loopback", "HPOUT2L", "OUT2L" },
726 { "AEC Loopback", "HPOUT2R", "OUT2R" },
Mark Brown93e87912012-06-19 16:38:15 +0100727 { "HPOUT2L", NULL, "OUT2L" },
728 { "HPOUT2R", NULL, "OUT2R" },
729
Mark Browna3150f02012-08-16 20:28:18 +0100730 { "AEC Loopback", "EPOUT", "OUT3L" },
Mark Brown93e87912012-06-19 16:38:15 +0100731 { "EPOUTN", NULL, "OUT3L" },
732 { "EPOUTP", NULL, "OUT3L" },
733
Mark Browna3150f02012-08-16 20:28:18 +0100734 { "AEC Loopback", "SPKOUTL", "OUT4L" },
Mark Brown93e87912012-06-19 16:38:15 +0100735 { "SPKOUTLN", NULL, "OUT4L" },
736 { "SPKOUTLP", NULL, "OUT4L" },
737
Mark Browna3150f02012-08-16 20:28:18 +0100738 { "AEC Loopback", "SPKOUTR", "OUT4R" },
Mark Brown93e87912012-06-19 16:38:15 +0100739 { "SPKOUTRN", NULL, "OUT4R" },
740 { "SPKOUTRP", NULL, "OUT4R" },
741
Mark Browna3150f02012-08-16 20:28:18 +0100742 { "AEC Loopback", "SPKDAT1L", "OUT5L" },
743 { "AEC Loopback", "SPKDAT1R", "OUT5R" },
Mark Brown93e87912012-06-19 16:38:15 +0100744 { "SPKDAT1L", NULL, "OUT5L" },
745 { "SPKDAT1R", NULL, "OUT5R" },
746};
747
748static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
749 unsigned int Fref, unsigned int Fout)
750{
751 struct wm5102_priv *wm5102 = snd_soc_codec_get_drvdata(codec);
752
753 switch (fll_id) {
754 case WM5102_FLL1:
755 return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout);
756 case WM5102_FLL2:
757 return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout);
758 default:
759 return -EINVAL;
760 }
761}
762
763#define WM5102_RATES SNDRV_PCM_RATE_8000_192000
764
765#define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
766 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
767
768static struct snd_soc_dai_driver wm5102_dai[] = {
769 {
770 .name = "wm5102-aif1",
771 .id = 1,
772 .base = ARIZONA_AIF1_BCLK_CTRL,
773 .playback = {
774 .stream_name = "AIF1 Playback",
775 .channels_min = 1,
776 .channels_max = 8,
777 .rates = WM5102_RATES,
778 .formats = WM5102_FORMATS,
779 },
780 .capture = {
781 .stream_name = "AIF1 Capture",
782 .channels_min = 1,
783 .channels_max = 8,
784 .rates = WM5102_RATES,
785 .formats = WM5102_FORMATS,
786 },
787 .ops = &arizona_dai_ops,
788 .symmetric_rates = 1,
789 },
790 {
791 .name = "wm5102-aif2",
792 .id = 2,
793 .base = ARIZONA_AIF2_BCLK_CTRL,
794 .playback = {
795 .stream_name = "AIF2 Playback",
796 .channels_min = 1,
797 .channels_max = 2,
798 .rates = WM5102_RATES,
799 .formats = WM5102_FORMATS,
800 },
801 .capture = {
802 .stream_name = "AIF2 Capture",
803 .channels_min = 1,
804 .channels_max = 2,
805 .rates = WM5102_RATES,
806 .formats = WM5102_FORMATS,
807 },
808 .ops = &arizona_dai_ops,
809 .symmetric_rates = 1,
810 },
811 {
812 .name = "wm5102-aif3",
813 .id = 3,
814 .base = ARIZONA_AIF3_BCLK_CTRL,
815 .playback = {
816 .stream_name = "AIF3 Playback",
817 .channels_min = 1,
818 .channels_max = 2,
819 .rates = WM5102_RATES,
820 .formats = WM5102_FORMATS,
821 },
822 .capture = {
823 .stream_name = "AIF3 Capture",
824 .channels_min = 1,
825 .channels_max = 2,
826 .rates = WM5102_RATES,
827 .formats = WM5102_FORMATS,
828 },
829 .ops = &arizona_dai_ops,
830 .symmetric_rates = 1,
831 },
832};
833
834static int wm5102_codec_probe(struct snd_soc_codec *codec)
835{
836 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
837
838 codec->control_data = priv->core.arizona->regmap;
839 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
840}
841
842#define WM5102_DIG_VU 0x0200
843
844static unsigned int wm5102_digital_vu[] = {
845 ARIZONA_ADC_DIGITAL_VOLUME_1L,
846 ARIZONA_ADC_DIGITAL_VOLUME_1R,
847 ARIZONA_ADC_DIGITAL_VOLUME_2L,
848 ARIZONA_ADC_DIGITAL_VOLUME_2R,
849 ARIZONA_ADC_DIGITAL_VOLUME_3L,
850 ARIZONA_ADC_DIGITAL_VOLUME_3R,
851
852 ARIZONA_DAC_DIGITAL_VOLUME_1L,
853 ARIZONA_DAC_DIGITAL_VOLUME_1R,
854 ARIZONA_DAC_DIGITAL_VOLUME_2L,
855 ARIZONA_DAC_DIGITAL_VOLUME_2R,
856 ARIZONA_DAC_DIGITAL_VOLUME_3L,
857 ARIZONA_DAC_DIGITAL_VOLUME_3R,
858 ARIZONA_DAC_DIGITAL_VOLUME_4L,
859 ARIZONA_DAC_DIGITAL_VOLUME_4R,
860 ARIZONA_DAC_DIGITAL_VOLUME_5L,
861 ARIZONA_DAC_DIGITAL_VOLUME_5R,
862};
863
864static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
865 .probe = wm5102_codec_probe,
866
867 .idle_bias_off = true,
868
869 .set_sysclk = arizona_set_sysclk,
870 .set_pll = wm5102_set_fll,
871
872 .controls = wm5102_snd_controls,
873 .num_controls = ARRAY_SIZE(wm5102_snd_controls),
874 .dapm_widgets = wm5102_dapm_widgets,
875 .num_dapm_widgets = ARRAY_SIZE(wm5102_dapm_widgets),
876 .dapm_routes = wm5102_dapm_routes,
877 .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes),
878};
879
880static int __devinit wm5102_probe(struct platform_device *pdev)
881{
882 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
883 struct wm5102_priv *wm5102;
884 int i;
885
886 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv),
887 GFP_KERNEL);
888 if (wm5102 == NULL)
889 return -ENOMEM;
890 platform_set_drvdata(pdev, wm5102);
891
892 wm5102->core.arizona = arizona;
893
Mark Brown2b4d39f2012-07-10 17:03:46 +0100894 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++)
895 wm5102->fll[i].vco_mult = 1;
896
Mark Brown93e87912012-06-19 16:38:15 +0100897 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
898 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
899 &wm5102->fll[0]);
900 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
901 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
902 &wm5102->fll[1]);
903
Mark Brown5b2eec32012-07-04 17:32:05 +0100904 for (i = 0; i < ARRAY_SIZE(wm5102_dai); i++)
905 arizona_init_dai(&wm5102->core, i);
906
Mark Brown93e87912012-06-19 16:38:15 +0100907 /* Latch volume update bits */
908 for (i = 0; i < ARRAY_SIZE(wm5102_digital_vu); i++)
909 regmap_update_bits(arizona->regmap, wm5102_digital_vu[i],
910 WM5102_DIG_VU, WM5102_DIG_VU);
911
912 pm_runtime_enable(&pdev->dev);
913 pm_runtime_idle(&pdev->dev);
914
915 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102,
916 wm5102_dai, ARRAY_SIZE(wm5102_dai));
917}
918
919static int __devexit wm5102_remove(struct platform_device *pdev)
920{
921 snd_soc_unregister_codec(&pdev->dev);
922 pm_runtime_disable(&pdev->dev);
923
924 return 0;
925}
926
927static struct platform_driver wm5102_codec_driver = {
928 .driver = {
929 .name = "wm5102-codec",
930 .owner = THIS_MODULE,
931 },
932 .probe = wm5102_probe,
933 .remove = __devexit_p(wm5102_remove),
934};
935
936module_platform_driver(wm5102_codec_driver);
937
938MODULE_DESCRIPTION("ASoC WM5102 driver");
939MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
940MODULE_LICENSE("GPL");
941MODULE_ALIAS("platform:wm5102-codec");