2 * wm8990.c -- WM8990 ALSA Soc Audio driver
4 * Copyright 2008 Wolfson Microelectronics PLC.
5 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
13 #include <linux/module.h>
14 #include <linux/moduleparam.h>
15 #include <linux/kernel.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
19 #include <linux/i2c.h>
20 #include <linux/platform_device.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/soc-dapm.h>
26 #include <sound/initval.h>
27 #include <sound/tlv.h>
28 #include <asm/div64.h>
32 #define WM8990_VERSION "0.2"
34 /* codec private data */
41 * wm8990 register cache. Note that register 0 is not included in the
44 static const u16 wm8990_reg
[] = {
45 0x8990, /* R0 - Reset */
46 0x0000, /* R1 - Power Management (1) */
47 0x6000, /* R2 - Power Management (2) */
48 0x0000, /* R3 - Power Management (3) */
49 0x4050, /* R4 - Audio Interface (1) */
50 0x4000, /* R5 - Audio Interface (2) */
51 0x01C8, /* R6 - Clocking (1) */
52 0x0000, /* R7 - Clocking (2) */
53 0x0040, /* R8 - Audio Interface (3) */
54 0x0040, /* R9 - Audio Interface (4) */
55 0x0004, /* R10 - DAC CTRL */
56 0x00C0, /* R11 - Left DAC Digital Volume */
57 0x00C0, /* R12 - Right DAC Digital Volume */
58 0x0000, /* R13 - Digital Side Tone */
59 0x0100, /* R14 - ADC CTRL */
60 0x00C0, /* R15 - Left ADC Digital Volume */
61 0x00C0, /* R16 - Right ADC Digital Volume */
63 0x0000, /* R18 - GPIO CTRL 1 */
64 0x1000, /* R19 - GPIO1 & GPIO2 */
65 0x1010, /* R20 - GPIO3 & GPIO4 */
66 0x1010, /* R21 - GPIO5 & GPIO6 */
67 0x8000, /* R22 - GPIOCTRL 2 */
68 0x0800, /* R23 - GPIO_POL */
69 0x008B, /* R24 - Left Line Input 1&2 Volume */
70 0x008B, /* R25 - Left Line Input 3&4 Volume */
71 0x008B, /* R26 - Right Line Input 1&2 Volume */
72 0x008B, /* R27 - Right Line Input 3&4 Volume */
73 0x0000, /* R28 - Left Output Volume */
74 0x0000, /* R29 - Right Output Volume */
75 0x0066, /* R30 - Line Outputs Volume */
76 0x0022, /* R31 - Out3/4 Volume */
77 0x0079, /* R32 - Left OPGA Volume */
78 0x0079, /* R33 - Right OPGA Volume */
79 0x0003, /* R34 - Speaker Volume */
80 0x0003, /* R35 - ClassD1 */
82 0x0100, /* R37 - ClassD3 */
83 0x0079, /* R38 - ClassD4 */
84 0x0000, /* R39 - Input Mixer1 */
85 0x0000, /* R40 - Input Mixer2 */
86 0x0000, /* R41 - Input Mixer3 */
87 0x0000, /* R42 - Input Mixer4 */
88 0x0000, /* R43 - Input Mixer5 */
89 0x0000, /* R44 - Input Mixer6 */
90 0x0000, /* R45 - Output Mixer1 */
91 0x0000, /* R46 - Output Mixer2 */
92 0x0000, /* R47 - Output Mixer3 */
93 0x0000, /* R48 - Output Mixer4 */
94 0x0000, /* R49 - Output Mixer5 */
95 0x0000, /* R50 - Output Mixer6 */
96 0x0180, /* R51 - Out3/4 Mixer */
97 0x0000, /* R52 - Line Mixer1 */
98 0x0000, /* R53 - Line Mixer2 */
99 0x0000, /* R54 - Speaker Mixer */
100 0x0000, /* R55 - Additional Control */
101 0x0000, /* R56 - AntiPOP1 */
102 0x0000, /* R57 - AntiPOP2 */
103 0x0000, /* R58 - MICBIAS */
105 0x0008, /* R60 - PLL1 */
106 0x0031, /* R61 - PLL2 */
107 0x0026, /* R62 - PLL3 */
108 0x0000, /* R63 - Driver internal */
111 #define wm8990_reset(c) snd_soc_write(c, WM8990_RESET, 0)
113 static const DECLARE_TLV_DB_LINEAR(rec_mix_tlv
, -1500, 600);
115 static const DECLARE_TLV_DB_LINEAR(in_pga_tlv
, -1650, 3000);
117 static const DECLARE_TLV_DB_LINEAR(out_mix_tlv
, 0, -2100);
119 static const DECLARE_TLV_DB_LINEAR(out_pga_tlv
, -7300, 600);
121 static const DECLARE_TLV_DB_LINEAR(out_omix_tlv
, -600, 0);
123 static const DECLARE_TLV_DB_LINEAR(out_dac_tlv
, -7163, 0);
125 static const DECLARE_TLV_DB_LINEAR(in_adc_tlv
, -7163, 1763);
127 static const DECLARE_TLV_DB_LINEAR(out_sidetone_tlv
, -3600, 0);
129 static int wm899x_outpga_put_volsw_vu(struct snd_kcontrol
*kcontrol
,
130 struct snd_ctl_elem_value
*ucontrol
)
132 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
133 struct soc_mixer_control
*mc
=
134 (struct soc_mixer_control
*)kcontrol
->private_value
;
139 ret
= snd_soc_put_volsw(kcontrol
, ucontrol
);
143 /* now hit the volume update bits (always bit 8) */
144 val
= snd_soc_read(codec
, reg
);
145 return snd_soc_write(codec
, reg
, val
| 0x0100);
148 #define SOC_WM899X_OUTPGA_SINGLE_R_TLV(xname, reg, shift, max, invert,\
150 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
151 .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
152 SNDRV_CTL_ELEM_ACCESS_READWRITE,\
153 .tlv.p = (tlv_array), \
154 .info = snd_soc_info_volsw, \
155 .get = snd_soc_get_volsw, .put = wm899x_outpga_put_volsw_vu, \
156 .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
159 static const char *wm8990_digital_sidetone
[] =
160 {"None", "Left ADC", "Right ADC", "Reserved"};
162 static const struct soc_enum wm8990_left_digital_sidetone_enum
=
163 SOC_ENUM_SINGLE(WM8990_DIGITAL_SIDE_TONE
,
164 WM8990_ADC_TO_DACL_SHIFT
,
165 WM8990_ADC_TO_DACL_MASK
,
166 wm8990_digital_sidetone
);
168 static const struct soc_enum wm8990_right_digital_sidetone_enum
=
169 SOC_ENUM_SINGLE(WM8990_DIGITAL_SIDE_TONE
,
170 WM8990_ADC_TO_DACR_SHIFT
,
171 WM8990_ADC_TO_DACR_MASK
,
172 wm8990_digital_sidetone
);
174 static const char *wm8990_adcmode
[] =
175 {"Hi-fi mode", "Voice mode 1", "Voice mode 2", "Voice mode 3"};
177 static const struct soc_enum wm8990_right_adcmode_enum
=
178 SOC_ENUM_SINGLE(WM8990_ADC_CTRL
,
179 WM8990_ADC_HPF_CUT_SHIFT
,
180 WM8990_ADC_HPF_CUT_MASK
,
183 static const struct snd_kcontrol_new wm8990_snd_controls
[] = {
185 SOC_SINGLE("LIN12 PGA Boost", WM8990_INPUT_MIXER3
, WM8990_L12MNBST_BIT
, 1, 0),
186 SOC_SINGLE("LIN34 PGA Boost", WM8990_INPUT_MIXER3
, WM8990_L34MNBST_BIT
, 1, 0),
188 SOC_SINGLE("RIN12 PGA Boost", WM8990_INPUT_MIXER3
, WM8990_R12MNBST_BIT
, 1, 0),
189 SOC_SINGLE("RIN34 PGA Boost", WM8990_INPUT_MIXER3
, WM8990_R34MNBST_BIT
, 1, 0),
192 SOC_SINGLE_TLV("LOMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER3
,
193 WM8990_LLI3LOVOL_SHIFT
, WM8990_LLI3LOVOL_MASK
, 1, out_mix_tlv
),
194 SOC_SINGLE_TLV("LOMIX RIN12 PGA Bypass Volume", WM8990_OUTPUT_MIXER3
,
195 WM8990_LR12LOVOL_SHIFT
, WM8990_LR12LOVOL_MASK
, 1, out_mix_tlv
),
196 SOC_SINGLE_TLV("LOMIX LIN12 PGA Bypass Volume", WM8990_OUTPUT_MIXER3
,
197 WM8990_LL12LOVOL_SHIFT
, WM8990_LL12LOVOL_MASK
, 1, out_mix_tlv
),
198 SOC_SINGLE_TLV("LOMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER5
,
199 WM8990_LRI3LOVOL_SHIFT
, WM8990_LRI3LOVOL_MASK
, 1, out_mix_tlv
),
200 SOC_SINGLE_TLV("LOMIX AINRMUX Bypass Volume", WM8990_OUTPUT_MIXER5
,
201 WM8990_LRBLOVOL_SHIFT
, WM8990_LRBLOVOL_MASK
, 1, out_mix_tlv
),
202 SOC_SINGLE_TLV("LOMIX AINLMUX Bypass Volume", WM8990_OUTPUT_MIXER5
,
203 WM8990_LRBLOVOL_SHIFT
, WM8990_LRBLOVOL_MASK
, 1, out_mix_tlv
),
206 SOC_SINGLE_TLV("ROMIX RIN3 Bypass Volume", WM8990_OUTPUT_MIXER4
,
207 WM8990_RRI3ROVOL_SHIFT
, WM8990_RRI3ROVOL_MASK
, 1, out_mix_tlv
),
208 SOC_SINGLE_TLV("ROMIX LIN12 PGA Bypass Volume", WM8990_OUTPUT_MIXER4
,
209 WM8990_RL12ROVOL_SHIFT
, WM8990_RL12ROVOL_MASK
, 1, out_mix_tlv
),
210 SOC_SINGLE_TLV("ROMIX RIN12 PGA Bypass Volume", WM8990_OUTPUT_MIXER4
,
211 WM8990_RR12ROVOL_SHIFT
, WM8990_RR12ROVOL_MASK
, 1, out_mix_tlv
),
212 SOC_SINGLE_TLV("ROMIX LIN3 Bypass Volume", WM8990_OUTPUT_MIXER6
,
213 WM8990_RLI3ROVOL_SHIFT
, WM8990_RLI3ROVOL_MASK
, 1, out_mix_tlv
),
214 SOC_SINGLE_TLV("ROMIX AINLMUX Bypass Volume", WM8990_OUTPUT_MIXER6
,
215 WM8990_RLBROVOL_SHIFT
, WM8990_RLBROVOL_MASK
, 1, out_mix_tlv
),
216 SOC_SINGLE_TLV("ROMIX AINRMUX Bypass Volume", WM8990_OUTPUT_MIXER6
,
217 WM8990_RRBROVOL_SHIFT
, WM8990_RRBROVOL_MASK
, 1, out_mix_tlv
),
220 SOC_WM899X_OUTPGA_SINGLE_R_TLV("LOUT Volume", WM8990_LEFT_OUTPUT_VOLUME
,
221 WM8990_LOUTVOL_SHIFT
, WM8990_LOUTVOL_MASK
, 0, out_pga_tlv
),
222 SOC_SINGLE("LOUT ZC", WM8990_LEFT_OUTPUT_VOLUME
, WM8990_LOZC_BIT
, 1, 0),
225 SOC_WM899X_OUTPGA_SINGLE_R_TLV("ROUT Volume", WM8990_RIGHT_OUTPUT_VOLUME
,
226 WM8990_ROUTVOL_SHIFT
, WM8990_ROUTVOL_MASK
, 0, out_pga_tlv
),
227 SOC_SINGLE("ROUT ZC", WM8990_RIGHT_OUTPUT_VOLUME
, WM8990_ROZC_BIT
, 1, 0),
230 SOC_WM899X_OUTPGA_SINGLE_R_TLV("LOPGA Volume", WM8990_LEFT_OPGA_VOLUME
,
231 WM8990_LOPGAVOL_SHIFT
, WM8990_LOPGAVOL_MASK
, 0, out_pga_tlv
),
232 SOC_SINGLE("LOPGA ZC Switch", WM8990_LEFT_OPGA_VOLUME
,
233 WM8990_LOPGAZC_BIT
, 1, 0),
236 SOC_WM899X_OUTPGA_SINGLE_R_TLV("ROPGA Volume", WM8990_RIGHT_OPGA_VOLUME
,
237 WM8990_ROPGAVOL_SHIFT
, WM8990_ROPGAVOL_MASK
, 0, out_pga_tlv
),
238 SOC_SINGLE("ROPGA ZC Switch", WM8990_RIGHT_OPGA_VOLUME
,
239 WM8990_ROPGAZC_BIT
, 1, 0),
241 SOC_SINGLE("LON Mute Switch", WM8990_LINE_OUTPUTS_VOLUME
,
242 WM8990_LONMUTE_BIT
, 1, 0),
243 SOC_SINGLE("LOP Mute Switch", WM8990_LINE_OUTPUTS_VOLUME
,
244 WM8990_LOPMUTE_BIT
, 1, 0),
245 SOC_SINGLE("LOP Attenuation Switch", WM8990_LINE_OUTPUTS_VOLUME
,
246 WM8990_LOATTN_BIT
, 1, 0),
247 SOC_SINGLE("RON Mute Switch", WM8990_LINE_OUTPUTS_VOLUME
,
248 WM8990_RONMUTE_BIT
, 1, 0),
249 SOC_SINGLE("ROP Mute Switch", WM8990_LINE_OUTPUTS_VOLUME
,
250 WM8990_ROPMUTE_BIT
, 1, 0),
251 SOC_SINGLE("ROP Attenuation Switch", WM8990_LINE_OUTPUTS_VOLUME
,
252 WM8990_ROATTN_BIT
, 1, 0),
254 SOC_SINGLE("OUT3 Mute Switch", WM8990_OUT3_4_VOLUME
,
255 WM8990_OUT3MUTE_BIT
, 1, 0),
256 SOC_SINGLE("OUT3 Attenuation Switch", WM8990_OUT3_4_VOLUME
,
257 WM8990_OUT3ATTN_BIT
, 1, 0),
259 SOC_SINGLE("OUT4 Mute Switch", WM8990_OUT3_4_VOLUME
,
260 WM8990_OUT4MUTE_BIT
, 1, 0),
261 SOC_SINGLE("OUT4 Attenuation Switch", WM8990_OUT3_4_VOLUME
,
262 WM8990_OUT4ATTN_BIT
, 1, 0),
264 SOC_SINGLE("Speaker Mode Switch", WM8990_CLASSD1
,
265 WM8990_CDMODE_BIT
, 1, 0),
267 SOC_SINGLE("Speaker Output Attenuation Volume", WM8990_SPEAKER_VOLUME
,
268 WM8990_SPKATTN_SHIFT
, WM8990_SPKATTN_MASK
, 0),
269 SOC_SINGLE("Speaker DC Boost Volume", WM8990_CLASSD3
,
270 WM8990_DCGAIN_SHIFT
, WM8990_DCGAIN_MASK
, 0),
271 SOC_SINGLE("Speaker AC Boost Volume", WM8990_CLASSD3
,
272 WM8990_ACGAIN_SHIFT
, WM8990_ACGAIN_MASK
, 0),
273 SOC_SINGLE_TLV("Speaker Volume", WM8990_CLASSD4
,
274 WM8990_SPKVOL_SHIFT
, WM8990_SPKVOL_MASK
, 0, out_pga_tlv
),
275 SOC_SINGLE("Speaker ZC Switch", WM8990_CLASSD4
,
276 WM8990_SPKZC_SHIFT
, WM8990_SPKZC_MASK
, 0),
278 SOC_WM899X_OUTPGA_SINGLE_R_TLV("Left DAC Digital Volume",
279 WM8990_LEFT_DAC_DIGITAL_VOLUME
,
280 WM8990_DACL_VOL_SHIFT
,
281 WM8990_DACL_VOL_MASK
,
285 SOC_WM899X_OUTPGA_SINGLE_R_TLV("Right DAC Digital Volume",
286 WM8990_RIGHT_DAC_DIGITAL_VOLUME
,
287 WM8990_DACR_VOL_SHIFT
,
288 WM8990_DACR_VOL_MASK
,
292 SOC_ENUM("Left Digital Sidetone", wm8990_left_digital_sidetone_enum
),
293 SOC_ENUM("Right Digital Sidetone", wm8990_right_digital_sidetone_enum
),
295 SOC_SINGLE_TLV("Left Digital Sidetone Volume", WM8990_DIGITAL_SIDE_TONE
,
296 WM8990_ADCL_DAC_SVOL_SHIFT
, WM8990_ADCL_DAC_SVOL_MASK
, 0,
298 SOC_SINGLE_TLV("Right Digital Sidetone Volume", WM8990_DIGITAL_SIDE_TONE
,
299 WM8990_ADCR_DAC_SVOL_SHIFT
, WM8990_ADCR_DAC_SVOL_MASK
, 0,
302 SOC_SINGLE("ADC Digital High Pass Filter Switch", WM8990_ADC_CTRL
,
303 WM8990_ADC_HPF_ENA_BIT
, 1, 0),
305 SOC_ENUM("ADC HPF Mode", wm8990_right_adcmode_enum
),
307 SOC_WM899X_OUTPGA_SINGLE_R_TLV("Left ADC Digital Volume",
308 WM8990_LEFT_ADC_DIGITAL_VOLUME
,
309 WM8990_ADCL_VOL_SHIFT
,
310 WM8990_ADCL_VOL_MASK
,
314 SOC_WM899X_OUTPGA_SINGLE_R_TLV("Right ADC Digital Volume",
315 WM8990_RIGHT_ADC_DIGITAL_VOLUME
,
316 WM8990_ADCR_VOL_SHIFT
,
317 WM8990_ADCR_VOL_MASK
,
321 SOC_WM899X_OUTPGA_SINGLE_R_TLV("LIN12 Volume",
322 WM8990_LEFT_LINE_INPUT_1_2_VOLUME
,
323 WM8990_LIN12VOL_SHIFT
,
324 WM8990_LIN12VOL_MASK
,
328 SOC_SINGLE("LIN12 ZC Switch", WM8990_LEFT_LINE_INPUT_1_2_VOLUME
,
329 WM8990_LI12ZC_BIT
, 1, 0),
331 SOC_SINGLE("LIN12 Mute Switch", WM8990_LEFT_LINE_INPUT_1_2_VOLUME
,
332 WM8990_LI12MUTE_BIT
, 1, 0),
334 SOC_WM899X_OUTPGA_SINGLE_R_TLV("LIN34 Volume",
335 WM8990_LEFT_LINE_INPUT_3_4_VOLUME
,
336 WM8990_LIN34VOL_SHIFT
,
337 WM8990_LIN34VOL_MASK
,
341 SOC_SINGLE("LIN34 ZC Switch", WM8990_LEFT_LINE_INPUT_3_4_VOLUME
,
342 WM8990_LI34ZC_BIT
, 1, 0),
344 SOC_SINGLE("LIN34 Mute Switch", WM8990_LEFT_LINE_INPUT_3_4_VOLUME
,
345 WM8990_LI34MUTE_BIT
, 1, 0),
347 SOC_WM899X_OUTPGA_SINGLE_R_TLV("RIN12 Volume",
348 WM8990_RIGHT_LINE_INPUT_1_2_VOLUME
,
349 WM8990_RIN12VOL_SHIFT
,
350 WM8990_RIN12VOL_MASK
,
354 SOC_SINGLE("RIN12 ZC Switch", WM8990_RIGHT_LINE_INPUT_1_2_VOLUME
,
355 WM8990_RI12ZC_BIT
, 1, 0),
357 SOC_SINGLE("RIN12 Mute Switch", WM8990_RIGHT_LINE_INPUT_1_2_VOLUME
,
358 WM8990_RI12MUTE_BIT
, 1, 0),
360 SOC_WM899X_OUTPGA_SINGLE_R_TLV("RIN34 Volume",
361 WM8990_RIGHT_LINE_INPUT_3_4_VOLUME
,
362 WM8990_RIN34VOL_SHIFT
,
363 WM8990_RIN34VOL_MASK
,
367 SOC_SINGLE("RIN34 ZC Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME
,
368 WM8990_RI34ZC_BIT
, 1, 0),
370 SOC_SINGLE("RIN34 Mute Switch", WM8990_RIGHT_LINE_INPUT_3_4_VOLUME
,
371 WM8990_RI34MUTE_BIT
, 1, 0),
379 static int inmixer_event(struct snd_soc_dapm_widget
*w
,
380 struct snd_kcontrol
*kcontrol
, int event
)
384 reg
= snd_soc_read(w
->codec
, WM8990_POWER_MANAGEMENT_2
);
385 fakepower
= snd_soc_read(w
->codec
, WM8990_INTDRIVBITS
);
387 if (fakepower
& ((1 << WM8990_INMIXL_PWR_BIT
) |
388 (1 << WM8990_AINLMUX_PWR_BIT
))) {
389 reg
|= WM8990_AINL_ENA
;
391 reg
&= ~WM8990_AINL_ENA
;
394 if (fakepower
& ((1 << WM8990_INMIXR_PWR_BIT
) |
395 (1 << WM8990_AINRMUX_PWR_BIT
))) {
396 reg
|= WM8990_AINR_ENA
;
398 reg
&= ~WM8990_AINL_ENA
;
400 snd_soc_write(w
->codec
, WM8990_POWER_MANAGEMENT_2
, reg
);
405 static int outmixer_event(struct snd_soc_dapm_widget
*w
,
406 struct snd_kcontrol
*kcontrol
, int event
)
408 u32 reg_shift
= kcontrol
->private_value
& 0xfff;
413 case WM8990_SPEAKER_MIXER
| (WM8990_LDSPK_BIT
<< 8) :
414 reg
= snd_soc_read(w
->codec
, WM8990_OUTPUT_MIXER1
);
415 if (reg
& WM8990_LDLO
) {
417 "Cannot set as Output Mixer 1 LDLO Set\n");
421 case WM8990_SPEAKER_MIXER
| (WM8990_RDSPK_BIT
<< 8):
422 reg
= snd_soc_read(w
->codec
, WM8990_OUTPUT_MIXER2
);
423 if (reg
& WM8990_RDRO
) {
425 "Cannot set as Output Mixer 2 RDRO Set\n");
429 case WM8990_OUTPUT_MIXER1
| (WM8990_LDLO_BIT
<< 8):
430 reg
= snd_soc_read(w
->codec
, WM8990_SPEAKER_MIXER
);
431 if (reg
& WM8990_LDSPK
) {
433 "Cannot set as Speaker Mixer LDSPK Set\n");
437 case WM8990_OUTPUT_MIXER2
| (WM8990_RDRO_BIT
<< 8):
438 reg
= snd_soc_read(w
->codec
, WM8990_SPEAKER_MIXER
);
439 if (reg
& WM8990_RDSPK
) {
441 "Cannot set as Speaker Mixer RDSPK Set\n");
450 /* INMIX dB values */
451 static const unsigned int in_mix_tlv
[] = {
452 TLV_DB_RANGE_HEAD(1),
453 0, 7, TLV_DB_LINEAR_ITEM(-1200, 600),
456 /* Left In PGA Connections */
457 static const struct snd_kcontrol_new wm8990_dapm_lin12_pga_controls
[] = {
458 SOC_DAPM_SINGLE("LIN1 Switch", WM8990_INPUT_MIXER2
, WM8990_LMN1_BIT
, 1, 0),
459 SOC_DAPM_SINGLE("LIN2 Switch", WM8990_INPUT_MIXER2
, WM8990_LMP2_BIT
, 1, 0),
462 static const struct snd_kcontrol_new wm8990_dapm_lin34_pga_controls
[] = {
463 SOC_DAPM_SINGLE("LIN3 Switch", WM8990_INPUT_MIXER2
, WM8990_LMN3_BIT
, 1, 0),
464 SOC_DAPM_SINGLE("LIN4 Switch", WM8990_INPUT_MIXER2
, WM8990_LMP4_BIT
, 1, 0),
467 /* Right In PGA Connections */
468 static const struct snd_kcontrol_new wm8990_dapm_rin12_pga_controls
[] = {
469 SOC_DAPM_SINGLE("RIN1 Switch", WM8990_INPUT_MIXER2
, WM8990_RMN1_BIT
, 1, 0),
470 SOC_DAPM_SINGLE("RIN2 Switch", WM8990_INPUT_MIXER2
, WM8990_RMP2_BIT
, 1, 0),
473 static const struct snd_kcontrol_new wm8990_dapm_rin34_pga_controls
[] = {
474 SOC_DAPM_SINGLE("RIN3 Switch", WM8990_INPUT_MIXER2
, WM8990_RMN3_BIT
, 1, 0),
475 SOC_DAPM_SINGLE("RIN4 Switch", WM8990_INPUT_MIXER2
, WM8990_RMP4_BIT
, 1, 0),
479 static const struct snd_kcontrol_new wm8990_dapm_inmixl_controls
[] = {
480 SOC_DAPM_SINGLE_TLV("Record Left Volume", WM8990_INPUT_MIXER3
,
481 WM8990_LDBVOL_SHIFT
, WM8990_LDBVOL_MASK
, 0, in_mix_tlv
),
482 SOC_DAPM_SINGLE_TLV("LIN2 Volume", WM8990_INPUT_MIXER5
, WM8990_LI2BVOL_SHIFT
,
484 SOC_DAPM_SINGLE("LINPGA12 Switch", WM8990_INPUT_MIXER3
, WM8990_L12MNB_BIT
,
486 SOC_DAPM_SINGLE("LINPGA34 Switch", WM8990_INPUT_MIXER3
, WM8990_L34MNB_BIT
,
491 static const struct snd_kcontrol_new wm8990_dapm_inmixr_controls
[] = {
492 SOC_DAPM_SINGLE_TLV("Record Right Volume", WM8990_INPUT_MIXER4
,
493 WM8990_RDBVOL_SHIFT
, WM8990_RDBVOL_MASK
, 0, in_mix_tlv
),
494 SOC_DAPM_SINGLE_TLV("RIN2 Volume", WM8990_INPUT_MIXER6
, WM8990_RI2BVOL_SHIFT
,
496 SOC_DAPM_SINGLE("RINPGA12 Switch", WM8990_INPUT_MIXER3
, WM8990_L12MNB_BIT
,
498 SOC_DAPM_SINGLE("RINPGA34 Switch", WM8990_INPUT_MIXER3
, WM8990_L34MNB_BIT
,
503 static const char *wm8990_ainlmux
[] =
504 {"INMIXL Mix", "RXVOICE Mix", "DIFFINL Mix"};
506 static const struct soc_enum wm8990_ainlmux_enum
=
507 SOC_ENUM_SINGLE(WM8990_INPUT_MIXER1
, WM8990_AINLMODE_SHIFT
,
508 ARRAY_SIZE(wm8990_ainlmux
), wm8990_ainlmux
);
510 static const struct snd_kcontrol_new wm8990_dapm_ainlmux_controls
=
511 SOC_DAPM_ENUM("Route", wm8990_ainlmux_enum
);
516 static const char *wm8990_ainrmux
[] =
517 {"INMIXR Mix", "RXVOICE Mix", "DIFFINR Mix"};
519 static const struct soc_enum wm8990_ainrmux_enum
=
520 SOC_ENUM_SINGLE(WM8990_INPUT_MIXER1
, WM8990_AINRMODE_SHIFT
,
521 ARRAY_SIZE(wm8990_ainrmux
), wm8990_ainrmux
);
523 static const struct snd_kcontrol_new wm8990_dapm_ainrmux_controls
=
524 SOC_DAPM_ENUM("Route", wm8990_ainrmux_enum
);
527 static const struct snd_kcontrol_new wm8990_dapm_rxvoice_controls
[] = {
528 SOC_DAPM_SINGLE_TLV("LIN4/RXN", WM8990_INPUT_MIXER5
, WM8990_LR4BVOL_SHIFT
,
529 WM8990_LR4BVOL_MASK
, 0, in_mix_tlv
),
530 SOC_DAPM_SINGLE_TLV("RIN4/RXP", WM8990_INPUT_MIXER6
, WM8990_RL4BVOL_SHIFT
,
531 WM8990_RL4BVOL_MASK
, 0, in_mix_tlv
),
535 static const struct snd_kcontrol_new wm8990_dapm_lomix_controls
[] = {
536 SOC_DAPM_SINGLE("LOMIX Right ADC Bypass Switch", WM8990_OUTPUT_MIXER1
,
537 WM8990_LRBLO_BIT
, 1, 0),
538 SOC_DAPM_SINGLE("LOMIX Left ADC Bypass Switch", WM8990_OUTPUT_MIXER1
,
539 WM8990_LLBLO_BIT
, 1, 0),
540 SOC_DAPM_SINGLE("LOMIX RIN3 Bypass Switch", WM8990_OUTPUT_MIXER1
,
541 WM8990_LRI3LO_BIT
, 1, 0),
542 SOC_DAPM_SINGLE("LOMIX LIN3 Bypass Switch", WM8990_OUTPUT_MIXER1
,
543 WM8990_LLI3LO_BIT
, 1, 0),
544 SOC_DAPM_SINGLE("LOMIX RIN12 PGA Bypass Switch", WM8990_OUTPUT_MIXER1
,
545 WM8990_LR12LO_BIT
, 1, 0),
546 SOC_DAPM_SINGLE("LOMIX LIN12 PGA Bypass Switch", WM8990_OUTPUT_MIXER1
,
547 WM8990_LL12LO_BIT
, 1, 0),
548 SOC_DAPM_SINGLE("LOMIX Left DAC Switch", WM8990_OUTPUT_MIXER1
,
549 WM8990_LDLO_BIT
, 1, 0),
553 static const struct snd_kcontrol_new wm8990_dapm_romix_controls
[] = {
554 SOC_DAPM_SINGLE("ROMIX Left ADC Bypass Switch", WM8990_OUTPUT_MIXER2
,
555 WM8990_RLBRO_BIT
, 1, 0),
556 SOC_DAPM_SINGLE("ROMIX Right ADC Bypass Switch", WM8990_OUTPUT_MIXER2
,
557 WM8990_RRBRO_BIT
, 1, 0),
558 SOC_DAPM_SINGLE("ROMIX LIN3 Bypass Switch", WM8990_OUTPUT_MIXER2
,
559 WM8990_RLI3RO_BIT
, 1, 0),
560 SOC_DAPM_SINGLE("ROMIX RIN3 Bypass Switch", WM8990_OUTPUT_MIXER2
,
561 WM8990_RRI3RO_BIT
, 1, 0),
562 SOC_DAPM_SINGLE("ROMIX LIN12 PGA Bypass Switch", WM8990_OUTPUT_MIXER2
,
563 WM8990_RL12RO_BIT
, 1, 0),
564 SOC_DAPM_SINGLE("ROMIX RIN12 PGA Bypass Switch", WM8990_OUTPUT_MIXER2
,
565 WM8990_RR12RO_BIT
, 1, 0),
566 SOC_DAPM_SINGLE("ROMIX Right DAC Switch", WM8990_OUTPUT_MIXER2
,
567 WM8990_RDRO_BIT
, 1, 0),
571 static const struct snd_kcontrol_new wm8990_dapm_lonmix_controls
[] = {
572 SOC_DAPM_SINGLE("LONMIX Left Mixer PGA Switch", WM8990_LINE_MIXER1
,
573 WM8990_LLOPGALON_BIT
, 1, 0),
574 SOC_DAPM_SINGLE("LONMIX Right Mixer PGA Switch", WM8990_LINE_MIXER1
,
575 WM8990_LROPGALON_BIT
, 1, 0),
576 SOC_DAPM_SINGLE("LONMIX Inverted LOP Switch", WM8990_LINE_MIXER1
,
577 WM8990_LOPLON_BIT
, 1, 0),
581 static const struct snd_kcontrol_new wm8990_dapm_lopmix_controls
[] = {
582 SOC_DAPM_SINGLE("LOPMIX Right Mic Bypass Switch", WM8990_LINE_MIXER1
,
583 WM8990_LR12LOP_BIT
, 1, 0),
584 SOC_DAPM_SINGLE("LOPMIX Left Mic Bypass Switch", WM8990_LINE_MIXER1
,
585 WM8990_LL12LOP_BIT
, 1, 0),
586 SOC_DAPM_SINGLE("LOPMIX Left Mixer PGA Switch", WM8990_LINE_MIXER1
,
587 WM8990_LLOPGALOP_BIT
, 1, 0),
591 static const struct snd_kcontrol_new wm8990_dapm_ronmix_controls
[] = {
592 SOC_DAPM_SINGLE("RONMIX Right Mixer PGA Switch", WM8990_LINE_MIXER2
,
593 WM8990_RROPGARON_BIT
, 1, 0),
594 SOC_DAPM_SINGLE("RONMIX Left Mixer PGA Switch", WM8990_LINE_MIXER2
,
595 WM8990_RLOPGARON_BIT
, 1, 0),
596 SOC_DAPM_SINGLE("RONMIX Inverted ROP Switch", WM8990_LINE_MIXER2
,
597 WM8990_ROPRON_BIT
, 1, 0),
601 static const struct snd_kcontrol_new wm8990_dapm_ropmix_controls
[] = {
602 SOC_DAPM_SINGLE("ROPMIX Left Mic Bypass Switch", WM8990_LINE_MIXER2
,
603 WM8990_RL12ROP_BIT
, 1, 0),
604 SOC_DAPM_SINGLE("ROPMIX Right Mic Bypass Switch", WM8990_LINE_MIXER2
,
605 WM8990_RR12ROP_BIT
, 1, 0),
606 SOC_DAPM_SINGLE("ROPMIX Right Mixer PGA Switch", WM8990_LINE_MIXER2
,
607 WM8990_RROPGAROP_BIT
, 1, 0),
611 static const struct snd_kcontrol_new wm8990_dapm_out3mix_controls
[] = {
612 SOC_DAPM_SINGLE("OUT3MIX LIN4/RXP Bypass Switch", WM8990_OUT3_4_MIXER
,
613 WM8990_LI4O3_BIT
, 1, 0),
614 SOC_DAPM_SINGLE("OUT3MIX Left Out PGA Switch", WM8990_OUT3_4_MIXER
,
615 WM8990_LPGAO3_BIT
, 1, 0),
619 static const struct snd_kcontrol_new wm8990_dapm_out4mix_controls
[] = {
620 SOC_DAPM_SINGLE("OUT4MIX Right Out PGA Switch", WM8990_OUT3_4_MIXER
,
621 WM8990_RPGAO4_BIT
, 1, 0),
622 SOC_DAPM_SINGLE("OUT4MIX RIN4/RXP Bypass Switch", WM8990_OUT3_4_MIXER
,
623 WM8990_RI4O4_BIT
, 1, 0),
627 static const struct snd_kcontrol_new wm8990_dapm_spkmix_controls
[] = {
628 SOC_DAPM_SINGLE("SPKMIX LIN2 Bypass Switch", WM8990_SPEAKER_MIXER
,
629 WM8990_LI2SPK_BIT
, 1, 0),
630 SOC_DAPM_SINGLE("SPKMIX LADC Bypass Switch", WM8990_SPEAKER_MIXER
,
631 WM8990_LB2SPK_BIT
, 1, 0),
632 SOC_DAPM_SINGLE("SPKMIX Left Mixer PGA Switch", WM8990_SPEAKER_MIXER
,
633 WM8990_LOPGASPK_BIT
, 1, 0),
634 SOC_DAPM_SINGLE("SPKMIX Left DAC Switch", WM8990_SPEAKER_MIXER
,
635 WM8990_LDSPK_BIT
, 1, 0),
636 SOC_DAPM_SINGLE("SPKMIX Right DAC Switch", WM8990_SPEAKER_MIXER
,
637 WM8990_RDSPK_BIT
, 1, 0),
638 SOC_DAPM_SINGLE("SPKMIX Right Mixer PGA Switch", WM8990_SPEAKER_MIXER
,
639 WM8990_ROPGASPK_BIT
, 1, 0),
640 SOC_DAPM_SINGLE("SPKMIX RADC Bypass Switch", WM8990_SPEAKER_MIXER
,
641 WM8990_RL12ROP_BIT
, 1, 0),
642 SOC_DAPM_SINGLE("SPKMIX RIN2 Bypass Switch", WM8990_SPEAKER_MIXER
,
643 WM8990_RI2SPK_BIT
, 1, 0),
646 static const struct snd_soc_dapm_widget wm8990_dapm_widgets
[] = {
649 SND_SOC_DAPM_INPUT("LIN1"),
650 SND_SOC_DAPM_INPUT("LIN2"),
651 SND_SOC_DAPM_INPUT("LIN3"),
652 SND_SOC_DAPM_INPUT("LIN4/RXN"),
653 SND_SOC_DAPM_INPUT("RIN3"),
654 SND_SOC_DAPM_INPUT("RIN4/RXP"),
655 SND_SOC_DAPM_INPUT("RIN1"),
656 SND_SOC_DAPM_INPUT("RIN2"),
657 SND_SOC_DAPM_INPUT("Internal ADC Source"),
660 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8990_POWER_MANAGEMENT_2
,
661 WM8990_ADCL_ENA_BIT
, 0),
662 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8990_POWER_MANAGEMENT_2
,
663 WM8990_ADCR_ENA_BIT
, 0),
666 SND_SOC_DAPM_MIXER("LIN12 PGA", WM8990_POWER_MANAGEMENT_2
, WM8990_LIN12_ENA_BIT
,
667 0, &wm8990_dapm_lin12_pga_controls
[0],
668 ARRAY_SIZE(wm8990_dapm_lin12_pga_controls
)),
669 SND_SOC_DAPM_MIXER("LIN34 PGA", WM8990_POWER_MANAGEMENT_2
, WM8990_LIN34_ENA_BIT
,
670 0, &wm8990_dapm_lin34_pga_controls
[0],
671 ARRAY_SIZE(wm8990_dapm_lin34_pga_controls
)),
672 SND_SOC_DAPM_MIXER("RIN12 PGA", WM8990_POWER_MANAGEMENT_2
, WM8990_RIN12_ENA_BIT
,
673 0, &wm8990_dapm_rin12_pga_controls
[0],
674 ARRAY_SIZE(wm8990_dapm_rin12_pga_controls
)),
675 SND_SOC_DAPM_MIXER("RIN34 PGA", WM8990_POWER_MANAGEMENT_2
, WM8990_RIN34_ENA_BIT
,
676 0, &wm8990_dapm_rin34_pga_controls
[0],
677 ARRAY_SIZE(wm8990_dapm_rin34_pga_controls
)),
680 SND_SOC_DAPM_MIXER_E("INMIXL", WM8990_INTDRIVBITS
, WM8990_INMIXL_PWR_BIT
, 0,
681 &wm8990_dapm_inmixl_controls
[0],
682 ARRAY_SIZE(wm8990_dapm_inmixl_controls
),
683 inmixer_event
, SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
686 SND_SOC_DAPM_MUX_E("AINLMUX", WM8990_INTDRIVBITS
, WM8990_AINLMUX_PWR_BIT
, 0,
687 &wm8990_dapm_ainlmux_controls
, inmixer_event
,
688 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
691 SND_SOC_DAPM_MIXER_E("INMIXR", WM8990_INTDRIVBITS
, WM8990_INMIXR_PWR_BIT
, 0,
692 &wm8990_dapm_inmixr_controls
[0],
693 ARRAY_SIZE(wm8990_dapm_inmixr_controls
),
694 inmixer_event
, SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
697 SND_SOC_DAPM_MUX_E("AINRMUX", WM8990_INTDRIVBITS
, WM8990_AINRMUX_PWR_BIT
, 0,
698 &wm8990_dapm_ainrmux_controls
, inmixer_event
,
699 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_POST_PMD
),
703 SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8990_POWER_MANAGEMENT_3
,
704 WM8990_DACL_ENA_BIT
, 0),
705 SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8990_POWER_MANAGEMENT_3
,
706 WM8990_DACR_ENA_BIT
, 0),
709 SND_SOC_DAPM_MIXER_E("LOMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_LOMIX_ENA_BIT
,
710 0, &wm8990_dapm_lomix_controls
[0],
711 ARRAY_SIZE(wm8990_dapm_lomix_controls
),
712 outmixer_event
, SND_SOC_DAPM_PRE_REG
),
715 SND_SOC_DAPM_MIXER("LONMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_LON_ENA_BIT
, 0,
716 &wm8990_dapm_lonmix_controls
[0],
717 ARRAY_SIZE(wm8990_dapm_lonmix_controls
)),
720 SND_SOC_DAPM_MIXER("LOPMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_LOP_ENA_BIT
, 0,
721 &wm8990_dapm_lopmix_controls
[0],
722 ARRAY_SIZE(wm8990_dapm_lopmix_controls
)),
725 SND_SOC_DAPM_MIXER("OUT3MIX", WM8990_POWER_MANAGEMENT_1
, WM8990_OUT3_ENA_BIT
, 0,
726 &wm8990_dapm_out3mix_controls
[0],
727 ARRAY_SIZE(wm8990_dapm_out3mix_controls
)),
730 SND_SOC_DAPM_MIXER_E("SPKMIX", WM8990_POWER_MANAGEMENT_1
, WM8990_SPK_ENA_BIT
, 0,
731 &wm8990_dapm_spkmix_controls
[0],
732 ARRAY_SIZE(wm8990_dapm_spkmix_controls
), outmixer_event
,
733 SND_SOC_DAPM_PRE_REG
),
736 SND_SOC_DAPM_MIXER("OUT4MIX", WM8990_POWER_MANAGEMENT_1
, WM8990_OUT4_ENA_BIT
, 0,
737 &wm8990_dapm_out4mix_controls
[0],
738 ARRAY_SIZE(wm8990_dapm_out4mix_controls
)),
741 SND_SOC_DAPM_MIXER("ROPMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_ROP_ENA_BIT
, 0,
742 &wm8990_dapm_ropmix_controls
[0],
743 ARRAY_SIZE(wm8990_dapm_ropmix_controls
)),
746 SND_SOC_DAPM_MIXER("RONMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_RON_ENA_BIT
, 0,
747 &wm8990_dapm_ronmix_controls
[0],
748 ARRAY_SIZE(wm8990_dapm_ronmix_controls
)),
751 SND_SOC_DAPM_MIXER_E("ROMIX", WM8990_POWER_MANAGEMENT_3
, WM8990_ROMIX_ENA_BIT
,
752 0, &wm8990_dapm_romix_controls
[0],
753 ARRAY_SIZE(wm8990_dapm_romix_controls
),
754 outmixer_event
, SND_SOC_DAPM_PRE_REG
),
757 SND_SOC_DAPM_PGA("LOUT PGA", WM8990_POWER_MANAGEMENT_1
, WM8990_LOUT_ENA_BIT
, 0,
761 SND_SOC_DAPM_PGA("ROUT PGA", WM8990_POWER_MANAGEMENT_1
, WM8990_ROUT_ENA_BIT
, 0,
765 SND_SOC_DAPM_PGA("LOPGA", WM8990_POWER_MANAGEMENT_3
, WM8990_LOPGA_ENA_BIT
, 0,
769 SND_SOC_DAPM_PGA("ROPGA", WM8990_POWER_MANAGEMENT_3
, WM8990_ROPGA_ENA_BIT
, 0,
773 SND_SOC_DAPM_MICBIAS("MICBIAS", WM8990_POWER_MANAGEMENT_1
,
774 WM8990_MICBIAS_ENA_BIT
, 0),
776 SND_SOC_DAPM_OUTPUT("LON"),
777 SND_SOC_DAPM_OUTPUT("LOP"),
778 SND_SOC_DAPM_OUTPUT("OUT3"),
779 SND_SOC_DAPM_OUTPUT("LOUT"),
780 SND_SOC_DAPM_OUTPUT("SPKN"),
781 SND_SOC_DAPM_OUTPUT("SPKP"),
782 SND_SOC_DAPM_OUTPUT("ROUT"),
783 SND_SOC_DAPM_OUTPUT("OUT4"),
784 SND_SOC_DAPM_OUTPUT("ROP"),
785 SND_SOC_DAPM_OUTPUT("RON"),
787 SND_SOC_DAPM_OUTPUT("Internal DAC Sink"),
790 static const struct snd_soc_dapm_route audio_map
[] = {
791 /* Make DACs turn on when playing even if not mixed into any outputs */
792 {"Internal DAC Sink", NULL
, "Left DAC"},
793 {"Internal DAC Sink", NULL
, "Right DAC"},
795 /* Make ADCs turn on when recording even if not mixed from any inputs */
796 {"Left ADC", NULL
, "Internal ADC Source"},
797 {"Right ADC", NULL
, "Internal ADC Source"},
801 {"LIN12 PGA", "LIN1 Switch", "LIN1"},
802 {"LIN12 PGA", "LIN2 Switch", "LIN2"},
804 {"LIN34 PGA", "LIN3 Switch", "LIN3"},
805 {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"},
807 {"INMIXL", "Record Left Volume", "LOMIX"},
808 {"INMIXL", "LIN2 Volume", "LIN2"},
809 {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"},
810 {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"},
812 {"AINLMUX", "INMIXL Mix", "INMIXL"},
813 {"AINLMUX", "DIFFINL Mix", "LIN12 PGA"},
814 {"AINLMUX", "DIFFINL Mix", "LIN34 PGA"},
815 {"AINLMUX", "RXVOICE Mix", "LIN4/RXN"},
816 {"AINLMUX", "RXVOICE Mix", "RIN4/RXP"},
818 {"Left ADC", NULL
, "AINLMUX"},
821 {"RIN12 PGA", "RIN1 Switch", "RIN1"},
822 {"RIN12 PGA", "RIN2 Switch", "RIN2"},
824 {"RIN34 PGA", "RIN3 Switch", "RIN3"},
825 {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"},
827 {"INMIXR", "Record Right Volume", "ROMIX"},
828 {"INMIXR", "RIN2 Volume", "RIN2"},
829 {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"},
830 {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"},
832 {"AINRMUX", "INMIXR Mix", "INMIXR"},
833 {"AINRMUX", "DIFFINR Mix", "RIN12 PGA"},
834 {"AINRMUX", "DIFFINR Mix", "RIN34 PGA"},
835 {"AINRMUX", "RXVOICE Mix", "LIN4/RXN"},
836 {"AINRMUX", "RXVOICE Mix", "RIN4/RXP"},
838 {"Right ADC", NULL
, "AINRMUX"},
841 {"LOMIX", "LOMIX RIN3 Bypass Switch", "RIN3"},
842 {"LOMIX", "LOMIX LIN3 Bypass Switch", "LIN3"},
843 {"LOMIX", "LOMIX LIN12 PGA Bypass Switch", "LIN12 PGA"},
844 {"LOMIX", "LOMIX RIN12 PGA Bypass Switch", "RIN12 PGA"},
845 {"LOMIX", "LOMIX Right ADC Bypass Switch", "AINRMUX"},
846 {"LOMIX", "LOMIX Left ADC Bypass Switch", "AINLMUX"},
847 {"LOMIX", "LOMIX Left DAC Switch", "Left DAC"},
850 {"ROMIX", "ROMIX RIN3 Bypass Switch", "RIN3"},
851 {"ROMIX", "ROMIX LIN3 Bypass Switch", "LIN3"},
852 {"ROMIX", "ROMIX LIN12 PGA Bypass Switch", "LIN12 PGA"},
853 {"ROMIX", "ROMIX RIN12 PGA Bypass Switch", "RIN12 PGA"},
854 {"ROMIX", "ROMIX Right ADC Bypass Switch", "AINRMUX"},
855 {"ROMIX", "ROMIX Left ADC Bypass Switch", "AINLMUX"},
856 {"ROMIX", "ROMIX Right DAC Switch", "Right DAC"},
859 {"SPKMIX", "SPKMIX LIN2 Bypass Switch", "LIN2"},
860 {"SPKMIX", "SPKMIX RIN2 Bypass Switch", "RIN2"},
861 {"SPKMIX", "SPKMIX LADC Bypass Switch", "AINLMUX"},
862 {"SPKMIX", "SPKMIX RADC Bypass Switch", "AINRMUX"},
863 {"SPKMIX", "SPKMIX Left Mixer PGA Switch", "LOPGA"},
864 {"SPKMIX", "SPKMIX Right Mixer PGA Switch", "ROPGA"},
865 {"SPKMIX", "SPKMIX Right DAC Switch", "Right DAC"},
866 {"SPKMIX", "SPKMIX Left DAC Switch", "Left DAC"},
869 {"LONMIX", "LONMIX Left Mixer PGA Switch", "LOPGA"},
870 {"LONMIX", "LONMIX Right Mixer PGA Switch", "ROPGA"},
871 {"LONMIX", "LONMIX Inverted LOP Switch", "LOPMIX"},
874 {"LOPMIX", "LOPMIX Right Mic Bypass Switch", "RIN12 PGA"},
875 {"LOPMIX", "LOPMIX Left Mic Bypass Switch", "LIN12 PGA"},
876 {"LOPMIX", "LOPMIX Left Mixer PGA Switch", "LOPGA"},
879 {"OUT3MIX", "OUT3MIX LIN4/RXP Bypass Switch", "LIN4/RXN"},
880 {"OUT3MIX", "OUT3MIX Left Out PGA Switch", "LOPGA"},
883 {"OUT4MIX", "OUT4MIX Right Out PGA Switch", "ROPGA"},
884 {"OUT4MIX", "OUT4MIX RIN4/RXP Bypass Switch", "RIN4/RXP"},
887 {"RONMIX", "RONMIX Right Mixer PGA Switch", "ROPGA"},
888 {"RONMIX", "RONMIX Left Mixer PGA Switch", "LOPGA"},
889 {"RONMIX", "RONMIX Inverted ROP Switch", "ROPMIX"},
892 {"ROPMIX", "ROPMIX Left Mic Bypass Switch", "LIN12 PGA"},
893 {"ROPMIX", "ROPMIX Right Mic Bypass Switch", "RIN12 PGA"},
894 {"ROPMIX", "ROPMIX Right Mixer PGA Switch", "ROPGA"},
897 {"LOPGA", NULL
, "LOMIX"},
898 {"ROPGA", NULL
, "ROMIX"},
900 {"LOUT PGA", NULL
, "LOMIX"},
901 {"ROUT PGA", NULL
, "ROMIX"},
904 {"LON", NULL
, "LONMIX"},
905 {"LOP", NULL
, "LOPMIX"},
906 {"OUT3", NULL
, "OUT3MIX"},
907 {"LOUT", NULL
, "LOUT PGA"},
908 {"SPKN", NULL
, "SPKMIX"},
909 {"ROUT", NULL
, "ROUT PGA"},
910 {"OUT4", NULL
, "OUT4MIX"},
911 {"ROP", NULL
, "ROPMIX"},
912 {"RON", NULL
, "RONMIX"},
915 static int wm8990_add_widgets(struct snd_soc_codec
*codec
)
917 snd_soc_dapm_new_controls(codec
, wm8990_dapm_widgets
,
918 ARRAY_SIZE(wm8990_dapm_widgets
));
920 /* set up the WM8990 audio map */
921 snd_soc_dapm_add_routes(codec
, audio_map
, ARRAY_SIZE(audio_map
));
923 snd_soc_dapm_new_widgets(codec
);
934 /* The size in bits of the pll divide multiplied by 10
935 * to allow rounding later */
936 #define FIXED_PLL_SIZE ((1 << 16) * 10)
938 static void pll_factors(struct _pll_div
*pll_div
, unsigned int target
,
942 unsigned int K
, Ndiv
, Nmod
;
945 Ndiv
= target
/ source
;
949 Ndiv
= target
/ source
;
953 if ((Ndiv
< 6) || (Ndiv
> 12))
955 "WM8990 N value outwith recommended range! N = %u\n", Ndiv
);
958 Nmod
= target
% source
;
959 Kpart
= FIXED_PLL_SIZE
* (long long)Nmod
;
961 do_div(Kpart
, source
);
963 K
= Kpart
& 0xFFFFFFFF;
965 /* Check if we need to round */
969 /* Move down to proper range now rounding is done */
975 static int wm8990_set_dai_pll(struct snd_soc_dai
*codec_dai
,
976 int pll_id
, unsigned int freq_in
, unsigned int freq_out
)
979 struct snd_soc_codec
*codec
= codec_dai
->codec
;
980 struct _pll_div pll_div
;
982 if (freq_in
&& freq_out
) {
983 pll_factors(&pll_div
, freq_out
* 4, freq_in
);
986 reg
= snd_soc_read(codec
, WM8990_POWER_MANAGEMENT_2
);
987 reg
|= WM8990_PLL_ENA
;
988 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_2
, reg
);
990 /* sysclk comes from PLL */
991 reg
= snd_soc_read(codec
, WM8990_CLOCKING_2
);
992 snd_soc_write(codec
, WM8990_CLOCKING_2
, reg
| WM8990_SYSCLK_SRC
);
994 /* set up N , fractional mode and pre-divisor if neccessary */
995 snd_soc_write(codec
, WM8990_PLL1
, pll_div
.n
| WM8990_SDM
|
996 (pll_div
.div2
?WM8990_PRESCALE
:0));
997 snd_soc_write(codec
, WM8990_PLL2
, (u8
)(pll_div
.k
>>8));
998 snd_soc_write(codec
, WM8990_PLL3
, (u8
)(pll_div
.k
& 0xFF));
1001 reg
= snd_soc_read(codec
, WM8990_POWER_MANAGEMENT_2
);
1002 reg
&= ~WM8990_PLL_ENA
;
1003 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_2
, reg
);
1009 * Clock after PLL and dividers
1011 static int wm8990_set_dai_sysclk(struct snd_soc_dai
*codec_dai
,
1012 int clk_id
, unsigned int freq
, int dir
)
1014 struct snd_soc_codec
*codec
= codec_dai
->codec
;
1015 struct wm8990_priv
*wm8990
= codec
->private_data
;
1017 wm8990
->sysclk
= freq
;
1022 * Set's ADC and Voice DAC format.
1024 static int wm8990_set_dai_fmt(struct snd_soc_dai
*codec_dai
,
1027 struct snd_soc_codec
*codec
= codec_dai
->codec
;
1030 audio1
= snd_soc_read(codec
, WM8990_AUDIO_INTERFACE_1
);
1031 audio3
= snd_soc_read(codec
, WM8990_AUDIO_INTERFACE_3
);
1033 /* set master/slave audio interface */
1034 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
1035 case SND_SOC_DAIFMT_CBS_CFS
:
1036 audio3
&= ~WM8990_AIF_MSTR1
;
1038 case SND_SOC_DAIFMT_CBM_CFM
:
1039 audio3
|= WM8990_AIF_MSTR1
;
1045 audio1
&= ~WM8990_AIF_FMT_MASK
;
1047 /* interface format */
1048 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
1049 case SND_SOC_DAIFMT_I2S
:
1050 audio1
|= WM8990_AIF_TMF_I2S
;
1051 audio1
&= ~WM8990_AIF_LRCLK_INV
;
1053 case SND_SOC_DAIFMT_RIGHT_J
:
1054 audio1
|= WM8990_AIF_TMF_RIGHTJ
;
1055 audio1
&= ~WM8990_AIF_LRCLK_INV
;
1057 case SND_SOC_DAIFMT_LEFT_J
:
1058 audio1
|= WM8990_AIF_TMF_LEFTJ
;
1059 audio1
&= ~WM8990_AIF_LRCLK_INV
;
1061 case SND_SOC_DAIFMT_DSP_A
:
1062 audio1
|= WM8990_AIF_TMF_DSP
;
1063 audio1
&= ~WM8990_AIF_LRCLK_INV
;
1065 case SND_SOC_DAIFMT_DSP_B
:
1066 audio1
|= WM8990_AIF_TMF_DSP
| WM8990_AIF_LRCLK_INV
;
1072 snd_soc_write(codec
, WM8990_AUDIO_INTERFACE_1
, audio1
);
1073 snd_soc_write(codec
, WM8990_AUDIO_INTERFACE_3
, audio3
);
1077 static int wm8990_set_dai_clkdiv(struct snd_soc_dai
*codec_dai
,
1078 int div_id
, int div
)
1080 struct snd_soc_codec
*codec
= codec_dai
->codec
;
1084 case WM8990_MCLK_DIV
:
1085 reg
= snd_soc_read(codec
, WM8990_CLOCKING_2
) &
1086 ~WM8990_MCLK_DIV_MASK
;
1087 snd_soc_write(codec
, WM8990_CLOCKING_2
, reg
| div
);
1089 case WM8990_DACCLK_DIV
:
1090 reg
= snd_soc_read(codec
, WM8990_CLOCKING_2
) &
1091 ~WM8990_DAC_CLKDIV_MASK
;
1092 snd_soc_write(codec
, WM8990_CLOCKING_2
, reg
| div
);
1094 case WM8990_ADCCLK_DIV
:
1095 reg
= snd_soc_read(codec
, WM8990_CLOCKING_2
) &
1096 ~WM8990_ADC_CLKDIV_MASK
;
1097 snd_soc_write(codec
, WM8990_CLOCKING_2
, reg
| div
);
1099 case WM8990_BCLK_DIV
:
1100 reg
= snd_soc_read(codec
, WM8990_CLOCKING_1
) &
1101 ~WM8990_BCLK_DIV_MASK
;
1102 snd_soc_write(codec
, WM8990_CLOCKING_1
, reg
| div
);
1112 * Set PCM DAI bit size and sample rate.
1114 static int wm8990_hw_params(struct snd_pcm_substream
*substream
,
1115 struct snd_pcm_hw_params
*params
,
1116 struct snd_soc_dai
*dai
)
1118 struct snd_soc_pcm_runtime
*rtd
= substream
->private_data
;
1119 struct snd_soc_device
*socdev
= rtd
->socdev
;
1120 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1121 u16 audio1
= snd_soc_read(codec
, WM8990_AUDIO_INTERFACE_1
);
1123 audio1
&= ~WM8990_AIF_WL_MASK
;
1125 switch (params_format(params
)) {
1126 case SNDRV_PCM_FORMAT_S16_LE
:
1128 case SNDRV_PCM_FORMAT_S20_3LE
:
1129 audio1
|= WM8990_AIF_WL_20BITS
;
1131 case SNDRV_PCM_FORMAT_S24_LE
:
1132 audio1
|= WM8990_AIF_WL_24BITS
;
1134 case SNDRV_PCM_FORMAT_S32_LE
:
1135 audio1
|= WM8990_AIF_WL_32BITS
;
1139 snd_soc_write(codec
, WM8990_AUDIO_INTERFACE_1
, audio1
);
1143 static int wm8990_mute(struct snd_soc_dai
*dai
, int mute
)
1145 struct snd_soc_codec
*codec
= dai
->codec
;
1148 val
= snd_soc_read(codec
, WM8990_DAC_CTRL
) & ~WM8990_DAC_MUTE
;
1151 snd_soc_write(codec
, WM8990_DAC_CTRL
, val
| WM8990_DAC_MUTE
);
1153 snd_soc_write(codec
, WM8990_DAC_CTRL
, val
);
1158 static int wm8990_set_bias_level(struct snd_soc_codec
*codec
,
1159 enum snd_soc_bias_level level
)
1164 case SND_SOC_BIAS_ON
:
1167 case SND_SOC_BIAS_PREPARE
:
1169 val
= snd_soc_read(codec
, WM8990_POWER_MANAGEMENT_1
) &
1170 ~WM8990_VMID_MODE_MASK
;
1171 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, val
| 0x2);
1174 case SND_SOC_BIAS_STANDBY
:
1175 if (codec
->bias_level
== SND_SOC_BIAS_OFF
) {
1176 /* Enable all output discharge bits */
1177 snd_soc_write(codec
, WM8990_ANTIPOP1
, WM8990_DIS_LLINE
|
1178 WM8990_DIS_RLINE
| WM8990_DIS_OUT3
|
1179 WM8990_DIS_OUT4
| WM8990_DIS_LOUT
|
1182 /* Enable POBCTRL, SOFT_ST, VMIDTOG and BUFDCOPEN */
1183 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_SOFTST
|
1184 WM8990_BUFDCOPEN
| WM8990_POBCTRL
|
1187 /* Delay to allow output caps to discharge */
1188 msleep(msecs_to_jiffies(300));
1190 /* Disable VMIDTOG */
1191 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_SOFTST
|
1192 WM8990_BUFDCOPEN
| WM8990_POBCTRL
);
1194 /* disable all output discharge bits */
1195 snd_soc_write(codec
, WM8990_ANTIPOP1
, 0);
1197 /* Enable outputs */
1198 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x1b00);
1200 msleep(msecs_to_jiffies(50));
1202 /* Enable VMID at 2x50k */
1203 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x1f02);
1205 msleep(msecs_to_jiffies(100));
1208 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x1f03);
1210 msleep(msecs_to_jiffies(600));
1212 /* Enable BUFIOEN */
1213 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_SOFTST
|
1214 WM8990_BUFDCOPEN
| WM8990_POBCTRL
|
1217 /* Disable outputs */
1218 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x3);
1220 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */
1221 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_BUFIOEN
);
1223 /* Enable workaround for ADC clocking issue. */
1224 snd_soc_write(codec
, WM8990_EXT_ACCESS_ENA
, 0x2);
1225 snd_soc_write(codec
, WM8990_EXT_CTL1
, 0xa003);
1226 snd_soc_write(codec
, WM8990_EXT_ACCESS_ENA
, 0);
1230 val
= snd_soc_read(codec
, WM8990_POWER_MANAGEMENT_1
) &
1231 ~WM8990_VMID_MODE_MASK
;
1232 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, val
| 0x4);
1235 case SND_SOC_BIAS_OFF
:
1236 /* Enable POBCTRL and SOFT_ST */
1237 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_SOFTST
|
1238 WM8990_POBCTRL
| WM8990_BUFIOEN
);
1240 /* Enable POBCTRL, SOFT_ST and BUFDCOPEN */
1241 snd_soc_write(codec
, WM8990_ANTIPOP2
, WM8990_SOFTST
|
1242 WM8990_BUFDCOPEN
| WM8990_POBCTRL
|
1246 val
= snd_soc_read(codec
, WM8990_DAC_CTRL
);
1247 snd_soc_write(codec
, WM8990_DAC_CTRL
, val
| WM8990_DAC_MUTE
);
1249 /* Enable any disabled outputs */
1250 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x1f03);
1253 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x1f01);
1255 msleep(msecs_to_jiffies(300));
1257 /* Enable all output discharge bits */
1258 snd_soc_write(codec
, WM8990_ANTIPOP1
, WM8990_DIS_LLINE
|
1259 WM8990_DIS_RLINE
| WM8990_DIS_OUT3
|
1260 WM8990_DIS_OUT4
| WM8990_DIS_LOUT
|
1264 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_1
, 0x0);
1266 /* disable POBCTRL, SOFT_ST and BUFDCOPEN */
1267 snd_soc_write(codec
, WM8990_ANTIPOP2
, 0x0);
1271 codec
->bias_level
= level
;
1275 #define WM8990_RATES (SNDRV_PCM_RATE_8000 | SNDRV_PCM_RATE_11025 |\
1276 SNDRV_PCM_RATE_16000 | SNDRV_PCM_RATE_22050 | SNDRV_PCM_RATE_44100 | \
1277 SNDRV_PCM_RATE_48000)
1279 #define WM8990_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
1280 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1283 * The WM8990 supports 2 different and mutually exclusive DAI
1286 * 1. ADC/DAC on Primary Interface
1287 * 2. ADC on Primary Interface/DAC on secondary
1289 static struct snd_soc_dai_ops wm8990_dai_ops
= {
1290 .hw_params
= wm8990_hw_params
,
1291 .digital_mute
= wm8990_mute
,
1292 .set_fmt
= wm8990_set_dai_fmt
,
1293 .set_clkdiv
= wm8990_set_dai_clkdiv
,
1294 .set_pll
= wm8990_set_dai_pll
,
1295 .set_sysclk
= wm8990_set_dai_sysclk
,
1298 struct snd_soc_dai wm8990_dai
= {
1299 /* ADC/DAC on primary */
1300 .name
= "WM8990 ADC/DAC Primary",
1303 .stream_name
= "Playback",
1306 .rates
= WM8990_RATES
,
1307 .formats
= WM8990_FORMATS
,},
1309 .stream_name
= "Capture",
1312 .rates
= WM8990_RATES
,
1313 .formats
= WM8990_FORMATS
,},
1314 .ops
= &wm8990_dai_ops
,
1316 EXPORT_SYMBOL_GPL(wm8990_dai
);
1318 static int wm8990_suspend(struct platform_device
*pdev
, pm_message_t state
)
1320 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
1321 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1323 /* we only need to suspend if we are a valid card */
1327 wm8990_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
1331 static int wm8990_resume(struct platform_device
*pdev
)
1333 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
1334 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1337 u16
*cache
= codec
->reg_cache
;
1339 /* we only need to resume if we are a valid card */
1343 /* Sync reg_cache with the hardware */
1344 for (i
= 0; i
< ARRAY_SIZE(wm8990_reg
); i
++) {
1345 if (i
+ 1 == WM8990_RESET
)
1347 data
[0] = ((i
+ 1) << 1) | ((cache
[i
] >> 8) & 0x0001);
1348 data
[1] = cache
[i
] & 0x00ff;
1349 codec
->hw_write(codec
->control_data
, data
, 2);
1352 wm8990_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
1357 * initialise the WM8990 driver
1358 * register the mixer and dsp interfaces with the kernel
1360 static int wm8990_init(struct snd_soc_device
*socdev
)
1362 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1366 codec
->name
= "WM8990";
1367 codec
->owner
= THIS_MODULE
;
1368 codec
->set_bias_level
= wm8990_set_bias_level
;
1369 codec
->dai
= &wm8990_dai
;
1371 codec
->reg_cache_size
= ARRAY_SIZE(wm8990_reg
);
1372 codec
->reg_cache
= kmemdup(wm8990_reg
, sizeof(wm8990_reg
), GFP_KERNEL
);
1374 if (codec
->reg_cache
== NULL
)
1377 ret
= snd_soc_codec_set_cache_io(codec
, 8, 16, SND_SOC_I2C
);
1379 printk(KERN_ERR
"wm8990: failed to set cache I/O: %d\n", ret
);
1383 wm8990_reset(codec
);
1386 ret
= snd_soc_new_pcms(socdev
, SNDRV_DEFAULT_IDX1
, SNDRV_DEFAULT_STR1
);
1388 printk(KERN_ERR
"wm8990: failed to create pcms\n");
1392 /* charge output caps */
1393 codec
->bias_level
= SND_SOC_BIAS_OFF
;
1394 wm8990_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
1396 reg
= snd_soc_read(codec
, WM8990_AUDIO_INTERFACE_4
);
1397 snd_soc_write(codec
, WM8990_AUDIO_INTERFACE_4
, reg
| WM8990_ALRCGPIO1
);
1399 reg
= snd_soc_read(codec
, WM8990_GPIO1_GPIO2
) &
1400 ~WM8990_GPIO1_SEL_MASK
;
1401 snd_soc_write(codec
, WM8990_GPIO1_GPIO2
, reg
| 1);
1403 reg
= snd_soc_read(codec
, WM8990_POWER_MANAGEMENT_2
);
1404 snd_soc_write(codec
, WM8990_POWER_MANAGEMENT_2
, reg
| WM8990_OPCLK_ENA
);
1406 snd_soc_write(codec
, WM8990_LEFT_OUTPUT_VOLUME
, 0x50 | (1<<8));
1407 snd_soc_write(codec
, WM8990_RIGHT_OUTPUT_VOLUME
, 0x50 | (1<<8));
1409 snd_soc_add_controls(codec
, wm8990_snd_controls
,
1410 ARRAY_SIZE(wm8990_snd_controls
));
1411 wm8990_add_widgets(codec
);
1412 ret
= snd_soc_init_card(socdev
);
1414 printk(KERN_ERR
"wm8990: failed to register card\n");
1420 snd_soc_free_pcms(socdev
);
1421 snd_soc_dapm_free(socdev
);
1423 kfree(codec
->reg_cache
);
1427 /* If the i2c layer weren't so broken, we could pass this kind of data
1429 static struct snd_soc_device
*wm8990_socdev
;
1431 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1434 * WM891 2 wire address is determined by GPIO5
1435 * state during powerup.
1440 static int wm8990_i2c_probe(struct i2c_client
*i2c
,
1441 const struct i2c_device_id
*id
)
1443 struct snd_soc_device
*socdev
= wm8990_socdev
;
1444 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1447 i2c_set_clientdata(i2c
, codec
);
1448 codec
->control_data
= i2c
;
1450 ret
= wm8990_init(socdev
);
1452 pr_err("failed to initialise WM8990\n");
1457 static int wm8990_i2c_remove(struct i2c_client
*client
)
1459 struct snd_soc_codec
*codec
= i2c_get_clientdata(client
);
1460 kfree(codec
->reg_cache
);
1464 static const struct i2c_device_id wm8990_i2c_id
[] = {
1468 MODULE_DEVICE_TABLE(i2c
, wm8990_i2c_id
);
1470 static struct i2c_driver wm8990_i2c_driver
= {
1472 .name
= "WM8990 I2C Codec",
1473 .owner
= THIS_MODULE
,
1475 .probe
= wm8990_i2c_probe
,
1476 .remove
= wm8990_i2c_remove
,
1477 .id_table
= wm8990_i2c_id
,
1480 static int wm8990_add_i2c_device(struct platform_device
*pdev
,
1481 const struct wm8990_setup_data
*setup
)
1483 struct i2c_board_info info
;
1484 struct i2c_adapter
*adapter
;
1485 struct i2c_client
*client
;
1488 ret
= i2c_add_driver(&wm8990_i2c_driver
);
1490 dev_err(&pdev
->dev
, "can't add i2c driver\n");
1494 memset(&info
, 0, sizeof(struct i2c_board_info
));
1495 info
.addr
= setup
->i2c_address
;
1496 strlcpy(info
.type
, "wm8990", I2C_NAME_SIZE
);
1498 adapter
= i2c_get_adapter(setup
->i2c_bus
);
1500 dev_err(&pdev
->dev
, "can't get i2c adapter %d\n",
1505 client
= i2c_new_device(adapter
, &info
);
1506 i2c_put_adapter(adapter
);
1508 dev_err(&pdev
->dev
, "can't add i2c device at 0x%x\n",
1509 (unsigned int)info
.addr
);
1516 i2c_del_driver(&wm8990_i2c_driver
);
1521 static int wm8990_probe(struct platform_device
*pdev
)
1523 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
1524 struct wm8990_setup_data
*setup
;
1525 struct snd_soc_codec
*codec
;
1526 struct wm8990_priv
*wm8990
;
1529 pr_info("WM8990 Audio Codec %s\n", WM8990_VERSION
);
1531 setup
= socdev
->codec_data
;
1532 codec
= kzalloc(sizeof(struct snd_soc_codec
), GFP_KERNEL
);
1536 wm8990
= kzalloc(sizeof(struct wm8990_priv
), GFP_KERNEL
);
1537 if (wm8990
== NULL
) {
1542 codec
->private_data
= wm8990
;
1543 socdev
->card
->codec
= codec
;
1544 mutex_init(&codec
->mutex
);
1545 INIT_LIST_HEAD(&codec
->dapm_widgets
);
1546 INIT_LIST_HEAD(&codec
->dapm_paths
);
1547 wm8990_socdev
= socdev
;
1551 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1552 if (setup
->i2c_address
) {
1553 codec
->hw_write
= (hw_write_t
)i2c_master_send
;
1554 ret
= wm8990_add_i2c_device(pdev
, setup
);
1559 kfree(codec
->private_data
);
1565 /* power down chip */
1566 static int wm8990_remove(struct platform_device
*pdev
)
1568 struct snd_soc_device
*socdev
= platform_get_drvdata(pdev
);
1569 struct snd_soc_codec
*codec
= socdev
->card
->codec
;
1571 if (codec
->control_data
)
1572 wm8990_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
1573 snd_soc_free_pcms(socdev
);
1574 snd_soc_dapm_free(socdev
);
1575 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1576 i2c_unregister_device(codec
->control_data
);
1577 i2c_del_driver(&wm8990_i2c_driver
);
1579 kfree(codec
->private_data
);
1585 struct snd_soc_codec_device soc_codec_dev_wm8990
= {
1586 .probe
= wm8990_probe
,
1587 .remove
= wm8990_remove
,
1588 .suspend
= wm8990_suspend
,
1589 .resume
= wm8990_resume
,
1591 EXPORT_SYMBOL_GPL(soc_codec_dev_wm8990
);
1593 static int __init
wm8990_modinit(void)
1595 return snd_soc_register_dai(&wm8990_dai
);
1597 module_init(wm8990_modinit
);
1599 static void __exit
wm8990_exit(void)
1601 snd_soc_unregister_dai(&wm8990_dai
);
1603 module_exit(wm8990_exit
);
1605 MODULE_DESCRIPTION("ASoC WM8990 driver");
1606 MODULE_AUTHOR("Liam Girdwood");
1607 MODULE_LICENSE("GPL");