2 * wm2000.c -- WM2000 ALSA Soc Audio driver
4 * Copyright 2008-2010 Wolfson Microelectronics PLC.
6 * Author: Mark Brown <broonie@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.
12 * The download image for the WM2000 will be requested as
13 * 'wm2000_anc.bin' by default (overridable via platform data) at
14 * runtime and is expected to be in flat binary format. This is
15 * generated by Wolfson configuration tools and includes
16 * system-specific callibration information. If supplied as a
17 * sequence of ASCII-encoded hexidecimal bytes this can be converted
18 * into a flat binary with a command such as this on the command line:
20 * perl -e 'while (<>) { s/[\r\n]+// ; printf("%c", hex($_)); }'
21 * < file > wm2000_anc.bin
24 #include <linux/module.h>
25 #include <linux/moduleparam.h>
26 #include <linux/kernel.h>
27 #include <linux/init.h>
28 #include <linux/firmware.h>
29 #include <linux/delay.h>
31 #include <linux/i2c.h>
32 #include <linux/platform_device.h>
33 #include <linux/debugfs.h>
34 #include <linux/slab.h>
35 #include <sound/core.h>
36 #include <sound/pcm.h>
37 #include <sound/pcm_params.h>
38 #include <sound/soc.h>
39 #include <sound/initval.h>
40 #include <sound/tlv.h>
42 #include <sound/wm2000.h>
46 enum wm2000_anc_mode
{
54 struct i2c_client
*i2c
;
56 enum wm2000_anc_mode anc_mode
;
58 unsigned int anc_active
:1;
59 unsigned int anc_eng_ena
:1;
60 unsigned int spk_ena
:1;
62 unsigned int mclk_div
:1;
63 unsigned int speech_clarity
:1;
65 int anc_download_size
;
69 static struct i2c_client
*wm2000_i2c
;
71 static int wm2000_write(struct i2c_client
*i2c
, unsigned int reg
,
77 data
[0] = (reg
>> 8) & 0xff;
79 data
[2] = value
& 0xff;
81 dev_vdbg(&i2c
->dev
, "write %x = %x\n", reg
, value
);
83 ret
= i2c_master_send(i2c
, data
, 3);
92 static unsigned int wm2000_read(struct i2c_client
*i2c
, unsigned int r
)
94 struct i2c_msg xfer
[2];
100 reg
[0] = (r
>> 8) & 0xff;
102 xfer
[0].addr
= i2c
->addr
;
104 xfer
[0].len
= sizeof(reg
);
105 xfer
[0].buf
= ®
[0];
108 xfer
[1].addr
= i2c
->addr
;
109 xfer
[1].flags
= I2C_M_RD
;
113 ret
= i2c_transfer(i2c
->adapter
, xfer
, 2);
115 dev_err(&i2c
->dev
, "i2c_transfer() returned %d\n", ret
);
119 dev_vdbg(&i2c
->dev
, "read %x from %x\n", data
, r
);
124 static void wm2000_reset(struct wm2000_priv
*wm2000
)
126 struct i2c_client
*i2c
= wm2000
->i2c
;
128 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
129 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
130 wm2000_write(i2c
, WM2000_REG_ID1
, 0);
132 wm2000
->anc_mode
= ANC_OFF
;
135 static int wm2000_poll_bit(struct i2c_client
*i2c
,
136 unsigned int reg
, u8 mask
, int timeout
)
140 val
= wm2000_read(i2c
, reg
);
142 while (!(val
& mask
) && --timeout
) {
144 val
= wm2000_read(i2c
, reg
);
153 static int wm2000_power_up(struct i2c_client
*i2c
, int analogue
)
155 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
158 BUG_ON(wm2000
->anc_mode
!= ANC_OFF
);
160 dev_dbg(&i2c
->dev
, "Beginning power up\n");
162 if (!wm2000
->mclk_div
) {
163 dev_dbg(&i2c
->dev
, "Disabling MCLK divider\n");
164 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
165 WM2000_MCLK_DIV2_ENA_CLR
);
167 dev_dbg(&i2c
->dev
, "Enabling MCLK divider\n");
168 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
169 WM2000_MCLK_DIV2_ENA_SET
);
172 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
173 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_SET
);
175 /* Wait for ANC engine to become ready */
176 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
177 WM2000_ANC_ENG_IDLE
, 1)) {
178 dev_err(&i2c
->dev
, "ANC engine failed to reset\n");
182 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
183 WM2000_STATUS_BOOT_COMPLETE
, 1)) {
184 dev_err(&i2c
->dev
, "ANC engine failed to initialise\n");
188 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
190 /* Open code download of the data since it is the only bulk
192 dev_dbg(&i2c
->dev
, "Downloading %d bytes\n",
193 wm2000
->anc_download_size
- 2);
195 ret
= i2c_master_send(i2c
, wm2000
->anc_download
,
196 wm2000
->anc_download_size
);
198 dev_err(&i2c
->dev
, "i2c_transfer() failed: %d\n", ret
);
201 if (ret
!= wm2000
->anc_download_size
) {
202 dev_err(&i2c
->dev
, "i2c_transfer() failed, %d != %d\n",
203 ret
, wm2000
->anc_download_size
);
207 dev_dbg(&i2c
->dev
, "Download complete\n");
211 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
213 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
214 WM2000_MODE_ANA_SEQ_INCLUDE
|
215 WM2000_MODE_MOUSE_ENABLE
|
216 WM2000_MODE_THERMAL_ENABLE
);
220 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
221 WM2000_MODE_MOUSE_ENABLE
|
222 WM2000_MODE_THERMAL_ENABLE
);
225 ret
= wm2000_read(i2c
, WM2000_REG_SPEECH_CLARITY
);
226 if (wm2000
->speech_clarity
)
227 ret
&= ~WM2000_SPEECH_CLARITY
;
229 ret
|= WM2000_SPEECH_CLARITY
;
230 wm2000_write(i2c
, WM2000_REG_SPEECH_CLARITY
, ret
);
232 wm2000_write(i2c
, WM2000_REG_SYS_START0
, 0x33);
233 wm2000_write(i2c
, WM2000_REG_SYS_START1
, 0x02);
235 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
237 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
238 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
239 dev_err(&i2c
->dev
, "Timed out waiting for device after %dms\n",
244 dev_dbg(&i2c
->dev
, "ANC active\n");
246 dev_dbg(&i2c
->dev
, "Analogue active\n");
247 wm2000
->anc_mode
= ANC_ACTIVE
;
252 static int wm2000_power_down(struct i2c_client
*i2c
, int analogue
)
254 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
259 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
260 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
261 WM2000_MODE_ANA_SEQ_INCLUDE
|
262 WM2000_MODE_POWER_DOWN
);
265 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
266 WM2000_MODE_POWER_DOWN
);
269 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
270 WM2000_STATUS_POWER_DOWN_COMPLETE
, timeout
)) {
271 dev_err(&i2c
->dev
, "Timeout waiting for ANC power down\n");
275 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
276 WM2000_ANC_ENG_IDLE
, 1)) {
277 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
281 dev_dbg(&i2c
->dev
, "powered off\n");
282 wm2000
->anc_mode
= ANC_OFF
;
287 static int wm2000_enter_bypass(struct i2c_client
*i2c
, int analogue
)
289 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
291 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
294 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
295 WM2000_MODE_ANA_SEQ_INCLUDE
|
296 WM2000_MODE_THERMAL_ENABLE
|
297 WM2000_MODE_BYPASS_ENTRY
);
299 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
300 WM2000_MODE_THERMAL_ENABLE
|
301 WM2000_MODE_BYPASS_ENTRY
);
304 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
305 WM2000_STATUS_ANC_DISABLED
, 10)) {
306 dev_err(&i2c
->dev
, "Timeout waiting for ANC disable\n");
310 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
311 WM2000_ANC_ENG_IDLE
, 1)) {
312 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
316 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
317 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
319 wm2000
->anc_mode
= ANC_BYPASS
;
320 dev_dbg(&i2c
->dev
, "bypass enabled\n");
325 static int wm2000_exit_bypass(struct i2c_client
*i2c
, int analogue
)
327 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
329 BUG_ON(wm2000
->anc_mode
!= ANC_BYPASS
);
331 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
334 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
335 WM2000_MODE_ANA_SEQ_INCLUDE
|
336 WM2000_MODE_MOUSE_ENABLE
|
337 WM2000_MODE_THERMAL_ENABLE
);
339 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
340 WM2000_MODE_MOUSE_ENABLE
|
341 WM2000_MODE_THERMAL_ENABLE
);
344 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
345 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
347 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
348 WM2000_STATUS_MOUSE_ACTIVE
, 10)) {
349 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE\n");
353 wm2000
->anc_mode
= ANC_ACTIVE
;
354 dev_dbg(&i2c
->dev
, "MOUSE active\n");
359 static int wm2000_enter_standby(struct i2c_client
*i2c
, int analogue
)
361 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
364 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
368 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
370 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
371 WM2000_MODE_ANA_SEQ_INCLUDE
|
372 WM2000_MODE_THERMAL_ENABLE
|
373 WM2000_MODE_STANDBY_ENTRY
);
377 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
378 WM2000_MODE_THERMAL_ENABLE
|
379 WM2000_MODE_STANDBY_ENTRY
);
382 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
383 WM2000_STATUS_ANC_DISABLED
, timeout
)) {
385 "Timed out waiting for ANC disable after 1ms\n");
389 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
, WM2000_ANC_ENG_IDLE
,
392 "Timed out waiting for standby after %dms\n",
397 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
398 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
400 wm2000
->anc_mode
= ANC_STANDBY
;
401 dev_dbg(&i2c
->dev
, "standby\n");
403 dev_dbg(&i2c
->dev
, "Analogue disabled\n");
408 static int wm2000_exit_standby(struct i2c_client
*i2c
, int analogue
)
410 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
413 BUG_ON(wm2000
->anc_mode
!= ANC_STANDBY
);
415 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
419 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
421 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
422 WM2000_MODE_ANA_SEQ_INCLUDE
|
423 WM2000_MODE_THERMAL_ENABLE
|
424 WM2000_MODE_MOUSE_ENABLE
);
428 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
429 WM2000_MODE_THERMAL_ENABLE
|
430 WM2000_MODE_MOUSE_ENABLE
);
433 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
434 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
436 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
437 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
438 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE after %dms\n",
443 wm2000
->anc_mode
= ANC_ACTIVE
;
444 dev_dbg(&i2c
->dev
, "MOUSE active\n");
446 dev_dbg(&i2c
->dev
, "Analogue enabled\n");
451 typedef int (*wm2000_mode_fn
)(struct i2c_client
*i2c
, int analogue
);
454 enum wm2000_anc_mode source
;
455 enum wm2000_anc_mode dest
;
457 wm2000_mode_fn step
[2];
458 } anc_transitions
[] = {
472 wm2000_enter_standby
,
485 .source
= ANC_ACTIVE
,
493 .source
= ANC_ACTIVE
,
497 wm2000_enter_standby
,
501 .source
= ANC_ACTIVE
,
509 .source
= ANC_BYPASS
,
517 .source
= ANC_BYPASS
,
522 wm2000_enter_standby
,
526 .source
= ANC_BYPASS
,
534 .source
= ANC_STANDBY
,
542 .source
= ANC_STANDBY
,
551 .source
= ANC_STANDBY
,
560 static int wm2000_anc_transition(struct wm2000_priv
*wm2000
,
561 enum wm2000_anc_mode mode
)
563 struct i2c_client
*i2c
= wm2000
->i2c
;
567 if (wm2000
->anc_mode
== mode
)
570 for (i
= 0; i
< ARRAY_SIZE(anc_transitions
); i
++)
571 if (anc_transitions
[i
].source
== wm2000
->anc_mode
&&
572 anc_transitions
[i
].dest
== mode
)
574 if (i
== ARRAY_SIZE(anc_transitions
)) {
575 dev_err(&i2c
->dev
, "No transition for %d->%d\n",
576 wm2000
->anc_mode
, mode
);
580 for (j
= 0; j
< ARRAY_SIZE(anc_transitions
[j
].step
); j
++) {
581 if (!anc_transitions
[i
].step
[j
])
583 ret
= anc_transitions
[i
].step
[j
](i2c
,
584 anc_transitions
[i
].analogue
);
592 static int wm2000_anc_set_mode(struct wm2000_priv
*wm2000
)
594 struct i2c_client
*i2c
= wm2000
->i2c
;
595 enum wm2000_anc_mode mode
;
597 if (wm2000
->anc_eng_ena
&& wm2000
->spk_ena
)
598 if (wm2000
->anc_active
)
605 dev_dbg(&i2c
->dev
, "Set mode %d (enabled %d, mute %d, active %d)\n",
606 mode
, wm2000
->anc_eng_ena
, !wm2000
->spk_ena
,
609 return wm2000_anc_transition(wm2000
, mode
);
612 static int wm2000_anc_mode_get(struct snd_kcontrol
*kcontrol
,
613 struct snd_ctl_elem_value
*ucontrol
)
615 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
617 ucontrol
->value
.enumerated
.item
[0] = wm2000
->anc_active
;
622 static int wm2000_anc_mode_put(struct snd_kcontrol
*kcontrol
,
623 struct snd_ctl_elem_value
*ucontrol
)
625 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
626 int anc_active
= ucontrol
->value
.enumerated
.item
[0];
631 wm2000
->anc_active
= anc_active
;
633 return wm2000_anc_set_mode(wm2000
);
636 static int wm2000_speaker_get(struct snd_kcontrol
*kcontrol
,
637 struct snd_ctl_elem_value
*ucontrol
)
639 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
641 ucontrol
->value
.enumerated
.item
[0] = wm2000
->spk_ena
;
646 static int wm2000_speaker_put(struct snd_kcontrol
*kcontrol
,
647 struct snd_ctl_elem_value
*ucontrol
)
649 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
650 int val
= ucontrol
->value
.enumerated
.item
[0];
655 wm2000
->spk_ena
= val
;
657 return wm2000_anc_set_mode(wm2000
);
660 static const struct snd_kcontrol_new wm2000_controls
[] = {
661 SOC_SINGLE_BOOL_EXT("WM2000 ANC Switch", 0,
663 wm2000_anc_mode_put
),
664 SOC_SINGLE_BOOL_EXT("WM2000 Switch", 0,
669 static int wm2000_anc_power_event(struct snd_soc_dapm_widget
*w
,
670 struct snd_kcontrol
*kcontrol
, int event
)
672 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
674 if (SND_SOC_DAPM_EVENT_ON(event
))
675 wm2000
->anc_eng_ena
= 1;
677 if (SND_SOC_DAPM_EVENT_OFF(event
))
678 wm2000
->anc_eng_ena
= 0;
680 return wm2000_anc_set_mode(wm2000
);
683 static const struct snd_soc_dapm_widget wm2000_dapm_widgets
[] = {
684 /* Externally visible pins */
685 SND_SOC_DAPM_OUTPUT("WM2000 SPKN"),
686 SND_SOC_DAPM_OUTPUT("WM2000 SPKP"),
688 SND_SOC_DAPM_INPUT("WM2000 LINN"),
689 SND_SOC_DAPM_INPUT("WM2000 LINP"),
691 SND_SOC_DAPM_PGA_E("ANC Engine", SND_SOC_NOPM
, 0, 0, NULL
, 0,
692 wm2000_anc_power_event
,
693 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
696 /* Target, Path, Source */
697 static const struct snd_soc_dapm_route audio_map
[] = {
698 { "WM2000 SPKN", NULL
, "ANC Engine" },
699 { "WM2000 SPKP", NULL
, "ANC Engine" },
700 { "ANC Engine", NULL
, "WM2000 LINN" },
701 { "ANC Engine", NULL
, "WM2000 LINP" },
704 /* Called from the machine driver */
705 int wm2000_add_controls(struct snd_soc_codec
*codec
)
707 struct snd_soc_dapm_context
*dapm
= &codec
->dapm
;
711 pr_err("WM2000 not yet probed\n");
715 ret
= snd_soc_dapm_new_controls(dapm
, wm2000_dapm_widgets
,
716 ARRAY_SIZE(wm2000_dapm_widgets
));
720 ret
= snd_soc_dapm_add_routes(dapm
, audio_map
, ARRAY_SIZE(audio_map
));
724 return snd_soc_add_controls(codec
, wm2000_controls
,
725 ARRAY_SIZE(wm2000_controls
));
727 EXPORT_SYMBOL_GPL(wm2000_add_controls
);
729 static int __devinit
wm2000_i2c_probe(struct i2c_client
*i2c
,
730 const struct i2c_device_id
*i2c_id
)
732 struct wm2000_priv
*wm2000
;
733 struct wm2000_platform_data
*pdata
;
734 const char *filename
;
735 const struct firmware
*fw
;
740 dev_err(&i2c
->dev
, "Another WM2000 is already registered\n");
744 wm2000
= kzalloc(sizeof(struct wm2000_priv
), GFP_KERNEL
);
745 if (wm2000
== NULL
) {
746 dev_err(&i2c
->dev
, "Unable to allocate private data\n");
750 /* Verify that this is a WM2000 */
751 reg
= wm2000_read(i2c
, WM2000_REG_ID1
);
753 reg
= wm2000_read(i2c
, WM2000_REG_ID2
);
757 dev_err(&i2c
->dev
, "Device is not a WM2000 - ID %x\n", id
);
762 reg
= wm2000_read(i2c
, WM2000_REG_REVISON
);
763 dev_info(&i2c
->dev
, "revision %c\n", reg
+ 'A');
765 filename
= "wm2000_anc.bin";
766 pdata
= dev_get_platdata(&i2c
->dev
);
768 wm2000
->mclk_div
= pdata
->mclkdiv2
;
769 wm2000
->speech_clarity
= !pdata
->speech_enh_disable
;
771 if (pdata
->download_file
)
772 filename
= pdata
->download_file
;
775 ret
= request_firmware(&fw
, filename
, &i2c
->dev
);
777 dev_err(&i2c
->dev
, "Failed to acquire ANC data: %d\n", ret
);
781 /* Pre-cook the concatenation of the register address onto the image */
782 wm2000
->anc_download_size
= fw
->size
+ 2;
783 wm2000
->anc_download
= kmalloc(wm2000
->anc_download_size
, GFP_KERNEL
);
784 if (wm2000
->anc_download
== NULL
) {
785 dev_err(&i2c
->dev
, "Out of memory\n");
790 wm2000
->anc_download
[0] = 0x80;
791 wm2000
->anc_download
[1] = 0x00;
792 memcpy(wm2000
->anc_download
+ 2, fw
->data
, fw
->size
);
794 release_firmware(fw
);
796 dev_set_drvdata(&i2c
->dev
, wm2000
);
797 wm2000
->anc_eng_ena
= 1;
798 wm2000
->anc_active
= 1;
802 wm2000_reset(wm2000
);
804 /* This will trigger a transition to standby mode by default */
805 wm2000_anc_set_mode(wm2000
);
812 release_firmware(fw
);
818 static __devexit
int wm2000_i2c_remove(struct i2c_client
*i2c
)
820 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
822 wm2000_anc_transition(wm2000
, ANC_OFF
);
825 kfree(wm2000
->anc_download
);
831 static void wm2000_i2c_shutdown(struct i2c_client
*i2c
)
833 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
835 wm2000_anc_transition(wm2000
, ANC_OFF
);
839 static int wm2000_i2c_suspend(struct i2c_client
*i2c
, pm_message_t mesg
)
841 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
843 return wm2000_anc_transition(wm2000
, ANC_OFF
);
846 static int wm2000_i2c_resume(struct i2c_client
*i2c
)
848 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
850 return wm2000_anc_set_mode(wm2000
);
853 #define wm2000_i2c_suspend NULL
854 #define wm2000_i2c_resume NULL
857 static const struct i2c_device_id wm2000_i2c_id
[] = {
861 MODULE_DEVICE_TABLE(i2c
, wm2000_i2c_id
);
863 static struct i2c_driver wm2000_i2c_driver
= {
866 .owner
= THIS_MODULE
,
868 .probe
= wm2000_i2c_probe
,
869 .remove
= __devexit_p(wm2000_i2c_remove
),
870 .suspend
= wm2000_i2c_suspend
,
871 .resume
= wm2000_i2c_resume
,
872 .shutdown
= wm2000_i2c_shutdown
,
873 .id_table
= wm2000_i2c_id
,
876 static int __init
wm2000_init(void)
878 return i2c_add_driver(&wm2000_i2c_driver
);
880 module_init(wm2000_init
);
882 static void __exit
wm2000_exit(void)
884 i2c_del_driver(&wm2000_i2c_driver
);
886 module_exit(wm2000_exit
);
888 MODULE_DESCRIPTION("ASoC WM2000 driver");
889 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfonmicro.com>");
890 MODULE_LICENSE("GPL");