blob: 1722b586bdba65bde94d9d3cb5cc1ca51cd44aee [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),
Mark Brown93e87912012-06-19 16:38:15 +0100131
132SND_SOC_BYTES_MASK("DRC1", ARIZONA_DRC1_CTRL1, 5,
133 ARIZONA_DRC1R_ENA | ARIZONA_DRC1L_ENA),
Mark Brown93e87912012-06-19 16:38:15 +0100134
135ARIZONA_MIXER_CONTROLS("LHPF1", ARIZONA_HPLP1MIX_INPUT_1_SOURCE),
136ARIZONA_MIXER_CONTROLS("LHPF2", ARIZONA_HPLP2MIX_INPUT_1_SOURCE),
137ARIZONA_MIXER_CONTROLS("LHPF3", ARIZONA_HPLP3MIX_INPUT_1_SOURCE),
138ARIZONA_MIXER_CONTROLS("LHPF4", ARIZONA_HPLP4MIX_INPUT_1_SOURCE),
139
140SOC_ENUM("LHPF1 Mode", arizona_lhpf1_mode),
141SOC_ENUM("LHPF2 Mode", arizona_lhpf2_mode),
142SOC_ENUM("LHPF3 Mode", arizona_lhpf3_mode),
143SOC_ENUM("LHPF4 Mode", arizona_lhpf4_mode),
144
145ARIZONA_MIXER_CONTROLS("Mic", ARIZONA_MICMIX_INPUT_1_SOURCE),
146ARIZONA_MIXER_CONTROLS("Noise", ARIZONA_NOISEMIX_INPUT_1_SOURCE),
147
148SOC_SINGLE_TLV("Noise Generator Volume", ARIZONA_COMFORT_NOISE_GENERATOR,
149 ARIZONA_NOISE_GEN_GAIN_SHIFT, 0x16, 0, noise_tlv),
150
151ARIZONA_MIXER_CONTROLS("HPOUT1L", ARIZONA_OUT1LMIX_INPUT_1_SOURCE),
152ARIZONA_MIXER_CONTROLS("HPOUT1R", ARIZONA_OUT1RMIX_INPUT_1_SOURCE),
153ARIZONA_MIXER_CONTROLS("HPOUT2L", ARIZONA_OUT2LMIX_INPUT_1_SOURCE),
154ARIZONA_MIXER_CONTROLS("HPOUT2R", ARIZONA_OUT2RMIX_INPUT_1_SOURCE),
155ARIZONA_MIXER_CONTROLS("EPOUT", ARIZONA_OUT3LMIX_INPUT_1_SOURCE),
156ARIZONA_MIXER_CONTROLS("SPKOUTL", ARIZONA_OUT4LMIX_INPUT_1_SOURCE),
157ARIZONA_MIXER_CONTROLS("SPKOUTR", ARIZONA_OUT4RMIX_INPUT_1_SOURCE),
158ARIZONA_MIXER_CONTROLS("SPKDAT1L", ARIZONA_OUT5LMIX_INPUT_1_SOURCE),
159ARIZONA_MIXER_CONTROLS("SPKDAT1R", ARIZONA_OUT5RMIX_INPUT_1_SOURCE),
160
161SOC_SINGLE("HPOUT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_1L,
162 ARIZONA_OUT1_OSR_SHIFT, 1, 0),
163SOC_SINGLE("OUT2 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_2L,
164 ARIZONA_OUT2_OSR_SHIFT, 1, 0),
165SOC_SINGLE("EPOUT High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_3L,
166 ARIZONA_OUT3_OSR_SHIFT, 1, 0),
167SOC_SINGLE("Speaker High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_4L,
168 ARIZONA_OUT4_OSR_SHIFT, 1, 0),
169SOC_SINGLE("SPKDAT1 High Performance Switch", ARIZONA_OUTPUT_PATH_CONFIG_5L,
170 ARIZONA_OUT5_OSR_SHIFT, 1, 0),
171
172SOC_DOUBLE_R("HPOUT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_1L,
173 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_MUTE_SHIFT, 1, 1),
174SOC_DOUBLE_R("OUT2 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_2L,
175 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_MUTE_SHIFT, 1, 1),
176SOC_SINGLE("EPOUT Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_3L,
177 ARIZONA_OUT3L_MUTE_SHIFT, 1, 1),
178SOC_DOUBLE_R("Speaker Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_4L,
179 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_MUTE_SHIFT, 1, 1),
180SOC_DOUBLE_R("SPKDAT1 Digital Switch", ARIZONA_DAC_DIGITAL_VOLUME_5L,
181 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_MUTE_SHIFT, 1, 1),
182
183SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_1L,
184 ARIZONA_DAC_DIGITAL_VOLUME_1R, ARIZONA_OUT1L_VOL_SHIFT,
185 0xbf, 0, digital_tlv),
186SOC_DOUBLE_R_TLV("OUT2 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_2L,
187 ARIZONA_DAC_DIGITAL_VOLUME_2R, ARIZONA_OUT2L_VOL_SHIFT,
188 0xbf, 0, digital_tlv),
189SOC_SINGLE_TLV("EPOUT Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_3L,
190 ARIZONA_OUT3L_VOL_SHIFT, 0xbf, 0, digital_tlv),
191SOC_DOUBLE_R_TLV("Speaker Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_4L,
192 ARIZONA_DAC_DIGITAL_VOLUME_4R, ARIZONA_OUT4L_VOL_SHIFT,
193 0xbf, 0, digital_tlv),
194SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", ARIZONA_DAC_DIGITAL_VOLUME_5L,
195 ARIZONA_DAC_DIGITAL_VOLUME_5R, ARIZONA_OUT5L_VOL_SHIFT,
196 0xbf, 0, digital_tlv),
197
198SOC_DOUBLE_R_RANGE_TLV("HPOUT1 Volume", ARIZONA_OUTPUT_PATH_CONFIG_1L,
199 ARIZONA_OUTPUT_PATH_CONFIG_1R,
200 ARIZONA_OUT1L_PGA_VOL_SHIFT,
201 0x34, 0x40, 0, ana_tlv),
202SOC_DOUBLE_R_RANGE_TLV("OUT2 Volume", ARIZONA_OUTPUT_PATH_CONFIG_2L,
203 ARIZONA_OUTPUT_PATH_CONFIG_2R,
204 ARIZONA_OUT2L_PGA_VOL_SHIFT,
205 0x34, 0x40, 0, ana_tlv),
206SOC_SINGLE_RANGE_TLV("EPOUT Volume", ARIZONA_OUTPUT_PATH_CONFIG_3L,
207 ARIZONA_OUT3L_PGA_VOL_SHIFT, 0x34, 0x40, 0, ana_tlv),
208
209SOC_DOUBLE("SPKDAT1 Switch", ARIZONA_PDM_SPK1_CTRL_1, ARIZONA_SPK1L_MUTE_SHIFT,
210 ARIZONA_SPK1R_MUTE_SHIFT, 1, 1),
211
212ARIZONA_MIXER_CONTROLS("AIF1TX1", ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE),
213ARIZONA_MIXER_CONTROLS("AIF1TX2", ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE),
214ARIZONA_MIXER_CONTROLS("AIF1TX3", ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE),
215ARIZONA_MIXER_CONTROLS("AIF1TX4", ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE),
216ARIZONA_MIXER_CONTROLS("AIF1TX5", ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE),
217ARIZONA_MIXER_CONTROLS("AIF1TX6", ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE),
218ARIZONA_MIXER_CONTROLS("AIF1TX7", ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE),
219ARIZONA_MIXER_CONTROLS("AIF1TX8", ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE),
220
221ARIZONA_MIXER_CONTROLS("AIF2TX1", ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE),
222ARIZONA_MIXER_CONTROLS("AIF2TX2", ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE),
223
224ARIZONA_MIXER_CONTROLS("AIF3TX1", ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE),
225ARIZONA_MIXER_CONTROLS("AIF3TX2", ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE),
226};
227
228ARIZONA_MIXER_ENUMS(EQ1, ARIZONA_EQ1MIX_INPUT_1_SOURCE);
229ARIZONA_MIXER_ENUMS(EQ2, ARIZONA_EQ2MIX_INPUT_1_SOURCE);
230ARIZONA_MIXER_ENUMS(EQ3, ARIZONA_EQ3MIX_INPUT_1_SOURCE);
231ARIZONA_MIXER_ENUMS(EQ4, ARIZONA_EQ4MIX_INPUT_1_SOURCE);
232
233ARIZONA_MIXER_ENUMS(DRC1L, ARIZONA_DRC1LMIX_INPUT_1_SOURCE);
234ARIZONA_MIXER_ENUMS(DRC1R, ARIZONA_DRC1RMIX_INPUT_1_SOURCE);
Mark Brown93e87912012-06-19 16:38:15 +0100235
236ARIZONA_MIXER_ENUMS(LHPF1, ARIZONA_HPLP1MIX_INPUT_1_SOURCE);
237ARIZONA_MIXER_ENUMS(LHPF2, ARIZONA_HPLP2MIX_INPUT_1_SOURCE);
238ARIZONA_MIXER_ENUMS(LHPF3, ARIZONA_HPLP3MIX_INPUT_1_SOURCE);
239ARIZONA_MIXER_ENUMS(LHPF4, ARIZONA_HPLP4MIX_INPUT_1_SOURCE);
240
241ARIZONA_MIXER_ENUMS(Mic, ARIZONA_MICMIX_INPUT_1_SOURCE);
242ARIZONA_MIXER_ENUMS(Noise, ARIZONA_NOISEMIX_INPUT_1_SOURCE);
243
244ARIZONA_MIXER_ENUMS(PWM1, ARIZONA_PWM1MIX_INPUT_1_SOURCE);
245ARIZONA_MIXER_ENUMS(PWM2, ARIZONA_PWM2MIX_INPUT_1_SOURCE);
246
247ARIZONA_MIXER_ENUMS(OUT1L, ARIZONA_OUT1LMIX_INPUT_1_SOURCE);
248ARIZONA_MIXER_ENUMS(OUT1R, ARIZONA_OUT1RMIX_INPUT_1_SOURCE);
249ARIZONA_MIXER_ENUMS(OUT2L, ARIZONA_OUT2LMIX_INPUT_1_SOURCE);
250ARIZONA_MIXER_ENUMS(OUT2R, ARIZONA_OUT2RMIX_INPUT_1_SOURCE);
251ARIZONA_MIXER_ENUMS(OUT3, ARIZONA_OUT3LMIX_INPUT_1_SOURCE);
252ARIZONA_MIXER_ENUMS(SPKOUTL, ARIZONA_OUT4LMIX_INPUT_1_SOURCE);
253ARIZONA_MIXER_ENUMS(SPKOUTR, ARIZONA_OUT4RMIX_INPUT_1_SOURCE);
254ARIZONA_MIXER_ENUMS(SPKDAT1L, ARIZONA_OUT5LMIX_INPUT_1_SOURCE);
255ARIZONA_MIXER_ENUMS(SPKDAT1R, ARIZONA_OUT5RMIX_INPUT_1_SOURCE);
256
257ARIZONA_MIXER_ENUMS(AIF1TX1, ARIZONA_AIF1TX1MIX_INPUT_1_SOURCE);
258ARIZONA_MIXER_ENUMS(AIF1TX2, ARIZONA_AIF1TX2MIX_INPUT_1_SOURCE);
259ARIZONA_MIXER_ENUMS(AIF1TX3, ARIZONA_AIF1TX3MIX_INPUT_1_SOURCE);
260ARIZONA_MIXER_ENUMS(AIF1TX4, ARIZONA_AIF1TX4MIX_INPUT_1_SOURCE);
261ARIZONA_MIXER_ENUMS(AIF1TX5, ARIZONA_AIF1TX5MIX_INPUT_1_SOURCE);
262ARIZONA_MIXER_ENUMS(AIF1TX6, ARIZONA_AIF1TX6MIX_INPUT_1_SOURCE);
263ARIZONA_MIXER_ENUMS(AIF1TX7, ARIZONA_AIF1TX7MIX_INPUT_1_SOURCE);
264ARIZONA_MIXER_ENUMS(AIF1TX8, ARIZONA_AIF1TX8MIX_INPUT_1_SOURCE);
265
266ARIZONA_MIXER_ENUMS(AIF2TX1, ARIZONA_AIF2TX1MIX_INPUT_1_SOURCE);
267ARIZONA_MIXER_ENUMS(AIF2TX2, ARIZONA_AIF2TX2MIX_INPUT_1_SOURCE);
268
269ARIZONA_MIXER_ENUMS(AIF3TX1, ARIZONA_AIF3TX1MIX_INPUT_1_SOURCE);
270ARIZONA_MIXER_ENUMS(AIF3TX2, ARIZONA_AIF3TX2MIX_INPUT_1_SOURCE);
271
Mark Brown94988222012-07-04 20:07:03 +0100272ARIZONA_MIXER_ENUMS(ASRC1L, ARIZONA_ASRC1LMIX_INPUT_1_SOURCE);
273ARIZONA_MIXER_ENUMS(ASRC1R, ARIZONA_ASRC1RMIX_INPUT_1_SOURCE);
274ARIZONA_MIXER_ENUMS(ASRC2L, ARIZONA_ASRC2LMIX_INPUT_1_SOURCE);
275ARIZONA_MIXER_ENUMS(ASRC2R, ARIZONA_ASRC2RMIX_INPUT_1_SOURCE);
276
Mark Browna3150f02012-08-16 20:28:18 +0100277
278static const char *wm5102_aec_loopback_texts[] = {
279 "HPOUT1L", "HPOUT1R", "HPOUT2L", "HPOUT2R", "EPOUT",
280 "SPKOUTL", "SPKOUTR", "SPKDAT1L", "SPKDAT1R",
281};
282
283static const unsigned int wm5102_aec_loopback_values[] = {
284 0, 1, 2, 3, 4, 6, 7, 8, 9,
285};
286
287static const struct soc_enum wm5102_aec_loopback =
288 SOC_VALUE_ENUM_SINGLE(ARIZONA_DAC_AEC_CONTROL_1,
289 ARIZONA_AEC_LOOPBACK_SRC_SHIFT,
290 ARIZONA_AEC_LOOPBACK_SRC_MASK,
291 ARRAY_SIZE(wm5102_aec_loopback_texts),
292 wm5102_aec_loopback_texts,
293 wm5102_aec_loopback_values);
294
295static const struct snd_kcontrol_new wm5102_aec_loopback_mux =
296 SOC_DAPM_VALUE_ENUM("AEC Loopback", wm5102_aec_loopback);
297
Mark Brown93e87912012-06-19 16:38:15 +0100298static const struct snd_soc_dapm_widget wm5102_dapm_widgets[] = {
299SND_SOC_DAPM_SUPPLY("SYSCLK", ARIZONA_SYSTEM_CLOCK_1, ARIZONA_SYSCLK_ENA_SHIFT,
300 0, NULL, 0),
301SND_SOC_DAPM_SUPPLY("ASYNCCLK", ARIZONA_ASYNC_CLOCK_1,
302 ARIZONA_ASYNC_CLK_ENA_SHIFT, 0, NULL, 0),
Mark Brownc665d1a2012-08-08 17:53:01 +0100303SND_SOC_DAPM_SUPPLY("OPCLK", ARIZONA_OUTPUT_SYSTEM_CLOCK,
304 ARIZONA_OPCLK_ENA_SHIFT, 0, NULL, 0),
305SND_SOC_DAPM_SUPPLY("ASYNCOPCLK", ARIZONA_OUTPUT_ASYNC_CLOCK,
306 ARIZONA_OPCLK_ASYNC_ENA_SHIFT, 0, NULL, 0),
Mark Brown93e87912012-06-19 16:38:15 +0100307
Mark Brown822b4b82012-09-07 10:54:32 +0800308SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD2", 0, 0),
309SND_SOC_DAPM_REGULATOR_SUPPLY("DBVDD3", 0, 0),
310SND_SOC_DAPM_REGULATOR_SUPPLY("CPVDD", 20, 0),
Mark Brownbb09d972012-09-07 12:58:43 +0800311SND_SOC_DAPM_REGULATOR_SUPPLY("MICVDD", 0, SND_SOC_DAPM_REGULATOR_BYPASS),
Mark Brown822b4b82012-09-07 10:54:32 +0800312SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDL", 0, 0),
313SND_SOC_DAPM_REGULATOR_SUPPLY("SPKVDDR", 0, 0),
Mark Brown93e87912012-06-19 16:38:15 +0100314
315SND_SOC_DAPM_SIGGEN("TONE"),
316SND_SOC_DAPM_SIGGEN("NOISE"),
317
318SND_SOC_DAPM_INPUT("IN1L"),
319SND_SOC_DAPM_INPUT("IN1R"),
320SND_SOC_DAPM_INPUT("IN2L"),
321SND_SOC_DAPM_INPUT("IN2R"),
322SND_SOC_DAPM_INPUT("IN3L"),
323SND_SOC_DAPM_INPUT("IN3R"),
324
325SND_SOC_DAPM_PGA_E("IN1L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1L_ENA_SHIFT,
326 0, NULL, 0, arizona_in_ev,
327 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
328SND_SOC_DAPM_PGA_E("IN1R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN1R_ENA_SHIFT,
329 0, NULL, 0, arizona_in_ev,
330 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
331SND_SOC_DAPM_PGA_E("IN2L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2L_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("IN2R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN2R_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("IN3L PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3L_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("IN3R PGA", ARIZONA_INPUT_ENABLES, ARIZONA_IN3R_ENA_SHIFT,
341 0, NULL, 0, arizona_in_ev,
342 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
343
344SND_SOC_DAPM_SUPPLY("MICBIAS1", ARIZONA_MIC_BIAS_CTRL_1,
345 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
346SND_SOC_DAPM_SUPPLY("MICBIAS2", ARIZONA_MIC_BIAS_CTRL_2,
347 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
348SND_SOC_DAPM_SUPPLY("MICBIAS3", ARIZONA_MIC_BIAS_CTRL_3,
349 ARIZONA_MICB1_ENA_SHIFT, 0, NULL, 0),
350
351SND_SOC_DAPM_PGA("Noise Generator", ARIZONA_COMFORT_NOISE_GENERATOR,
352 ARIZONA_NOISE_GEN_ENA_SHIFT, 0, NULL, 0),
353
354SND_SOC_DAPM_PGA("Tone Generator 1", ARIZONA_TONE_GENERATOR_1,
355 ARIZONA_TONE1_ENA_SHIFT, 0, NULL, 0),
356SND_SOC_DAPM_PGA("Tone Generator 2", ARIZONA_TONE_GENERATOR_1,
357 ARIZONA_TONE2_ENA_SHIFT, 0, NULL, 0),
358
359SND_SOC_DAPM_PGA("Mic Mute Mixer", ARIZONA_MIC_NOISE_MIX_CONTROL_1,
360 ARIZONA_MICMUTE_MIX_ENA_SHIFT, 0, NULL, 0),
361
362SND_SOC_DAPM_PGA("EQ1", ARIZONA_EQ1_1, ARIZONA_EQ1_ENA_SHIFT, 0, NULL, 0),
363SND_SOC_DAPM_PGA("EQ2", ARIZONA_EQ2_1, ARIZONA_EQ2_ENA_SHIFT, 0, NULL, 0),
364SND_SOC_DAPM_PGA("EQ3", ARIZONA_EQ3_1, ARIZONA_EQ3_ENA_SHIFT, 0, NULL, 0),
365SND_SOC_DAPM_PGA("EQ4", ARIZONA_EQ4_1, ARIZONA_EQ4_ENA_SHIFT, 0, NULL, 0),
366
367SND_SOC_DAPM_PGA("DRC1L", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1L_ENA_SHIFT, 0,
368 NULL, 0),
369SND_SOC_DAPM_PGA("DRC1R", ARIZONA_DRC1_CTRL1, ARIZONA_DRC1R_ENA_SHIFT, 0,
370 NULL, 0),
Mark Brown93e87912012-06-19 16:38:15 +0100371
372SND_SOC_DAPM_PGA("LHPF1", ARIZONA_HPLPF1_1, ARIZONA_LHPF1_ENA_SHIFT, 0,
373 NULL, 0),
374SND_SOC_DAPM_PGA("LHPF2", ARIZONA_HPLPF2_1, ARIZONA_LHPF2_ENA_SHIFT, 0,
375 NULL, 0),
376SND_SOC_DAPM_PGA("LHPF3", ARIZONA_HPLPF3_1, ARIZONA_LHPF3_ENA_SHIFT, 0,
377 NULL, 0),
378SND_SOC_DAPM_PGA("LHPF4", ARIZONA_HPLPF4_1, ARIZONA_LHPF4_ENA_SHIFT, 0,
379 NULL, 0),
380
381SND_SOC_DAPM_PGA("PWM1 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM1_ENA_SHIFT,
382 0, NULL, 0),
383SND_SOC_DAPM_PGA("PWM2 Driver", ARIZONA_PWM_DRIVE_1, ARIZONA_PWM2_ENA_SHIFT,
384 0, NULL, 0),
385
Mark Brown94988222012-07-04 20:07:03 +0100386SND_SOC_DAPM_PGA("ASRC1L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1L_ENA_SHIFT, 0,
387 NULL, 0),
388SND_SOC_DAPM_PGA("ASRC1R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC1R_ENA_SHIFT, 0,
389 NULL, 0),
390SND_SOC_DAPM_PGA("ASRC2L", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2L_ENA_SHIFT, 0,
391 NULL, 0),
392SND_SOC_DAPM_PGA("ASRC2R", ARIZONA_ASRC_ENABLE, ARIZONA_ASRC2R_ENA_SHIFT, 0,
393 NULL, 0),
394
Mark Brown93e87912012-06-19 16:38:15 +0100395SND_SOC_DAPM_AIF_OUT("AIF1TX1", NULL, 0,
396 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX1_ENA_SHIFT, 0),
397SND_SOC_DAPM_AIF_OUT("AIF1TX2", NULL, 0,
398 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX2_ENA_SHIFT, 0),
399SND_SOC_DAPM_AIF_OUT("AIF1TX3", NULL, 0,
400 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX3_ENA_SHIFT, 0),
401SND_SOC_DAPM_AIF_OUT("AIF1TX4", NULL, 0,
402 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX4_ENA_SHIFT, 0),
403SND_SOC_DAPM_AIF_OUT("AIF1TX5", NULL, 0,
404 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX5_ENA_SHIFT, 0),
405SND_SOC_DAPM_AIF_OUT("AIF1TX6", NULL, 0,
406 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX6_ENA_SHIFT, 0),
407SND_SOC_DAPM_AIF_OUT("AIF1TX7", NULL, 0,
408 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX7_ENA_SHIFT, 0),
409SND_SOC_DAPM_AIF_OUT("AIF1TX8", NULL, 0,
410 ARIZONA_AIF1_TX_ENABLES, ARIZONA_AIF1TX8_ENA_SHIFT, 0),
411
412SND_SOC_DAPM_AIF_IN("AIF1RX1", NULL, 0,
413 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX1_ENA_SHIFT, 0),
414SND_SOC_DAPM_AIF_IN("AIF1RX2", NULL, 0,
415 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX2_ENA_SHIFT, 0),
416SND_SOC_DAPM_AIF_IN("AIF1RX3", NULL, 0,
417 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX3_ENA_SHIFT, 0),
418SND_SOC_DAPM_AIF_IN("AIF1RX4", NULL, 0,
419 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX4_ENA_SHIFT, 0),
420SND_SOC_DAPM_AIF_IN("AIF1RX5", NULL, 0,
421 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX5_ENA_SHIFT, 0),
422SND_SOC_DAPM_AIF_IN("AIF1RX6", NULL, 0,
423 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX6_ENA_SHIFT, 0),
424SND_SOC_DAPM_AIF_IN("AIF1RX7", NULL, 0,
425 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX7_ENA_SHIFT, 0),
426SND_SOC_DAPM_AIF_IN("AIF1RX8", NULL, 0,
427 ARIZONA_AIF1_RX_ENABLES, ARIZONA_AIF1RX8_ENA_SHIFT, 0),
428
429SND_SOC_DAPM_AIF_OUT("AIF2TX1", NULL, 0,
430 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX1_ENA_SHIFT, 0),
431SND_SOC_DAPM_AIF_OUT("AIF2TX2", NULL, 0,
432 ARIZONA_AIF2_TX_ENABLES, ARIZONA_AIF2TX2_ENA_SHIFT, 0),
433
434SND_SOC_DAPM_AIF_IN("AIF2RX1", NULL, 0,
435 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX1_ENA_SHIFT, 0),
436SND_SOC_DAPM_AIF_IN("AIF2RX2", NULL, 0,
437 ARIZONA_AIF2_RX_ENABLES, ARIZONA_AIF2RX2_ENA_SHIFT, 0),
438
439SND_SOC_DAPM_AIF_OUT("AIF3TX1", NULL, 0,
440 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX1_ENA_SHIFT, 0),
441SND_SOC_DAPM_AIF_OUT("AIF3TX2", NULL, 0,
442 ARIZONA_AIF3_TX_ENABLES, ARIZONA_AIF3TX2_ENA_SHIFT, 0),
443
444SND_SOC_DAPM_AIF_IN("AIF3RX1", NULL, 0,
445 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX1_ENA_SHIFT, 0),
446SND_SOC_DAPM_AIF_IN("AIF3RX2", NULL, 0,
447 ARIZONA_AIF3_RX_ENABLES, ARIZONA_AIF3RX2_ENA_SHIFT, 0),
448
Mark Browna3150f02012-08-16 20:28:18 +0100449SND_SOC_DAPM_VALUE_MUX("AEC Loopback", ARIZONA_DAC_AEC_CONTROL_1,
450 ARIZONA_AEC_LOOPBACK_ENA, 0, &wm5102_aec_loopback_mux),
451
Mark Brown93e87912012-06-19 16:38:15 +0100452SND_SOC_DAPM_PGA_E("OUT1L", ARIZONA_OUTPUT_ENABLES_1,
453 ARIZONA_OUT1L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
454 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
455SND_SOC_DAPM_PGA_E("OUT1R", ARIZONA_OUTPUT_ENABLES_1,
456 ARIZONA_OUT1R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
457 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
458SND_SOC_DAPM_PGA_E("OUT2L", ARIZONA_OUTPUT_ENABLES_1,
459 ARIZONA_OUT2L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
460 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
461SND_SOC_DAPM_PGA_E("OUT2R", ARIZONA_OUTPUT_ENABLES_1,
462 ARIZONA_OUT2R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
463 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
464SND_SOC_DAPM_PGA_E("OUT3L", ARIZONA_OUTPUT_ENABLES_1,
465 ARIZONA_OUT3L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
466 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
467SND_SOC_DAPM_PGA_E("OUT4L", ARIZONA_OUTPUT_ENABLES_1,
468 ARIZONA_OUT4L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
469 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
470SND_SOC_DAPM_PGA_E("OUT4R", ARIZONA_OUTPUT_ENABLES_1,
471 ARIZONA_OUT4R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
472 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
473SND_SOC_DAPM_PGA_E("OUT5L", ARIZONA_OUTPUT_ENABLES_1,
474 ARIZONA_OUT5L_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
475 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
476SND_SOC_DAPM_PGA_E("OUT5R", ARIZONA_OUTPUT_ENABLES_1,
477 ARIZONA_OUT5R_ENA_SHIFT, 0, NULL, 0, arizona_out_ev,
478 SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU),
479
480ARIZONA_MIXER_WIDGETS(EQ1, "EQ1"),
481ARIZONA_MIXER_WIDGETS(EQ2, "EQ2"),
482ARIZONA_MIXER_WIDGETS(EQ3, "EQ3"),
483ARIZONA_MIXER_WIDGETS(EQ4, "EQ4"),
484
485ARIZONA_MIXER_WIDGETS(DRC1L, "DRC1L"),
486ARIZONA_MIXER_WIDGETS(DRC1R, "DRC1R"),
Mark Brown93e87912012-06-19 16:38:15 +0100487
488ARIZONA_MIXER_WIDGETS(LHPF1, "LHPF1"),
489ARIZONA_MIXER_WIDGETS(LHPF2, "LHPF2"),
490ARIZONA_MIXER_WIDGETS(LHPF3, "LHPF3"),
491ARIZONA_MIXER_WIDGETS(LHPF4, "LHPF4"),
492
493ARIZONA_MIXER_WIDGETS(Mic, "Mic"),
494ARIZONA_MIXER_WIDGETS(Noise, "Noise"),
495
496ARIZONA_MIXER_WIDGETS(PWM1, "PWM1"),
497ARIZONA_MIXER_WIDGETS(PWM2, "PWM2"),
498
499ARIZONA_MIXER_WIDGETS(OUT1L, "HPOUT1L"),
500ARIZONA_MIXER_WIDGETS(OUT1R, "HPOUT1R"),
501ARIZONA_MIXER_WIDGETS(OUT2L, "HPOUT2L"),
502ARIZONA_MIXER_WIDGETS(OUT2R, "HPOUT2R"),
503ARIZONA_MIXER_WIDGETS(OUT3, "EPOUT"),
504ARIZONA_MIXER_WIDGETS(SPKOUTL, "SPKOUTL"),
505ARIZONA_MIXER_WIDGETS(SPKOUTR, "SPKOUTR"),
506ARIZONA_MIXER_WIDGETS(SPKDAT1L, "SPKDAT1L"),
507ARIZONA_MIXER_WIDGETS(SPKDAT1R, "SPKDAT1R"),
508
509ARIZONA_MIXER_WIDGETS(AIF1TX1, "AIF1TX1"),
510ARIZONA_MIXER_WIDGETS(AIF1TX2, "AIF1TX2"),
511ARIZONA_MIXER_WIDGETS(AIF1TX3, "AIF1TX3"),
512ARIZONA_MIXER_WIDGETS(AIF1TX4, "AIF1TX4"),
513ARIZONA_MIXER_WIDGETS(AIF1TX5, "AIF1TX5"),
514ARIZONA_MIXER_WIDGETS(AIF1TX6, "AIF1TX6"),
515ARIZONA_MIXER_WIDGETS(AIF1TX7, "AIF1TX7"),
516ARIZONA_MIXER_WIDGETS(AIF1TX8, "AIF1TX8"),
517
518ARIZONA_MIXER_WIDGETS(AIF2TX1, "AIF2TX1"),
519ARIZONA_MIXER_WIDGETS(AIF2TX2, "AIF2TX2"),
520
521ARIZONA_MIXER_WIDGETS(AIF3TX1, "AIF3TX1"),
522ARIZONA_MIXER_WIDGETS(AIF3TX2, "AIF3TX2"),
523
Mark Brown94988222012-07-04 20:07:03 +0100524ARIZONA_MIXER_WIDGETS(ASRC1L, "ASRC1L"),
525ARIZONA_MIXER_WIDGETS(ASRC1R, "ASRC1R"),
526ARIZONA_MIXER_WIDGETS(ASRC2L, "ASRC2L"),
527ARIZONA_MIXER_WIDGETS(ASRC2R, "ASRC2R"),
528
Mark Brown93e87912012-06-19 16:38:15 +0100529SND_SOC_DAPM_OUTPUT("HPOUT1L"),
530SND_SOC_DAPM_OUTPUT("HPOUT1R"),
531SND_SOC_DAPM_OUTPUT("HPOUT2L"),
532SND_SOC_DAPM_OUTPUT("HPOUT2R"),
533SND_SOC_DAPM_OUTPUT("EPOUTN"),
534SND_SOC_DAPM_OUTPUT("EPOUTP"),
535SND_SOC_DAPM_OUTPUT("SPKOUTLN"),
536SND_SOC_DAPM_OUTPUT("SPKOUTLP"),
537SND_SOC_DAPM_OUTPUT("SPKOUTRN"),
538SND_SOC_DAPM_OUTPUT("SPKOUTRP"),
539SND_SOC_DAPM_OUTPUT("SPKDAT1L"),
540SND_SOC_DAPM_OUTPUT("SPKDAT1R"),
541};
542
543#define ARIZONA_MIXER_INPUT_ROUTES(name) \
544 { name, "Noise Generator", "Noise Generator" }, \
545 { name, "Tone Generator 1", "Tone Generator 1" }, \
546 { name, "Tone Generator 2", "Tone Generator 2" }, \
Mark Browna3150f02012-08-16 20:28:18 +0100547 { name, "AEC", "AEC Loopback" }, \
Mark Brown93e87912012-06-19 16:38:15 +0100548 { name, "IN1L", "IN1L PGA" }, \
549 { name, "IN1R", "IN1R PGA" }, \
550 { name, "IN2L", "IN2L PGA" }, \
551 { name, "IN2R", "IN2R PGA" }, \
552 { name, "IN3L", "IN3L PGA" }, \
553 { name, "IN3R", "IN3R PGA" }, \
554 { name, "Mic Mute Mixer", "Mic Mute Mixer" }, \
555 { name, "AIF1RX1", "AIF1RX1" }, \
556 { name, "AIF1RX2", "AIF1RX2" }, \
557 { name, "AIF1RX3", "AIF1RX3" }, \
558 { name, "AIF1RX4", "AIF1RX4" }, \
559 { name, "AIF1RX5", "AIF1RX5" }, \
560 { name, "AIF1RX6", "AIF1RX6" }, \
561 { name, "AIF1RX7", "AIF1RX7" }, \
562 { name, "AIF1RX8", "AIF1RX8" }, \
563 { name, "AIF2RX1", "AIF2RX1" }, \
564 { name, "AIF2RX2", "AIF2RX2" }, \
565 { name, "AIF3RX1", "AIF3RX1" }, \
566 { name, "AIF3RX2", "AIF3RX2" }, \
567 { name, "EQ1", "EQ1" }, \
568 { name, "EQ2", "EQ2" }, \
569 { name, "EQ3", "EQ3" }, \
570 { name, "EQ4", "EQ4" }, \
571 { name, "DRC1L", "DRC1L" }, \
572 { name, "DRC1R", "DRC1R" }, \
Mark Brown93e87912012-06-19 16:38:15 +0100573 { name, "LHPF1", "LHPF1" }, \
574 { name, "LHPF2", "LHPF2" }, \
575 { name, "LHPF3", "LHPF3" }, \
Mark Brown94988222012-07-04 20:07:03 +0100576 { name, "LHPF4", "LHPF4" }, \
577 { name, "ASRC1L", "ASRC1L" }, \
578 { name, "ASRC1R", "ASRC1R" }, \
579 { name, "ASRC2L", "ASRC2L" }, \
580 { name, "ASRC2R", "ASRC2R" }
Mark Brown93e87912012-06-19 16:38:15 +0100581
582static const struct snd_soc_dapm_route wm5102_dapm_routes[] = {
583 { "AIF2 Capture", NULL, "DBVDD2" },
584 { "AIF2 Playback", NULL, "DBVDD2" },
585
586 { "AIF3 Capture", NULL, "DBVDD3" },
587 { "AIF3 Playback", NULL, "DBVDD3" },
588
589 { "OUT1L", NULL, "CPVDD" },
590 { "OUT1R", NULL, "CPVDD" },
591 { "OUT2L", NULL, "CPVDD" },
592 { "OUT2R", NULL, "CPVDD" },
593 { "OUT3L", NULL, "CPVDD" },
594
595 { "OUT4L", NULL, "SPKVDDL" },
596 { "OUT4R", NULL, "SPKVDDR" },
597
598 { "OUT1L", NULL, "SYSCLK" },
599 { "OUT1R", NULL, "SYSCLK" },
600 { "OUT2L", NULL, "SYSCLK" },
601 { "OUT2R", NULL, "SYSCLK" },
602 { "OUT3L", NULL, "SYSCLK" },
603 { "OUT4L", NULL, "SYSCLK" },
604 { "OUT4R", NULL, "SYSCLK" },
605 { "OUT5L", NULL, "SYSCLK" },
606 { "OUT5R", NULL, "SYSCLK" },
607
608 { "MICBIAS1", NULL, "MICVDD" },
609 { "MICBIAS2", NULL, "MICVDD" },
610 { "MICBIAS3", NULL, "MICVDD" },
611
612 { "Noise Generator", NULL, "NOISE" },
613 { "Tone Generator 1", NULL, "TONE" },
614 { "Tone Generator 2", NULL, "TONE" },
615
616 { "Mic Mute Mixer", NULL, "Noise Mixer" },
617 { "Mic Mute Mixer", NULL, "Mic Mixer" },
618
619 { "AIF1 Capture", NULL, "AIF1TX1" },
620 { "AIF1 Capture", NULL, "AIF1TX2" },
621 { "AIF1 Capture", NULL, "AIF1TX3" },
622 { "AIF1 Capture", NULL, "AIF1TX4" },
623 { "AIF1 Capture", NULL, "AIF1TX5" },
624 { "AIF1 Capture", NULL, "AIF1TX6" },
625 { "AIF1 Capture", NULL, "AIF1TX7" },
626 { "AIF1 Capture", NULL, "AIF1TX8" },
627
628 { "AIF1RX1", NULL, "AIF1 Playback" },
629 { "AIF1RX2", NULL, "AIF1 Playback" },
630 { "AIF1RX3", NULL, "AIF1 Playback" },
631 { "AIF1RX4", NULL, "AIF1 Playback" },
632 { "AIF1RX5", NULL, "AIF1 Playback" },
633 { "AIF1RX6", NULL, "AIF1 Playback" },
634 { "AIF1RX7", NULL, "AIF1 Playback" },
635 { "AIF1RX8", NULL, "AIF1 Playback" },
636
637 { "AIF2 Capture", NULL, "AIF2TX1" },
638 { "AIF2 Capture", NULL, "AIF2TX2" },
639
640 { "AIF2RX1", NULL, "AIF2 Playback" },
641 { "AIF2RX2", NULL, "AIF2 Playback" },
642
643 { "AIF3 Capture", NULL, "AIF3TX1" },
644 { "AIF3 Capture", NULL, "AIF3TX2" },
645
646 { "AIF3RX1", NULL, "AIF3 Playback" },
647 { "AIF3RX2", NULL, "AIF3 Playback" },
648
649 { "AIF1 Playback", NULL, "SYSCLK" },
650 { "AIF2 Playback", NULL, "SYSCLK" },
651 { "AIF3 Playback", NULL, "SYSCLK" },
652
653 { "AIF1 Capture", NULL, "SYSCLK" },
654 { "AIF2 Capture", NULL, "SYSCLK" },
655 { "AIF3 Capture", NULL, "SYSCLK" },
656
Mark Brown14ebd8a2012-08-10 15:40:12 +0100657 { "IN1L PGA", NULL, "IN1L" },
658 { "IN1R PGA", NULL, "IN1R" },
659
660 { "IN2L PGA", NULL, "IN2L" },
661 { "IN2R PGA", NULL, "IN2R" },
662
663 { "IN3L PGA", NULL, "IN3L" },
664 { "IN3R PGA", NULL, "IN3R" },
665
Mark Brown93e87912012-06-19 16:38:15 +0100666 ARIZONA_MIXER_ROUTES("OUT1L", "HPOUT1L"),
667 ARIZONA_MIXER_ROUTES("OUT1R", "HPOUT1R"),
668 ARIZONA_MIXER_ROUTES("OUT2L", "HPOUT2L"),
669 ARIZONA_MIXER_ROUTES("OUT2R", "HPOUT2R"),
670 ARIZONA_MIXER_ROUTES("OUT3L", "EPOUT"),
671
672 ARIZONA_MIXER_ROUTES("OUT4L", "SPKOUTL"),
673 ARIZONA_MIXER_ROUTES("OUT4R", "SPKOUTR"),
674 ARIZONA_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
675 ARIZONA_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
676
677 ARIZONA_MIXER_ROUTES("PWM1 Driver", "PWM1"),
678 ARIZONA_MIXER_ROUTES("PWM2 Driver", "PWM2"),
679
680 ARIZONA_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
681 ARIZONA_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
682 ARIZONA_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
683 ARIZONA_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
684 ARIZONA_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
685 ARIZONA_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
686 ARIZONA_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
687 ARIZONA_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
688
689 ARIZONA_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
690 ARIZONA_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
691
692 ARIZONA_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
693 ARIZONA_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
694
695 ARIZONA_MIXER_ROUTES("EQ1", "EQ1"),
696 ARIZONA_MIXER_ROUTES("EQ2", "EQ2"),
697 ARIZONA_MIXER_ROUTES("EQ3", "EQ3"),
698 ARIZONA_MIXER_ROUTES("EQ4", "EQ4"),
699
700 ARIZONA_MIXER_ROUTES("DRC1L", "DRC1L"),
701 ARIZONA_MIXER_ROUTES("DRC1R", "DRC1R"),
Mark Brown93e87912012-06-19 16:38:15 +0100702
703 ARIZONA_MIXER_ROUTES("LHPF1", "LHPF1"),
704 ARIZONA_MIXER_ROUTES("LHPF2", "LHPF2"),
705 ARIZONA_MIXER_ROUTES("LHPF3", "LHPF3"),
706 ARIZONA_MIXER_ROUTES("LHPF4", "LHPF4"),
707
Mark Brown94988222012-07-04 20:07:03 +0100708 ARIZONA_MIXER_ROUTES("ASRC1L", "ASRC1L"),
709 ARIZONA_MIXER_ROUTES("ASRC1R", "ASRC1R"),
710 ARIZONA_MIXER_ROUTES("ASRC2L", "ASRC2L"),
711 ARIZONA_MIXER_ROUTES("ASRC2R", "ASRC2R"),
712
Mark Browna3150f02012-08-16 20:28:18 +0100713 { "AEC Loopback", "HPOUT1L", "OUT1L" },
714 { "AEC Loopback", "HPOUT1R", "OUT1R" },
Mark Brown93e87912012-06-19 16:38:15 +0100715 { "HPOUT1L", NULL, "OUT1L" },
716 { "HPOUT1R", NULL, "OUT1R" },
717
Mark Browna3150f02012-08-16 20:28:18 +0100718 { "AEC Loopback", "HPOUT2L", "OUT2L" },
719 { "AEC Loopback", "HPOUT2R", "OUT2R" },
Mark Brown93e87912012-06-19 16:38:15 +0100720 { "HPOUT2L", NULL, "OUT2L" },
721 { "HPOUT2R", NULL, "OUT2R" },
722
Mark Browna3150f02012-08-16 20:28:18 +0100723 { "AEC Loopback", "EPOUT", "OUT3L" },
Mark Brown93e87912012-06-19 16:38:15 +0100724 { "EPOUTN", NULL, "OUT3L" },
725 { "EPOUTP", NULL, "OUT3L" },
726
Mark Browna3150f02012-08-16 20:28:18 +0100727 { "AEC Loopback", "SPKOUTL", "OUT4L" },
Mark Brown93e87912012-06-19 16:38:15 +0100728 { "SPKOUTLN", NULL, "OUT4L" },
729 { "SPKOUTLP", NULL, "OUT4L" },
730
Mark Browna3150f02012-08-16 20:28:18 +0100731 { "AEC Loopback", "SPKOUTR", "OUT4R" },
Mark Brown93e87912012-06-19 16:38:15 +0100732 { "SPKOUTRN", NULL, "OUT4R" },
733 { "SPKOUTRP", NULL, "OUT4R" },
734
Mark Browna3150f02012-08-16 20:28:18 +0100735 { "AEC Loopback", "SPKDAT1L", "OUT5L" },
736 { "AEC Loopback", "SPKDAT1R", "OUT5R" },
Mark Brown93e87912012-06-19 16:38:15 +0100737 { "SPKDAT1L", NULL, "OUT5L" },
738 { "SPKDAT1R", NULL, "OUT5R" },
739};
740
741static int wm5102_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
742 unsigned int Fref, unsigned int Fout)
743{
744 struct wm5102_priv *wm5102 = snd_soc_codec_get_drvdata(codec);
745
746 switch (fll_id) {
747 case WM5102_FLL1:
748 return arizona_set_fll(&wm5102->fll[0], source, Fref, Fout);
749 case WM5102_FLL2:
750 return arizona_set_fll(&wm5102->fll[1], source, Fref, Fout);
751 default:
752 return -EINVAL;
753 }
754}
755
756#define WM5102_RATES SNDRV_PCM_RATE_8000_192000
757
758#define WM5102_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
759 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
760
761static struct snd_soc_dai_driver wm5102_dai[] = {
762 {
763 .name = "wm5102-aif1",
764 .id = 1,
765 .base = ARIZONA_AIF1_BCLK_CTRL,
766 .playback = {
767 .stream_name = "AIF1 Playback",
768 .channels_min = 1,
769 .channels_max = 8,
770 .rates = WM5102_RATES,
771 .formats = WM5102_FORMATS,
772 },
773 .capture = {
774 .stream_name = "AIF1 Capture",
775 .channels_min = 1,
776 .channels_max = 8,
777 .rates = WM5102_RATES,
778 .formats = WM5102_FORMATS,
779 },
780 .ops = &arizona_dai_ops,
781 .symmetric_rates = 1,
782 },
783 {
784 .name = "wm5102-aif2",
785 .id = 2,
786 .base = ARIZONA_AIF2_BCLK_CTRL,
787 .playback = {
788 .stream_name = "AIF2 Playback",
789 .channels_min = 1,
790 .channels_max = 2,
791 .rates = WM5102_RATES,
792 .formats = WM5102_FORMATS,
793 },
794 .capture = {
795 .stream_name = "AIF2 Capture",
796 .channels_min = 1,
797 .channels_max = 2,
798 .rates = WM5102_RATES,
799 .formats = WM5102_FORMATS,
800 },
801 .ops = &arizona_dai_ops,
802 .symmetric_rates = 1,
803 },
804 {
805 .name = "wm5102-aif3",
806 .id = 3,
807 .base = ARIZONA_AIF3_BCLK_CTRL,
808 .playback = {
809 .stream_name = "AIF3 Playback",
810 .channels_min = 1,
811 .channels_max = 2,
812 .rates = WM5102_RATES,
813 .formats = WM5102_FORMATS,
814 },
815 .capture = {
816 .stream_name = "AIF3 Capture",
817 .channels_min = 1,
818 .channels_max = 2,
819 .rates = WM5102_RATES,
820 .formats = WM5102_FORMATS,
821 },
822 .ops = &arizona_dai_ops,
823 .symmetric_rates = 1,
824 },
825};
826
827static int wm5102_codec_probe(struct snd_soc_codec *codec)
828{
829 struct wm5102_priv *priv = snd_soc_codec_get_drvdata(codec);
830
831 codec->control_data = priv->core.arizona->regmap;
832 return snd_soc_codec_set_cache_io(codec, 32, 16, SND_SOC_REGMAP);
833}
834
835#define WM5102_DIG_VU 0x0200
836
837static unsigned int wm5102_digital_vu[] = {
838 ARIZONA_ADC_DIGITAL_VOLUME_1L,
839 ARIZONA_ADC_DIGITAL_VOLUME_1R,
840 ARIZONA_ADC_DIGITAL_VOLUME_2L,
841 ARIZONA_ADC_DIGITAL_VOLUME_2R,
842 ARIZONA_ADC_DIGITAL_VOLUME_3L,
843 ARIZONA_ADC_DIGITAL_VOLUME_3R,
844
845 ARIZONA_DAC_DIGITAL_VOLUME_1L,
846 ARIZONA_DAC_DIGITAL_VOLUME_1R,
847 ARIZONA_DAC_DIGITAL_VOLUME_2L,
848 ARIZONA_DAC_DIGITAL_VOLUME_2R,
849 ARIZONA_DAC_DIGITAL_VOLUME_3L,
850 ARIZONA_DAC_DIGITAL_VOLUME_3R,
851 ARIZONA_DAC_DIGITAL_VOLUME_4L,
852 ARIZONA_DAC_DIGITAL_VOLUME_4R,
853 ARIZONA_DAC_DIGITAL_VOLUME_5L,
854 ARIZONA_DAC_DIGITAL_VOLUME_5R,
855};
856
857static struct snd_soc_codec_driver soc_codec_dev_wm5102 = {
858 .probe = wm5102_codec_probe,
859
860 .idle_bias_off = true,
861
862 .set_sysclk = arizona_set_sysclk,
863 .set_pll = wm5102_set_fll,
864
865 .controls = wm5102_snd_controls,
866 .num_controls = ARRAY_SIZE(wm5102_snd_controls),
867 .dapm_widgets = wm5102_dapm_widgets,
868 .num_dapm_widgets = ARRAY_SIZE(wm5102_dapm_widgets),
869 .dapm_routes = wm5102_dapm_routes,
870 .num_dapm_routes = ARRAY_SIZE(wm5102_dapm_routes),
871};
872
873static int __devinit wm5102_probe(struct platform_device *pdev)
874{
875 struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
876 struct wm5102_priv *wm5102;
877 int i;
878
879 wm5102 = devm_kzalloc(&pdev->dev, sizeof(struct wm5102_priv),
880 GFP_KERNEL);
881 if (wm5102 == NULL)
882 return -ENOMEM;
883 platform_set_drvdata(pdev, wm5102);
884
885 wm5102->core.arizona = arizona;
886
Mark Brown2b4d39f2012-07-10 17:03:46 +0100887 for (i = 0; i < ARRAY_SIZE(wm5102->fll); i++)
888 wm5102->fll[i].vco_mult = 1;
889
Mark Brown93e87912012-06-19 16:38:15 +0100890 arizona_init_fll(arizona, 1, ARIZONA_FLL1_CONTROL_1 - 1,
891 ARIZONA_IRQ_FLL1_LOCK, ARIZONA_IRQ_FLL1_CLOCK_OK,
892 &wm5102->fll[0]);
893 arizona_init_fll(arizona, 2, ARIZONA_FLL2_CONTROL_1 - 1,
894 ARIZONA_IRQ_FLL2_LOCK, ARIZONA_IRQ_FLL2_CLOCK_OK,
895 &wm5102->fll[1]);
896
Mark Brown5b2eec32012-07-04 17:32:05 +0100897 for (i = 0; i < ARRAY_SIZE(wm5102_dai); i++)
898 arizona_init_dai(&wm5102->core, i);
899
Mark Brown93e87912012-06-19 16:38:15 +0100900 /* Latch volume update bits */
901 for (i = 0; i < ARRAY_SIZE(wm5102_digital_vu); i++)
902 regmap_update_bits(arizona->regmap, wm5102_digital_vu[i],
903 WM5102_DIG_VU, WM5102_DIG_VU);
904
905 pm_runtime_enable(&pdev->dev);
906 pm_runtime_idle(&pdev->dev);
907
908 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm5102,
909 wm5102_dai, ARRAY_SIZE(wm5102_dai));
910}
911
912static int __devexit wm5102_remove(struct platform_device *pdev)
913{
914 snd_soc_unregister_codec(&pdev->dev);
915 pm_runtime_disable(&pdev->dev);
916
917 return 0;
918}
919
920static struct platform_driver wm5102_codec_driver = {
921 .driver = {
922 .name = "wm5102-codec",
923 .owner = THIS_MODULE,
924 },
925 .probe = wm5102_probe,
926 .remove = __devexit_p(wm5102_remove),
927};
928
929module_platform_driver(wm5102_codec_driver);
930
931MODULE_DESCRIPTION("ASoC WM5102 driver");
932MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
933MODULE_LICENSE("GPL");
934MODULE_ALIAS("platform:wm5102-codec");