2 * wm9081.c -- WM9081 ALSA SoC Audio driver
6 * Copyright 2009-12 Wolfson Microelectronics plc
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.
14 #include <linux/module.h>
15 #include <linux/moduleparam.h>
16 #include <linux/init.h>
17 #include <linux/delay.h>
18 #include <linux/device.h>
20 #include <linux/i2c.h>
21 #include <linux/regmap.h>
22 #include <linux/slab.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/soc.h>
27 #include <sound/initval.h>
28 #include <sound/tlv.h>
30 #include <sound/wm9081.h>
33 static struct reg_default wm9081_reg
[] = {
34 { 2, 0x00B9 }, /* R2 - Analogue Lineout */
35 { 3, 0x00B9 }, /* R3 - Analogue Speaker PGA */
36 { 4, 0x0001 }, /* R4 - VMID Control */
37 { 5, 0x0068 }, /* R5 - Bias Control 1 */
38 { 7, 0x0000 }, /* R7 - Analogue Mixer */
39 { 8, 0x0000 }, /* R8 - Anti Pop Control */
40 { 9, 0x01DB }, /* R9 - Analogue Speaker 1 */
41 { 10, 0x0018 }, /* R10 - Analogue Speaker 2 */
42 { 11, 0x0180 }, /* R11 - Power Management */
43 { 12, 0x0000 }, /* R12 - Clock Control 1 */
44 { 13, 0x0038 }, /* R13 - Clock Control 2 */
45 { 14, 0x4000 }, /* R14 - Clock Control 3 */
46 { 16, 0x0000 }, /* R16 - FLL Control 1 */
47 { 17, 0x0200 }, /* R17 - FLL Control 2 */
48 { 18, 0x0000 }, /* R18 - FLL Control 3 */
49 { 19, 0x0204 }, /* R19 - FLL Control 4 */
50 { 20, 0x0000 }, /* R20 - FLL Control 5 */
51 { 22, 0x0000 }, /* R22 - Audio Interface 1 */
52 { 23, 0x0002 }, /* R23 - Audio Interface 2 */
53 { 24, 0x0008 }, /* R24 - Audio Interface 3 */
54 { 25, 0x0022 }, /* R25 - Audio Interface 4 */
55 { 27, 0x0006 }, /* R27 - Interrupt Status Mask */
56 { 28, 0x0000 }, /* R28 - Interrupt Polarity */
57 { 29, 0x0000 }, /* R29 - Interrupt Control */
58 { 30, 0x00C0 }, /* R30 - DAC Digital 1 */
59 { 31, 0x0008 }, /* R31 - DAC Digital 2 */
60 { 32, 0x09AF }, /* R32 - DRC 1 */
61 { 33, 0x4201 }, /* R33 - DRC 2 */
62 { 34, 0x0000 }, /* R34 - DRC 3 */
63 { 35, 0x0000 }, /* R35 - DRC 4 */
64 { 38, 0x0000 }, /* R38 - Write Sequencer 1 */
65 { 39, 0x0000 }, /* R39 - Write Sequencer 2 */
66 { 40, 0x0002 }, /* R40 - MW Slave 1 */
67 { 42, 0x0000 }, /* R42 - EQ 1 */
68 { 43, 0x0000 }, /* R43 - EQ 2 */
69 { 44, 0x0FCA }, /* R44 - EQ 3 */
70 { 45, 0x0400 }, /* R45 - EQ 4 */
71 { 46, 0x00B8 }, /* R46 - EQ 5 */
72 { 47, 0x1EB5 }, /* R47 - EQ 6 */
73 { 48, 0xF145 }, /* R48 - EQ 7 */
74 { 49, 0x0B75 }, /* R49 - EQ 8 */
75 { 50, 0x01C5 }, /* R50 - EQ 9 */
76 { 51, 0x169E }, /* R51 - EQ 10 */
77 { 52, 0xF829 }, /* R52 - EQ 11 */
78 { 53, 0x07AD }, /* R53 - EQ 12 */
79 { 54, 0x1103 }, /* R54 - EQ 13 */
80 { 55, 0x1C58 }, /* R55 - EQ 14 */
81 { 56, 0xF373 }, /* R56 - EQ 15 */
82 { 57, 0x0A54 }, /* R57 - EQ 16 */
83 { 58, 0x0558 }, /* R58 - EQ 17 */
84 { 59, 0x0564 }, /* R59 - EQ 18 */
85 { 60, 0x0559 }, /* R60 - EQ 19 */
86 { 61, 0x4000 }, /* R61 - EQ 20 */
123 int div
; /* *10 due to .5s */
150 struct regmap
*regmap
;
160 struct wm9081_pdata pdata
;
163 static bool wm9081_volatile_register(struct device
*dev
, unsigned int reg
)
166 case WM9081_SOFTWARE_RESET
:
167 case WM9081_INTERRUPT_STATUS
:
174 static bool wm9081_readable_register(struct device
*dev
, unsigned int reg
)
177 case WM9081_SOFTWARE_RESET
:
178 case WM9081_ANALOGUE_LINEOUT
:
179 case WM9081_ANALOGUE_SPEAKER_PGA
:
180 case WM9081_VMID_CONTROL
:
181 case WM9081_BIAS_CONTROL_1
:
182 case WM9081_ANALOGUE_MIXER
:
183 case WM9081_ANTI_POP_CONTROL
:
184 case WM9081_ANALOGUE_SPEAKER_1
:
185 case WM9081_ANALOGUE_SPEAKER_2
:
186 case WM9081_POWER_MANAGEMENT
:
187 case WM9081_CLOCK_CONTROL_1
:
188 case WM9081_CLOCK_CONTROL_2
:
189 case WM9081_CLOCK_CONTROL_3
:
190 case WM9081_FLL_CONTROL_1
:
191 case WM9081_FLL_CONTROL_2
:
192 case WM9081_FLL_CONTROL_3
:
193 case WM9081_FLL_CONTROL_4
:
194 case WM9081_FLL_CONTROL_5
:
195 case WM9081_AUDIO_INTERFACE_1
:
196 case WM9081_AUDIO_INTERFACE_2
:
197 case WM9081_AUDIO_INTERFACE_3
:
198 case WM9081_AUDIO_INTERFACE_4
:
199 case WM9081_INTERRUPT_STATUS
:
200 case WM9081_INTERRUPT_STATUS_MASK
:
201 case WM9081_INTERRUPT_POLARITY
:
202 case WM9081_INTERRUPT_CONTROL
:
203 case WM9081_DAC_DIGITAL_1
:
204 case WM9081_DAC_DIGITAL_2
:
209 case WM9081_WRITE_SEQUENCER_1
:
210 case WM9081_WRITE_SEQUENCER_2
:
211 case WM9081_MW_SLAVE_1
:
238 static int wm9081_reset(struct regmap
*map
)
240 return regmap_write(map
, WM9081_SOFTWARE_RESET
, 0x9081);
243 static const DECLARE_TLV_DB_SCALE(drc_in_tlv
, -4500, 75, 0);
244 static const DECLARE_TLV_DB_SCALE(drc_out_tlv
, -2250, 75, 0);
245 static const DECLARE_TLV_DB_SCALE(drc_min_tlv
, -1800, 600, 0);
246 static unsigned int drc_max_tlv
[] = {
247 TLV_DB_RANGE_HEAD(4),
248 0, 0, TLV_DB_SCALE_ITEM(1200, 0, 0),
249 1, 1, TLV_DB_SCALE_ITEM(1800, 0, 0),
250 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
251 3, 3, TLV_DB_SCALE_ITEM(3600, 0, 0),
253 static const DECLARE_TLV_DB_SCALE(drc_qr_tlv
, 1200, 600, 0);
254 static const DECLARE_TLV_DB_SCALE(drc_startup_tlv
, -300, 50, 0);
256 static const DECLARE_TLV_DB_SCALE(eq_tlv
, -1200, 100, 0);
258 static const DECLARE_TLV_DB_SCALE(in_tlv
, -600, 600, 0);
259 static const DECLARE_TLV_DB_SCALE(dac_tlv
, -7200, 75, 1);
260 static const DECLARE_TLV_DB_SCALE(out_tlv
, -5700, 100, 0);
262 static const char *drc_high_text
[] = {
271 static const struct soc_enum drc_high
=
272 SOC_ENUM_SINGLE(WM9081_DRC_3
, 3, 6, drc_high_text
);
274 static const char *drc_low_text
[] = {
282 static const struct soc_enum drc_low
=
283 SOC_ENUM_SINGLE(WM9081_DRC_3
, 0, 5, drc_low_text
);
285 static const char *drc_atk_text
[] = {
300 static const struct soc_enum drc_atk
=
301 SOC_ENUM_SINGLE(WM9081_DRC_2
, 12, 12, drc_atk_text
);
303 static const char *drc_dcy_text
[] = {
315 static const struct soc_enum drc_dcy
=
316 SOC_ENUM_SINGLE(WM9081_DRC_2
, 8, 9, drc_dcy_text
);
318 static const char *drc_qr_dcy_text
[] = {
324 static const struct soc_enum drc_qr_dcy
=
325 SOC_ENUM_SINGLE(WM9081_DRC_2
, 4, 3, drc_qr_dcy_text
);
327 static const char *dac_deemph_text
[] = {
334 static const struct soc_enum dac_deemph
=
335 SOC_ENUM_SINGLE(WM9081_DAC_DIGITAL_2
, 1, 4, dac_deemph_text
);
337 static const char *speaker_mode_text
[] = {
342 static const struct soc_enum speaker_mode
=
343 SOC_ENUM_SINGLE(WM9081_ANALOGUE_SPEAKER_2
, 6, 2, speaker_mode_text
);
345 static int speaker_mode_get(struct snd_kcontrol
*kcontrol
,
346 struct snd_ctl_elem_value
*ucontrol
)
348 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
351 reg
= snd_soc_read(codec
, WM9081_ANALOGUE_SPEAKER_2
);
352 if (reg
& WM9081_SPK_MODE
)
353 ucontrol
->value
.integer
.value
[0] = 1;
355 ucontrol
->value
.integer
.value
[0] = 0;
361 * Stop any attempts to change speaker mode while the speaker is enabled.
363 * We also have some special anti-pop controls dependent on speaker
364 * mode which must be changed along with the mode.
366 static int speaker_mode_put(struct snd_kcontrol
*kcontrol
,
367 struct snd_ctl_elem_value
*ucontrol
)
369 struct snd_soc_codec
*codec
= snd_kcontrol_chip(kcontrol
);
370 unsigned int reg_pwr
= snd_soc_read(codec
, WM9081_POWER_MANAGEMENT
);
371 unsigned int reg2
= snd_soc_read(codec
, WM9081_ANALOGUE_SPEAKER_2
);
373 /* Are we changing anything? */
374 if (ucontrol
->value
.integer
.value
[0] ==
375 ((reg2
& WM9081_SPK_MODE
) != 0))
378 /* Don't try to change modes while enabled */
379 if (reg_pwr
& WM9081_SPK_ENA
)
382 if (ucontrol
->value
.integer
.value
[0]) {
384 reg2
&= ~(WM9081_SPK_INV_MUTE
| WM9081_OUT_SPK_CTRL
);
385 reg2
|= WM9081_SPK_MODE
;
388 reg2
|= WM9081_SPK_INV_MUTE
| WM9081_OUT_SPK_CTRL
;
389 reg2
&= ~WM9081_SPK_MODE
;
392 snd_soc_write(codec
, WM9081_ANALOGUE_SPEAKER_2
, reg2
);
397 static const struct snd_kcontrol_new wm9081_snd_controls
[] = {
398 SOC_SINGLE_TLV("IN1 Volume", WM9081_ANALOGUE_MIXER
, 1, 1, 1, in_tlv
),
399 SOC_SINGLE_TLV("IN2 Volume", WM9081_ANALOGUE_MIXER
, 3, 1, 1, in_tlv
),
401 SOC_SINGLE_TLV("Playback Volume", WM9081_DAC_DIGITAL_1
, 1, 96, 0, dac_tlv
),
403 SOC_SINGLE("LINEOUT Switch", WM9081_ANALOGUE_LINEOUT
, 7, 1, 1),
404 SOC_SINGLE("LINEOUT ZC Switch", WM9081_ANALOGUE_LINEOUT
, 6, 1, 0),
405 SOC_SINGLE_TLV("LINEOUT Volume", WM9081_ANALOGUE_LINEOUT
, 0, 63, 0, out_tlv
),
407 SOC_SINGLE("DRC Switch", WM9081_DRC_1
, 15, 1, 0),
408 SOC_ENUM("DRC High Slope", drc_high
),
409 SOC_ENUM("DRC Low Slope", drc_low
),
410 SOC_SINGLE_TLV("DRC Input Volume", WM9081_DRC_4
, 5, 60, 1, drc_in_tlv
),
411 SOC_SINGLE_TLV("DRC Output Volume", WM9081_DRC_4
, 0, 30, 1, drc_out_tlv
),
412 SOC_SINGLE_TLV("DRC Minimum Volume", WM9081_DRC_2
, 2, 3, 1, drc_min_tlv
),
413 SOC_SINGLE_TLV("DRC Maximum Volume", WM9081_DRC_2
, 0, 3, 0, drc_max_tlv
),
414 SOC_ENUM("DRC Attack", drc_atk
),
415 SOC_ENUM("DRC Decay", drc_dcy
),
416 SOC_SINGLE("DRC Quick Release Switch", WM9081_DRC_1
, 2, 1, 0),
417 SOC_SINGLE_TLV("DRC Quick Release Volume", WM9081_DRC_2
, 6, 3, 0, drc_qr_tlv
),
418 SOC_ENUM("DRC Quick Release Decay", drc_qr_dcy
),
419 SOC_SINGLE_TLV("DRC Startup Volume", WM9081_DRC_1
, 6, 18, 0, drc_startup_tlv
),
421 SOC_SINGLE("EQ Switch", WM9081_EQ_1
, 0, 1, 0),
423 SOC_SINGLE("Speaker DC Volume", WM9081_ANALOGUE_SPEAKER_1
, 3, 5, 0),
424 SOC_SINGLE("Speaker AC Volume", WM9081_ANALOGUE_SPEAKER_1
, 0, 5, 0),
425 SOC_SINGLE("Speaker Switch", WM9081_ANALOGUE_SPEAKER_PGA
, 7, 1, 1),
426 SOC_SINGLE("Speaker ZC Switch", WM9081_ANALOGUE_SPEAKER_PGA
, 6, 1, 0),
427 SOC_SINGLE_TLV("Speaker Volume", WM9081_ANALOGUE_SPEAKER_PGA
, 0, 63, 0,
429 SOC_ENUM("DAC Deemphasis", dac_deemph
),
430 SOC_ENUM_EXT("Speaker Mode", speaker_mode
, speaker_mode_get
, speaker_mode_put
),
433 static const struct snd_kcontrol_new wm9081_eq_controls
[] = {
434 SOC_SINGLE_TLV("EQ1 Volume", WM9081_EQ_1
, 11, 24, 0, eq_tlv
),
435 SOC_SINGLE_TLV("EQ2 Volume", WM9081_EQ_1
, 6, 24, 0, eq_tlv
),
436 SOC_SINGLE_TLV("EQ3 Volume", WM9081_EQ_1
, 1, 24, 0, eq_tlv
),
437 SOC_SINGLE_TLV("EQ4 Volume", WM9081_EQ_2
, 11, 24, 0, eq_tlv
),
438 SOC_SINGLE_TLV("EQ5 Volume", WM9081_EQ_2
, 6, 24, 0, eq_tlv
),
441 static const struct snd_kcontrol_new mixer
[] = {
442 SOC_DAPM_SINGLE("IN1 Switch", WM9081_ANALOGUE_MIXER
, 0, 1, 0),
443 SOC_DAPM_SINGLE("IN2 Switch", WM9081_ANALOGUE_MIXER
, 2, 1, 0),
444 SOC_DAPM_SINGLE("Playback Switch", WM9081_ANALOGUE_MIXER
, 4, 1, 0),
455 /* The size in bits of the FLL divide multiplied by 10
456 * to allow rounding later */
457 #define FIXED_FLL_SIZE ((1 << 16) * 10)
466 { 64000, 128000, 3, 8 },
467 { 128000, 256000, 2, 4 },
468 { 256000, 1000000, 1, 2 },
469 { 1000000, 13500000, 0, 1 },
472 static int fll_factors(struct _fll_div
*fll_div
, unsigned int Fref
,
476 unsigned int K
, Ndiv
, Nmod
, target
;
480 /* Fref must be <=13.5MHz */
482 while ((Fref
/ div
) > 13500000) {
486 pr_err("Can't scale %dMHz input down to <=13.5MHz\n",
491 fll_div
->fll_clk_ref_div
= div
/ 2;
493 pr_debug("Fref=%u Fout=%u\n", Fref
, Fout
);
495 /* Apply the division for our remaining calculations */
498 /* Fvco should be 90-100MHz; don't check the upper bound */
501 while (target
< 90000000) {
505 pr_err("Unable to find FLL_OUTDIV for Fout=%uHz\n",
510 fll_div
->fll_outdiv
= div
;
512 pr_debug("Fvco=%dHz\n", target
);
514 /* Find an appropriate FLL_FRATIO and factor it out of the target */
515 for (i
= 0; i
< ARRAY_SIZE(fll_fratios
); i
++) {
516 if (fll_fratios
[i
].min
<= Fref
&& Fref
<= fll_fratios
[i
].max
) {
517 fll_div
->fll_fratio
= fll_fratios
[i
].fll_fratio
;
518 target
/= fll_fratios
[i
].ratio
;
522 if (i
== ARRAY_SIZE(fll_fratios
)) {
523 pr_err("Unable to find FLL_FRATIO for Fref=%uHz\n", Fref
);
527 /* Now, calculate N.K */
528 Ndiv
= target
/ Fref
;
531 Nmod
= target
% Fref
;
532 pr_debug("Nmod=%d\n", Nmod
);
534 /* Calculate fractional part - scale up so we can round. */
535 Kpart
= FIXED_FLL_SIZE
* (long long)Nmod
;
539 K
= Kpart
& 0xFFFFFFFF;
544 /* Move down to proper range now rounding is done */
547 pr_debug("N=%x K=%x FLL_FRATIO=%x FLL_OUTDIV=%x FLL_CLK_REF_DIV=%x\n",
548 fll_div
->n
, fll_div
->k
,
549 fll_div
->fll_fratio
, fll_div
->fll_outdiv
,
550 fll_div
->fll_clk_ref_div
);
555 static int wm9081_set_fll(struct snd_soc_codec
*codec
, int fll_id
,
556 unsigned int Fref
, unsigned int Fout
)
558 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
559 u16 reg1
, reg4
, reg5
;
560 struct _fll_div fll_div
;
565 if (Fref
== wm9081
->fll_fref
&& Fout
== wm9081
->fll_fout
)
568 /* Disable the FLL */
570 dev_dbg(codec
->dev
, "FLL disabled\n");
571 wm9081
->fll_fref
= 0;
572 wm9081
->fll_fout
= 0;
577 ret
= fll_factors(&fll_div
, Fref
, Fout
);
581 reg5
= snd_soc_read(codec
, WM9081_FLL_CONTROL_5
);
582 reg5
&= ~WM9081_FLL_CLK_SRC_MASK
;
585 case WM9081_SYSCLK_FLL_MCLK
:
590 dev_err(codec
->dev
, "Unknown FLL ID %d\n", fll_id
);
594 /* Disable CLK_SYS while we reconfigure */
595 clk_sys_reg
= snd_soc_read(codec
, WM9081_CLOCK_CONTROL_3
);
596 if (clk_sys_reg
& WM9081_CLK_SYS_ENA
)
597 snd_soc_write(codec
, WM9081_CLOCK_CONTROL_3
,
598 clk_sys_reg
& ~WM9081_CLK_SYS_ENA
);
600 /* Any FLL configuration change requires that the FLL be
602 reg1
= snd_soc_read(codec
, WM9081_FLL_CONTROL_1
);
603 reg1
&= ~WM9081_FLL_ENA
;
604 snd_soc_write(codec
, WM9081_FLL_CONTROL_1
, reg1
);
606 /* Apply the configuration */
608 reg1
|= WM9081_FLL_FRAC_MASK
;
610 reg1
&= ~WM9081_FLL_FRAC_MASK
;
611 snd_soc_write(codec
, WM9081_FLL_CONTROL_1
, reg1
);
613 snd_soc_write(codec
, WM9081_FLL_CONTROL_2
,
614 (fll_div
.fll_outdiv
<< WM9081_FLL_OUTDIV_SHIFT
) |
615 (fll_div
.fll_fratio
<< WM9081_FLL_FRATIO_SHIFT
));
616 snd_soc_write(codec
, WM9081_FLL_CONTROL_3
, fll_div
.k
);
618 reg4
= snd_soc_read(codec
, WM9081_FLL_CONTROL_4
);
619 reg4
&= ~WM9081_FLL_N_MASK
;
620 reg4
|= fll_div
.n
<< WM9081_FLL_N_SHIFT
;
621 snd_soc_write(codec
, WM9081_FLL_CONTROL_4
, reg4
);
623 reg5
&= ~WM9081_FLL_CLK_REF_DIV_MASK
;
624 reg5
|= fll_div
.fll_clk_ref_div
<< WM9081_FLL_CLK_REF_DIV_SHIFT
;
625 snd_soc_write(codec
, WM9081_FLL_CONTROL_5
, reg5
);
627 /* Set gain to the recommended value */
628 snd_soc_update_bits(codec
, WM9081_FLL_CONTROL_4
,
629 WM9081_FLL_GAIN_MASK
, 0);
632 snd_soc_write(codec
, WM9081_FLL_CONTROL_1
, reg1
| WM9081_FLL_ENA
);
634 /* Then bring CLK_SYS up again if it was disabled */
635 if (clk_sys_reg
& WM9081_CLK_SYS_ENA
)
636 snd_soc_write(codec
, WM9081_CLOCK_CONTROL_3
, clk_sys_reg
);
638 dev_dbg(codec
->dev
, "FLL enabled at %dHz->%dHz\n", Fref
, Fout
);
640 wm9081
->fll_fref
= Fref
;
641 wm9081
->fll_fout
= Fout
;
646 static int configure_clock(struct snd_soc_codec
*codec
)
648 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
649 int new_sysclk
, i
, target
;
655 switch (wm9081
->sysclk_source
) {
656 case WM9081_SYSCLK_MCLK
:
657 if (wm9081
->mclk_rate
> 12225000) {
659 wm9081
->sysclk_rate
= wm9081
->mclk_rate
/ 2;
661 wm9081
->sysclk_rate
= wm9081
->mclk_rate
;
663 wm9081_set_fll(codec
, WM9081_SYSCLK_FLL_MCLK
, 0, 0);
666 case WM9081_SYSCLK_FLL_MCLK
:
667 /* If we have a sample rate calculate a CLK_SYS that
668 * gives us a suitable DAC configuration, plus BCLK.
669 * Ideally we would check to see if we can clock
670 * directly from MCLK and only use the FLL if this is
671 * not the case, though care must be taken with free
674 if (wm9081
->master
&& wm9081
->bclk
) {
675 /* Make sure we can generate CLK_SYS and BCLK
676 * and that we've got 3MHz for optimal
678 for (i
= 0; i
< ARRAY_SIZE(clk_sys_rates
); i
++) {
679 target
= wm9081
->fs
* clk_sys_rates
[i
].ratio
;
681 if (target
>= wm9081
->bclk
&&
686 if (i
== ARRAY_SIZE(clk_sys_rates
))
689 } else if (wm9081
->fs
) {
690 for (i
= 0; i
< ARRAY_SIZE(clk_sys_rates
); i
++) {
691 new_sysclk
= clk_sys_rates
[i
].ratio
693 if (new_sysclk
> 3000000)
697 if (i
== ARRAY_SIZE(clk_sys_rates
))
701 new_sysclk
= 12288000;
704 ret
= wm9081_set_fll(codec
, WM9081_SYSCLK_FLL_MCLK
,
705 wm9081
->mclk_rate
, new_sysclk
);
707 wm9081
->sysclk_rate
= new_sysclk
;
709 /* Switch SYSCLK over to FLL */
712 wm9081
->sysclk_rate
= wm9081
->mclk_rate
;
720 reg
= snd_soc_read(codec
, WM9081_CLOCK_CONTROL_1
);
722 reg
|= WM9081_MCLKDIV2
;
724 reg
&= ~WM9081_MCLKDIV2
;
725 snd_soc_write(codec
, WM9081_CLOCK_CONTROL_1
, reg
);
727 reg
= snd_soc_read(codec
, WM9081_CLOCK_CONTROL_3
);
729 reg
|= WM9081_CLK_SRC_SEL
;
731 reg
&= ~WM9081_CLK_SRC_SEL
;
732 snd_soc_write(codec
, WM9081_CLOCK_CONTROL_3
, reg
);
734 dev_dbg(codec
->dev
, "CLK_SYS is %dHz\n", wm9081
->sysclk_rate
);
739 static int clk_sys_event(struct snd_soc_dapm_widget
*w
,
740 struct snd_kcontrol
*kcontrol
, int event
)
742 struct snd_soc_codec
*codec
= w
->codec
;
743 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
745 /* This should be done on init() for bypass paths */
746 switch (wm9081
->sysclk_source
) {
747 case WM9081_SYSCLK_MCLK
:
748 dev_dbg(codec
->dev
, "Using %dHz MCLK\n", wm9081
->mclk_rate
);
750 case WM9081_SYSCLK_FLL_MCLK
:
751 dev_dbg(codec
->dev
, "Using %dHz MCLK with FLL\n",
755 dev_err(codec
->dev
, "System clock not configured\n");
760 case SND_SOC_DAPM_PRE_PMU
:
761 configure_clock(codec
);
764 case SND_SOC_DAPM_POST_PMD
:
765 /* Disable the FLL if it's running */
766 wm9081_set_fll(codec
, 0, 0, 0);
773 static const struct snd_soc_dapm_widget wm9081_dapm_widgets
[] = {
774 SND_SOC_DAPM_INPUT("IN1"),
775 SND_SOC_DAPM_INPUT("IN2"),
777 SND_SOC_DAPM_DAC("DAC", NULL
, WM9081_POWER_MANAGEMENT
, 0, 0),
779 SND_SOC_DAPM_MIXER_NAMED_CTL("Mixer", SND_SOC_NOPM
, 0, 0,
780 mixer
, ARRAY_SIZE(mixer
)),
782 SND_SOC_DAPM_PGA("LINEOUT PGA", WM9081_POWER_MANAGEMENT
, 4, 0, NULL
, 0),
784 SND_SOC_DAPM_PGA("Speaker PGA", WM9081_POWER_MANAGEMENT
, 2, 0, NULL
, 0),
785 SND_SOC_DAPM_OUT_DRV("Speaker", WM9081_POWER_MANAGEMENT
, 1, 0, NULL
, 0),
787 SND_SOC_DAPM_OUTPUT("LINEOUT"),
788 SND_SOC_DAPM_OUTPUT("SPKN"),
789 SND_SOC_DAPM_OUTPUT("SPKP"),
791 SND_SOC_DAPM_SUPPLY("CLK_SYS", WM9081_CLOCK_CONTROL_3
, 0, 0, clk_sys_event
,
792 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
793 SND_SOC_DAPM_SUPPLY("CLK_DSP", WM9081_CLOCK_CONTROL_3
, 1, 0, NULL
, 0),
794 SND_SOC_DAPM_SUPPLY("TOCLK", WM9081_CLOCK_CONTROL_3
, 2, 0, NULL
, 0),
795 SND_SOC_DAPM_SUPPLY("TSENSE", WM9081_POWER_MANAGEMENT
, 7, 0, NULL
, 0),
799 static const struct snd_soc_dapm_route wm9081_audio_paths
[] = {
800 { "DAC", NULL
, "CLK_SYS" },
801 { "DAC", NULL
, "CLK_DSP" },
802 { "DAC", NULL
, "AIF" },
804 { "Mixer", "IN1 Switch", "IN1" },
805 { "Mixer", "IN2 Switch", "IN2" },
806 { "Mixer", "Playback Switch", "DAC" },
808 { "LINEOUT PGA", NULL
, "Mixer" },
809 { "LINEOUT PGA", NULL
, "TOCLK" },
810 { "LINEOUT PGA", NULL
, "CLK_SYS" },
812 { "LINEOUT", NULL
, "LINEOUT PGA" },
814 { "Speaker PGA", NULL
, "Mixer" },
815 { "Speaker PGA", NULL
, "TOCLK" },
816 { "Speaker PGA", NULL
, "CLK_SYS" },
818 { "Speaker", NULL
, "Speaker PGA" },
819 { "Speaker", NULL
, "TSENSE" },
821 { "SPKN", NULL
, "Speaker" },
822 { "SPKP", NULL
, "Speaker" },
825 static int wm9081_set_bias_level(struct snd_soc_codec
*codec
,
826 enum snd_soc_bias_level level
)
828 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
831 case SND_SOC_BIAS_ON
:
834 case SND_SOC_BIAS_PREPARE
:
836 snd_soc_update_bits(codec
, WM9081_VMID_CONTROL
,
837 WM9081_VMID_SEL_MASK
, 0x2);
839 /* Normal bias current */
840 snd_soc_update_bits(codec
, WM9081_BIAS_CONTROL_1
,
841 WM9081_STBY_BIAS_ENA
, 0);
844 case SND_SOC_BIAS_STANDBY
:
845 /* Initial cold start */
846 if (codec
->dapm
.bias_level
== SND_SOC_BIAS_OFF
) {
847 regcache_cache_only(wm9081
->regmap
, false);
848 regcache_sync(wm9081
->regmap
);
850 /* Disable LINEOUT discharge */
851 snd_soc_update_bits(codec
, WM9081_ANTI_POP_CONTROL
,
852 WM9081_LINEOUT_DISCH
, 0);
854 /* Select startup bias source */
855 snd_soc_update_bits(codec
, WM9081_BIAS_CONTROL_1
,
856 WM9081_BIAS_SRC
| WM9081_BIAS_ENA
,
857 WM9081_BIAS_SRC
| WM9081_BIAS_ENA
);
859 /* VMID 2*4k; Soft VMID ramp enable */
860 snd_soc_update_bits(codec
, WM9081_VMID_CONTROL
,
862 WM9081_VMID_SEL_MASK
,
863 WM9081_VMID_RAMP
| 0x6);
867 /* Normal bias enable & soft start off */
868 snd_soc_update_bits(codec
, WM9081_VMID_CONTROL
,
869 WM9081_VMID_RAMP
, 0);
871 /* Standard bias source */
872 snd_soc_update_bits(codec
, WM9081_BIAS_CONTROL_1
,
877 snd_soc_update_bits(codec
, WM9081_VMID_CONTROL
,
878 WM9081_VMID_SEL_MASK
, 0x04);
880 /* Standby bias current on */
881 snd_soc_update_bits(codec
, WM9081_BIAS_CONTROL_1
,
882 WM9081_STBY_BIAS_ENA
,
883 WM9081_STBY_BIAS_ENA
);
886 case SND_SOC_BIAS_OFF
:
887 /* Startup bias source and disable bias */
888 snd_soc_update_bits(codec
, WM9081_BIAS_CONTROL_1
,
889 WM9081_BIAS_SRC
| WM9081_BIAS_ENA
,
892 /* Disable VMID with soft ramping */
893 snd_soc_update_bits(codec
, WM9081_VMID_CONTROL
,
894 WM9081_VMID_RAMP
| WM9081_VMID_SEL_MASK
,
897 /* Actively discharge LINEOUT */
898 snd_soc_update_bits(codec
, WM9081_ANTI_POP_CONTROL
,
899 WM9081_LINEOUT_DISCH
,
900 WM9081_LINEOUT_DISCH
);
902 regcache_cache_only(wm9081
->regmap
, true);
906 codec
->dapm
.bias_level
= level
;
911 static int wm9081_set_dai_fmt(struct snd_soc_dai
*dai
,
914 struct snd_soc_codec
*codec
= dai
->codec
;
915 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
916 unsigned int aif2
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_2
);
918 aif2
&= ~(WM9081_AIF_BCLK_INV
| WM9081_AIF_LRCLK_INV
|
919 WM9081_BCLK_DIR
| WM9081_LRCLK_DIR
| WM9081_AIF_FMT_MASK
);
921 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
922 case SND_SOC_DAIFMT_CBS_CFS
:
925 case SND_SOC_DAIFMT_CBS_CFM
:
926 aif2
|= WM9081_LRCLK_DIR
;
929 case SND_SOC_DAIFMT_CBM_CFS
:
930 aif2
|= WM9081_BCLK_DIR
;
933 case SND_SOC_DAIFMT_CBM_CFM
:
934 aif2
|= WM9081_LRCLK_DIR
| WM9081_BCLK_DIR
;
941 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
942 case SND_SOC_DAIFMT_DSP_B
:
943 aif2
|= WM9081_AIF_LRCLK_INV
;
944 case SND_SOC_DAIFMT_DSP_A
:
947 case SND_SOC_DAIFMT_I2S
:
950 case SND_SOC_DAIFMT_RIGHT_J
:
952 case SND_SOC_DAIFMT_LEFT_J
:
959 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
960 case SND_SOC_DAIFMT_DSP_A
:
961 case SND_SOC_DAIFMT_DSP_B
:
962 /* frame inversion not valid for DSP modes */
963 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
964 case SND_SOC_DAIFMT_NB_NF
:
966 case SND_SOC_DAIFMT_IB_NF
:
967 aif2
|= WM9081_AIF_BCLK_INV
;
974 case SND_SOC_DAIFMT_I2S
:
975 case SND_SOC_DAIFMT_RIGHT_J
:
976 case SND_SOC_DAIFMT_LEFT_J
:
977 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
978 case SND_SOC_DAIFMT_NB_NF
:
980 case SND_SOC_DAIFMT_IB_IF
:
981 aif2
|= WM9081_AIF_BCLK_INV
| WM9081_AIF_LRCLK_INV
;
983 case SND_SOC_DAIFMT_IB_NF
:
984 aif2
|= WM9081_AIF_BCLK_INV
;
986 case SND_SOC_DAIFMT_NB_IF
:
987 aif2
|= WM9081_AIF_LRCLK_INV
;
997 snd_soc_write(codec
, WM9081_AUDIO_INTERFACE_2
, aif2
);
1002 static int wm9081_hw_params(struct snd_pcm_substream
*substream
,
1003 struct snd_pcm_hw_params
*params
,
1004 struct snd_soc_dai
*dai
)
1006 struct snd_soc_codec
*codec
= dai
->codec
;
1007 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
1008 int ret
, i
, best
, best_val
, cur_val
;
1009 unsigned int clk_ctrl2
, aif1
, aif2
, aif3
, aif4
;
1011 clk_ctrl2
= snd_soc_read(codec
, WM9081_CLOCK_CONTROL_2
);
1012 clk_ctrl2
&= ~(WM9081_CLK_SYS_RATE_MASK
| WM9081_SAMPLE_RATE_MASK
);
1014 aif1
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_1
);
1016 aif2
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_2
);
1017 aif2
&= ~WM9081_AIF_WL_MASK
;
1019 aif3
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_3
);
1020 aif3
&= ~WM9081_BCLK_DIV_MASK
;
1022 aif4
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_4
);
1023 aif4
&= ~WM9081_LRCLK_RATE_MASK
;
1025 wm9081
->fs
= params_rate(params
);
1027 if (wm9081
->tdm_width
) {
1028 /* If TDM is set up then that fixes our BCLK. */
1029 int slots
= ((aif1
& WM9081_AIFDAC_TDM_MODE_MASK
) >>
1030 WM9081_AIFDAC_TDM_MODE_SHIFT
) + 1;
1032 wm9081
->bclk
= wm9081
->fs
* wm9081
->tdm_width
* slots
;
1034 /* Otherwise work out a BCLK from the sample size */
1035 wm9081
->bclk
= 2 * wm9081
->fs
;
1037 switch (params_format(params
)) {
1038 case SNDRV_PCM_FORMAT_S16_LE
:
1041 case SNDRV_PCM_FORMAT_S20_3LE
:
1045 case SNDRV_PCM_FORMAT_S24_LE
:
1049 case SNDRV_PCM_FORMAT_S32_LE
:
1058 dev_dbg(codec
->dev
, "Target BCLK is %dHz\n", wm9081
->bclk
);
1060 ret
= configure_clock(codec
);
1064 /* Select nearest CLK_SYS_RATE */
1066 best_val
= abs((wm9081
->sysclk_rate
/ clk_sys_rates
[0].ratio
)
1068 for (i
= 1; i
< ARRAY_SIZE(clk_sys_rates
); i
++) {
1069 cur_val
= abs((wm9081
->sysclk_rate
/
1070 clk_sys_rates
[i
].ratio
) - wm9081
->fs
);
1071 if (cur_val
< best_val
) {
1076 dev_dbg(codec
->dev
, "Selected CLK_SYS_RATIO of %d\n",
1077 clk_sys_rates
[best
].ratio
);
1078 clk_ctrl2
|= (clk_sys_rates
[best
].clk_sys_rate
1079 << WM9081_CLK_SYS_RATE_SHIFT
);
1083 best_val
= abs(wm9081
->fs
- sample_rates
[0].rate
);
1084 for (i
= 1; i
< ARRAY_SIZE(sample_rates
); i
++) {
1086 cur_val
= abs(wm9081
->fs
- sample_rates
[i
].rate
);
1087 if (cur_val
< best_val
) {
1092 dev_dbg(codec
->dev
, "Selected SAMPLE_RATE of %dHz\n",
1093 sample_rates
[best
].rate
);
1094 clk_ctrl2
|= (sample_rates
[best
].sample_rate
1095 << WM9081_SAMPLE_RATE_SHIFT
);
1100 for (i
= 0; i
< ARRAY_SIZE(bclk_divs
); i
++) {
1101 cur_val
= ((wm9081
->sysclk_rate
* 10) / bclk_divs
[i
].div
)
1103 if (cur_val
< 0) /* Table is sorted */
1105 if (cur_val
< best_val
) {
1110 wm9081
->bclk
= (wm9081
->sysclk_rate
* 10) / bclk_divs
[best
].div
;
1111 dev_dbg(codec
->dev
, "Selected BCLK_DIV of %d for %dHz BCLK\n",
1112 bclk_divs
[best
].div
, wm9081
->bclk
);
1113 aif3
|= bclk_divs
[best
].bclk_div
;
1115 /* LRCLK is a simple fraction of BCLK */
1116 dev_dbg(codec
->dev
, "LRCLK_RATE is %d\n", wm9081
->bclk
/ wm9081
->fs
);
1117 aif4
|= wm9081
->bclk
/ wm9081
->fs
;
1119 /* Apply a ReTune Mobile configuration if it's in use */
1120 if (wm9081
->pdata
.num_retune_configs
) {
1121 struct wm9081_pdata
*pdata
= &wm9081
->pdata
;
1122 struct wm9081_retune_mobile_setting
*s
;
1126 best_val
= abs(pdata
->retune_configs
[0].rate
- wm9081
->fs
);
1127 for (i
= 0; i
< pdata
->num_retune_configs
; i
++) {
1128 cur_val
= abs(pdata
->retune_configs
[i
].rate
-
1130 if (cur_val
< best_val
) {
1135 s
= &pdata
->retune_configs
[best
];
1137 dev_dbg(codec
->dev
, "ReTune Mobile %s tuned for %dHz\n",
1140 /* If the EQ is enabled then disable it while we write out */
1141 eq1
= snd_soc_read(codec
, WM9081_EQ_1
) & WM9081_EQ_ENA
;
1142 if (eq1
& WM9081_EQ_ENA
)
1143 snd_soc_write(codec
, WM9081_EQ_1
, 0);
1145 /* Write out the other values */
1146 for (i
= 1; i
< ARRAY_SIZE(s
->config
); i
++)
1147 snd_soc_write(codec
, WM9081_EQ_1
+ i
, s
->config
[i
]);
1149 eq1
|= (s
->config
[0] & ~WM9081_EQ_ENA
);
1150 snd_soc_write(codec
, WM9081_EQ_1
, eq1
);
1153 snd_soc_write(codec
, WM9081_CLOCK_CONTROL_2
, clk_ctrl2
);
1154 snd_soc_write(codec
, WM9081_AUDIO_INTERFACE_2
, aif2
);
1155 snd_soc_write(codec
, WM9081_AUDIO_INTERFACE_3
, aif3
);
1156 snd_soc_write(codec
, WM9081_AUDIO_INTERFACE_4
, aif4
);
1161 static int wm9081_digital_mute(struct snd_soc_dai
*codec_dai
, int mute
)
1163 struct snd_soc_codec
*codec
= codec_dai
->codec
;
1166 reg
= snd_soc_read(codec
, WM9081_DAC_DIGITAL_2
);
1169 reg
|= WM9081_DAC_MUTE
;
1171 reg
&= ~WM9081_DAC_MUTE
;
1173 snd_soc_write(codec
, WM9081_DAC_DIGITAL_2
, reg
);
1178 static int wm9081_set_sysclk(struct snd_soc_codec
*codec
, int clk_id
,
1179 int source
, unsigned int freq
, int dir
)
1181 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
1184 case WM9081_SYSCLK_MCLK
:
1185 case WM9081_SYSCLK_FLL_MCLK
:
1186 wm9081
->sysclk_source
= clk_id
;
1187 wm9081
->mclk_rate
= freq
;
1197 static int wm9081_set_tdm_slot(struct snd_soc_dai
*dai
,
1198 unsigned int tx_mask
, unsigned int rx_mask
, int slots
, int slot_width
)
1200 struct snd_soc_codec
*codec
= dai
->codec
;
1201 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
1202 unsigned int aif1
= snd_soc_read(codec
, WM9081_AUDIO_INTERFACE_1
);
1204 aif1
&= ~(WM9081_AIFDAC_TDM_SLOT_MASK
| WM9081_AIFDAC_TDM_MODE_MASK
);
1206 if (slots
< 0 || slots
> 4)
1209 wm9081
->tdm_width
= slot_width
;
1214 aif1
|= (slots
- 1) << WM9081_AIFDAC_TDM_MODE_SHIFT
;
1232 snd_soc_write(codec
, WM9081_AUDIO_INTERFACE_1
, aif1
);
1237 #define WM9081_RATES SNDRV_PCM_RATE_8000_96000
1239 #define WM9081_FORMATS \
1240 (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
1241 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
1243 static const struct snd_soc_dai_ops wm9081_dai_ops
= {
1244 .hw_params
= wm9081_hw_params
,
1245 .set_fmt
= wm9081_set_dai_fmt
,
1246 .digital_mute
= wm9081_digital_mute
,
1247 .set_tdm_slot
= wm9081_set_tdm_slot
,
1250 /* We report two channels because the CODEC processes a stereo signal, even
1251 * though it is only capable of handling a mono output.
1253 static struct snd_soc_dai_driver wm9081_dai
= {
1254 .name
= "wm9081-hifi",
1256 .stream_name
= "AIF",
1259 .rates
= WM9081_RATES
,
1260 .formats
= WM9081_FORMATS
,
1262 .ops
= &wm9081_dai_ops
,
1265 static int wm9081_probe(struct snd_soc_codec
*codec
)
1267 struct wm9081_priv
*wm9081
= snd_soc_codec_get_drvdata(codec
);
1270 codec
->control_data
= wm9081
->regmap
;
1272 ret
= snd_soc_codec_set_cache_io(codec
, 8, 16, SND_SOC_REGMAP
);
1274 dev_err(codec
->dev
, "Failed to set cache I/O: %d\n", ret
);
1278 /* Enable zero cross by default */
1279 snd_soc_update_bits(codec
, WM9081_ANALOGUE_LINEOUT
,
1280 WM9081_LINEOUTZC
, WM9081_LINEOUTZC
);
1281 snd_soc_update_bits(codec
, WM9081_ANALOGUE_SPEAKER_PGA
,
1282 WM9081_SPKPGAZC
, WM9081_SPKPGAZC
);
1284 if (!wm9081
->pdata
.num_retune_configs
) {
1286 "No ReTune Mobile data, using normal EQ\n");
1287 snd_soc_add_codec_controls(codec
, wm9081_eq_controls
,
1288 ARRAY_SIZE(wm9081_eq_controls
));
1294 static int wm9081_remove(struct snd_soc_codec
*codec
)
1296 wm9081_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
1300 static struct snd_soc_codec_driver soc_codec_dev_wm9081
= {
1301 .probe
= wm9081_probe
,
1302 .remove
= wm9081_remove
,
1304 .set_sysclk
= wm9081_set_sysclk
,
1305 .set_bias_level
= wm9081_set_bias_level
,
1307 .idle_bias_off
= true,
1309 .controls
= wm9081_snd_controls
,
1310 .num_controls
= ARRAY_SIZE(wm9081_snd_controls
),
1311 .dapm_widgets
= wm9081_dapm_widgets
,
1312 .num_dapm_widgets
= ARRAY_SIZE(wm9081_dapm_widgets
),
1313 .dapm_routes
= wm9081_audio_paths
,
1314 .num_dapm_routes
= ARRAY_SIZE(wm9081_audio_paths
),
1317 static const struct regmap_config wm9081_regmap
= {
1321 .max_register
= WM9081_MAX_REGISTER
,
1322 .reg_defaults
= wm9081_reg
,
1323 .num_reg_defaults
= ARRAY_SIZE(wm9081_reg
),
1324 .volatile_reg
= wm9081_volatile_register
,
1325 .readable_reg
= wm9081_readable_register
,
1326 .cache_type
= REGCACHE_RBTREE
,
1329 #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE)
1330 static __devinit
int wm9081_i2c_probe(struct i2c_client
*i2c
,
1331 const struct i2c_device_id
*id
)
1333 struct wm9081_priv
*wm9081
;
1337 wm9081
= devm_kzalloc(&i2c
->dev
, sizeof(struct wm9081_priv
),
1342 i2c_set_clientdata(i2c
, wm9081
);
1344 wm9081
->regmap
= regmap_init_i2c(i2c
, &wm9081_regmap
);
1345 if (IS_ERR(wm9081
->regmap
)) {
1346 ret
= PTR_ERR(wm9081
->regmap
);
1347 dev_err(&i2c
->dev
, "regmap_init() failed: %d\n", ret
);
1351 ret
= regmap_read(wm9081
->regmap
, WM9081_SOFTWARE_RESET
, ®
);
1353 dev_err(&i2c
->dev
, "Failed to read chip ID: %d\n", ret
);
1356 if (reg
!= 0x9081) {
1357 dev_err(&i2c
->dev
, "Device is not a WM9081: ID=0x%x\n", reg
);
1362 ret
= wm9081_reset(wm9081
->regmap
);
1364 dev_err(&i2c
->dev
, "Failed to issue reset\n");
1368 if (dev_get_platdata(&i2c
->dev
))
1369 memcpy(&wm9081
->pdata
, dev_get_platdata(&i2c
->dev
),
1370 sizeof(wm9081
->pdata
));
1373 if (wm9081
->pdata
.irq_high
)
1374 reg
|= WM9081_IRQ_POL
;
1375 if (!wm9081
->pdata
.irq_cmos
)
1376 reg
|= WM9081_IRQ_OP_CTRL
;
1377 regmap_update_bits(wm9081
->regmap
, WM9081_INTERRUPT_CONTROL
,
1378 WM9081_IRQ_POL
| WM9081_IRQ_OP_CTRL
, reg
);
1380 regcache_cache_only(wm9081
->regmap
, true);
1382 ret
= snd_soc_register_codec(&i2c
->dev
,
1383 &soc_codec_dev_wm9081
, &wm9081_dai
, 1);
1390 regmap_exit(wm9081
->regmap
);
1396 static __devexit
int wm9081_i2c_remove(struct i2c_client
*client
)
1398 struct wm9081_priv
*wm9081
= i2c_get_clientdata(client
);
1400 snd_soc_unregister_codec(&client
->dev
);
1401 regmap_exit(wm9081
->regmap
);
1405 static const struct i2c_device_id wm9081_i2c_id
[] = {
1409 MODULE_DEVICE_TABLE(i2c
, wm9081_i2c_id
);
1411 static struct i2c_driver wm9081_i2c_driver
= {
1414 .owner
= THIS_MODULE
,
1416 .probe
= wm9081_i2c_probe
,
1417 .remove
= __devexit_p(wm9081_i2c_remove
),
1418 .id_table
= wm9081_i2c_id
,
1422 module_i2c_driver(wm9081_i2c_driver
);
1424 MODULE_DESCRIPTION("ASoC WM9081 driver");
1425 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
1426 MODULE_LICENSE("GPL");