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/soc-dapm.h>
40 #include <sound/initval.h>
41 #include <sound/tlv.h>
43 #include <sound/wm2000.h>
47 enum wm2000_anc_mode
{
55 struct i2c_client
*i2c
;
57 enum wm2000_anc_mode anc_mode
;
59 unsigned int anc_active
:1;
60 unsigned int anc_eng_ena
:1;
61 unsigned int spk_ena
:1;
63 unsigned int mclk_div
:1;
64 unsigned int speech_clarity
:1;
66 int anc_download_size
;
70 static struct i2c_client
*wm2000_i2c
;
72 static int wm2000_write(struct i2c_client
*i2c
, unsigned int reg
,
78 data
[0] = (reg
>> 8) & 0xff;
80 data
[2] = value
& 0xff;
82 dev_vdbg(&i2c
->dev
, "write %x = %x\n", reg
, value
);
84 ret
= i2c_master_send(i2c
, data
, 3);
93 static unsigned int wm2000_read(struct i2c_client
*i2c
, unsigned int r
)
95 struct i2c_msg xfer
[2];
101 reg
[0] = (r
>> 8) & 0xff;
103 xfer
[0].addr
= i2c
->addr
;
105 xfer
[0].len
= sizeof(reg
);
106 xfer
[0].buf
= ®
[0];
109 xfer
[1].addr
= i2c
->addr
;
110 xfer
[1].flags
= I2C_M_RD
;
114 ret
= i2c_transfer(i2c
->adapter
, xfer
, 2);
116 dev_err(&i2c
->dev
, "i2c_transfer() returned %d\n", ret
);
120 dev_vdbg(&i2c
->dev
, "read %x from %x\n", data
, r
);
125 static void wm2000_reset(struct wm2000_priv
*wm2000
)
127 struct i2c_client
*i2c
= wm2000
->i2c
;
129 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
130 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
131 wm2000_write(i2c
, WM2000_REG_ID1
, 0);
133 wm2000
->anc_mode
= ANC_OFF
;
136 static int wm2000_poll_bit(struct i2c_client
*i2c
,
137 unsigned int reg
, u8 mask
, int timeout
)
141 val
= wm2000_read(i2c
, reg
);
143 while (!(val
& mask
) && --timeout
) {
145 val
= wm2000_read(i2c
, reg
);
154 static int wm2000_power_up(struct i2c_client
*i2c
, int analogue
)
156 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
159 BUG_ON(wm2000
->anc_mode
!= ANC_OFF
);
161 dev_dbg(&i2c
->dev
, "Beginning power up\n");
163 if (!wm2000
->mclk_div
) {
164 dev_dbg(&i2c
->dev
, "Disabling MCLK divider\n");
165 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
166 WM2000_MCLK_DIV2_ENA_CLR
);
168 dev_dbg(&i2c
->dev
, "Enabling MCLK divider\n");
169 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
170 WM2000_MCLK_DIV2_ENA_SET
);
173 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
174 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_SET
);
176 /* Wait for ANC engine to become ready */
177 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
178 WM2000_ANC_ENG_IDLE
, 1)) {
179 dev_err(&i2c
->dev
, "ANC engine failed to reset\n");
183 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
184 WM2000_STATUS_BOOT_COMPLETE
, 1)) {
185 dev_err(&i2c
->dev
, "ANC engine failed to initialise\n");
189 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
191 /* Open code download of the data since it is the only bulk
193 dev_dbg(&i2c
->dev
, "Downloading %d bytes\n",
194 wm2000
->anc_download_size
- 2);
196 ret
= i2c_master_send(i2c
, wm2000
->anc_download
,
197 wm2000
->anc_download_size
);
199 dev_err(&i2c
->dev
, "i2c_transfer() failed: %d\n", ret
);
202 if (ret
!= wm2000
->anc_download_size
) {
203 dev_err(&i2c
->dev
, "i2c_transfer() failed, %d != %d\n",
204 ret
, wm2000
->anc_download_size
);
208 dev_dbg(&i2c
->dev
, "Download complete\n");
212 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
214 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
215 WM2000_MODE_ANA_SEQ_INCLUDE
|
216 WM2000_MODE_MOUSE_ENABLE
|
217 WM2000_MODE_THERMAL_ENABLE
);
221 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
222 WM2000_MODE_MOUSE_ENABLE
|
223 WM2000_MODE_THERMAL_ENABLE
);
226 ret
= wm2000_read(i2c
, WM2000_REG_SPEECH_CLARITY
);
227 if (wm2000
->speech_clarity
)
228 ret
&= ~WM2000_SPEECH_CLARITY
;
230 ret
|= WM2000_SPEECH_CLARITY
;
231 wm2000_write(i2c
, WM2000_REG_SPEECH_CLARITY
, ret
);
233 wm2000_write(i2c
, WM2000_REG_SYS_START0
, 0x33);
234 wm2000_write(i2c
, WM2000_REG_SYS_START1
, 0x02);
236 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
238 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
239 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
240 dev_err(&i2c
->dev
, "Timed out waiting for device after %dms\n",
245 dev_dbg(&i2c
->dev
, "ANC active\n");
247 dev_dbg(&i2c
->dev
, "Analogue active\n");
248 wm2000
->anc_mode
= ANC_ACTIVE
;
253 static int wm2000_power_down(struct i2c_client
*i2c
, int analogue
)
255 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
260 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
261 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
262 WM2000_MODE_ANA_SEQ_INCLUDE
|
263 WM2000_MODE_POWER_DOWN
);
266 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
267 WM2000_MODE_POWER_DOWN
);
270 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
271 WM2000_STATUS_POWER_DOWN_COMPLETE
, timeout
)) {
272 dev_err(&i2c
->dev
, "Timeout waiting for ANC power down\n");
276 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
277 WM2000_ANC_ENG_IDLE
, 1)) {
278 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
282 dev_dbg(&i2c
->dev
, "powered off\n");
283 wm2000
->anc_mode
= ANC_OFF
;
288 static int wm2000_enter_bypass(struct i2c_client
*i2c
, int analogue
)
290 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
292 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
295 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
296 WM2000_MODE_ANA_SEQ_INCLUDE
|
297 WM2000_MODE_THERMAL_ENABLE
|
298 WM2000_MODE_BYPASS_ENTRY
);
300 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
301 WM2000_MODE_THERMAL_ENABLE
|
302 WM2000_MODE_BYPASS_ENTRY
);
305 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
306 WM2000_STATUS_ANC_DISABLED
, 10)) {
307 dev_err(&i2c
->dev
, "Timeout waiting for ANC disable\n");
311 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
312 WM2000_ANC_ENG_IDLE
, 1)) {
313 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
317 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
318 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
320 wm2000
->anc_mode
= ANC_BYPASS
;
321 dev_dbg(&i2c
->dev
, "bypass enabled\n");
326 static int wm2000_exit_bypass(struct i2c_client
*i2c
, int analogue
)
328 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
330 BUG_ON(wm2000
->anc_mode
!= ANC_BYPASS
);
332 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
335 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
336 WM2000_MODE_ANA_SEQ_INCLUDE
|
337 WM2000_MODE_MOUSE_ENABLE
|
338 WM2000_MODE_THERMAL_ENABLE
);
340 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
341 WM2000_MODE_MOUSE_ENABLE
|
342 WM2000_MODE_THERMAL_ENABLE
);
345 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
346 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
348 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
349 WM2000_STATUS_MOUSE_ACTIVE
, 10)) {
350 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE\n");
354 wm2000
->anc_mode
= ANC_ACTIVE
;
355 dev_dbg(&i2c
->dev
, "MOUSE active\n");
360 static int wm2000_enter_standby(struct i2c_client
*i2c
, int analogue
)
362 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
365 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
369 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
371 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
372 WM2000_MODE_ANA_SEQ_INCLUDE
|
373 WM2000_MODE_THERMAL_ENABLE
|
374 WM2000_MODE_STANDBY_ENTRY
);
378 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
379 WM2000_MODE_THERMAL_ENABLE
|
380 WM2000_MODE_STANDBY_ENTRY
);
383 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
384 WM2000_STATUS_ANC_DISABLED
, timeout
)) {
386 "Timed out waiting for ANC disable after 1ms\n");
390 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
, WM2000_ANC_ENG_IDLE
,
393 "Timed out waiting for standby after %dms\n",
398 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
399 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
401 wm2000
->anc_mode
= ANC_STANDBY
;
402 dev_dbg(&i2c
->dev
, "standby\n");
404 dev_dbg(&i2c
->dev
, "Analogue disabled\n");
409 static int wm2000_exit_standby(struct i2c_client
*i2c
, int analogue
)
411 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
414 BUG_ON(wm2000
->anc_mode
!= ANC_STANDBY
);
416 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
420 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
422 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
423 WM2000_MODE_ANA_SEQ_INCLUDE
|
424 WM2000_MODE_THERMAL_ENABLE
|
425 WM2000_MODE_MOUSE_ENABLE
);
429 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
430 WM2000_MODE_THERMAL_ENABLE
|
431 WM2000_MODE_MOUSE_ENABLE
);
434 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
435 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
437 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
438 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
439 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE after %dms\n",
444 wm2000
->anc_mode
= ANC_ACTIVE
;
445 dev_dbg(&i2c
->dev
, "MOUSE active\n");
447 dev_dbg(&i2c
->dev
, "Analogue enabled\n");
452 typedef int (*wm2000_mode_fn
)(struct i2c_client
*i2c
, int analogue
);
455 enum wm2000_anc_mode source
;
456 enum wm2000_anc_mode dest
;
458 wm2000_mode_fn step
[2];
459 } anc_transitions
[] = {
473 wm2000_enter_standby
,
486 .source
= ANC_ACTIVE
,
494 .source
= ANC_ACTIVE
,
498 wm2000_enter_standby
,
502 .source
= ANC_ACTIVE
,
510 .source
= ANC_BYPASS
,
518 .source
= ANC_BYPASS
,
523 wm2000_enter_standby
,
527 .source
= ANC_BYPASS
,
535 .source
= ANC_STANDBY
,
543 .source
= ANC_STANDBY
,
552 .source
= ANC_STANDBY
,
561 static int wm2000_anc_transition(struct wm2000_priv
*wm2000
,
562 enum wm2000_anc_mode mode
)
564 struct i2c_client
*i2c
= wm2000
->i2c
;
568 if (wm2000
->anc_mode
== mode
)
571 for (i
= 0; i
< ARRAY_SIZE(anc_transitions
); i
++)
572 if (anc_transitions
[i
].source
== wm2000
->anc_mode
&&
573 anc_transitions
[i
].dest
== mode
)
575 if (i
== ARRAY_SIZE(anc_transitions
)) {
576 dev_err(&i2c
->dev
, "No transition for %d->%d\n",
577 wm2000
->anc_mode
, mode
);
581 for (j
= 0; j
< ARRAY_SIZE(anc_transitions
[j
].step
); j
++) {
582 if (!anc_transitions
[i
].step
[j
])
584 ret
= anc_transitions
[i
].step
[j
](i2c
,
585 anc_transitions
[i
].analogue
);
593 static int wm2000_anc_set_mode(struct wm2000_priv
*wm2000
)
595 struct i2c_client
*i2c
= wm2000
->i2c
;
596 enum wm2000_anc_mode mode
;
598 if (wm2000
->anc_eng_ena
&& wm2000
->spk_ena
)
599 if (wm2000
->anc_active
)
606 dev_dbg(&i2c
->dev
, "Set mode %d (enabled %d, mute %d, active %d)\n",
607 mode
, wm2000
->anc_eng_ena
, !wm2000
->spk_ena
,
610 return wm2000_anc_transition(wm2000
, mode
);
613 static int wm2000_anc_mode_get(struct snd_kcontrol
*kcontrol
,
614 struct snd_ctl_elem_value
*ucontrol
)
616 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
618 ucontrol
->value
.enumerated
.item
[0] = wm2000
->anc_active
;
623 static int wm2000_anc_mode_put(struct snd_kcontrol
*kcontrol
,
624 struct snd_ctl_elem_value
*ucontrol
)
626 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
627 int anc_active
= ucontrol
->value
.enumerated
.item
[0];
632 wm2000
->anc_active
= anc_active
;
634 return wm2000_anc_set_mode(wm2000
);
637 static int wm2000_speaker_get(struct snd_kcontrol
*kcontrol
,
638 struct snd_ctl_elem_value
*ucontrol
)
640 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
642 ucontrol
->value
.enumerated
.item
[0] = wm2000
->spk_ena
;
647 static int wm2000_speaker_put(struct snd_kcontrol
*kcontrol
,
648 struct snd_ctl_elem_value
*ucontrol
)
650 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
651 int val
= ucontrol
->value
.enumerated
.item
[0];
656 wm2000
->spk_ena
= val
;
658 return wm2000_anc_set_mode(wm2000
);
661 static const struct snd_kcontrol_new wm2000_controls
[] = {
662 SOC_SINGLE_BOOL_EXT("WM2000 ANC Switch", 0,
664 wm2000_anc_mode_put
),
665 SOC_SINGLE_BOOL_EXT("WM2000 Switch", 0,
670 static int wm2000_anc_power_event(struct snd_soc_dapm_widget
*w
,
671 struct snd_kcontrol
*kcontrol
, int event
)
673 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
675 if (SND_SOC_DAPM_EVENT_ON(event
))
676 wm2000
->anc_eng_ena
= 1;
678 if (SND_SOC_DAPM_EVENT_OFF(event
))
679 wm2000
->anc_eng_ena
= 0;
681 return wm2000_anc_set_mode(wm2000
);
684 static const struct snd_soc_dapm_widget wm2000_dapm_widgets
[] = {
685 /* Externally visible pins */
686 SND_SOC_DAPM_OUTPUT("WM2000 SPKN"),
687 SND_SOC_DAPM_OUTPUT("WM2000 SPKP"),
689 SND_SOC_DAPM_INPUT("WM2000 LINN"),
690 SND_SOC_DAPM_INPUT("WM2000 LINP"),
692 SND_SOC_DAPM_PGA_E("ANC Engine", SND_SOC_NOPM
, 0, 0, NULL
, 0,
693 wm2000_anc_power_event
,
694 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
697 /* Target, Path, Source */
698 static const struct snd_soc_dapm_route audio_map
[] = {
699 { "WM2000 SPKN", NULL
, "ANC Engine" },
700 { "WM2000 SPKP", NULL
, "ANC Engine" },
701 { "ANC Engine", NULL
, "WM2000 LINN" },
702 { "ANC Engine", NULL
, "WM2000 LINP" },
705 /* Called from the machine driver */
706 int wm2000_add_controls(struct snd_soc_codec
*codec
)
711 pr_err("WM2000 not yet probed\n");
715 ret
= snd_soc_dapm_new_controls(codec
, wm2000_dapm_widgets
,
716 ARRAY_SIZE(wm2000_dapm_widgets
));
720 ret
= snd_soc_dapm_add_routes(codec
, 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;
800 wm2000_reset(wm2000
);
802 /* This will trigger a transition to standby mode by default */
803 wm2000_anc_set_mode(wm2000
);
810 release_firmware(fw
);
816 static __devexit
int wm2000_i2c_remove(struct i2c_client
*i2c
)
818 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
820 wm2000_anc_transition(wm2000
, ANC_OFF
);
823 kfree(wm2000
->anc_download
);
829 static void wm2000_i2c_shutdown(struct i2c_client
*i2c
)
831 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
833 wm2000_anc_transition(wm2000
, ANC_OFF
);
837 static int wm2000_i2c_suspend(struct i2c_client
*i2c
, pm_message_t mesg
)
839 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
841 return wm2000_anc_transition(wm2000
, ANC_OFF
);
844 static int wm2000_i2c_resume(struct i2c_client
*i2c
)
846 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
848 return wm2000_anc_set_mode(wm2000
);
851 #define wm2000_i2c_suspend NULL
852 #define wm2000_i2c_resume NULL
855 static const struct i2c_device_id wm2000_i2c_id
[] = {
859 MODULE_DEVICE_TABLE(i2c
, wm2000_i2c_id
);
861 static struct i2c_driver wm2000_i2c_driver
= {
864 .owner
= THIS_MODULE
,
866 .probe
= wm2000_i2c_probe
,
867 .remove
= __devexit_p(wm2000_i2c_remove
),
868 .suspend
= wm2000_i2c_suspend
,
869 .resume
= wm2000_i2c_resume
,
870 .shutdown
= wm2000_i2c_shutdown
,
871 .id_table
= wm2000_i2c_id
,
874 static int __init
wm2000_init(void)
876 return i2c_add_driver(&wm2000_i2c_driver
);
878 module_init(wm2000_init
);
880 static void __exit
wm2000_exit(void)
882 i2c_del_driver(&wm2000_i2c_driver
);
884 module_exit(wm2000_exit
);
886 MODULE_DESCRIPTION("ASoC WM2000 driver");
887 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfonmicro.com>");
888 MODULE_LICENSE("GPL");