2 * wm8985.c -- WM8985 ALSA SoC Audio driver
4 * Copyright 2010 Wolfson Microelectronics plc
6 * Author: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
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.
13 * o Add OUT3/OUT4 mixer controls.
16 #include <linux/module.h>
17 #include <linux/moduleparam.h>
18 #include <linux/init.h>
19 #include <linux/delay.h>
21 #include <linux/i2c.h>
22 #include <linux/regulator/consumer.h>
23 #include <linux/spi/spi.h>
24 #include <linux/slab.h>
25 #include <sound/core.h>
26 #include <sound/pcm.h>
27 #include <sound/pcm_params.h>
28 #include <sound/soc.h>
29 #include <sound/initval.h>
30 #include <sound/tlv.h>
34 #define WM8985_NUM_SUPPLIES 4
35 static const char *wm8985_supply_names
[WM8985_NUM_SUPPLIES
] = {
42 static const u16 wm8985_reg_defs
[] = {
43 0x0000, /* R0 - Software Reset */
44 0x0000, /* R1 - Power management 1 */
45 0x0000, /* R2 - Power management 2 */
46 0x0000, /* R3 - Power management 3 */
47 0x0050, /* R4 - Audio Interface */
48 0x0000, /* R5 - Companding control */
49 0x0140, /* R6 - Clock Gen control */
50 0x0000, /* R7 - Additional control */
51 0x0000, /* R8 - GPIO Control */
52 0x0000, /* R9 - Jack Detect Control 1 */
53 0x0000, /* R10 - DAC Control */
54 0x00FF, /* R11 - Left DAC digital Vol */
55 0x00FF, /* R12 - Right DAC digital vol */
56 0x0000, /* R13 - Jack Detect Control 2 */
57 0x0100, /* R14 - ADC Control */
58 0x00FF, /* R15 - Left ADC Digital Vol */
59 0x00FF, /* R16 - Right ADC Digital Vol */
61 0x012C, /* R18 - EQ1 - low shelf */
62 0x002C, /* R19 - EQ2 - peak 1 */
63 0x002C, /* R20 - EQ3 - peak 2 */
64 0x002C, /* R21 - EQ4 - peak 3 */
65 0x002C, /* R22 - EQ5 - high shelf */
67 0x0032, /* R24 - DAC Limiter 1 */
68 0x0000, /* R25 - DAC Limiter 2 */
70 0x0000, /* R27 - Notch Filter 1 */
71 0x0000, /* R28 - Notch Filter 2 */
72 0x0000, /* R29 - Notch Filter 3 */
73 0x0000, /* R30 - Notch Filter 4 */
75 0x0038, /* R32 - ALC control 1 */
76 0x000B, /* R33 - ALC control 2 */
77 0x0032, /* R34 - ALC control 3 */
78 0x0000, /* R35 - Noise Gate */
79 0x0008, /* R36 - PLL N */
80 0x000C, /* R37 - PLL K 1 */
81 0x0093, /* R38 - PLL K 2 */
82 0x00E9, /* R39 - PLL K 3 */
84 0x0000, /* R41 - 3D control */
85 0x0000, /* R42 - OUT4 to ADC */
86 0x0000, /* R43 - Beep control */
87 0x0033, /* R44 - Input ctrl */
88 0x0010, /* R45 - Left INP PGA gain ctrl */
89 0x0010, /* R46 - Right INP PGA gain ctrl */
90 0x0100, /* R47 - Left ADC BOOST ctrl */
91 0x0100, /* R48 - Right ADC BOOST ctrl */
92 0x0002, /* R49 - Output ctrl */
93 0x0001, /* R50 - Left mixer ctrl */
94 0x0001, /* R51 - Right mixer ctrl */
95 0x0039, /* R52 - LOUT1 (HP) volume ctrl */
96 0x0039, /* R53 - ROUT1 (HP) volume ctrl */
97 0x0039, /* R54 - LOUT2 (SPK) volume ctrl */
98 0x0039, /* R55 - ROUT2 (SPK) volume ctrl */
99 0x0001, /* R56 - OUT3 mixer ctrl */
100 0x0001, /* R57 - OUT4 (MONO) mix ctrl */
103 0x0004, /* R60 - OUTPUT ctrl */
104 0x0000, /* R61 - BIAS CTRL */
110 * latch bit 8 of these registers to ensure instant
113 static const int volume_update_regs
[] = {
114 WM8985_LEFT_DAC_DIGITAL_VOL
,
115 WM8985_RIGHT_DAC_DIGITAL_VOL
,
116 WM8985_LEFT_ADC_DIGITAL_VOL
,
117 WM8985_RIGHT_ADC_DIGITAL_VOL
,
118 WM8985_LOUT2_SPK_VOLUME_CTRL
,
119 WM8985_ROUT2_SPK_VOLUME_CTRL
,
120 WM8985_LOUT1_HP_VOLUME_CTRL
,
121 WM8985_ROUT1_HP_VOLUME_CTRL
,
122 WM8985_LEFT_INP_PGA_GAIN_CTRL
,
123 WM8985_RIGHT_INP_PGA_GAIN_CTRL
127 enum snd_soc_control_type control_type
;
128 struct regulator_bulk_data supplies
[WM8985_NUM_SUPPLIES
];
133 static const struct {
147 static const int srates
[] = { 48000, 32000, 24000, 16000, 12000, 8000 };
149 static const int bclk_divs
[] = {
153 static int eqmode_get(struct snd_kcontrol
*kcontrol
,
154 struct snd_ctl_elem_value
*ucontrol
);
155 static int eqmode_put(struct snd_kcontrol
*kcontrol
,
156 struct snd_ctl_elem_value
*ucontrol
);
158 static const DECLARE_TLV_DB_SCALE(dac_tlv
, -12700, 50, 1);
159 static const DECLARE_TLV_DB_SCALE(adc_tlv
, -12700, 50, 1);
160 static const DECLARE_TLV_DB_SCALE(out_tlv
, -5700, 100, 0);
161 static const DECLARE_TLV_DB_SCALE(lim_thresh_tlv
, -600, 100, 0);
162 static const DECLARE_TLV_DB_SCALE(lim_boost_tlv
, 0, 100, 0);
163 static const DECLARE_TLV_DB_SCALE(alc_min_tlv
, -1200, 600, 0);
164 static const DECLARE_TLV_DB_SCALE(alc_max_tlv
, -675, 600, 0);
165 static const DECLARE_TLV_DB_SCALE(alc_tar_tlv
, -2250, 150, 0);
166 static const DECLARE_TLV_DB_SCALE(pga_vol_tlv
, -1200, 75, 0);
167 static const DECLARE_TLV_DB_SCALE(boost_tlv
, -1200, 300, 1);
168 static const DECLARE_TLV_DB_SCALE(eq_tlv
, -1200, 100, 0);
169 static const DECLARE_TLV_DB_SCALE(aux_tlv
, -1500, 300, 0);
170 static const DECLARE_TLV_DB_SCALE(bypass_tlv
, -1500, 300, 0);
171 static const DECLARE_TLV_DB_SCALE(pga_boost_tlv
, 0, 2000, 0);
173 static const char *alc_sel_text
[] = { "Off", "Right", "Left", "Stereo" };
174 static const SOC_ENUM_SINGLE_DECL(alc_sel
, WM8985_ALC_CONTROL_1
, 7,
177 static const char *alc_mode_text
[] = { "ALC", "Limiter" };
178 static const SOC_ENUM_SINGLE_DECL(alc_mode
, WM8985_ALC_CONTROL_3
, 8,
181 static const char *filter_mode_text
[] = { "Audio", "Application" };
182 static const SOC_ENUM_SINGLE_DECL(filter_mode
, WM8985_ADC_CONTROL
, 7,
185 static const char *eq_bw_text
[] = { "Narrow", "Wide" };
186 static const char *eqmode_text
[] = { "Capture", "Playback" };
187 static const SOC_ENUM_SINGLE_EXT_DECL(eqmode
, eqmode_text
);
189 static const char *eq1_cutoff_text
[] = {
190 "80Hz", "105Hz", "135Hz", "175Hz"
192 static const SOC_ENUM_SINGLE_DECL(eq1_cutoff
, WM8985_EQ1_LOW_SHELF
, 5,
194 static const char *eq2_cutoff_text
[] = {
195 "230Hz", "300Hz", "385Hz", "500Hz"
197 static const SOC_ENUM_SINGLE_DECL(eq2_bw
, WM8985_EQ2_PEAK_1
, 8, eq_bw_text
);
198 static const SOC_ENUM_SINGLE_DECL(eq2_cutoff
, WM8985_EQ2_PEAK_1
, 5,
200 static const char *eq3_cutoff_text
[] = {
201 "650Hz", "850Hz", "1.1kHz", "1.4kHz"
203 static const SOC_ENUM_SINGLE_DECL(eq3_bw
, WM8985_EQ3_PEAK_2
, 8, eq_bw_text
);
204 static const SOC_ENUM_SINGLE_DECL(eq3_cutoff
, WM8985_EQ3_PEAK_2
, 5,
206 static const char *eq4_cutoff_text
[] = {
207 "1.8kHz", "2.4kHz", "3.2kHz", "4.1kHz"
209 static const SOC_ENUM_SINGLE_DECL(eq4_bw
, WM8985_EQ4_PEAK_3
, 8, eq_bw_text
);
210 static const SOC_ENUM_SINGLE_DECL(eq4_cutoff
, WM8985_EQ4_PEAK_3
, 5,
212 static const char *eq5_cutoff_text
[] = {
213 "5.3kHz", "6.9kHz", "9kHz", "11.7kHz"
215 static const SOC_ENUM_SINGLE_DECL(eq5_cutoff
, WM8985_EQ5_HIGH_SHELF
, 5,
218 static const char *speaker_mode_text
[] = { "Class A/B", "Class D" };
219 static const SOC_ENUM_SINGLE_DECL(speaker_mode
, 0x17, 8, speaker_mode_text
);
221 static const char *depth_3d_text
[] = {
239 static const SOC_ENUM_SINGLE_DECL(depth_3d
, WM8985_3D_CONTROL
, 0,
242 static const struct snd_kcontrol_new wm8985_snd_controls
[] = {
243 SOC_SINGLE("Digital Loopback Switch", WM8985_COMPANDING_CONTROL
,
246 SOC_ENUM("ALC Capture Function", alc_sel
),
247 SOC_SINGLE_TLV("ALC Capture Max Volume", WM8985_ALC_CONTROL_1
,
248 3, 7, 0, alc_max_tlv
),
249 SOC_SINGLE_TLV("ALC Capture Min Volume", WM8985_ALC_CONTROL_1
,
250 0, 7, 0, alc_min_tlv
),
251 SOC_SINGLE_TLV("ALC Capture Target Volume", WM8985_ALC_CONTROL_2
,
252 0, 15, 0, alc_tar_tlv
),
253 SOC_SINGLE("ALC Capture Attack", WM8985_ALC_CONTROL_3
, 0, 10, 0),
254 SOC_SINGLE("ALC Capture Hold", WM8985_ALC_CONTROL_2
, 4, 10, 0),
255 SOC_SINGLE("ALC Capture Decay", WM8985_ALC_CONTROL_3
, 4, 10, 0),
256 SOC_ENUM("ALC Mode", alc_mode
),
257 SOC_SINGLE("ALC Capture NG Switch", WM8985_NOISE_GATE
,
259 SOC_SINGLE("ALC Capture NG Threshold", WM8985_NOISE_GATE
,
262 SOC_DOUBLE_R_TLV("Capture Volume", WM8985_LEFT_ADC_DIGITAL_VOL
,
263 WM8985_RIGHT_ADC_DIGITAL_VOL
, 0, 255, 0, adc_tlv
),
264 SOC_DOUBLE_R("Capture PGA ZC Switch", WM8985_LEFT_INP_PGA_GAIN_CTRL
,
265 WM8985_RIGHT_INP_PGA_GAIN_CTRL
, 7, 1, 0),
266 SOC_DOUBLE_R_TLV("Capture PGA Volume", WM8985_LEFT_INP_PGA_GAIN_CTRL
,
267 WM8985_RIGHT_INP_PGA_GAIN_CTRL
, 0, 63, 0, pga_vol_tlv
),
269 SOC_DOUBLE_R_TLV("Capture PGA Boost Volume",
270 WM8985_LEFT_ADC_BOOST_CTRL
, WM8985_RIGHT_ADC_BOOST_CTRL
,
271 8, 1, 0, pga_boost_tlv
),
273 SOC_DOUBLE("ADC Inversion Switch", WM8985_ADC_CONTROL
, 0, 1, 1, 0),
274 SOC_SINGLE("ADC 128x Oversampling Switch", WM8985_ADC_CONTROL
, 8, 1, 0),
276 SOC_DOUBLE_R_TLV("Playback Volume", WM8985_LEFT_DAC_DIGITAL_VOL
,
277 WM8985_RIGHT_DAC_DIGITAL_VOL
, 0, 255, 0, dac_tlv
),
279 SOC_SINGLE("DAC Playback Limiter Switch", WM8985_DAC_LIMITER_1
, 8, 1, 0),
280 SOC_SINGLE("DAC Playback Limiter Decay", WM8985_DAC_LIMITER_1
, 4, 10, 0),
281 SOC_SINGLE("DAC Playback Limiter Attack", WM8985_DAC_LIMITER_1
, 0, 11, 0),
282 SOC_SINGLE_TLV("DAC Playback Limiter Threshold", WM8985_DAC_LIMITER_2
,
283 4, 7, 1, lim_thresh_tlv
),
284 SOC_SINGLE_TLV("DAC Playback Limiter Boost Volume", WM8985_DAC_LIMITER_2
,
285 0, 12, 0, lim_boost_tlv
),
286 SOC_DOUBLE("DAC Inversion Switch", WM8985_DAC_CONTROL
, 0, 1, 1, 0),
287 SOC_SINGLE("DAC Auto Mute Switch", WM8985_DAC_CONTROL
, 2, 1, 0),
288 SOC_SINGLE("DAC 128x Oversampling Switch", WM8985_DAC_CONTROL
, 3, 1, 0),
290 SOC_DOUBLE_R_TLV("Headphone Playback Volume", WM8985_LOUT1_HP_VOLUME_CTRL
,
291 WM8985_ROUT1_HP_VOLUME_CTRL
, 0, 63, 0, out_tlv
),
292 SOC_DOUBLE_R("Headphone Playback ZC Switch", WM8985_LOUT1_HP_VOLUME_CTRL
,
293 WM8985_ROUT1_HP_VOLUME_CTRL
, 7, 1, 0),
294 SOC_DOUBLE_R("Headphone Switch", WM8985_LOUT1_HP_VOLUME_CTRL
,
295 WM8985_ROUT1_HP_VOLUME_CTRL
, 6, 1, 1),
297 SOC_DOUBLE_R_TLV("Speaker Playback Volume", WM8985_LOUT2_SPK_VOLUME_CTRL
,
298 WM8985_ROUT2_SPK_VOLUME_CTRL
, 0, 63, 0, out_tlv
),
299 SOC_DOUBLE_R("Speaker Playback ZC Switch", WM8985_LOUT2_SPK_VOLUME_CTRL
,
300 WM8985_ROUT2_SPK_VOLUME_CTRL
, 7, 1, 0),
301 SOC_DOUBLE_R("Speaker Switch", WM8985_LOUT2_SPK_VOLUME_CTRL
,
302 WM8985_ROUT2_SPK_VOLUME_CTRL
, 6, 1, 1),
304 SOC_SINGLE("High Pass Filter Switch", WM8985_ADC_CONTROL
, 8, 1, 0),
305 SOC_ENUM("High Pass Filter Mode", filter_mode
),
306 SOC_SINGLE("High Pass Filter Cutoff", WM8985_ADC_CONTROL
, 4, 7, 0),
308 SOC_DOUBLE_R_TLV("Aux Bypass Volume",
309 WM8985_LEFT_MIXER_CTRL
, WM8985_RIGHT_MIXER_CTRL
, 6, 7, 0,
312 SOC_DOUBLE_R_TLV("Input PGA Bypass Volume",
313 WM8985_LEFT_MIXER_CTRL
, WM8985_RIGHT_MIXER_CTRL
, 2, 7, 0,
316 SOC_ENUM_EXT("Equalizer Function", eqmode
, eqmode_get
, eqmode_put
),
317 SOC_ENUM("EQ1 Cutoff", eq1_cutoff
),
318 SOC_SINGLE_TLV("EQ1 Volume", WM8985_EQ1_LOW_SHELF
, 0, 24, 1, eq_tlv
),
319 SOC_ENUM("EQ2 Bandwith", eq2_bw
),
320 SOC_ENUM("EQ2 Cutoff", eq2_cutoff
),
321 SOC_SINGLE_TLV("EQ2 Volume", WM8985_EQ2_PEAK_1
, 0, 24, 1, eq_tlv
),
322 SOC_ENUM("EQ3 Bandwith", eq3_bw
),
323 SOC_ENUM("EQ3 Cutoff", eq3_cutoff
),
324 SOC_SINGLE_TLV("EQ3 Volume", WM8985_EQ3_PEAK_2
, 0, 24, 1, eq_tlv
),
325 SOC_ENUM("EQ4 Bandwith", eq4_bw
),
326 SOC_ENUM("EQ4 Cutoff", eq4_cutoff
),
327 SOC_SINGLE_TLV("EQ4 Volume", WM8985_EQ4_PEAK_3
, 0, 24, 1, eq_tlv
),
328 SOC_ENUM("EQ5 Cutoff", eq5_cutoff
),
329 SOC_SINGLE_TLV("EQ5 Volume", WM8985_EQ5_HIGH_SHELF
, 0, 24, 1, eq_tlv
),
331 SOC_ENUM("3D Depth", depth_3d
),
333 SOC_ENUM("Speaker Mode", speaker_mode
)
336 static const struct snd_kcontrol_new left_out_mixer
[] = {
337 SOC_DAPM_SINGLE("Line Switch", WM8985_LEFT_MIXER_CTRL
, 1, 1, 0),
338 SOC_DAPM_SINGLE("Aux Switch", WM8985_LEFT_MIXER_CTRL
, 5, 1, 0),
339 SOC_DAPM_SINGLE("PCM Switch", WM8985_LEFT_MIXER_CTRL
, 0, 1, 0),
342 static const struct snd_kcontrol_new right_out_mixer
[] = {
343 SOC_DAPM_SINGLE("Line Switch", WM8985_RIGHT_MIXER_CTRL
, 1, 1, 0),
344 SOC_DAPM_SINGLE("Aux Switch", WM8985_RIGHT_MIXER_CTRL
, 5, 1, 0),
345 SOC_DAPM_SINGLE("PCM Switch", WM8985_RIGHT_MIXER_CTRL
, 0, 1, 0),
348 static const struct snd_kcontrol_new left_input_mixer
[] = {
349 SOC_DAPM_SINGLE("L2 Switch", WM8985_INPUT_CTRL
, 2, 1, 0),
350 SOC_DAPM_SINGLE("MicN Switch", WM8985_INPUT_CTRL
, 1, 1, 0),
351 SOC_DAPM_SINGLE("MicP Switch", WM8985_INPUT_CTRL
, 0, 1, 0),
354 static const struct snd_kcontrol_new right_input_mixer
[] = {
355 SOC_DAPM_SINGLE("R2 Switch", WM8985_INPUT_CTRL
, 6, 1, 0),
356 SOC_DAPM_SINGLE("MicN Switch", WM8985_INPUT_CTRL
, 5, 1, 0),
357 SOC_DAPM_SINGLE("MicP Switch", WM8985_INPUT_CTRL
, 4, 1, 0),
360 static const struct snd_kcontrol_new left_boost_mixer
[] = {
361 SOC_DAPM_SINGLE_TLV("L2 Volume", WM8985_LEFT_ADC_BOOST_CTRL
,
363 SOC_DAPM_SINGLE_TLV("AUXL Volume", WM8985_LEFT_ADC_BOOST_CTRL
,
367 static const struct snd_kcontrol_new right_boost_mixer
[] = {
368 SOC_DAPM_SINGLE_TLV("R2 Volume", WM8985_RIGHT_ADC_BOOST_CTRL
,
370 SOC_DAPM_SINGLE_TLV("AUXR Volume", WM8985_RIGHT_ADC_BOOST_CTRL
,
374 static const struct snd_soc_dapm_widget wm8985_dapm_widgets
[] = {
375 SND_SOC_DAPM_DAC("Left DAC", "Left Playback", WM8985_POWER_MANAGEMENT_3
,
377 SND_SOC_DAPM_DAC("Right DAC", "Right Playback", WM8985_POWER_MANAGEMENT_3
,
379 SND_SOC_DAPM_ADC("Left ADC", "Left Capture", WM8985_POWER_MANAGEMENT_2
,
381 SND_SOC_DAPM_ADC("Right ADC", "Right Capture", WM8985_POWER_MANAGEMENT_2
,
384 SND_SOC_DAPM_MIXER("Left Output Mixer", WM8985_POWER_MANAGEMENT_3
,
385 2, 0, left_out_mixer
, ARRAY_SIZE(left_out_mixer
)),
386 SND_SOC_DAPM_MIXER("Right Output Mixer", WM8985_POWER_MANAGEMENT_3
,
387 3, 0, right_out_mixer
, ARRAY_SIZE(right_out_mixer
)),
389 SND_SOC_DAPM_MIXER("Left Input Mixer", WM8985_POWER_MANAGEMENT_2
,
390 2, 0, left_input_mixer
, ARRAY_SIZE(left_input_mixer
)),
391 SND_SOC_DAPM_MIXER("Right Input Mixer", WM8985_POWER_MANAGEMENT_2
,
392 3, 0, right_input_mixer
, ARRAY_SIZE(right_input_mixer
)),
394 SND_SOC_DAPM_MIXER("Left Boost Mixer", WM8985_POWER_MANAGEMENT_2
,
395 4, 0, left_boost_mixer
, ARRAY_SIZE(left_boost_mixer
)),
396 SND_SOC_DAPM_MIXER("Right Boost Mixer", WM8985_POWER_MANAGEMENT_2
,
397 5, 0, right_boost_mixer
, ARRAY_SIZE(right_boost_mixer
)),
399 SND_SOC_DAPM_PGA("Left Capture PGA", WM8985_LEFT_INP_PGA_GAIN_CTRL
,
401 SND_SOC_DAPM_PGA("Right Capture PGA", WM8985_RIGHT_INP_PGA_GAIN_CTRL
,
404 SND_SOC_DAPM_PGA("Left Headphone Out", WM8985_POWER_MANAGEMENT_2
,
406 SND_SOC_DAPM_PGA("Right Headphone Out", WM8985_POWER_MANAGEMENT_2
,
409 SND_SOC_DAPM_PGA("Left Speaker Out", WM8985_POWER_MANAGEMENT_3
,
411 SND_SOC_DAPM_PGA("Right Speaker Out", WM8985_POWER_MANAGEMENT_3
,
414 SND_SOC_DAPM_MICBIAS("Mic Bias", WM8985_POWER_MANAGEMENT_1
, 4, 0),
416 SND_SOC_DAPM_INPUT("LIN"),
417 SND_SOC_DAPM_INPUT("LIP"),
418 SND_SOC_DAPM_INPUT("RIN"),
419 SND_SOC_DAPM_INPUT("RIP"),
420 SND_SOC_DAPM_INPUT("AUXL"),
421 SND_SOC_DAPM_INPUT("AUXR"),
422 SND_SOC_DAPM_INPUT("L2"),
423 SND_SOC_DAPM_INPUT("R2"),
424 SND_SOC_DAPM_OUTPUT("HPL"),
425 SND_SOC_DAPM_OUTPUT("HPR"),
426 SND_SOC_DAPM_OUTPUT("SPKL"),
427 SND_SOC_DAPM_OUTPUT("SPKR")
430 static const struct snd_soc_dapm_route audio_map
[] = {
431 { "Right Output Mixer", "PCM Switch", "Right DAC" },
432 { "Right Output Mixer", "Aux Switch", "AUXR" },
433 { "Right Output Mixer", "Line Switch", "Right Boost Mixer" },
435 { "Left Output Mixer", "PCM Switch", "Left DAC" },
436 { "Left Output Mixer", "Aux Switch", "AUXL" },
437 { "Left Output Mixer", "Line Switch", "Left Boost Mixer" },
439 { "Right Headphone Out", NULL
, "Right Output Mixer" },
440 { "HPR", NULL
, "Right Headphone Out" },
442 { "Left Headphone Out", NULL
, "Left Output Mixer" },
443 { "HPL", NULL
, "Left Headphone Out" },
445 { "Right Speaker Out", NULL
, "Right Output Mixer" },
446 { "SPKR", NULL
, "Right Speaker Out" },
448 { "Left Speaker Out", NULL
, "Left Output Mixer" },
449 { "SPKL", NULL
, "Left Speaker Out" },
451 { "Right ADC", NULL
, "Right Boost Mixer" },
453 { "Right Boost Mixer", "AUXR Volume", "AUXR" },
454 { "Right Boost Mixer", NULL
, "Right Capture PGA" },
455 { "Right Boost Mixer", "R2 Volume", "R2" },
457 { "Left ADC", NULL
, "Left Boost Mixer" },
459 { "Left Boost Mixer", "AUXL Volume", "AUXL" },
460 { "Left Boost Mixer", NULL
, "Left Capture PGA" },
461 { "Left Boost Mixer", "L2 Volume", "L2" },
463 { "Right Capture PGA", NULL
, "Right Input Mixer" },
464 { "Left Capture PGA", NULL
, "Left Input Mixer" },
466 { "Right Input Mixer", "R2 Switch", "R2" },
467 { "Right Input Mixer", "MicN Switch", "RIN" },
468 { "Right Input Mixer", "MicP Switch", "RIP" },
470 { "Left Input Mixer", "L2 Switch", "L2" },
471 { "Left Input Mixer", "MicN Switch", "LIN" },
472 { "Left Input Mixer", "MicP Switch", "LIP" },
475 static int eqmode_get(struct snd_kcontrol
*kcontrol
,
476 struct snd_ctl_elem_value
*ucontrol
)
478 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
481 reg
= snd_soc_read(codec
, WM8985_EQ1_LOW_SHELF
);
482 if (reg
& WM8985_EQ3DMODE
)
483 ucontrol
->value
.integer
.value
[0] = 1;
485 ucontrol
->value
.integer
.value
[0] = 0;
490 static int eqmode_put(struct snd_kcontrol
*kcontrol
,
491 struct snd_ctl_elem_value
*ucontrol
)
493 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
494 unsigned int regpwr2
, regpwr3
;
497 if (ucontrol
->value
.integer
.value
[0] != 0
498 && ucontrol
->value
.integer
.value
[0] != 1)
501 reg_eq
= snd_soc_read(codec
, WM8985_EQ1_LOW_SHELF
);
502 switch ((reg_eq
& WM8985_EQ3DMODE
) >> WM8985_EQ3DMODE_SHIFT
) {
504 if (!ucontrol
->value
.integer
.value
[0])
508 if (ucontrol
->value
.integer
.value
[0])
513 regpwr2
= snd_soc_read(codec
, WM8985_POWER_MANAGEMENT_2
);
514 regpwr3
= snd_soc_read(codec
, WM8985_POWER_MANAGEMENT_3
);
515 /* disable the DACs and ADCs */
516 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_2
,
517 WM8985_ADCENR_MASK
| WM8985_ADCENL_MASK
, 0);
518 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_3
,
519 WM8985_DACENR_MASK
| WM8985_DACENL_MASK
, 0);
520 snd_soc_update_bits(codec
, WM8985_ADDITIONAL_CONTROL
,
521 WM8985_M128ENB_MASK
, WM8985_M128ENB
);
522 /* set the desired eqmode */
523 snd_soc_update_bits(codec
, WM8985_EQ1_LOW_SHELF
,
524 WM8985_EQ3DMODE_MASK
,
525 ucontrol
->value
.integer
.value
[0]
526 << WM8985_EQ3DMODE_SHIFT
);
527 /* restore DAC/ADC configuration */
528 snd_soc_write(codec
, WM8985_POWER_MANAGEMENT_2
, regpwr2
);
529 snd_soc_write(codec
, WM8985_POWER_MANAGEMENT_3
, regpwr3
);
533 static int wm8985_add_widgets(struct snd_soc_codec
*codec
)
535 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
537 snd_soc_dapm_new_controls(dapm
, wm8985_dapm_widgets
,
538 ARRAY_SIZE(wm8985_dapm_widgets
));
539 snd_soc_dapm_add_routes(dapm
, audio_map
,
540 ARRAY_SIZE(audio_map
));
544 static int wm8985_reset(struct snd_soc_codec
*codec
)
546 return snd_soc_write(codec
, WM8985_SOFTWARE_RESET
, 0x0);
549 static int wm8985_dac_mute(struct snd_soc_dai
*dai
, int mute
)
551 struct snd_soc_codec
*codec
= dai
->codec
;
553 return snd_soc_update_bits(codec
, WM8985_DAC_CONTROL
,
554 WM8985_SOFTMUTE_MASK
,
555 !!mute
<< WM8985_SOFTMUTE_SHIFT
);
558 static int wm8985_set_fmt(struct snd_soc_dai
*dai
, unsigned int fmt
)
560 struct snd_soc_codec
*codec
;
561 u16 format
, master
, bcp
, lrp
;
565 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
566 case SND_SOC_DAIFMT_I2S
:
569 case SND_SOC_DAIFMT_RIGHT_J
:
572 case SND_SOC_DAIFMT_LEFT_J
:
575 case SND_SOC_DAIFMT_DSP_A
:
576 case SND_SOC_DAIFMT_DSP_B
:
580 dev_err(dai
->dev
, "Unknown dai format\n");
584 snd_soc_update_bits(codec
, WM8985_AUDIO_INTERFACE
,
585 WM8985_FMT_MASK
, format
<< WM8985_FMT_SHIFT
);
587 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
588 case SND_SOC_DAIFMT_CBM_CFM
:
591 case SND_SOC_DAIFMT_CBS_CFS
:
595 dev_err(dai
->dev
, "Unknown master/slave configuration\n");
599 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
600 WM8985_MS_MASK
, master
<< WM8985_MS_SHIFT
);
602 /* frame inversion is not valid for dsp modes */
603 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
604 case SND_SOC_DAIFMT_DSP_A
:
605 case SND_SOC_DAIFMT_DSP_B
:
606 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
607 case SND_SOC_DAIFMT_IB_IF
:
608 case SND_SOC_DAIFMT_NB_IF
:
619 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
620 case SND_SOC_DAIFMT_NB_NF
:
622 case SND_SOC_DAIFMT_IB_IF
:
625 case SND_SOC_DAIFMT_IB_NF
:
628 case SND_SOC_DAIFMT_NB_IF
:
632 dev_err(dai
->dev
, "Unknown polarity configuration\n");
636 snd_soc_update_bits(codec
, WM8985_AUDIO_INTERFACE
,
637 WM8985_LRP_MASK
, lrp
<< WM8985_LRP_SHIFT
);
638 snd_soc_update_bits(codec
, WM8985_AUDIO_INTERFACE
,
639 WM8985_BCP_MASK
, bcp
<< WM8985_BCP_SHIFT
);
643 static int wm8985_hw_params(struct snd_pcm_substream
*substream
,
644 struct snd_pcm_hw_params
*params
,
645 struct snd_soc_dai
*dai
)
648 struct snd_soc_codec
*codec
;
649 struct wm8985_priv
*wm8985
;
655 wm8985
= snd_soc_codec_get_drvdata(codec
);
657 wm8985
->bclk
= snd_soc_params_to_bclk(params
);
658 if ((int)wm8985
->bclk
< 0)
661 switch (params_format(params
)) {
662 case SNDRV_PCM_FORMAT_S16_LE
:
665 case SNDRV_PCM_FORMAT_S20_3LE
:
668 case SNDRV_PCM_FORMAT_S24_LE
:
671 case SNDRV_PCM_FORMAT_S32_LE
:
675 dev_err(dai
->dev
, "Unsupported word length %u\n",
676 params_format(params
));
680 snd_soc_update_bits(codec
, WM8985_AUDIO_INTERFACE
,
681 WM8985_WL_MASK
, blen
<< WM8985_WL_SHIFT
);
684 * match to the nearest possible sample rate and rely
685 * on the array index to configure the SR register
688 srate_best
= abs(srates
[0] - params_rate(params
));
689 for (i
= 1; i
< ARRAY_SIZE(srates
); ++i
) {
690 if (abs(srates
[i
] - params_rate(params
)) >= srate_best
)
693 srate_best
= abs(srates
[i
] - params_rate(params
));
696 dev_dbg(dai
->dev
, "Selected SRATE = %d\n", srates
[srate_idx
]);
697 snd_soc_update_bits(codec
, WM8985_ADDITIONAL_CONTROL
,
698 WM8985_SR_MASK
, srate_idx
<< WM8985_SR_SHIFT
);
700 dev_dbg(dai
->dev
, "Target BCLK = %uHz\n", wm8985
->bclk
);
701 dev_dbg(dai
->dev
, "SYSCLK = %uHz\n", wm8985
->sysclk
);
703 for (i
= 0; i
< ARRAY_SIZE(fs_ratios
); ++i
) {
704 if (wm8985
->sysclk
/ params_rate(params
)
705 == fs_ratios
[i
].ratio
)
709 if (i
== ARRAY_SIZE(fs_ratios
)) {
710 dev_err(dai
->dev
, "Unable to configure MCLK ratio %u/%u\n",
711 wm8985
->sysclk
, params_rate(params
));
715 dev_dbg(dai
->dev
, "MCLK ratio = %dfs\n", fs_ratios
[i
].ratio
);
716 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
717 WM8985_MCLKDIV_MASK
, i
<< WM8985_MCLKDIV_SHIFT
);
719 /* select the appropriate bclk divider */
720 tmp
= (wm8985
->sysclk
/ fs_ratios
[i
].div
) * 10;
721 for (i
= 0; i
< ARRAY_SIZE(bclk_divs
); ++i
) {
722 if (wm8985
->bclk
== tmp
/ bclk_divs
[i
])
726 if (i
== ARRAY_SIZE(bclk_divs
)) {
727 dev_err(dai
->dev
, "No matching BCLK divider found\n");
731 dev_dbg(dai
->dev
, "BCLK div = %d\n", i
);
732 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
733 WM8985_BCLKDIV_MASK
, i
<< WM8985_BCLKDIV_SHIFT
);
743 #define FIXED_PLL_SIZE ((1ULL << 24) * 10)
744 static int pll_factors(struct pll_div
*pll_div
, unsigned int target
,
748 unsigned long int K
, Ndiv
, Nmod
;
751 Ndiv
= target
/ source
;
755 Ndiv
= target
/ source
;
758 if (Ndiv
< 6 || Ndiv
> 12) {
759 printk(KERN_ERR
"%s: WM8985 N value is not within"
760 " the recommended range: %lu\n", __func__
, Ndiv
);
765 Nmod
= target
% source
;
766 Kpart
= FIXED_PLL_SIZE
* (u64
)Nmod
;
768 do_div(Kpart
, source
);
770 K
= Kpart
& 0xffffffff;
779 static int wm8985_set_pll(struct snd_soc_dai
*dai
, int pll_id
,
780 int source
, unsigned int freq_in
,
781 unsigned int freq_out
)
784 struct snd_soc_codec
*codec
;
785 struct pll_div pll_div
;
788 if (freq_in
&& freq_out
) {
789 ret
= pll_factors(&pll_div
, freq_out
* 4 * 2, freq_in
);
794 /* disable the PLL before reprogramming it */
795 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
796 WM8985_PLLEN_MASK
, 0);
798 if (!freq_in
|| !freq_out
)
801 /* set PLLN and PRESCALE */
802 snd_soc_write(codec
, WM8985_PLL_N
,
803 (pll_div
.div2
<< WM8985_PLL_PRESCALE_SHIFT
)
806 snd_soc_write(codec
, WM8985_PLL_K_3
, pll_div
.k
& 0x1ff);
807 snd_soc_write(codec
, WM8985_PLL_K_2
, (pll_div
.k
>> 9) & 0x1ff);
808 snd_soc_write(codec
, WM8985_PLL_K_1
, (pll_div
.k
>> 18));
809 /* set the source of the clock to be the PLL */
810 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
811 WM8985_CLKSEL_MASK
, WM8985_CLKSEL
);
813 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
814 WM8985_PLLEN_MASK
, WM8985_PLLEN
);
818 static int wm8985_set_sysclk(struct snd_soc_dai
*dai
,
819 int clk_id
, unsigned int freq
, int dir
)
821 struct snd_soc_codec
*codec
;
822 struct wm8985_priv
*wm8985
;
825 wm8985
= snd_soc_codec_get_drvdata(codec
);
828 case WM8985_CLKSRC_MCLK
:
829 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
830 WM8985_CLKSEL_MASK
, 0);
831 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
832 WM8985_PLLEN_MASK
, 0);
834 case WM8985_CLKSRC_PLL
:
835 snd_soc_update_bits(codec
, WM8985_CLOCK_GEN_CONTROL
,
836 WM8985_CLKSEL_MASK
, WM8985_CLKSEL
);
839 dev_err(dai
->dev
, "Unknown clock source %d\n", clk_id
);
843 wm8985
->sysclk
= freq
;
847 static void wm8985_sync_cache(struct snd_soc_codec
*codec
)
852 if (!codec
->cache_sync
)
854 codec
->cache_only
= 0;
856 cache
= codec
->reg_cache
;
857 for (i
= 0; i
< codec
->driver
->reg_cache_size
; i
++) {
858 if (i
== WM8985_SOFTWARE_RESET
859 || cache
[i
] == wm8985_reg_defs
[i
])
861 snd_soc_write(codec
, i
, cache
[i
]);
863 codec
->cache_sync
= 0;
866 static int wm8985_set_bias_level(struct snd_soc_codec
*codec
,
867 enum snd_soc_bias_level level
)
870 struct wm8985_priv
*wm8985
;
872 wm8985
= snd_soc_codec_get_drvdata(codec
);
874 case SND_SOC_BIAS_ON
:
875 case SND_SOC_BIAS_PREPARE
:
877 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
879 1 << WM8985_VMIDSEL_SHIFT
);
881 case SND_SOC_BIAS_STANDBY
:
882 if (codec
->dapm
.bias_level
== SND_SOC_BIAS_OFF
) {
883 ret
= regulator_bulk_enable(ARRAY_SIZE(wm8985
->supplies
),
887 "Failed to enable supplies: %d\n",
892 wm8985_sync_cache(codec
);
894 /* enable anti-pop features */
895 snd_soc_update_bits(codec
, WM8985_OUT4_TO_ADC
,
898 /* enable thermal shutdown */
899 snd_soc_update_bits(codec
, WM8985_OUTPUT_CTRL0
,
900 WM8985_TSDEN_MASK
, WM8985_TSDEN
);
901 snd_soc_update_bits(codec
, WM8985_OUTPUT_CTRL0
,
902 WM8985_TSOPCTRL_MASK
,
905 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
906 WM8985_BIASEN_MASK
, WM8985_BIASEN
);
908 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
910 1 << WM8985_VMIDSEL_SHIFT
);
912 /* disable anti-pop features */
913 snd_soc_update_bits(codec
, WM8985_OUT4_TO_ADC
,
914 WM8985_POBCTRL_MASK
, 0);
917 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
919 2 << WM8985_VMIDSEL_SHIFT
);
921 case SND_SOC_BIAS_OFF
:
922 /* disable thermal shutdown */
923 snd_soc_update_bits(codec
, WM8985_OUTPUT_CTRL0
,
924 WM8985_TSOPCTRL_MASK
, 0);
925 snd_soc_update_bits(codec
, WM8985_OUTPUT_CTRL0
,
926 WM8985_TSDEN_MASK
, 0);
927 /* disable VMIDSEL and BIASEN */
928 snd_soc_update_bits(codec
, WM8985_POWER_MANAGEMENT_1
,
929 WM8985_VMIDSEL_MASK
| WM8985_BIASEN_MASK
,
931 snd_soc_write(codec
, WM8985_POWER_MANAGEMENT_1
, 0);
932 snd_soc_write(codec
, WM8985_POWER_MANAGEMENT_2
, 0);
933 snd_soc_write(codec
, WM8985_POWER_MANAGEMENT_3
, 0);
935 codec
->cache_sync
= 1;
937 regulator_bulk_disable(ARRAY_SIZE(wm8985
->supplies
),
942 codec
->dapm
.bias_level
= level
;
947 static int wm8985_suspend(struct snd_soc_codec
*codec
, pm_message_t state
)
949 wm8985_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
953 static int wm8985_resume(struct snd_soc_codec
*codec
)
955 wm8985_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
959 #define wm8985_suspend NULL
960 #define wm8985_resume NULL
963 static int wm8985_remove(struct snd_soc_codec
*codec
)
965 struct wm8985_priv
*wm8985
;
967 wm8985
= snd_soc_codec_get_drvdata(codec
);
968 wm8985_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
969 regulator_bulk_free(ARRAY_SIZE(wm8985
->supplies
), wm8985
->supplies
);
973 static int wm8985_probe(struct snd_soc_codec
*codec
)
976 struct wm8985_priv
*wm8985
;
980 wm8985
= snd_soc_codec_get_drvdata(codec
);
982 ret
= snd_soc_codec_set_cache_io(codec
, 7, 9, wm8985
->control_type
);
984 dev_err(codec
->dev
, "Failed to set cache i/o: %d\n", ret
);
988 for (i
= 0; i
< ARRAY_SIZE(wm8985
->supplies
); i
++)
989 wm8985
->supplies
[i
].supply
= wm8985_supply_names
[i
];
991 ret
= regulator_bulk_get(codec
->dev
, ARRAY_SIZE(wm8985
->supplies
),
994 dev_err(codec
->dev
, "Failed to request supplies: %d\n", ret
);
998 ret
= regulator_bulk_enable(ARRAY_SIZE(wm8985
->supplies
),
1001 dev_err(codec
->dev
, "Failed to enable supplies: %d\n", ret
);
1005 ret
= wm8985_reset(codec
);
1007 dev_err(codec
->dev
, "Failed to issue reset: %d\n", ret
);
1008 goto err_reg_enable
;
1011 cache
= codec
->reg_cache
;
1012 /* latch volume update bits */
1013 for (i
= 0; i
< ARRAY_SIZE(volume_update_regs
); ++i
)
1014 cache
[volume_update_regs
[i
]] |= 0x100;
1015 /* enable BIASCUT */
1016 cache
[WM8985_BIAS_CTRL
] |= WM8985_BIASCUT
;
1017 codec
->cache_sync
= 1;
1019 snd_soc_add_controls(codec
, wm8985_snd_controls
,
1020 ARRAY_SIZE(wm8985_snd_controls
));
1021 wm8985_add_widgets(codec
);
1023 wm8985_set_bias_level(codec
, SND_SOC_BIAS_STANDBY
);
1027 regulator_bulk_disable(ARRAY_SIZE(wm8985
->supplies
), wm8985
->supplies
);
1029 regulator_bulk_free(ARRAY_SIZE(wm8985
->supplies
), wm8985
->supplies
);
1033 static struct snd_soc_dai_ops wm8985_dai_ops
= {
1034 .digital_mute
= wm8985_dac_mute
,
1035 .hw_params
= wm8985_hw_params
,
1036 .set_fmt
= wm8985_set_fmt
,
1037 .set_sysclk
= wm8985_set_sysclk
,
1038 .set_pll
= wm8985_set_pll
1041 #define WM8985_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1042 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1044 static struct snd_soc_dai_driver wm8985_dai
= {
1045 .name
= "wm8985-hifi",
1047 .stream_name
= "Playback",
1050 .rates
= SNDRV_PCM_RATE_8000_48000
,
1051 .formats
= WM8985_FORMATS
,
1054 .stream_name
= "Capture",
1057 .rates
= SNDRV_PCM_RATE_8000_48000
,
1058 .formats
= WM8985_FORMATS
,
1060 .ops
= &wm8985_dai_ops
,
1061 .symmetric_rates
= 1
1064 static struct snd_soc_codec_driver soc_codec_dev_wm8985
= {
1065 .probe
= wm8985_probe
,
1066 .remove
= wm8985_remove
,
1067 .suspend
= wm8985_suspend
,
1068 .resume
= wm8985_resume
,
1069 .set_bias_level
= wm8985_set_bias_level
,
1070 .reg_cache_size
= ARRAY_SIZE(wm8985_reg_defs
),
1071 .reg_word_size
= sizeof(u16
),
1072 .reg_cache_default
= wm8985_reg_defs
1075 #if defined(CONFIG_SPI_MASTER)
1076 static int __devinit
wm8985_spi_probe(struct spi_device
*spi
)
1078 struct wm8985_priv
*wm8985
;
1081 wm8985
= kzalloc(sizeof *wm8985
, GFP_KERNEL
);
1085 wm8985
->control_type
= SND_SOC_SPI
;
1086 spi_set_drvdata(spi
, wm8985
);
1088 ret
= snd_soc_register_codec(&spi
->dev
,
1089 &soc_codec_dev_wm8985
, &wm8985_dai
, 1);
1095 static int __devexit
wm8985_spi_remove(struct spi_device
*spi
)
1097 snd_soc_unregister_codec(&spi
->dev
);
1098 kfree(spi_get_drvdata(spi
));
1102 static struct spi_driver wm8985_spi_driver
= {
1105 .owner
= THIS_MODULE
,
1107 .probe
= wm8985_spi_probe
,
1108 .remove
= __devexit_p(wm8985_spi_remove
)
1112 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1113 static __devinit
int wm8985_i2c_probe(struct i2c_client
*i2c
,
1114 const struct i2c_device_id
*id
)
1116 struct wm8985_priv
*wm8985
;
1119 wm8985
= kzalloc(sizeof *wm8985
, GFP_KERNEL
);
1123 wm8985
->control_type
= SND_SOC_I2C
;
1124 i2c_set_clientdata(i2c
, wm8985
);
1126 ret
= snd_soc_register_codec(&i2c
->dev
,
1127 &soc_codec_dev_wm8985
, &wm8985_dai
, 1);
1133 static __devexit
int wm8985_i2c_remove(struct i2c_client
*client
)
1135 snd_soc_unregister_codec(&client
->dev
);
1136 kfree(i2c_get_clientdata(client
));
1140 static const struct i2c_device_id wm8985_i2c_id
[] = {
1144 MODULE_DEVICE_TABLE(i2c
, wm8985_i2c_id
);
1146 static struct i2c_driver wm8985_i2c_driver
= {
1149 .owner
= THIS_MODULE
,
1151 .probe
= wm8985_i2c_probe
,
1152 .remove
= __devexit_p(wm8985_i2c_remove
),
1153 .id_table
= wm8985_i2c_id
1157 static int __init
wm8985_modinit(void)
1161 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1162 ret
= i2c_add_driver(&wm8985_i2c_driver
);
1164 printk(KERN_ERR
"Failed to register wm8985 I2C driver: %d\n",
1168 #if defined(CONFIG_SPI_MASTER)
1169 ret
= spi_register_driver(&wm8985_spi_driver
);
1171 printk(KERN_ERR
"Failed to register wm8985 SPI driver: %d\n",
1177 module_init(wm8985_modinit
);
1179 static void __exit
wm8985_exit(void)
1181 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1182 i2c_del_driver(&wm8985_i2c_driver
);
1184 #if defined(CONFIG_SPI_MASTER)
1185 spi_unregister_driver(&wm8985_spi_driver
);
1188 module_exit(wm8985_exit
);
1190 MODULE_DESCRIPTION("ASoC WM8985 driver");
1191 MODULE_AUTHOR("Dimitris Papastamos <dp@opensource.wolfsonmicro.com>");
1192 MODULE_LICENSE("GPL");