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/version.h>
27 #include <linux/kernel.h>
28 #include <linux/init.h>
29 #include <linux/firmware.h>
30 #include <linux/delay.h>
32 #include <linux/i2c.h>
33 #include <linux/platform_device.h>
34 #include <linux/debugfs.h>
35 #include <linux/slab.h>
36 #include <sound/core.h>
37 #include <sound/pcm.h>
38 #include <sound/pcm_params.h>
39 #include <sound/soc.h>
40 #include <sound/soc-dapm.h>
41 #include <sound/initval.h>
42 #include <sound/tlv.h>
44 #include <sound/wm2000.h>
48 enum wm2000_anc_mode
{
56 struct i2c_client
*i2c
;
58 enum wm2000_anc_mode anc_mode
;
60 unsigned int anc_active
:1;
61 unsigned int anc_eng_ena
:1;
62 unsigned int spk_ena
:1;
64 unsigned int mclk_div
:1;
65 unsigned int speech_clarity
:1;
67 int anc_download_size
;
71 static struct i2c_client
*wm2000_i2c
;
73 static int wm2000_write(struct i2c_client
*i2c
, unsigned int reg
,
79 data
[0] = (reg
>> 8) & 0xff;
81 data
[2] = value
& 0xff;
83 dev_vdbg(&i2c
->dev
, "write %x = %x\n", reg
, value
);
85 ret
= i2c_master_send(i2c
, data
, 3);
94 static unsigned int wm2000_read(struct i2c_client
*i2c
, unsigned int r
)
96 struct i2c_msg xfer
[2];
102 reg
[0] = (r
>> 8) & 0xff;
104 xfer
[0].addr
= i2c
->addr
;
106 xfer
[0].len
= sizeof(reg
);
107 xfer
[0].buf
= ®
[0];
110 xfer
[1].addr
= i2c
->addr
;
111 xfer
[1].flags
= I2C_M_RD
;
115 ret
= i2c_transfer(i2c
->adapter
, xfer
, 2);
117 dev_err(&i2c
->dev
, "i2c_transfer() returned %d\n", ret
);
121 dev_vdbg(&i2c
->dev
, "read %x from %x\n", data
, r
);
126 static void wm2000_reset(struct wm2000_priv
*wm2000
)
128 struct i2c_client
*i2c
= wm2000
->i2c
;
130 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
131 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
132 wm2000_write(i2c
, WM2000_REG_ID1
, 0);
134 wm2000
->anc_mode
= ANC_OFF
;
137 static int wm2000_poll_bit(struct i2c_client
*i2c
,
138 unsigned int reg
, u8 mask
, int timeout
)
142 val
= wm2000_read(i2c
, reg
);
144 while (!(val
& mask
) && --timeout
) {
146 val
= wm2000_read(i2c
, reg
);
155 static int wm2000_power_up(struct i2c_client
*i2c
, int analogue
)
157 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
160 BUG_ON(wm2000
->anc_mode
!= ANC_OFF
);
162 dev_dbg(&i2c
->dev
, "Beginning power up\n");
164 if (!wm2000
->mclk_div
) {
165 dev_dbg(&i2c
->dev
, "Disabling MCLK divider\n");
166 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
167 WM2000_MCLK_DIV2_ENA_CLR
);
169 dev_dbg(&i2c
->dev
, "Enabling MCLK divider\n");
170 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
,
171 WM2000_MCLK_DIV2_ENA_SET
);
174 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_CLR
);
175 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_ENG_SET
);
177 /* Wait for ANC engine to become ready */
178 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
179 WM2000_ANC_ENG_IDLE
, 1)) {
180 dev_err(&i2c
->dev
, "ANC engine failed to reset\n");
184 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
185 WM2000_STATUS_BOOT_COMPLETE
, 1)) {
186 dev_err(&i2c
->dev
, "ANC engine failed to initialise\n");
190 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
192 /* Open code download of the data since it is the only bulk
194 dev_dbg(&i2c
->dev
, "Downloading %d bytes\n",
195 wm2000
->anc_download_size
- 2);
197 ret
= i2c_master_send(i2c
, wm2000
->anc_download
,
198 wm2000
->anc_download_size
);
200 dev_err(&i2c
->dev
, "i2c_transfer() failed: %d\n", ret
);
203 if (ret
!= wm2000
->anc_download_size
) {
204 dev_err(&i2c
->dev
, "i2c_transfer() failed, %d != %d\n",
205 ret
, wm2000
->anc_download_size
);
209 dev_dbg(&i2c
->dev
, "Download complete\n");
213 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
215 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
216 WM2000_MODE_ANA_SEQ_INCLUDE
|
217 WM2000_MODE_MOUSE_ENABLE
|
218 WM2000_MODE_THERMAL_ENABLE
);
222 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
223 WM2000_MODE_MOUSE_ENABLE
|
224 WM2000_MODE_THERMAL_ENABLE
);
227 ret
= wm2000_read(i2c
, WM2000_REG_SPEECH_CLARITY
);
228 if (wm2000
->speech_clarity
)
229 ret
&= ~WM2000_SPEECH_CLARITY
;
231 ret
|= WM2000_SPEECH_CLARITY
;
232 wm2000_write(i2c
, WM2000_REG_SPEECH_CLARITY
, ret
);
234 wm2000_write(i2c
, WM2000_REG_SYS_START0
, 0x33);
235 wm2000_write(i2c
, WM2000_REG_SYS_START1
, 0x02);
237 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
239 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
240 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
241 dev_err(&i2c
->dev
, "Timed out waiting for device after %dms\n",
246 dev_dbg(&i2c
->dev
, "ANC active\n");
248 dev_dbg(&i2c
->dev
, "Analogue active\n");
249 wm2000
->anc_mode
= ANC_ACTIVE
;
254 static int wm2000_power_down(struct i2c_client
*i2c
, int analogue
)
256 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
261 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
262 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
263 WM2000_MODE_ANA_SEQ_INCLUDE
|
264 WM2000_MODE_POWER_DOWN
);
267 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
268 WM2000_MODE_POWER_DOWN
);
271 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
272 WM2000_STATUS_POWER_DOWN_COMPLETE
, timeout
)) {
273 dev_err(&i2c
->dev
, "Timeout waiting for ANC power down\n");
277 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
278 WM2000_ANC_ENG_IDLE
, 1)) {
279 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
283 dev_dbg(&i2c
->dev
, "powered off\n");
284 wm2000
->anc_mode
= ANC_OFF
;
289 static int wm2000_enter_bypass(struct i2c_client
*i2c
, int analogue
)
291 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
293 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
296 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
297 WM2000_MODE_ANA_SEQ_INCLUDE
|
298 WM2000_MODE_THERMAL_ENABLE
|
299 WM2000_MODE_BYPASS_ENTRY
);
301 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
302 WM2000_MODE_THERMAL_ENABLE
|
303 WM2000_MODE_BYPASS_ENTRY
);
306 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
307 WM2000_STATUS_ANC_DISABLED
, 10)) {
308 dev_err(&i2c
->dev
, "Timeout waiting for ANC disable\n");
312 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
,
313 WM2000_ANC_ENG_IDLE
, 1)) {
314 dev_err(&i2c
->dev
, "Timeout waiting for ANC engine idle\n");
318 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
319 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
321 wm2000
->anc_mode
= ANC_BYPASS
;
322 dev_dbg(&i2c
->dev
, "bypass enabled\n");
327 static int wm2000_exit_bypass(struct i2c_client
*i2c
, int analogue
)
329 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
331 BUG_ON(wm2000
->anc_mode
!= ANC_BYPASS
);
333 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
336 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
337 WM2000_MODE_ANA_SEQ_INCLUDE
|
338 WM2000_MODE_MOUSE_ENABLE
|
339 WM2000_MODE_THERMAL_ENABLE
);
341 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
342 WM2000_MODE_MOUSE_ENABLE
|
343 WM2000_MODE_THERMAL_ENABLE
);
346 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
347 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
349 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
350 WM2000_STATUS_MOUSE_ACTIVE
, 10)) {
351 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE\n");
355 wm2000
->anc_mode
= ANC_ACTIVE
;
356 dev_dbg(&i2c
->dev
, "MOUSE active\n");
361 static int wm2000_enter_standby(struct i2c_client
*i2c
, int analogue
)
363 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
366 BUG_ON(wm2000
->anc_mode
!= ANC_ACTIVE
);
370 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PD_TIME
, timeout
/ 4);
372 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
373 WM2000_MODE_ANA_SEQ_INCLUDE
|
374 WM2000_MODE_THERMAL_ENABLE
|
375 WM2000_MODE_STANDBY_ENTRY
);
379 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
380 WM2000_MODE_THERMAL_ENABLE
|
381 WM2000_MODE_STANDBY_ENTRY
);
384 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
385 WM2000_STATUS_ANC_DISABLED
, timeout
)) {
387 "Timed out waiting for ANC disable after 1ms\n");
391 if (!wm2000_poll_bit(i2c
, WM2000_REG_ANC_STAT
, WM2000_ANC_ENG_IDLE
,
394 "Timed out waiting for standby after %dms\n",
399 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, WM2000_SYS_STBY
);
400 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_CLR
);
402 wm2000
->anc_mode
= ANC_STANDBY
;
403 dev_dbg(&i2c
->dev
, "standby\n");
405 dev_dbg(&i2c
->dev
, "Analogue disabled\n");
410 static int wm2000_exit_standby(struct i2c_client
*i2c
, int analogue
)
412 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
415 BUG_ON(wm2000
->anc_mode
!= ANC_STANDBY
);
417 wm2000_write(i2c
, WM2000_REG_SYS_CTL1
, 0);
421 wm2000_write(i2c
, WM2000_REG_ANA_VMID_PU_TIME
, timeout
/ 4);
423 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
424 WM2000_MODE_ANA_SEQ_INCLUDE
|
425 WM2000_MODE_THERMAL_ENABLE
|
426 WM2000_MODE_MOUSE_ENABLE
);
430 wm2000_write(i2c
, WM2000_REG_SYS_MODE_CNTRL
,
431 WM2000_MODE_THERMAL_ENABLE
|
432 WM2000_MODE_MOUSE_ENABLE
);
435 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_RAM_SET
);
436 wm2000_write(i2c
, WM2000_REG_SYS_CTL2
, WM2000_ANC_INT_N_CLR
);
438 if (!wm2000_poll_bit(i2c
, WM2000_REG_SYS_STATUS
,
439 WM2000_STATUS_MOUSE_ACTIVE
, timeout
)) {
440 dev_err(&i2c
->dev
, "Timed out waiting for MOUSE after %dms\n",
445 wm2000
->anc_mode
= ANC_ACTIVE
;
446 dev_dbg(&i2c
->dev
, "MOUSE active\n");
448 dev_dbg(&i2c
->dev
, "Analogue enabled\n");
453 typedef int (*wm2000_mode_fn
)(struct i2c_client
*i2c
, int analogue
);
456 enum wm2000_anc_mode source
;
457 enum wm2000_anc_mode dest
;
459 wm2000_mode_fn step
[2];
460 } anc_transitions
[] = {
474 wm2000_enter_standby
,
487 .source
= ANC_ACTIVE
,
495 .source
= ANC_ACTIVE
,
499 wm2000_enter_standby
,
503 .source
= ANC_ACTIVE
,
511 .source
= ANC_BYPASS
,
519 .source
= ANC_BYPASS
,
524 wm2000_enter_standby
,
528 .source
= ANC_BYPASS
,
536 .source
= ANC_STANDBY
,
544 .source
= ANC_STANDBY
,
553 .source
= ANC_STANDBY
,
562 static int wm2000_anc_transition(struct wm2000_priv
*wm2000
,
563 enum wm2000_anc_mode mode
)
565 struct i2c_client
*i2c
= wm2000
->i2c
;
569 if (wm2000
->anc_mode
== mode
)
572 for (i
= 0; i
< ARRAY_SIZE(anc_transitions
); i
++)
573 if (anc_transitions
[i
].source
== wm2000
->anc_mode
&&
574 anc_transitions
[i
].dest
== mode
)
576 if (i
== ARRAY_SIZE(anc_transitions
)) {
577 dev_err(&i2c
->dev
, "No transition for %d->%d\n",
578 wm2000
->anc_mode
, mode
);
582 for (j
= 0; j
< ARRAY_SIZE(anc_transitions
[j
].step
); j
++) {
583 if (!anc_transitions
[i
].step
[j
])
585 ret
= anc_transitions
[i
].step
[j
](i2c
,
586 anc_transitions
[i
].analogue
);
594 static int wm2000_anc_set_mode(struct wm2000_priv
*wm2000
)
596 struct i2c_client
*i2c
= wm2000
->i2c
;
597 enum wm2000_anc_mode mode
;
599 if (wm2000
->anc_eng_ena
&& wm2000
->spk_ena
)
600 if (wm2000
->anc_active
)
607 dev_dbg(&i2c
->dev
, "Set mode %d (enabled %d, mute %d, active %d)\n",
608 mode
, wm2000
->anc_eng_ena
, !wm2000
->spk_ena
,
611 return wm2000_anc_transition(wm2000
, mode
);
614 static int wm2000_anc_mode_get(struct snd_kcontrol
*kcontrol
,
615 struct snd_ctl_elem_value
*ucontrol
)
617 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
619 ucontrol
->value
.enumerated
.item
[0] = wm2000
->anc_active
;
624 static int wm2000_anc_mode_put(struct snd_kcontrol
*kcontrol
,
625 struct snd_ctl_elem_value
*ucontrol
)
627 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
628 int anc_active
= ucontrol
->value
.enumerated
.item
[0];
633 wm2000
->anc_active
= anc_active
;
635 return wm2000_anc_set_mode(wm2000
);
638 static int wm2000_speaker_get(struct snd_kcontrol
*kcontrol
,
639 struct snd_ctl_elem_value
*ucontrol
)
641 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
643 ucontrol
->value
.enumerated
.item
[0] = wm2000
->spk_ena
;
648 static int wm2000_speaker_put(struct snd_kcontrol
*kcontrol
,
649 struct snd_ctl_elem_value
*ucontrol
)
651 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
652 int val
= ucontrol
->value
.enumerated
.item
[0];
657 wm2000
->spk_ena
= val
;
659 return wm2000_anc_set_mode(wm2000
);
662 static const struct snd_kcontrol_new wm2000_controls
[] = {
663 SOC_SINGLE_BOOL_EXT("WM2000 ANC Switch", 0,
665 wm2000_anc_mode_put
),
666 SOC_SINGLE_BOOL_EXT("WM2000 Switch", 0,
671 static int wm2000_anc_power_event(struct snd_soc_dapm_widget
*w
,
672 struct snd_kcontrol
*kcontrol
, int event
)
674 struct wm2000_priv
*wm2000
= dev_get_drvdata(&wm2000_i2c
->dev
);
676 if (SND_SOC_DAPM_EVENT_ON(event
))
677 wm2000
->anc_eng_ena
= 1;
679 if (SND_SOC_DAPM_EVENT_OFF(event
))
680 wm2000
->anc_eng_ena
= 0;
682 return wm2000_anc_set_mode(wm2000
);
685 static const struct snd_soc_dapm_widget wm2000_dapm_widgets
[] = {
686 /* Externally visible pins */
687 SND_SOC_DAPM_OUTPUT("WM2000 SPKN"),
688 SND_SOC_DAPM_OUTPUT("WM2000 SPKP"),
690 SND_SOC_DAPM_INPUT("WM2000 LINN"),
691 SND_SOC_DAPM_INPUT("WM2000 LINP"),
693 SND_SOC_DAPM_PGA_E("ANC Engine", SND_SOC_NOPM
, 0, 0, NULL
, 0,
694 wm2000_anc_power_event
,
695 SND_SOC_DAPM_POST_PMU
| SND_SOC_DAPM_PRE_PMD
),
698 /* Target, Path, Source */
699 static const struct snd_soc_dapm_route audio_map
[] = {
700 { "WM2000 SPKN", NULL
, "ANC Engine" },
701 { "WM2000 SPKP", NULL
, "ANC Engine" },
702 { "ANC Engine", NULL
, "WM2000 LINN" },
703 { "ANC Engine", NULL
, "WM2000 LINP" },
706 /* Called from the machine driver */
707 int wm2000_add_controls(struct snd_soc_codec
*codec
)
712 pr_err("WM2000 not yet probed\n");
716 ret
= snd_soc_dapm_new_controls(codec
, wm2000_dapm_widgets
,
717 ARRAY_SIZE(wm2000_dapm_widgets
));
721 ret
= snd_soc_dapm_add_routes(codec
, audio_map
, ARRAY_SIZE(audio_map
));
725 return snd_soc_add_controls(codec
, wm2000_controls
,
726 ARRAY_SIZE(wm2000_controls
));
728 EXPORT_SYMBOL_GPL(wm2000_add_controls
);
730 static int __devinit
wm2000_i2c_probe(struct i2c_client
*i2c
,
731 const struct i2c_device_id
*i2c_id
)
733 struct wm2000_priv
*wm2000
;
734 struct wm2000_platform_data
*pdata
;
735 const char *filename
;
736 const struct firmware
*fw
;
741 dev_err(&i2c
->dev
, "Another WM2000 is already registered\n");
745 wm2000
= kzalloc(sizeof(struct wm2000_priv
), GFP_KERNEL
);
746 if (wm2000
== NULL
) {
747 dev_err(&i2c
->dev
, "Unable to allocate private data\n");
751 /* Verify that this is a WM2000 */
752 reg
= wm2000_read(i2c
, WM2000_REG_ID1
);
754 reg
= wm2000_read(i2c
, WM2000_REG_ID2
);
758 dev_err(&i2c
->dev
, "Device is not a WM2000 - ID %x\n", id
);
763 reg
= wm2000_read(i2c
, WM2000_REG_REVISON
);
764 dev_info(&i2c
->dev
, "revision %c\n", reg
+ 'A');
766 filename
= "wm2000_anc.bin";
767 pdata
= dev_get_platdata(&i2c
->dev
);
769 wm2000
->mclk_div
= pdata
->mclkdiv2
;
770 wm2000
->speech_clarity
= !pdata
->speech_enh_disable
;
772 if (pdata
->download_file
)
773 filename
= pdata
->download_file
;
776 ret
= request_firmware(&fw
, filename
, &i2c
->dev
);
778 dev_err(&i2c
->dev
, "Failed to acquire ANC data: %d\n", ret
);
782 /* Pre-cook the concatenation of the register address onto the image */
783 wm2000
->anc_download_size
= fw
->size
+ 2;
784 wm2000
->anc_download
= kmalloc(wm2000
->anc_download_size
, GFP_KERNEL
);
785 if (wm2000
->anc_download
== NULL
) {
786 dev_err(&i2c
->dev
, "Out of memory\n");
791 wm2000
->anc_download
[0] = 0x80;
792 wm2000
->anc_download
[1] = 0x00;
793 memcpy(wm2000
->anc_download
+ 2, fw
->data
, fw
->size
);
795 release_firmware(fw
);
797 dev_set_drvdata(&i2c
->dev
, wm2000
);
798 wm2000
->anc_eng_ena
= 1;
801 wm2000_reset(wm2000
);
803 /* This will trigger a transition to standby mode by default */
804 wm2000_anc_set_mode(wm2000
);
811 release_firmware(fw
);
817 static __devexit
int wm2000_i2c_remove(struct i2c_client
*i2c
)
819 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
821 wm2000_anc_transition(wm2000
, ANC_OFF
);
824 kfree(wm2000
->anc_download
);
830 static void wm2000_i2c_shutdown(struct i2c_client
*i2c
)
832 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
834 wm2000_anc_transition(wm2000
, ANC_OFF
);
838 static int wm2000_i2c_suspend(struct i2c_client
*i2c
, pm_message_t mesg
)
840 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
842 return wm2000_anc_transition(wm2000
, ANC_OFF
);
845 static int wm2000_i2c_resume(struct i2c_client
*i2c
)
847 struct wm2000_priv
*wm2000
= dev_get_drvdata(&i2c
->dev
);
849 return wm2000_anc_set_mode(wm2000
);
852 #define wm2000_i2c_suspend NULL
853 #define wm2000_i2c_resume NULL
856 static const struct i2c_device_id wm2000_i2c_id
[] = {
860 MODULE_DEVICE_TABLE(i2c
, wm2000_i2c_id
);
862 static struct i2c_driver wm2000_i2c_driver
= {
865 .owner
= THIS_MODULE
,
867 .probe
= wm2000_i2c_probe
,
868 .remove
= __devexit_p(wm2000_i2c_remove
),
869 .suspend
= wm2000_i2c_suspend
,
870 .resume
= wm2000_i2c_resume
,
871 .shutdown
= wm2000_i2c_shutdown
,
872 .id_table
= wm2000_i2c_id
,
875 static int __init
wm2000_init(void)
877 return i2c_add_driver(&wm2000_i2c_driver
);
879 module_init(wm2000_init
);
881 static void __exit
wm2000_exit(void)
883 i2c_del_driver(&wm2000_i2c_driver
);
885 module_exit(wm2000_exit
);
887 MODULE_DESCRIPTION("ASoC WM2000 driver");
888 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfonmicro.com>");
889 MODULE_LICENSE("GPL");