2 * wm5100.c -- WM5100 ALSA SoC Audio driver
4 * Copyright 2011 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.
13 #include <linux/module.h>
14 #include <linux/moduleparam.h>
15 #include <linux/init.h>
16 #include <linux/delay.h>
18 #include <linux/gcd.h>
19 #include <linux/gpio.h>
20 #include <linux/i2c.h>
21 #include <linux/platform_device.h>
22 #include <linux/regulator/consumer.h>
23 #include <linux/regulator/fixed.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/jack.h>
30 #include <sound/initval.h>
31 #include <sound/tlv.h>
32 #include <sound/wm5100.h>
36 #define WM5100_NUM_CORE_SUPPLIES 2
37 static const char *wm5100_core_supply_names
[WM5100_NUM_CORE_SUPPLIES
] = {
39 "LDOVDD", /* If DCVDD is supplied externally specify as LDOVDD */
43 #define WM5100_SYNC_SRS 3
49 struct completion lock
;
52 /* codec private data */
54 struct snd_soc_codec
*codec
;
56 struct regulator_bulk_data core_supplies
[WM5100_NUM_CORE_SUPPLIES
];
57 struct regulator
*cpvdd
;
58 struct regulator
*dbvdd2
;
59 struct regulator
*dbvdd3
;
66 bool aif_async
[WM5100_AIFS
];
67 bool aif_symmetric
[WM5100_AIFS
];
68 int sr_ref
[WM5100_SYNC_SRS
];
72 struct snd_soc_jack
*jack
;
77 struct wm5100_fll fll
[2];
79 struct wm5100_pdata pdata
;
82 struct gpio_chip gpio_chip
;
86 static int wm5100_sr_code
[] = {
113 static int wm5100_sr_regs
[WM5100_SYNC_SRS
] = {
119 static int wm5100_alloc_sr(struct snd_soc_codec
*codec
, int rate
)
121 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
122 int sr_code
, sr_free
, i
;
124 for (i
= 0; i
< ARRAY_SIZE(wm5100_sr_code
); i
++)
125 if (wm5100_sr_code
[i
] == rate
)
127 if (i
== ARRAY_SIZE(wm5100_sr_code
)) {
128 dev_err(codec
->dev
, "Unsupported sample rate: %dHz\n", rate
);
133 if ((wm5100
->sysclk
% rate
) == 0) {
134 /* Is this rate already in use? */
136 for (i
= 0; i
< ARRAY_SIZE(wm5100_sr_regs
); i
++) {
137 if (!wm5100
->sr_ref
[i
] && sr_free
== -1) {
141 if ((snd_soc_read(codec
, wm5100_sr_regs
[i
]) &
142 WM5100_SAMPLE_RATE_1_MASK
) == sr_code
)
146 if (i
< ARRAY_SIZE(wm5100_sr_regs
)) {
148 dev_dbg(codec
->dev
, "SR %dHz, slot %d, ref %d\n",
149 rate
, i
, wm5100
->sr_ref
[i
]);
154 dev_err(codec
->dev
, "All SR slots already in use\n");
158 dev_dbg(codec
->dev
, "Allocating SR slot %d for %dHz\n",
160 wm5100
->sr_ref
[sr_free
]++;
161 snd_soc_update_bits(codec
, wm5100_sr_regs
[sr_free
],
162 WM5100_SAMPLE_RATE_1_MASK
,
169 "SR %dHz incompatible with %dHz SYSCLK and %dHz ASYNCCLK\n",
170 rate
, wm5100
->sysclk
, wm5100
->asyncclk
);
175 static void wm5100_free_sr(struct snd_soc_codec
*codec
, int rate
)
177 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
180 for (i
= 0; i
< ARRAY_SIZE(wm5100_sr_code
); i
++)
181 if (wm5100_sr_code
[i
] == rate
)
183 if (i
== ARRAY_SIZE(wm5100_sr_code
)) {
184 dev_err(codec
->dev
, "Unsupported sample rate: %dHz\n", rate
);
187 sr_code
= wm5100_sr_code
[i
];
189 for (i
= 0; i
< ARRAY_SIZE(wm5100_sr_regs
); i
++) {
190 if (!wm5100
->sr_ref
[i
])
193 if ((snd_soc_read(codec
, wm5100_sr_regs
[i
]) &
194 WM5100_SAMPLE_RATE_1_MASK
) == sr_code
)
197 if (i
< ARRAY_SIZE(wm5100_sr_regs
)) {
199 dev_dbg(codec
->dev
, "Dereference SR %dHz, count now %d\n",
200 rate
, wm5100
->sr_ref
[i
]);
202 dev_warn(codec
->dev
, "Freeing unreferenced sample rate %dHz\n",
207 static int wm5100_reset(struct snd_soc_codec
*codec
)
209 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
211 if (wm5100
->pdata
.reset
) {
212 gpio_set_value_cansleep(wm5100
->pdata
.reset
, 0);
213 gpio_set_value_cansleep(wm5100
->pdata
.reset
, 1);
217 return snd_soc_write(codec
, WM5100_SOFTWARE_RESET
, 0);
221 static DECLARE_TLV_DB_SCALE(in_tlv
, -6300, 100, 0);
222 static DECLARE_TLV_DB_SCALE(eq_tlv
, -1200, 100, 0);
223 static DECLARE_TLV_DB_SCALE(mixer_tlv
, -3200, 100, 0);
224 static DECLARE_TLV_DB_SCALE(out_tlv
, -6400, 100, 0);
225 static DECLARE_TLV_DB_SCALE(digital_tlv
, -6400, 50, 0);
227 static const char *wm5100_mixer_texts
[] = {
302 static int wm5100_mixer_values
[] = {
325 0x30, /* AIF3 - check */
360 0xa0, /* ISRC1DEC1 */
364 0xa4, /* ISRC1INT1 */
368 0xa8, /* ISRC2DEC1 */
372 0xac, /* ISRC2INT1 */
378 #define WM5100_MIXER_CONTROLS(name, base) \
379 SOC_SINGLE_TLV(name " Input 1 Volume", base + 1 , \
380 WM5100_MIXER_VOL_SHIFT, 80, 0, mixer_tlv), \
381 SOC_SINGLE_TLV(name " Input 2 Volume", base + 3 , \
382 WM5100_MIXER_VOL_SHIFT, 80, 0, mixer_tlv), \
383 SOC_SINGLE_TLV(name " Input 3 Volume", base + 5 , \
384 WM5100_MIXER_VOL_SHIFT, 80, 0, mixer_tlv), \
385 SOC_SINGLE_TLV(name " Input 4 Volume", base + 7 , \
386 WM5100_MIXER_VOL_SHIFT, 80, 0, mixer_tlv)
388 #define WM5100_MUX_ENUM_DECL(name, reg) \
389 SOC_VALUE_ENUM_SINGLE_DECL(name, reg, 0, 0xff, \
390 wm5100_mixer_texts, wm5100_mixer_values)
392 #define WM5100_MUX_CTL_DECL(name) \
393 const struct snd_kcontrol_new name##_mux = \
394 SOC_DAPM_VALUE_ENUM("Route", name##_enum)
396 #define WM5100_MIXER_ENUMS(name, base_reg) \
397 static WM5100_MUX_ENUM_DECL(name##_in1_enum, base_reg); \
398 static WM5100_MUX_ENUM_DECL(name##_in2_enum, base_reg + 2); \
399 static WM5100_MUX_ENUM_DECL(name##_in3_enum, base_reg + 4); \
400 static WM5100_MUX_ENUM_DECL(name##_in4_enum, base_reg + 6); \
401 static WM5100_MUX_CTL_DECL(name##_in1); \
402 static WM5100_MUX_CTL_DECL(name##_in2); \
403 static WM5100_MUX_CTL_DECL(name##_in3); \
404 static WM5100_MUX_CTL_DECL(name##_in4)
406 WM5100_MIXER_ENUMS(HPOUT1L
, WM5100_OUT1LMIX_INPUT_1_SOURCE
);
407 WM5100_MIXER_ENUMS(HPOUT1R
, WM5100_OUT1RMIX_INPUT_1_SOURCE
);
408 WM5100_MIXER_ENUMS(HPOUT2L
, WM5100_OUT2LMIX_INPUT_1_SOURCE
);
409 WM5100_MIXER_ENUMS(HPOUT2R
, WM5100_OUT2RMIX_INPUT_1_SOURCE
);
410 WM5100_MIXER_ENUMS(HPOUT3L
, WM5100_OUT3LMIX_INPUT_1_SOURCE
);
411 WM5100_MIXER_ENUMS(HPOUT3R
, WM5100_OUT3RMIX_INPUT_1_SOURCE
);
413 WM5100_MIXER_ENUMS(SPKOUTL
, WM5100_OUT4LMIX_INPUT_1_SOURCE
);
414 WM5100_MIXER_ENUMS(SPKOUTR
, WM5100_OUT4RMIX_INPUT_1_SOURCE
);
415 WM5100_MIXER_ENUMS(SPKDAT1L
, WM5100_OUT5LMIX_INPUT_1_SOURCE
);
416 WM5100_MIXER_ENUMS(SPKDAT1R
, WM5100_OUT5RMIX_INPUT_1_SOURCE
);
417 WM5100_MIXER_ENUMS(SPKDAT2L
, WM5100_OUT6LMIX_INPUT_1_SOURCE
);
418 WM5100_MIXER_ENUMS(SPKDAT2R
, WM5100_OUT6RMIX_INPUT_1_SOURCE
);
420 WM5100_MIXER_ENUMS(PWM1
, WM5100_PWM1MIX_INPUT_1_SOURCE
);
421 WM5100_MIXER_ENUMS(PWM2
, WM5100_PWM1MIX_INPUT_1_SOURCE
);
423 WM5100_MIXER_ENUMS(AIF1TX1
, WM5100_AIF1TX1MIX_INPUT_1_SOURCE
);
424 WM5100_MIXER_ENUMS(AIF1TX2
, WM5100_AIF1TX2MIX_INPUT_1_SOURCE
);
425 WM5100_MIXER_ENUMS(AIF1TX3
, WM5100_AIF1TX3MIX_INPUT_1_SOURCE
);
426 WM5100_MIXER_ENUMS(AIF1TX4
, WM5100_AIF1TX4MIX_INPUT_1_SOURCE
);
427 WM5100_MIXER_ENUMS(AIF1TX5
, WM5100_AIF1TX5MIX_INPUT_1_SOURCE
);
428 WM5100_MIXER_ENUMS(AIF1TX6
, WM5100_AIF1TX6MIX_INPUT_1_SOURCE
);
429 WM5100_MIXER_ENUMS(AIF1TX7
, WM5100_AIF1TX7MIX_INPUT_1_SOURCE
);
430 WM5100_MIXER_ENUMS(AIF1TX8
, WM5100_AIF1TX8MIX_INPUT_1_SOURCE
);
432 WM5100_MIXER_ENUMS(AIF2TX1
, WM5100_AIF2TX1MIX_INPUT_1_SOURCE
);
433 WM5100_MIXER_ENUMS(AIF2TX2
, WM5100_AIF2TX2MIX_INPUT_1_SOURCE
);
435 WM5100_MIXER_ENUMS(AIF3TX1
, WM5100_AIF1TX1MIX_INPUT_1_SOURCE
);
436 WM5100_MIXER_ENUMS(AIF3TX2
, WM5100_AIF1TX2MIX_INPUT_1_SOURCE
);
438 WM5100_MIXER_ENUMS(EQ1
, WM5100_EQ1MIX_INPUT_1_SOURCE
);
439 WM5100_MIXER_ENUMS(EQ2
, WM5100_EQ2MIX_INPUT_1_SOURCE
);
440 WM5100_MIXER_ENUMS(EQ3
, WM5100_EQ3MIX_INPUT_1_SOURCE
);
441 WM5100_MIXER_ENUMS(EQ4
, WM5100_EQ4MIX_INPUT_1_SOURCE
);
443 WM5100_MIXER_ENUMS(DRC1L
, WM5100_DRC1LMIX_INPUT_1_SOURCE
);
444 WM5100_MIXER_ENUMS(DRC1R
, WM5100_DRC1RMIX_INPUT_1_SOURCE
);
446 WM5100_MIXER_ENUMS(LHPF1
, WM5100_HPLP1MIX_INPUT_1_SOURCE
);
447 WM5100_MIXER_ENUMS(LHPF2
, WM5100_HPLP2MIX_INPUT_1_SOURCE
);
448 WM5100_MIXER_ENUMS(LHPF3
, WM5100_HPLP3MIX_INPUT_1_SOURCE
);
449 WM5100_MIXER_ENUMS(LHPF4
, WM5100_HPLP4MIX_INPUT_1_SOURCE
);
451 #define WM5100_MUX(name, ctrl) \
452 SND_SOC_DAPM_VALUE_MUX(name, SND_SOC_NOPM, 0, 0, ctrl)
454 #define WM5100_MIXER_WIDGETS(name, name_str) \
455 WM5100_MUX(name_str " Input 1", &name##_in1_mux), \
456 WM5100_MUX(name_str " Input 2", &name##_in2_mux), \
457 WM5100_MUX(name_str " Input 3", &name##_in3_mux), \
458 WM5100_MUX(name_str " Input 4", &name##_in4_mux), \
459 SND_SOC_DAPM_MIXER(name_str " Mixer", SND_SOC_NOPM, 0, 0, NULL, 0)
461 #define WM5100_MIXER_INPUT_ROUTES(name) \
462 { name, "Tone Generator 1", "Tone Generator 1" }, \
463 { name, "Tone Generator 2", "Tone Generator 2" }, \
464 { name, "IN1L", "IN1L PGA" }, \
465 { name, "IN1R", "IN1R PGA" }, \
466 { name, "IN2L", "IN2L PGA" }, \
467 { name, "IN2R", "IN2R PGA" }, \
468 { name, "IN3L", "IN3L PGA" }, \
469 { name, "IN3R", "IN3R PGA" }, \
470 { name, "IN4L", "IN4L PGA" }, \
471 { name, "IN4R", "IN4R PGA" }, \
472 { name, "AIF1RX1", "AIF1RX1" }, \
473 { name, "AIF1RX2", "AIF1RX2" }, \
474 { name, "AIF1RX3", "AIF1RX3" }, \
475 { name, "AIF1RX4", "AIF1RX4" }, \
476 { name, "AIF1RX5", "AIF1RX5" }, \
477 { name, "AIF1RX6", "AIF1RX6" }, \
478 { name, "AIF1RX7", "AIF1RX7" }, \
479 { name, "AIF1RX8", "AIF1RX8" }, \
480 { name, "AIF2RX1", "AIF2RX1" }, \
481 { name, "AIF2RX2", "AIF2RX2" }, \
482 { name, "AIF3RX1", "AIF3RX1" }, \
483 { name, "AIF3RX2", "AIF3RX2" }, \
484 { name, "EQ1", "EQ1" }, \
485 { name, "EQ2", "EQ2" }, \
486 { name, "EQ3", "EQ3" }, \
487 { name, "EQ4", "EQ4" }, \
488 { name, "DRC1L", "DRC1L" }, \
489 { name, "DRC1R", "DRC1R" }, \
490 { name, "LHPF1", "LHPF1" }, \
491 { name, "LHPF2", "LHPF2" }, \
492 { name, "LHPF3", "LHPF3" }, \
493 { name, "LHPF4", "LHPF4" }
495 #define WM5100_MIXER_ROUTES(widget, name) \
496 { widget, NULL, name " Mixer" }, \
497 { name " Mixer", NULL, name " Input 1" }, \
498 { name " Mixer", NULL, name " Input 2" }, \
499 { name " Mixer", NULL, name " Input 3" }, \
500 { name " Mixer", NULL, name " Input 4" }, \
501 WM5100_MIXER_INPUT_ROUTES(name " Input 1"), \
502 WM5100_MIXER_INPUT_ROUTES(name " Input 2"), \
503 WM5100_MIXER_INPUT_ROUTES(name " Input 3"), \
504 WM5100_MIXER_INPUT_ROUTES(name " Input 4")
506 static const char *wm5100_lhpf_mode_text
[] = {
507 "Low-pass", "High-pass"
510 static const struct soc_enum wm5100_lhpf1_mode
=
511 SOC_ENUM_SINGLE(WM5100_HPLPF1_1
, WM5100_LHPF1_MODE_SHIFT
, 2,
512 wm5100_lhpf_mode_text
);
514 static const struct soc_enum wm5100_lhpf2_mode
=
515 SOC_ENUM_SINGLE(WM5100_HPLPF2_1
, WM5100_LHPF2_MODE_SHIFT
, 2,
516 wm5100_lhpf_mode_text
);
518 static const struct soc_enum wm5100_lhpf3_mode
=
519 SOC_ENUM_SINGLE(WM5100_HPLPF3_1
, WM5100_LHPF3_MODE_SHIFT
, 2,
520 wm5100_lhpf_mode_text
);
522 static const struct soc_enum wm5100_lhpf4_mode
=
523 SOC_ENUM_SINGLE(WM5100_HPLPF4_1
, WM5100_LHPF4_MODE_SHIFT
, 2,
524 wm5100_lhpf_mode_text
);
526 static const struct snd_kcontrol_new wm5100_snd_controls
[] = {
527 SOC_SINGLE("IN1 High Performance Switch", WM5100_IN1L_CONTROL
,
528 WM5100_IN1_OSR_SHIFT
, 1, 0),
529 SOC_SINGLE("IN2 High Performance Switch", WM5100_IN2L_CONTROL
,
530 WM5100_IN2_OSR_SHIFT
, 1, 0),
531 SOC_SINGLE("IN3 High Performance Switch", WM5100_IN3L_CONTROL
,
532 WM5100_IN3_OSR_SHIFT
, 1, 0),
533 SOC_SINGLE("IN4 High Performance Switch", WM5100_IN4L_CONTROL
,
534 WM5100_IN4_OSR_SHIFT
, 1, 0),
536 /* Only applicable for analogue inputs */
537 SOC_DOUBLE_R_TLV("IN1 Volume", WM5100_IN1L_CONTROL
, WM5100_IN1R_CONTROL
,
538 WM5100_IN1L_PGA_VOL_SHIFT
, 94, 0, in_tlv
),
539 SOC_DOUBLE_R_TLV("IN2 Volume", WM5100_IN2L_CONTROL
, WM5100_IN2R_CONTROL
,
540 WM5100_IN2L_PGA_VOL_SHIFT
, 94, 0, in_tlv
),
541 SOC_DOUBLE_R_TLV("IN3 Volume", WM5100_IN3L_CONTROL
, WM5100_IN3R_CONTROL
,
542 WM5100_IN3L_PGA_VOL_SHIFT
, 94, 0, in_tlv
),
543 SOC_DOUBLE_R_TLV("IN4 Volume", WM5100_IN4L_CONTROL
, WM5100_IN4R_CONTROL
,
544 WM5100_IN4L_PGA_VOL_SHIFT
, 94, 0, in_tlv
),
546 SOC_DOUBLE_R_TLV("IN1 Digital Volume", WM5100_ADC_DIGITAL_VOLUME_1L
,
547 WM5100_ADC_DIGITAL_VOLUME_1R
, WM5100_IN1L_VOL_SHIFT
, 191,
549 SOC_DOUBLE_R_TLV("IN2 Digital Volume", WM5100_ADC_DIGITAL_VOLUME_2L
,
550 WM5100_ADC_DIGITAL_VOLUME_2R
, WM5100_IN2L_VOL_SHIFT
, 191,
552 SOC_DOUBLE_R_TLV("IN3 Digital Volume", WM5100_ADC_DIGITAL_VOLUME_3L
,
553 WM5100_ADC_DIGITAL_VOLUME_3R
, WM5100_IN3L_VOL_SHIFT
, 191,
555 SOC_DOUBLE_R_TLV("IN4 Digital Volume", WM5100_ADC_DIGITAL_VOLUME_4L
,
556 WM5100_ADC_DIGITAL_VOLUME_4R
, WM5100_IN4L_VOL_SHIFT
, 191,
559 SOC_DOUBLE_R("IN1 Switch", WM5100_ADC_DIGITAL_VOLUME_1L
,
560 WM5100_ADC_DIGITAL_VOLUME_1R
, WM5100_IN1L_MUTE_SHIFT
, 1, 1),
561 SOC_DOUBLE_R("IN2 Switch", WM5100_ADC_DIGITAL_VOLUME_2L
,
562 WM5100_ADC_DIGITAL_VOLUME_2R
, WM5100_IN2L_MUTE_SHIFT
, 1, 1),
563 SOC_DOUBLE_R("IN3 Switch", WM5100_ADC_DIGITAL_VOLUME_3L
,
564 WM5100_ADC_DIGITAL_VOLUME_3R
, WM5100_IN3L_MUTE_SHIFT
, 1, 1),
565 SOC_DOUBLE_R("IN4 Switch", WM5100_ADC_DIGITAL_VOLUME_4L
,
566 WM5100_ADC_DIGITAL_VOLUME_4R
, WM5100_IN4L_MUTE_SHIFT
, 1, 1),
568 SOC_SINGLE("HPOUT1 High Performance Switch", WM5100_OUT_VOLUME_1L
,
569 WM5100_OUT1_OSR_SHIFT
, 1, 0),
570 SOC_SINGLE("HPOUT2 High Performance Switch", WM5100_OUT_VOLUME_2L
,
571 WM5100_OUT2_OSR_SHIFT
, 1, 0),
572 SOC_SINGLE("HPOUT3 High Performance Switch", WM5100_OUT_VOLUME_3L
,
573 WM5100_OUT3_OSR_SHIFT
, 1, 0),
574 SOC_SINGLE("SPKOUT High Performance Switch", WM5100_OUT_VOLUME_4L
,
575 WM5100_OUT4_OSR_SHIFT
, 1, 0),
576 SOC_SINGLE("SPKDAT1 High Performance Switch", WM5100_DAC_VOLUME_LIMIT_5L
,
577 WM5100_OUT5_OSR_SHIFT
, 1, 0),
578 SOC_SINGLE("SPKDAT2 High Performance Switch", WM5100_DAC_VOLUME_LIMIT_6L
,
579 WM5100_OUT6_OSR_SHIFT
, 1, 0),
581 SOC_DOUBLE_R_TLV("HPOUT1 Digital Volume", WM5100_DAC_DIGITAL_VOLUME_1L
,
582 WM5100_DAC_DIGITAL_VOLUME_1R
, WM5100_OUT1L_VOL_SHIFT
, 159, 0,
584 SOC_DOUBLE_R_TLV("HPOUT2 Digital Volume", WM5100_DAC_DIGITAL_VOLUME_2L
,
585 WM5100_DAC_DIGITAL_VOLUME_2R
, WM5100_OUT2L_VOL_SHIFT
, 159, 0,
587 SOC_DOUBLE_R_TLV("HPOUT3 Digital Volume", WM5100_DAC_DIGITAL_VOLUME_3L
,
588 WM5100_DAC_DIGITAL_VOLUME_3R
, WM5100_OUT3L_VOL_SHIFT
, 159, 0,
590 SOC_DOUBLE_R_TLV("SPKOUT Digital Volume", WM5100_DAC_DIGITAL_VOLUME_4L
,
591 WM5100_DAC_DIGITAL_VOLUME_4R
, WM5100_OUT4L_VOL_SHIFT
, 159, 0,
593 SOC_DOUBLE_R_TLV("SPKDAT1 Digital Volume", WM5100_DAC_DIGITAL_VOLUME_5L
,
594 WM5100_DAC_DIGITAL_VOLUME_5R
, WM5100_OUT5L_VOL_SHIFT
, 159, 0,
596 SOC_DOUBLE_R_TLV("SPKDAT2 Digital Volume", WM5100_DAC_DIGITAL_VOLUME_6L
,
597 WM5100_DAC_DIGITAL_VOLUME_6R
, WM5100_OUT6L_VOL_SHIFT
, 159, 0,
600 SOC_DOUBLE_R("HPOUT1 Digital Switch", WM5100_DAC_DIGITAL_VOLUME_1L
,
601 WM5100_DAC_DIGITAL_VOLUME_1R
, WM5100_OUT1L_MUTE_SHIFT
, 1, 1),
602 SOC_DOUBLE_R("HPOUT2 Digital Switch", WM5100_DAC_DIGITAL_VOLUME_2L
,
603 WM5100_DAC_DIGITAL_VOLUME_2R
, WM5100_OUT2L_MUTE_SHIFT
, 1, 1),
604 SOC_DOUBLE_R("HPOUT3 Digital Switch", WM5100_DAC_DIGITAL_VOLUME_3L
,
605 WM5100_DAC_DIGITAL_VOLUME_3R
, WM5100_OUT3L_MUTE_SHIFT
, 1, 1),
606 SOC_DOUBLE_R("SPKOUT Digital Switch", WM5100_DAC_DIGITAL_VOLUME_4L
,
607 WM5100_DAC_DIGITAL_VOLUME_4R
, WM5100_OUT4L_MUTE_SHIFT
, 1, 1),
608 SOC_DOUBLE_R("SPKDAT1 Digital Switch", WM5100_DAC_DIGITAL_VOLUME_5L
,
609 WM5100_DAC_DIGITAL_VOLUME_5R
, WM5100_OUT5L_MUTE_SHIFT
, 1, 1),
610 SOC_DOUBLE_R("SPKDAT2 Digital Switch", WM5100_DAC_DIGITAL_VOLUME_6L
,
611 WM5100_DAC_DIGITAL_VOLUME_6R
, WM5100_OUT6L_MUTE_SHIFT
, 1, 1),
613 /* FIXME: Only valid from -12dB to 0dB (52-64) */
614 SOC_DOUBLE_R_TLV("HPOUT1 Volume", WM5100_OUT_VOLUME_1L
, WM5100_OUT_VOLUME_1R
,
615 WM5100_OUT1L_PGA_VOL_SHIFT
, 64, 0, out_tlv
),
616 SOC_DOUBLE_R_TLV("HPOUT2 Volume", WM5100_OUT_VOLUME_2L
, WM5100_OUT_VOLUME_2R
,
617 WM5100_OUT2L_PGA_VOL_SHIFT
, 64, 0, out_tlv
),
618 SOC_DOUBLE_R_TLV("HPOUT3 Volume", WM5100_OUT_VOLUME_3L
, WM5100_OUT_VOLUME_3R
,
619 WM5100_OUT2L_PGA_VOL_SHIFT
, 64, 0, out_tlv
),
621 SOC_DOUBLE("SPKDAT1 Switch", WM5100_PDM_SPK1_CTRL_1
, WM5100_SPK1L_MUTE_SHIFT
,
622 WM5100_SPK1R_MUTE_SHIFT
, 1, 1),
623 SOC_DOUBLE("SPKDAT2 Switch", WM5100_PDM_SPK2_CTRL_1
, WM5100_SPK2L_MUTE_SHIFT
,
624 WM5100_SPK2R_MUTE_SHIFT
, 1, 1),
626 SOC_SINGLE_TLV("EQ1 Band 1 Volume", WM5100_EQ1_1
, WM5100_EQ1_B1_GAIN_SHIFT
,
628 SOC_SINGLE_TLV("EQ1 Band 2 Volume", WM5100_EQ1_1
, WM5100_EQ1_B2_GAIN_SHIFT
,
630 SOC_SINGLE_TLV("EQ1 Band 3 Volume", WM5100_EQ1_1
, WM5100_EQ1_B3_GAIN_SHIFT
,
632 SOC_SINGLE_TLV("EQ1 Band 4 Volume", WM5100_EQ1_2
, WM5100_EQ1_B4_GAIN_SHIFT
,
634 SOC_SINGLE_TLV("EQ1 Band 5 Volume", WM5100_EQ1_2
, WM5100_EQ1_B5_GAIN_SHIFT
,
637 SOC_SINGLE_TLV("EQ2 Band 1 Volume", WM5100_EQ2_1
, WM5100_EQ2_B1_GAIN_SHIFT
,
639 SOC_SINGLE_TLV("EQ2 Band 2 Volume", WM5100_EQ2_1
, WM5100_EQ2_B2_GAIN_SHIFT
,
641 SOC_SINGLE_TLV("EQ2 Band 3 Volume", WM5100_EQ2_1
, WM5100_EQ2_B3_GAIN_SHIFT
,
643 SOC_SINGLE_TLV("EQ2 Band 4 Volume", WM5100_EQ2_2
, WM5100_EQ2_B4_GAIN_SHIFT
,
645 SOC_SINGLE_TLV("EQ2 Band 5 Volume", WM5100_EQ2_2
, WM5100_EQ2_B5_GAIN_SHIFT
,
648 SOC_SINGLE_TLV("EQ3 Band 1 Volume", WM5100_EQ1_1
, WM5100_EQ3_B1_GAIN_SHIFT
,
650 SOC_SINGLE_TLV("EQ3 Band 2 Volume", WM5100_EQ3_1
, WM5100_EQ3_B2_GAIN_SHIFT
,
652 SOC_SINGLE_TLV("EQ3 Band 3 Volume", WM5100_EQ3_1
, WM5100_EQ3_B3_GAIN_SHIFT
,
654 SOC_SINGLE_TLV("EQ3 Band 4 Volume", WM5100_EQ3_2
, WM5100_EQ3_B4_GAIN_SHIFT
,
656 SOC_SINGLE_TLV("EQ3 Band 5 Volume", WM5100_EQ3_2
, WM5100_EQ3_B5_GAIN_SHIFT
,
659 SOC_SINGLE_TLV("EQ4 Band 1 Volume", WM5100_EQ4_1
, WM5100_EQ4_B1_GAIN_SHIFT
,
661 SOC_SINGLE_TLV("EQ4 Band 2 Volume", WM5100_EQ4_1
, WM5100_EQ4_B2_GAIN_SHIFT
,
663 SOC_SINGLE_TLV("EQ4 Band 3 Volume", WM5100_EQ4_1
, WM5100_EQ4_B3_GAIN_SHIFT
,
665 SOC_SINGLE_TLV("EQ4 Band 4 Volume", WM5100_EQ4_2
, WM5100_EQ4_B4_GAIN_SHIFT
,
667 SOC_SINGLE_TLV("EQ4 Band 5 Volume", WM5100_EQ4_2
, WM5100_EQ4_B5_GAIN_SHIFT
,
670 SOC_ENUM("LHPF1 Mode", wm5100_lhpf1_mode
),
671 SOC_ENUM("LHPF2 Mode", wm5100_lhpf2_mode
),
672 SOC_ENUM("LHPF3 Mode", wm5100_lhpf3_mode
),
673 SOC_ENUM("LHPF4 Mode", wm5100_lhpf4_mode
),
675 WM5100_MIXER_CONTROLS("HPOUT1L", WM5100_OUT1LMIX_INPUT_1_SOURCE
),
676 WM5100_MIXER_CONTROLS("HPOUT1R", WM5100_OUT1RMIX_INPUT_1_SOURCE
),
677 WM5100_MIXER_CONTROLS("HPOUT2L", WM5100_OUT2LMIX_INPUT_1_SOURCE
),
678 WM5100_MIXER_CONTROLS("HPOUT2R", WM5100_OUT2RMIX_INPUT_1_SOURCE
),
679 WM5100_MIXER_CONTROLS("HPOUT3L", WM5100_OUT3LMIX_INPUT_1_SOURCE
),
680 WM5100_MIXER_CONTROLS("HPOUT3R", WM5100_OUT3RMIX_INPUT_1_SOURCE
),
682 WM5100_MIXER_CONTROLS("SPKOUTL", WM5100_OUT4LMIX_INPUT_1_SOURCE
),
683 WM5100_MIXER_CONTROLS("SPKOUTR", WM5100_OUT4RMIX_INPUT_1_SOURCE
),
684 WM5100_MIXER_CONTROLS("SPKDAT1L", WM5100_OUT5LMIX_INPUT_1_SOURCE
),
685 WM5100_MIXER_CONTROLS("SPKDAT1R", WM5100_OUT5RMIX_INPUT_1_SOURCE
),
686 WM5100_MIXER_CONTROLS("SPKDAT2L", WM5100_OUT6LMIX_INPUT_1_SOURCE
),
687 WM5100_MIXER_CONTROLS("SPKDAT2R", WM5100_OUT6RMIX_INPUT_1_SOURCE
),
689 WM5100_MIXER_CONTROLS("PWM1", WM5100_PWM1MIX_INPUT_1_SOURCE
),
690 WM5100_MIXER_CONTROLS("PWM2", WM5100_PWM2MIX_INPUT_1_SOURCE
),
692 WM5100_MIXER_CONTROLS("AIF1TX1", WM5100_AIF1TX1MIX_INPUT_1_SOURCE
),
693 WM5100_MIXER_CONTROLS("AIF1TX2", WM5100_AIF1TX2MIX_INPUT_1_SOURCE
),
694 WM5100_MIXER_CONTROLS("AIF1TX3", WM5100_AIF1TX3MIX_INPUT_1_SOURCE
),
695 WM5100_MIXER_CONTROLS("AIF1TX4", WM5100_AIF1TX4MIX_INPUT_1_SOURCE
),
696 WM5100_MIXER_CONTROLS("AIF1TX5", WM5100_AIF1TX5MIX_INPUT_1_SOURCE
),
697 WM5100_MIXER_CONTROLS("AIF1TX6", WM5100_AIF1TX6MIX_INPUT_1_SOURCE
),
698 WM5100_MIXER_CONTROLS("AIF1TX7", WM5100_AIF1TX7MIX_INPUT_1_SOURCE
),
699 WM5100_MIXER_CONTROLS("AIF1TX8", WM5100_AIF1TX8MIX_INPUT_1_SOURCE
),
701 WM5100_MIXER_CONTROLS("AIF2TX1", WM5100_AIF2TX1MIX_INPUT_1_SOURCE
),
702 WM5100_MIXER_CONTROLS("AIF2TX2", WM5100_AIF2TX2MIX_INPUT_1_SOURCE
),
704 WM5100_MIXER_CONTROLS("AIF3TX1", WM5100_AIF3TX1MIX_INPUT_1_SOURCE
),
705 WM5100_MIXER_CONTROLS("AIF3TX2", WM5100_AIF3TX2MIX_INPUT_1_SOURCE
),
707 WM5100_MIXER_CONTROLS("EQ1", WM5100_EQ1MIX_INPUT_1_SOURCE
),
708 WM5100_MIXER_CONTROLS("EQ2", WM5100_EQ2MIX_INPUT_1_SOURCE
),
709 WM5100_MIXER_CONTROLS("EQ3", WM5100_EQ3MIX_INPUT_1_SOURCE
),
710 WM5100_MIXER_CONTROLS("EQ4", WM5100_EQ4MIX_INPUT_1_SOURCE
),
712 WM5100_MIXER_CONTROLS("DRC1L", WM5100_DRC1LMIX_INPUT_1_SOURCE
),
713 WM5100_MIXER_CONTROLS("DRC1R", WM5100_DRC1RMIX_INPUT_1_SOURCE
),
715 WM5100_MIXER_CONTROLS("LHPF1", WM5100_HPLP1MIX_INPUT_1_SOURCE
),
716 WM5100_MIXER_CONTROLS("LHPF2", WM5100_HPLP2MIX_INPUT_1_SOURCE
),
717 WM5100_MIXER_CONTROLS("LHPF3", WM5100_HPLP3MIX_INPUT_1_SOURCE
),
718 WM5100_MIXER_CONTROLS("LHPF4", WM5100_HPLP4MIX_INPUT_1_SOURCE
),
721 static void wm5100_seq_notifier(struct snd_soc_dapm_context
*dapm
,
722 enum snd_soc_dapm_type event
, int subseq
)
724 struct snd_soc_codec
*codec
= container_of(dapm
,
725 struct snd_soc_codec
, dapm
);
726 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
729 /* Wait for the outputs to flag themselves as enabled */
730 if (wm5100
->out_ena
[0]) {
731 expect
= snd_soc_read(codec
, WM5100_CHANNEL_ENABLES_1
);
732 for (i
= 0; i
< 200; i
++) {
733 val
= snd_soc_read(codec
, WM5100_OUTPUT_STATUS_1
);
735 wm5100
->out_ena
[0] = false;
740 dev_err(codec
->dev
, "Timeout waiting for OUTPUT1 %x\n",
745 if (wm5100
->out_ena
[1]) {
746 expect
= snd_soc_read(codec
, WM5100_OUTPUT_ENABLES_2
);
747 for (i
= 0; i
< 200; i
++) {
748 val
= snd_soc_read(codec
, WM5100_OUTPUT_STATUS_2
);
750 wm5100
->out_ena
[1] = false;
755 dev_err(codec
->dev
, "Timeout waiting for OUTPUT2 %x\n",
761 static int wm5100_out_ev(struct snd_soc_dapm_widget
*w
,
762 struct snd_kcontrol
*kcontrol
,
765 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(w
->codec
);
768 case WM5100_CHANNEL_ENABLES_1
:
769 wm5100
->out_ena
[0] = true;
771 case WM5100_OUTPUT_ENABLES_2
:
772 wm5100
->out_ena
[0] = true;
781 static int wm5100_cp_ev(struct snd_soc_dapm_widget
*w
,
782 struct snd_kcontrol
*kcontrol
,
785 struct snd_soc_codec
*codec
= w
->codec
;
786 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
790 case SND_SOC_DAPM_PRE_PMU
:
791 ret
= regulator_enable(wm5100
->cpvdd
);
793 dev_err(codec
->dev
, "Failed to enable CPVDD: %d\n",
799 case SND_SOC_DAPM_POST_PMD
:
800 ret
= regulator_disable_deferred(wm5100
->cpvdd
, 20);
802 dev_err(codec
->dev
, "Failed to disable CPVDD: %d\n",
814 static int wm5100_dbvdd_ev(struct snd_soc_dapm_widget
*w
,
815 struct snd_kcontrol
*kcontrol
,
818 struct snd_soc_codec
*codec
= w
->codec
;
819 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
820 struct regulator
*regulator
;
825 regulator
= wm5100
->dbvdd2
;
828 regulator
= wm5100
->dbvdd3
;
836 case SND_SOC_DAPM_PRE_PMU
:
837 ret
= regulator_enable(regulator
);
839 dev_err(codec
->dev
, "Failed to enable DBVDD%d: %d\n",
845 case SND_SOC_DAPM_POST_PMD
:
846 ret
= regulator_disable(regulator
);
848 dev_err(codec
->dev
, "Failed to enable DBVDD%d: %d\n",
860 static void wm5100_log_status3(struct snd_soc_codec
*codec
, int val
)
862 if (val
& WM5100_SPK_SHUTDOWN_WARN_EINT
)
863 dev_crit(codec
->dev
, "Speaker shutdown warning\n");
864 if (val
& WM5100_SPK_SHUTDOWN_EINT
)
865 dev_crit(codec
->dev
, "Speaker shutdown\n");
866 if (val
& WM5100_CLKGEN_ERR_EINT
)
867 dev_crit(codec
->dev
, "SYSCLK underclocked\n");
868 if (val
& WM5100_CLKGEN_ERR_ASYNC_EINT
)
869 dev_crit(codec
->dev
, "ASYNCCLK underclocked\n");
872 static void wm5100_log_status4(struct snd_soc_codec
*codec
, int val
)
874 if (val
& WM5100_AIF3_ERR_EINT
)
875 dev_err(codec
->dev
, "AIF3 configuration error\n");
876 if (val
& WM5100_AIF2_ERR_EINT
)
877 dev_err(codec
->dev
, "AIF2 configuration error\n");
878 if (val
& WM5100_AIF1_ERR_EINT
)
879 dev_err(codec
->dev
, "AIF1 configuration error\n");
880 if (val
& WM5100_CTRLIF_ERR_EINT
)
881 dev_err(codec
->dev
, "Control interface error\n");
882 if (val
& WM5100_ISRC2_UNDERCLOCKED_EINT
)
883 dev_err(codec
->dev
, "ISRC2 underclocked\n");
884 if (val
& WM5100_ISRC1_UNDERCLOCKED_EINT
)
885 dev_err(codec
->dev
, "ISRC1 underclocked\n");
886 if (val
& WM5100_FX_UNDERCLOCKED_EINT
)
887 dev_err(codec
->dev
, "FX underclocked\n");
888 if (val
& WM5100_AIF3_UNDERCLOCKED_EINT
)
889 dev_err(codec
->dev
, "AIF3 underclocked\n");
890 if (val
& WM5100_AIF2_UNDERCLOCKED_EINT
)
891 dev_err(codec
->dev
, "AIF2 underclocked\n");
892 if (val
& WM5100_AIF1_UNDERCLOCKED_EINT
)
893 dev_err(codec
->dev
, "AIF1 underclocked\n");
894 if (val
& WM5100_ASRC_UNDERCLOCKED_EINT
)
895 dev_err(codec
->dev
, "ASRC underclocked\n");
896 if (val
& WM5100_DAC_UNDERCLOCKED_EINT
)
897 dev_err(codec
->dev
, "DAC underclocked\n");
898 if (val
& WM5100_ADC_UNDERCLOCKED_EINT
)
899 dev_err(codec
->dev
, "ADC underclocked\n");
900 if (val
& WM5100_MIXER_UNDERCLOCKED_EINT
)
901 dev_err(codec
->dev
, "Mixer underclocked\n");
904 static int wm5100_post_ev(struct snd_soc_dapm_widget
*w
,
905 struct snd_kcontrol
*kcontrol
,
908 struct snd_soc_codec
*codec
= w
->codec
;
911 ret
= snd_soc_read(codec
, WM5100_INTERRUPT_RAW_STATUS_3
);
912 ret
&= WM5100_SPK_SHUTDOWN_WARN_STS
|
913 WM5100_SPK_SHUTDOWN_STS
| WM5100_CLKGEN_ERR_STS
|
914 WM5100_CLKGEN_ERR_ASYNC_STS
;
915 wm5100_log_status3(codec
, ret
);
917 ret
= snd_soc_read(codec
, WM5100_INTERRUPT_RAW_STATUS_4
);
918 wm5100_log_status4(codec
, ret
);
923 static const struct snd_soc_dapm_widget wm5100_dapm_widgets
[] = {
924 SND_SOC_DAPM_SUPPLY("SYSCLK", WM5100_CLOCKING_3
, WM5100_SYSCLK_ENA_SHIFT
, 0,
926 SND_SOC_DAPM_SUPPLY("ASYNCCLK", WM5100_CLOCKING_6
, WM5100_ASYNC_CLK_ENA_SHIFT
,
929 SND_SOC_DAPM_SUPPLY("CP1", WM5100_HP_CHARGE_PUMP_1
, WM5100_CP1_ENA_SHIFT
, 0,
931 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
932 SND_SOC_DAPM_SUPPLY("CP2", WM5100_MIC_CHARGE_PUMP_1
, WM5100_CP2_ENA_SHIFT
, 0,
934 SND_SOC_DAPM_SUPPLY("CP2 Active", WM5100_MIC_CHARGE_PUMP_1
,
935 WM5100_CP2_BYPASS_SHIFT
, 1, wm5100_cp_ev
,
936 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
937 SND_SOC_DAPM_SUPPLY("DBVDD2", SND_SOC_NOPM
, 2, 0, wm5100_dbvdd_ev
,
938 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
939 SND_SOC_DAPM_SUPPLY("DBVDD3", SND_SOC_NOPM
, 3, 0, wm5100_dbvdd_ev
,
940 SND_SOC_DAPM_PRE_PMU
| SND_SOC_DAPM_POST_PMD
),
942 SND_SOC_DAPM_SUPPLY("MICBIAS1", WM5100_MIC_BIAS_CTRL_1
, WM5100_MICB1_ENA_SHIFT
,
944 SND_SOC_DAPM_SUPPLY("MICBIAS2", WM5100_MIC_BIAS_CTRL_2
, WM5100_MICB2_ENA_SHIFT
,
946 SND_SOC_DAPM_SUPPLY("MICBIAS3", WM5100_MIC_BIAS_CTRL_3
, WM5100_MICB3_ENA_SHIFT
,
949 SND_SOC_DAPM_INPUT("IN1L"),
950 SND_SOC_DAPM_INPUT("IN1R"),
951 SND_SOC_DAPM_INPUT("IN2L"),
952 SND_SOC_DAPM_INPUT("IN2R"),
953 SND_SOC_DAPM_INPUT("IN3L"),
954 SND_SOC_DAPM_INPUT("IN3R"),
955 SND_SOC_DAPM_INPUT("IN4L"),
956 SND_SOC_DAPM_INPUT("IN4R"),
957 SND_SOC_DAPM_INPUT("TONE"),
959 SND_SOC_DAPM_PGA_E("IN1L PGA", WM5100_INPUT_ENABLES
, WM5100_IN1L_ENA_SHIFT
, 0,
960 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
961 SND_SOC_DAPM_PGA_E("IN1R PGA", WM5100_INPUT_ENABLES
, WM5100_IN1R_ENA_SHIFT
, 0,
962 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
963 SND_SOC_DAPM_PGA_E("IN2L PGA", WM5100_INPUT_ENABLES
, WM5100_IN2L_ENA_SHIFT
, 0,
964 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
965 SND_SOC_DAPM_PGA_E("IN2R PGA", WM5100_INPUT_ENABLES
, WM5100_IN2R_ENA_SHIFT
, 0,
966 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
967 SND_SOC_DAPM_PGA_E("IN3L PGA", WM5100_INPUT_ENABLES
, WM5100_IN3L_ENA_SHIFT
, 0,
968 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
969 SND_SOC_DAPM_PGA_E("IN3R PGA", WM5100_INPUT_ENABLES
, WM5100_IN3R_ENA_SHIFT
, 0,
970 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
971 SND_SOC_DAPM_PGA_E("IN4L PGA", WM5100_INPUT_ENABLES
, WM5100_IN4L_ENA_SHIFT
, 0,
972 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
973 SND_SOC_DAPM_PGA_E("IN4R PGA", WM5100_INPUT_ENABLES
, WM5100_IN4R_ENA_SHIFT
, 0,
974 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
976 SND_SOC_DAPM_PGA("Tone Generator 1", WM5100_TONE_GENERATOR_1
,
977 WM5100_TONE1_ENA_SHIFT
, 0, NULL
, 0),
978 SND_SOC_DAPM_PGA("Tone Generator 2", WM5100_TONE_GENERATOR_1
,
979 WM5100_TONE2_ENA_SHIFT
, 0, NULL
, 0),
981 SND_SOC_DAPM_AIF_IN("AIF1RX1", "AIF1 Playback", 0,
982 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX1_ENA_SHIFT
, 0),
983 SND_SOC_DAPM_AIF_IN("AIF1RX2", "AIF1 Playback", 1,
984 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX2_ENA_SHIFT
, 0),
985 SND_SOC_DAPM_AIF_IN("AIF1RX3", "AIF1 Playback", 2,
986 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX3_ENA_SHIFT
, 0),
987 SND_SOC_DAPM_AIF_IN("AIF1RX4", "AIF1 Playback", 3,
988 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX4_ENA_SHIFT
, 0),
989 SND_SOC_DAPM_AIF_IN("AIF1RX5", "AIF1 Playback", 4,
990 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX5_ENA_SHIFT
, 0),
991 SND_SOC_DAPM_AIF_IN("AIF1RX6", "AIF1 Playback", 5,
992 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX6_ENA_SHIFT
, 0),
993 SND_SOC_DAPM_AIF_IN("AIF1RX7", "AIF1 Playback", 6,
994 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX7_ENA_SHIFT
, 0),
995 SND_SOC_DAPM_AIF_IN("AIF1RX8", "AIF1 Playback", 7,
996 WM5100_AUDIO_IF_1_27
, WM5100_AIF1RX8_ENA_SHIFT
, 0),
998 SND_SOC_DAPM_AIF_IN("AIF2RX1", "AIF2 Playback", 0,
999 WM5100_AUDIO_IF_2_27
, WM5100_AIF2RX1_ENA_SHIFT
, 0),
1000 SND_SOC_DAPM_AIF_IN("AIF2RX2", "AIF2 Playback", 1,
1001 WM5100_AUDIO_IF_2_27
, WM5100_AIF2RX2_ENA_SHIFT
, 0),
1003 SND_SOC_DAPM_AIF_IN("AIF3RX1", "AIF3 Playback", 0,
1004 WM5100_AUDIO_IF_3_27
, WM5100_AIF3RX1_ENA_SHIFT
, 0),
1005 SND_SOC_DAPM_AIF_IN("AIF3RX2", "AIF3 Playback", 1,
1006 WM5100_AUDIO_IF_3_27
, WM5100_AIF3RX2_ENA_SHIFT
, 0),
1008 SND_SOC_DAPM_AIF_OUT("AIF1TX1", "AIF1 Capture", 0,
1009 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX1_ENA_SHIFT
, 0),
1010 SND_SOC_DAPM_AIF_OUT("AIF1TX2", "AIF1 Capture", 1,
1011 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX2_ENA_SHIFT
, 0),
1012 SND_SOC_DAPM_AIF_OUT("AIF1TX3", "AIF1 Capture", 2,
1013 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX3_ENA_SHIFT
, 0),
1014 SND_SOC_DAPM_AIF_OUT("AIF1TX4", "AIF1 Capture", 3,
1015 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX4_ENA_SHIFT
, 0),
1016 SND_SOC_DAPM_AIF_OUT("AIF1TX5", "AIF1 Capture", 4,
1017 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX5_ENA_SHIFT
, 0),
1018 SND_SOC_DAPM_AIF_OUT("AIF1TX6", "AIF1 Capture", 5,
1019 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX6_ENA_SHIFT
, 0),
1020 SND_SOC_DAPM_AIF_OUT("AIF1TX7", "AIF1 Capture", 6,
1021 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX7_ENA_SHIFT
, 0),
1022 SND_SOC_DAPM_AIF_OUT("AIF1TX8", "AIF1 Capture", 7,
1023 WM5100_AUDIO_IF_1_26
, WM5100_AIF1TX8_ENA_SHIFT
, 0),
1025 SND_SOC_DAPM_AIF_OUT("AIF2TX1", "AIF2 Capture", 0,
1026 WM5100_AUDIO_IF_2_26
, WM5100_AIF2TX1_ENA_SHIFT
, 0),
1027 SND_SOC_DAPM_AIF_OUT("AIF2TX2", "AIF2 Capture", 1,
1028 WM5100_AUDIO_IF_2_26
, WM5100_AIF2TX2_ENA_SHIFT
, 0),
1030 SND_SOC_DAPM_AIF_OUT("AIF3TX1", "AIF3 Capture", 0,
1031 WM5100_AUDIO_IF_3_26
, WM5100_AIF3TX1_ENA_SHIFT
, 0),
1032 SND_SOC_DAPM_AIF_OUT("AIF3TX2", "AIF3 Capture", 1,
1033 WM5100_AUDIO_IF_3_26
, WM5100_AIF3TX2_ENA_SHIFT
, 0),
1035 SND_SOC_DAPM_PGA_E("OUT6L", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT6L_ENA_SHIFT
, 0,
1036 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1037 SND_SOC_DAPM_PGA_E("OUT6R", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT6R_ENA_SHIFT
, 0,
1038 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1039 SND_SOC_DAPM_PGA_E("OUT5L", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT5L_ENA_SHIFT
, 0,
1040 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1041 SND_SOC_DAPM_PGA_E("OUT5R", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT5R_ENA_SHIFT
, 0,
1042 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1043 SND_SOC_DAPM_PGA_E("OUT4L", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT4L_ENA_SHIFT
, 0,
1044 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1045 SND_SOC_DAPM_PGA_E("OUT4R", WM5100_OUTPUT_ENABLES_2
, WM5100_OUT4R_ENA_SHIFT
, 0,
1046 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1047 SND_SOC_DAPM_PGA_E("OUT3L", WM5100_CHANNEL_ENABLES_1
, WM5100_HP3L_ENA_SHIFT
, 0,
1048 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1049 SND_SOC_DAPM_PGA_E("OUT3R", WM5100_CHANNEL_ENABLES_1
, WM5100_HP3R_ENA_SHIFT
, 0,
1050 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1051 SND_SOC_DAPM_PGA_E("OUT2L", WM5100_CHANNEL_ENABLES_1
, WM5100_HP2L_ENA_SHIFT
, 0,
1052 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1053 SND_SOC_DAPM_PGA_E("OUT2R", WM5100_CHANNEL_ENABLES_1
, WM5100_HP2R_ENA_SHIFT
, 0,
1054 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1055 SND_SOC_DAPM_PGA_E("OUT1L", WM5100_CHANNEL_ENABLES_1
, WM5100_HP1L_ENA_SHIFT
, 0,
1056 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1057 SND_SOC_DAPM_PGA_E("OUT1R", WM5100_CHANNEL_ENABLES_1
, WM5100_HP1R_ENA_SHIFT
, 0,
1058 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1059 SND_SOC_DAPM_PGA_E("PWM1 Driver", WM5100_PWM_DRIVE_1
, WM5100_PWM1_ENA_SHIFT
, 0,
1060 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1061 SND_SOC_DAPM_PGA_E("PWM2 Driver", WM5100_PWM_DRIVE_1
, WM5100_PWM2_ENA_SHIFT
, 0,
1062 NULL
, 0, wm5100_out_ev
, SND_SOC_DAPM_POST_PMU
),
1064 SND_SOC_DAPM_PGA("EQ1", WM5100_EQ1_1
, WM5100_EQ1_ENA_SHIFT
, 0, NULL
, 0),
1065 SND_SOC_DAPM_PGA("EQ2", WM5100_EQ2_1
, WM5100_EQ2_ENA_SHIFT
, 0, NULL
, 0),
1066 SND_SOC_DAPM_PGA("EQ3", WM5100_EQ3_1
, WM5100_EQ3_ENA_SHIFT
, 0, NULL
, 0),
1067 SND_SOC_DAPM_PGA("EQ4", WM5100_EQ4_1
, WM5100_EQ4_ENA_SHIFT
, 0, NULL
, 0),
1069 SND_SOC_DAPM_PGA("DRC1L", WM5100_DRC1_CTRL1
, WM5100_DRCL_ENA_SHIFT
, 0,
1071 SND_SOC_DAPM_PGA("DRC1R", WM5100_DRC1_CTRL1
, WM5100_DRCR_ENA_SHIFT
, 0,
1074 SND_SOC_DAPM_PGA("LHPF1", WM5100_HPLPF1_1
, WM5100_LHPF1_ENA_SHIFT
, 0,
1076 SND_SOC_DAPM_PGA("LHPF2", WM5100_HPLPF2_1
, WM5100_LHPF2_ENA_SHIFT
, 0,
1078 SND_SOC_DAPM_PGA("LHPF3", WM5100_HPLPF3_1
, WM5100_LHPF3_ENA_SHIFT
, 0,
1080 SND_SOC_DAPM_PGA("LHPF4", WM5100_HPLPF4_1
, WM5100_LHPF4_ENA_SHIFT
, 0,
1083 WM5100_MIXER_WIDGETS(EQ1
, "EQ1"),
1084 WM5100_MIXER_WIDGETS(EQ2
, "EQ2"),
1085 WM5100_MIXER_WIDGETS(EQ3
, "EQ3"),
1086 WM5100_MIXER_WIDGETS(EQ4
, "EQ4"),
1088 WM5100_MIXER_WIDGETS(DRC1L
, "DRC1L"),
1089 WM5100_MIXER_WIDGETS(DRC1R
, "DRC1R"),
1091 WM5100_MIXER_WIDGETS(LHPF1
, "LHPF1"),
1092 WM5100_MIXER_WIDGETS(LHPF2
, "LHPF2"),
1093 WM5100_MIXER_WIDGETS(LHPF3
, "LHPF3"),
1094 WM5100_MIXER_WIDGETS(LHPF4
, "LHPF4"),
1096 WM5100_MIXER_WIDGETS(AIF1TX1
, "AIF1TX1"),
1097 WM5100_MIXER_WIDGETS(AIF1TX2
, "AIF1TX2"),
1098 WM5100_MIXER_WIDGETS(AIF1TX3
, "AIF1TX3"),
1099 WM5100_MIXER_WIDGETS(AIF1TX4
, "AIF1TX4"),
1100 WM5100_MIXER_WIDGETS(AIF1TX5
, "AIF1TX5"),
1101 WM5100_MIXER_WIDGETS(AIF1TX6
, "AIF1TX6"),
1102 WM5100_MIXER_WIDGETS(AIF1TX7
, "AIF1TX7"),
1103 WM5100_MIXER_WIDGETS(AIF1TX8
, "AIF1TX8"),
1105 WM5100_MIXER_WIDGETS(AIF2TX1
, "AIF2TX1"),
1106 WM5100_MIXER_WIDGETS(AIF2TX2
, "AIF2TX2"),
1108 WM5100_MIXER_WIDGETS(AIF3TX1
, "AIF3TX1"),
1109 WM5100_MIXER_WIDGETS(AIF3TX2
, "AIF3TX2"),
1111 WM5100_MIXER_WIDGETS(HPOUT1L
, "HPOUT1L"),
1112 WM5100_MIXER_WIDGETS(HPOUT1R
, "HPOUT1R"),
1113 WM5100_MIXER_WIDGETS(HPOUT2L
, "HPOUT2L"),
1114 WM5100_MIXER_WIDGETS(HPOUT2R
, "HPOUT2R"),
1115 WM5100_MIXER_WIDGETS(HPOUT3L
, "HPOUT3L"),
1116 WM5100_MIXER_WIDGETS(HPOUT3R
, "HPOUT3R"),
1118 WM5100_MIXER_WIDGETS(SPKOUTL
, "SPKOUTL"),
1119 WM5100_MIXER_WIDGETS(SPKOUTR
, "SPKOUTR"),
1120 WM5100_MIXER_WIDGETS(SPKDAT1L
, "SPKDAT1L"),
1121 WM5100_MIXER_WIDGETS(SPKDAT1R
, "SPKDAT1R"),
1122 WM5100_MIXER_WIDGETS(SPKDAT2L
, "SPKDAT2L"),
1123 WM5100_MIXER_WIDGETS(SPKDAT2R
, "SPKDAT2R"),
1125 WM5100_MIXER_WIDGETS(PWM1
, "PWM1"),
1126 WM5100_MIXER_WIDGETS(PWM2
, "PWM2"),
1128 SND_SOC_DAPM_OUTPUT("HPOUT1L"),
1129 SND_SOC_DAPM_OUTPUT("HPOUT1R"),
1130 SND_SOC_DAPM_OUTPUT("HPOUT2L"),
1131 SND_SOC_DAPM_OUTPUT("HPOUT2R"),
1132 SND_SOC_DAPM_OUTPUT("HPOUT3L"),
1133 SND_SOC_DAPM_OUTPUT("HPOUT3R"),
1134 SND_SOC_DAPM_OUTPUT("SPKOUTL"),
1135 SND_SOC_DAPM_OUTPUT("SPKOUTR"),
1136 SND_SOC_DAPM_OUTPUT("SPKDAT1"),
1137 SND_SOC_DAPM_OUTPUT("SPKDAT2"),
1138 SND_SOC_DAPM_OUTPUT("PWM1"),
1139 SND_SOC_DAPM_OUTPUT("PWM2"),
1142 /* We register a _POST event if we don't have IRQ support so we can
1143 * look at the error status from the CODEC - if we've got the IRQ
1144 * hooked up then we will get prompted to look by an interrupt.
1146 static const struct snd_soc_dapm_widget wm5100_dapm_widgets_noirq
[] = {
1147 SND_SOC_DAPM_POST("Post", wm5100_post_ev
),
1150 static const struct snd_soc_dapm_route wm5100_dapm_routes
[] = {
1151 { "IN1L", NULL
, "SYSCLK" },
1152 { "IN1R", NULL
, "SYSCLK" },
1153 { "IN2L", NULL
, "SYSCLK" },
1154 { "IN2R", NULL
, "SYSCLK" },
1155 { "IN3L", NULL
, "SYSCLK" },
1156 { "IN3R", NULL
, "SYSCLK" },
1157 { "IN4L", NULL
, "SYSCLK" },
1158 { "IN4R", NULL
, "SYSCLK" },
1160 { "OUT1L", NULL
, "SYSCLK" },
1161 { "OUT1R", NULL
, "SYSCLK" },
1162 { "OUT2L", NULL
, "SYSCLK" },
1163 { "OUT2R", NULL
, "SYSCLK" },
1164 { "OUT3L", NULL
, "SYSCLK" },
1165 { "OUT3R", NULL
, "SYSCLK" },
1166 { "OUT4L", NULL
, "SYSCLK" },
1167 { "OUT4R", NULL
, "SYSCLK" },
1168 { "OUT5L", NULL
, "SYSCLK" },
1169 { "OUT5R", NULL
, "SYSCLK" },
1170 { "OUT6L", NULL
, "SYSCLK" },
1171 { "OUT6R", NULL
, "SYSCLK" },
1173 { "AIF1RX1", NULL
, "SYSCLK" },
1174 { "AIF1RX2", NULL
, "SYSCLK" },
1175 { "AIF1RX3", NULL
, "SYSCLK" },
1176 { "AIF1RX4", NULL
, "SYSCLK" },
1177 { "AIF1RX5", NULL
, "SYSCLK" },
1178 { "AIF1RX6", NULL
, "SYSCLK" },
1179 { "AIF1RX7", NULL
, "SYSCLK" },
1180 { "AIF1RX8", NULL
, "SYSCLK" },
1182 { "AIF2RX1", NULL
, "SYSCLK" },
1183 { "AIF2RX1", NULL
, "DBVDD2" },
1184 { "AIF2RX2", NULL
, "SYSCLK" },
1185 { "AIF2RX2", NULL
, "DBVDD2" },
1187 { "AIF3RX1", NULL
, "SYSCLK" },
1188 { "AIF3RX1", NULL
, "DBVDD3" },
1189 { "AIF3RX2", NULL
, "SYSCLK" },
1190 { "AIF3RX2", NULL
, "DBVDD3" },
1192 { "AIF1TX1", NULL
, "SYSCLK" },
1193 { "AIF1TX2", NULL
, "SYSCLK" },
1194 { "AIF1TX3", NULL
, "SYSCLK" },
1195 { "AIF1TX4", NULL
, "SYSCLK" },
1196 { "AIF1TX5", NULL
, "SYSCLK" },
1197 { "AIF1TX6", NULL
, "SYSCLK" },
1198 { "AIF1TX7", NULL
, "SYSCLK" },
1199 { "AIF1TX8", NULL
, "SYSCLK" },
1201 { "AIF2TX1", NULL
, "SYSCLK" },
1202 { "AIF2TX1", NULL
, "DBVDD2" },
1203 { "AIF2TX2", NULL
, "SYSCLK" },
1204 { "AIF2TX2", NULL
, "DBVDD2" },
1206 { "AIF3TX1", NULL
, "SYSCLK" },
1207 { "AIF3TX1", NULL
, "DBVDD3" },
1208 { "AIF3TX2", NULL
, "SYSCLK" },
1209 { "AIF3TX2", NULL
, "DBVDD3" },
1211 { "MICBIAS1", NULL
, "CP2" },
1212 { "MICBIAS2", NULL
, "CP2" },
1213 { "MICBIAS3", NULL
, "CP2" },
1215 { "IN1L PGA", NULL
, "CP2" },
1216 { "IN1R PGA", NULL
, "CP2" },
1217 { "IN2L PGA", NULL
, "CP2" },
1218 { "IN2R PGA", NULL
, "CP2" },
1219 { "IN3L PGA", NULL
, "CP2" },
1220 { "IN3R PGA", NULL
, "CP2" },
1221 { "IN4L PGA", NULL
, "CP2" },
1222 { "IN4R PGA", NULL
, "CP2" },
1224 { "IN1L PGA", NULL
, "CP2 Active" },
1225 { "IN1R PGA", NULL
, "CP2 Active" },
1226 { "IN2L PGA", NULL
, "CP2 Active" },
1227 { "IN2R PGA", NULL
, "CP2 Active" },
1228 { "IN3L PGA", NULL
, "CP2 Active" },
1229 { "IN3R PGA", NULL
, "CP2 Active" },
1230 { "IN4L PGA", NULL
, "CP2 Active" },
1231 { "IN4R PGA", NULL
, "CP2 Active" },
1233 { "OUT1L", NULL
, "CP1" },
1234 { "OUT1R", NULL
, "CP1" },
1235 { "OUT2L", NULL
, "CP1" },
1236 { "OUT2R", NULL
, "CP1" },
1237 { "OUT3L", NULL
, "CP1" },
1238 { "OUT3R", NULL
, "CP1" },
1240 { "Tone Generator 1", NULL
, "TONE" },
1241 { "Tone Generator 2", NULL
, "TONE" },
1243 { "IN1L PGA", NULL
, "IN1L" },
1244 { "IN1R PGA", NULL
, "IN1R" },
1245 { "IN2L PGA", NULL
, "IN2L" },
1246 { "IN2R PGA", NULL
, "IN2R" },
1247 { "IN3L PGA", NULL
, "IN3L" },
1248 { "IN3R PGA", NULL
, "IN3R" },
1249 { "IN4L PGA", NULL
, "IN4L" },
1250 { "IN4R PGA", NULL
, "IN4R" },
1252 WM5100_MIXER_ROUTES("OUT1L", "HPOUT1L"),
1253 WM5100_MIXER_ROUTES("OUT1R", "HPOUT1R"),
1254 WM5100_MIXER_ROUTES("OUT2L", "HPOUT2L"),
1255 WM5100_MIXER_ROUTES("OUT2R", "HPOUT2R"),
1256 WM5100_MIXER_ROUTES("OUT3L", "HPOUT3L"),
1257 WM5100_MIXER_ROUTES("OUT3R", "HPOUT3R"),
1259 WM5100_MIXER_ROUTES("OUT4L", "SPKOUTL"),
1260 WM5100_MIXER_ROUTES("OUT4R", "SPKOUTR"),
1261 WM5100_MIXER_ROUTES("OUT5L", "SPKDAT1L"),
1262 WM5100_MIXER_ROUTES("OUT5R", "SPKDAT1R"),
1263 WM5100_MIXER_ROUTES("OUT6L", "SPKDAT2L"),
1264 WM5100_MIXER_ROUTES("OUT6R", "SPKDAT2R"),
1266 WM5100_MIXER_ROUTES("PWM1 Driver", "PWM1"),
1267 WM5100_MIXER_ROUTES("PWM2 Driver", "PWM2"),
1269 WM5100_MIXER_ROUTES("AIF1TX1", "AIF1TX1"),
1270 WM5100_MIXER_ROUTES("AIF1TX2", "AIF1TX2"),
1271 WM5100_MIXER_ROUTES("AIF1TX3", "AIF1TX3"),
1272 WM5100_MIXER_ROUTES("AIF1TX4", "AIF1TX4"),
1273 WM5100_MIXER_ROUTES("AIF1TX5", "AIF1TX5"),
1274 WM5100_MIXER_ROUTES("AIF1TX6", "AIF1TX6"),
1275 WM5100_MIXER_ROUTES("AIF1TX7", "AIF1TX7"),
1276 WM5100_MIXER_ROUTES("AIF1TX8", "AIF1TX8"),
1278 WM5100_MIXER_ROUTES("AIF2TX1", "AIF2TX1"),
1279 WM5100_MIXER_ROUTES("AIF2TX2", "AIF2TX2"),
1281 WM5100_MIXER_ROUTES("AIF3TX1", "AIF3TX1"),
1282 WM5100_MIXER_ROUTES("AIF3TX2", "AIF3TX2"),
1284 WM5100_MIXER_ROUTES("EQ1", "EQ1"),
1285 WM5100_MIXER_ROUTES("EQ2", "EQ2"),
1286 WM5100_MIXER_ROUTES("EQ3", "EQ3"),
1287 WM5100_MIXER_ROUTES("EQ4", "EQ4"),
1289 WM5100_MIXER_ROUTES("DRC1L", "DRC1L"),
1290 WM5100_MIXER_ROUTES("DRC1R", "DRC1R"),
1292 WM5100_MIXER_ROUTES("LHPF1", "LHPF1"),
1293 WM5100_MIXER_ROUTES("LHPF2", "LHPF2"),
1294 WM5100_MIXER_ROUTES("LHPF3", "LHPF3"),
1295 WM5100_MIXER_ROUTES("LHPF4", "LHPF4"),
1297 { "HPOUT1L", NULL
, "OUT1L" },
1298 { "HPOUT1R", NULL
, "OUT1R" },
1299 { "HPOUT2L", NULL
, "OUT2L" },
1300 { "HPOUT2R", NULL
, "OUT2R" },
1301 { "HPOUT3L", NULL
, "OUT3L" },
1302 { "HPOUT3R", NULL
, "OUT3R" },
1303 { "SPKOUTL", NULL
, "OUT4L" },
1304 { "SPKOUTR", NULL
, "OUT4R" },
1305 { "SPKDAT1", NULL
, "OUT5L" },
1306 { "SPKDAT1", NULL
, "OUT5R" },
1307 { "SPKDAT2", NULL
, "OUT6L" },
1308 { "SPKDAT2", NULL
, "OUT6R" },
1309 { "PWM1", NULL
, "PWM1 Driver" },
1310 { "PWM2", NULL
, "PWM2 Driver" },
1316 } wm5100_reva_patches
[] = {
1317 { WM5100_AUDIO_IF_1_10
, 0 },
1318 { WM5100_AUDIO_IF_1_11
, 1 },
1319 { WM5100_AUDIO_IF_1_12
, 2 },
1320 { WM5100_AUDIO_IF_1_13
, 3 },
1321 { WM5100_AUDIO_IF_1_14
, 4 },
1322 { WM5100_AUDIO_IF_1_15
, 5 },
1323 { WM5100_AUDIO_IF_1_16
, 6 },
1324 { WM5100_AUDIO_IF_1_17
, 7 },
1326 { WM5100_AUDIO_IF_1_18
, 0 },
1327 { WM5100_AUDIO_IF_1_19
, 1 },
1328 { WM5100_AUDIO_IF_1_20
, 2 },
1329 { WM5100_AUDIO_IF_1_21
, 3 },
1330 { WM5100_AUDIO_IF_1_22
, 4 },
1331 { WM5100_AUDIO_IF_1_23
, 5 },
1332 { WM5100_AUDIO_IF_1_24
, 6 },
1333 { WM5100_AUDIO_IF_1_25
, 7 },
1335 { WM5100_AUDIO_IF_2_10
, 0 },
1336 { WM5100_AUDIO_IF_2_11
, 1 },
1338 { WM5100_AUDIO_IF_2_18
, 0 },
1339 { WM5100_AUDIO_IF_2_19
, 1 },
1341 { WM5100_AUDIO_IF_3_10
, 0 },
1342 { WM5100_AUDIO_IF_3_11
, 1 },
1344 { WM5100_AUDIO_IF_3_18
, 0 },
1345 { WM5100_AUDIO_IF_3_19
, 1 },
1348 static int wm5100_set_bias_level(struct snd_soc_codec
*codec
,
1349 enum snd_soc_bias_level level
)
1351 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
1355 case SND_SOC_BIAS_ON
:
1358 case SND_SOC_BIAS_PREPARE
:
1361 case SND_SOC_BIAS_STANDBY
:
1362 if (codec
->dapm
.bias_level
== SND_SOC_BIAS_OFF
) {
1363 ret
= regulator_bulk_enable(ARRAY_SIZE(wm5100
->core_supplies
),
1364 wm5100
->core_supplies
);
1367 "Failed to enable supplies: %d\n",
1372 if (wm5100
->pdata
.ldo_ena
) {
1373 gpio_set_value_cansleep(wm5100
->pdata
.ldo_ena
,
1378 codec
->cache_only
= false;
1380 switch (wm5100
->rev
) {
1382 snd_soc_write(codec
, 0x11, 0x3);
1383 snd_soc_write(codec
, 0x203, 0xc);
1384 snd_soc_write(codec
, 0x206, 0);
1385 snd_soc_write(codec
, 0x207, 0xf0);
1386 snd_soc_write(codec
, 0x208, 0x3c);
1387 snd_soc_write(codec
, 0x209, 0);
1388 snd_soc_write(codec
, 0x211, 0x20d8);
1389 snd_soc_write(codec
, 0x11, 0);
1392 i
< ARRAY_SIZE(wm5100_reva_patches
);
1394 snd_soc_write(codec
,
1395 wm5100_reva_patches
[i
].reg
,
1396 wm5100_reva_patches
[i
].val
);
1402 snd_soc_cache_sync(codec
);
1406 case SND_SOC_BIAS_OFF
:
1407 if (wm5100
->pdata
.ldo_ena
)
1408 gpio_set_value_cansleep(wm5100
->pdata
.ldo_ena
, 0);
1409 regulator_bulk_disable(ARRAY_SIZE(wm5100
->core_supplies
),
1410 wm5100
->core_supplies
);
1413 codec
->dapm
.bias_level
= level
;
1418 static int wm5100_dai_to_base(struct snd_soc_dai
*dai
)
1422 return WM5100_AUDIO_IF_1_1
- 1;
1424 return WM5100_AUDIO_IF_2_1
- 1;
1426 return WM5100_AUDIO_IF_3_1
- 1;
1433 static int wm5100_set_fmt(struct snd_soc_dai
*dai
, unsigned int fmt
)
1435 struct snd_soc_codec
*codec
= dai
->codec
;
1436 int lrclk
, bclk
, mask
, base
;
1438 base
= wm5100_dai_to_base(dai
);
1445 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
1446 case SND_SOC_DAIFMT_DSP_A
:
1449 case SND_SOC_DAIFMT_DSP_B
:
1452 case SND_SOC_DAIFMT_I2S
:
1455 case SND_SOC_DAIFMT_LEFT_J
:
1459 dev_err(codec
->dev
, "Unsupported DAI format %d\n",
1460 fmt
& SND_SOC_DAIFMT_FORMAT_MASK
);
1464 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
1465 case SND_SOC_DAIFMT_CBS_CFS
:
1467 case SND_SOC_DAIFMT_CBS_CFM
:
1468 lrclk
|= WM5100_AIF1TX_LRCLK_MSTR
;
1470 case SND_SOC_DAIFMT_CBM_CFS
:
1471 bclk
|= WM5100_AIF1_BCLK_MSTR
;
1473 case SND_SOC_DAIFMT_CBM_CFM
:
1474 lrclk
|= WM5100_AIF1TX_LRCLK_MSTR
;
1475 bclk
|= WM5100_AIF1_BCLK_MSTR
;
1478 dev_err(codec
->dev
, "Unsupported master mode %d\n",
1479 fmt
& SND_SOC_DAIFMT_MASTER_MASK
);
1483 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
1484 case SND_SOC_DAIFMT_NB_NF
:
1486 case SND_SOC_DAIFMT_IB_IF
:
1487 bclk
|= WM5100_AIF1_BCLK_INV
;
1488 lrclk
|= WM5100_AIF1TX_LRCLK_INV
;
1490 case SND_SOC_DAIFMT_IB_NF
:
1491 bclk
|= WM5100_AIF1_BCLK_INV
;
1493 case SND_SOC_DAIFMT_NB_IF
:
1494 lrclk
|= WM5100_AIF1TX_LRCLK_INV
;
1500 snd_soc_update_bits(codec
, base
+ 1, WM5100_AIF1_BCLK_MSTR
|
1501 WM5100_AIF1_BCLK_INV
, bclk
);
1502 snd_soc_update_bits(codec
, base
+ 2, WM5100_AIF1TX_LRCLK_MSTR
|
1503 WM5100_AIF1TX_LRCLK_INV
, lrclk
);
1504 snd_soc_update_bits(codec
, base
+ 3, WM5100_AIF1TX_LRCLK_MSTR
|
1505 WM5100_AIF1TX_LRCLK_INV
, lrclk
);
1506 snd_soc_update_bits(codec
, base
+ 5, WM5100_AIF1_FMT_MASK
, mask
);
1511 #define WM5100_NUM_BCLK_RATES 19
1513 static int wm5100_bclk_rates_dat
[WM5100_NUM_BCLK_RATES
] = {
1535 static int wm5100_bclk_rates_cd
[WM5100_NUM_BCLK_RATES
] = {
1557 static int wm5100_hw_params(struct snd_pcm_substream
*substream
,
1558 struct snd_pcm_hw_params
*params
,
1559 struct snd_soc_dai
*dai
)
1561 struct snd_soc_codec
*codec
= dai
->codec
;
1562 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
1563 bool async
= wm5100
->aif_async
[dai
->id
];
1564 int i
, base
, bclk
, aif_rate
, lrclk
, wl
, fl
, sr
;
1567 base
= wm5100_dai_to_base(dai
);
1571 /* Data sizes if not using TDM */
1572 wl
= snd_pcm_format_width(params_format(params
));
1575 fl
= snd_soc_params_to_frame_size(params
);
1579 dev_dbg(codec
->dev
, "Word length %d bits, frame length %d bits\n",
1582 /* Target BCLK rate */
1583 bclk
= snd_soc_params_to_bclk(params
);
1587 /* Root for BCLK depends on SYS/ASYNCCLK */
1589 aif_rate
= wm5100
->sysclk
;
1590 sr
= wm5100_alloc_sr(codec
, params_rate(params
));
1594 /* If we're in ASYNCCLK set the ASYNC sample rate */
1595 aif_rate
= wm5100
->asyncclk
;
1598 for (i
= 0; i
< ARRAY_SIZE(wm5100_sr_code
); i
++)
1599 if (params_rate(params
) == wm5100_sr_code
[i
])
1601 if (i
== ARRAY_SIZE(wm5100_sr_code
)) {
1602 dev_err(codec
->dev
, "Invalid rate %dHzn",
1603 params_rate(params
));
1607 /* TODO: We should really check for symmetry */
1608 snd_soc_update_bits(codec
, WM5100_CLOCKING_8
,
1609 WM5100_ASYNC_SAMPLE_RATE_MASK
, i
);
1613 dev_err(codec
->dev
, "%s has no rate set\n",
1614 async
? "ASYNCCLK" : "SYSCLK");
1618 dev_dbg(codec
->dev
, "Target BCLK is %dHz, using %dHz %s\n",
1619 bclk
, aif_rate
, async
? "ASYNCCLK" : "SYSCLK");
1621 if (aif_rate
% 4000)
1622 bclk_rates
= wm5100_bclk_rates_cd
;
1624 bclk_rates
= wm5100_bclk_rates_dat
;
1626 for (i
= 0; i
< WM5100_NUM_BCLK_RATES
; i
++)
1627 if (bclk_rates
[i
] >= bclk
&& (bclk_rates
[i
] % bclk
== 0))
1629 if (i
== WM5100_NUM_BCLK_RATES
) {
1631 "No valid BCLK for %dHz found from %dHz %s\n",
1632 bclk
, aif_rate
, async
? "ASYNCCLK" : "SYSCLK");
1637 dev_dbg(codec
->dev
, "Setting %dHz BCLK\n", bclk_rates
[bclk
]);
1638 snd_soc_update_bits(codec
, base
+ 1, WM5100_AIF1_BCLK_FREQ_MASK
, bclk
);
1640 lrclk
= bclk_rates
[bclk
] / params_rate(params
);
1641 dev_dbg(codec
->dev
, "Setting %dHz LRCLK\n", bclk_rates
[bclk
] / lrclk
);
1642 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
||
1643 wm5100
->aif_symmetric
[dai
->id
])
1644 snd_soc_update_bits(codec
, base
+ 7,
1645 WM5100_AIF1RX_BCPF_MASK
, lrclk
);
1647 snd_soc_update_bits(codec
, base
+ 6,
1648 WM5100_AIF1TX_BCPF_MASK
, lrclk
);
1650 i
= (wl
<< WM5100_AIF1TX_WL_SHIFT
) | fl
;
1651 if (substream
->stream
== SNDRV_PCM_STREAM_PLAYBACK
)
1652 snd_soc_update_bits(codec
, base
+ 9,
1653 WM5100_AIF1RX_WL_MASK
|
1654 WM5100_AIF1RX_SLOT_LEN_MASK
, i
);
1656 snd_soc_update_bits(codec
, base
+ 8,
1657 WM5100_AIF1TX_WL_MASK
|
1658 WM5100_AIF1TX_SLOT_LEN_MASK
, i
);
1660 snd_soc_update_bits(codec
, base
+ 4, WM5100_AIF1_RATE_MASK
, sr
);
1665 static struct snd_soc_dai_ops wm5100_dai_ops
= {
1666 .set_fmt
= wm5100_set_fmt
,
1667 .hw_params
= wm5100_hw_params
,
1670 static int wm5100_set_sysclk(struct snd_soc_codec
*codec
, int clk_id
,
1671 int source
, unsigned int freq
, int dir
)
1673 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
1675 int fval
, audio_rate
, ret
, reg
;
1678 case WM5100_CLK_SYSCLK
:
1679 reg
= WM5100_CLOCKING_3
;
1680 rate_store
= &wm5100
->sysclk
;
1682 case WM5100_CLK_ASYNCCLK
:
1683 reg
= WM5100_CLOCKING_7
;
1684 rate_store
= &wm5100
->asyncclk
;
1686 case WM5100_CLK_32KHZ
:
1687 /* The 32kHz clock is slightly different to the others */
1689 case WM5100_CLKSRC_MCLK1
:
1690 case WM5100_CLKSRC_MCLK2
:
1691 case WM5100_CLKSRC_SYSCLK
:
1692 snd_soc_update_bits(codec
, WM5100_CLOCKING_1
,
1693 WM5100_CLK_32K_SRC_MASK
,
1701 case WM5100_CLK_AIF1
:
1702 case WM5100_CLK_AIF2
:
1703 case WM5100_CLK_AIF3
:
1704 /* Not real clocks, record which clock domain they're in */
1706 case WM5100_CLKSRC_SYSCLK
:
1707 wm5100
->aif_async
[clk_id
- 1] = false;
1709 case WM5100_CLKSRC_ASYNCCLK
:
1710 wm5100
->aif_async
[clk_id
- 1] = true;
1713 dev_err(codec
->dev
, "Invalid source %d\n", source
);
1718 case WM5100_CLK_OPCLK
:
1722 snd_soc_update_bits(codec
, WM5100_MISC_GPIO_1
,
1723 WM5100_OPCLK_SEL_MASK
, 0);
1727 snd_soc_update_bits(codec
, WM5100_MISC_GPIO_1
,
1728 WM5100_OPCLK_SEL_MASK
, 0);
1732 snd_soc_update_bits(codec
, WM5100_MISC_GPIO_1
,
1733 WM5100_OPCLK_SEL_MASK
, 0);
1736 dev_err(codec
->dev
, "Unsupported OPCLK %dHz\n",
1743 dev_err(codec
->dev
, "Unknown clock %d\n", clk_id
);
1748 case WM5100_CLKSRC_SYSCLK
:
1749 case WM5100_CLKSRC_ASYNCCLK
:
1750 dev_err(codec
->dev
, "Invalid source %d\n", source
);
1768 dev_err(codec
->dev
, "Invalid clock rate: %d\n", freq
);
1791 /* TODO: Check if MCLKs are in use and enable/disable pulls to
1795 snd_soc_update_bits(codec
, reg
, WM5100_SYSCLK_FREQ_MASK
|
1796 WM5100_SYSCLK_SRC_MASK
,
1797 fval
<< WM5100_SYSCLK_FREQ_SHIFT
| source
);
1799 /* If this is SYSCLK then configure the clock rate for the
1800 * internal audio functions to the natural sample rate for
1803 if (clk_id
== WM5100_CLK_SYSCLK
) {
1804 dev_dbg(codec
->dev
, "Setting primary audio rate to %dHz",
1806 if (0 && *rate_store
)
1807 wm5100_free_sr(codec
, audio_rate
);
1808 ret
= wm5100_alloc_sr(codec
, audio_rate
);
1810 dev_warn(codec
->dev
, "Primary audio slot is %d\n",
1834 { 0, 64000, 4, 16 },
1835 { 64000, 128000, 3, 8 },
1836 { 128000, 256000, 2, 4 },
1837 { 256000, 1000000, 1, 2 },
1838 { 1000000, 13500000, 0, 1 },
1841 static int fll_factors(struct _fll_div
*fll_div
, unsigned int Fref
,
1844 unsigned int target
;
1846 unsigned int fratio
, gcd_fll
;
1849 /* Fref must be <=13.5MHz */
1851 fll_div
->fll_refclk_div
= 0;
1852 while ((Fref
/ div
) > 13500000) {
1854 fll_div
->fll_refclk_div
++;
1857 pr_err("Can't scale %dMHz input down to <=13.5MHz\n",
1863 pr_debug("FLL Fref=%u Fout=%u\n", Fref
, Fout
);
1865 /* Apply the division for our remaining calculations */
1868 /* Fvco should be 90-100MHz; don't check the upper bound */
1870 while (Fout
* div
< 90000000) {
1873 pr_err("Unable to find FLL_OUTDIV for Fout=%uHz\n",
1878 target
= Fout
* div
;
1879 fll_div
->fll_outdiv
= div
- 1;
1881 pr_debug("FLL Fvco=%dHz\n", target
);
1883 /* Find an appropraite FLL_FRATIO and factor it out of the target */
1884 for (i
= 0; i
< ARRAY_SIZE(fll_fratios
); i
++) {
1885 if (fll_fratios
[i
].min
<= Fref
&& Fref
<= fll_fratios
[i
].max
) {
1886 fll_div
->fll_fratio
= fll_fratios
[i
].fll_fratio
;
1887 fratio
= fll_fratios
[i
].ratio
;
1891 if (i
== ARRAY_SIZE(fll_fratios
)) {
1892 pr_err("Unable to find FLL_FRATIO for Fref=%uHz\n", Fref
);
1896 fll_div
->n
= target
/ (fratio
* Fref
);
1898 if (target
% Fref
== 0) {
1900 fll_div
->lambda
= 0;
1902 gcd_fll
= gcd(target
, fratio
* Fref
);
1904 fll_div
->theta
= (target
- (fll_div
->n
* fratio
* Fref
))
1906 fll_div
->lambda
= (fratio
* Fref
) / gcd_fll
;
1909 pr_debug("FLL N=%x THETA=%x LAMBDA=%x\n",
1910 fll_div
->n
, fll_div
->theta
, fll_div
->lambda
);
1911 pr_debug("FLL_FRATIO=%x(%d) FLL_OUTDIV=%x FLL_REFCLK_DIV=%x\n",
1912 fll_div
->fll_fratio
, fratio
, fll_div
->fll_outdiv
,
1913 fll_div
->fll_refclk_div
);
1918 static int wm5100_set_fll(struct snd_soc_codec
*codec
, int fll_id
, int source
,
1919 unsigned int Fref
, unsigned int Fout
)
1921 struct i2c_client
*i2c
= to_i2c_client(codec
->dev
);
1922 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
1923 struct _fll_div factors
;
1924 struct wm5100_fll
*fll
;
1925 int ret
, base
, lock
, i
, timeout
;
1929 fll
= &wm5100
->fll
[0];
1930 base
= WM5100_FLL1_CONTROL_1
- 1;
1931 lock
= WM5100_FLL1_LOCK_STS
;
1934 fll
= &wm5100
->fll
[1];
1935 base
= WM5100_FLL2_CONTROL_2
- 1;
1936 lock
= WM5100_FLL2_LOCK_STS
;
1939 dev_err(codec
->dev
, "Unknown FLL %d\n",fll_id
);
1944 dev_dbg(codec
->dev
, "FLL%d disabled", fll_id
);
1946 snd_soc_update_bits(codec
, base
+ 1, WM5100_FLL1_ENA
, 0);
1951 case WM5100_FLL_SRC_MCLK1
:
1952 case WM5100_FLL_SRC_MCLK2
:
1953 case WM5100_FLL_SRC_FLL1
:
1954 case WM5100_FLL_SRC_FLL2
:
1955 case WM5100_FLL_SRC_AIF1BCLK
:
1956 case WM5100_FLL_SRC_AIF2BCLK
:
1957 case WM5100_FLL_SRC_AIF3BCLK
:
1960 dev_err(codec
->dev
, "Invalid FLL source %d\n", source
);
1964 ret
= fll_factors(&factors
, Fref
, Fout
);
1968 /* Disable the FLL while we reconfigure */
1969 snd_soc_update_bits(codec
, base
+ 1, WM5100_FLL1_ENA
, 0);
1971 snd_soc_update_bits(codec
, base
+ 2,
1972 WM5100_FLL1_OUTDIV_MASK
| WM5100_FLL1_FRATIO_MASK
,
1973 (factors
.fll_outdiv
<< WM5100_FLL1_OUTDIV_SHIFT
) |
1974 factors
.fll_fratio
);
1975 snd_soc_update_bits(codec
, base
+ 3, WM5100_FLL1_THETA_MASK
,
1977 snd_soc_update_bits(codec
, base
+ 5, WM5100_FLL1_N_MASK
, factors
.n
);
1978 snd_soc_update_bits(codec
, base
+ 6,
1979 WM5100_FLL1_REFCLK_DIV_MASK
|
1980 WM5100_FLL1_REFCLK_SRC_MASK
,
1981 (factors
.fll_refclk_div
1982 << WM5100_FLL1_REFCLK_DIV_SHIFT
) | source
);
1983 snd_soc_update_bits(codec
, base
+ 7, WM5100_FLL1_LAMBDA_MASK
,
1986 /* Clear any pending completions */
1987 try_wait_for_completion(&fll
->lock
);
1989 snd_soc_update_bits(codec
, base
+ 1, WM5100_FLL1_ENA
, WM5100_FLL1_ENA
);
1996 /* Poll for the lock; will use interrupt when we can test */
1997 for (i
= 0; i
< timeout
; i
++) {
1999 ret
= wait_for_completion_timeout(&fll
->lock
,
2000 msecs_to_jiffies(25));
2007 ret
= snd_soc_read(codec
,
2008 WM5100_INTERRUPT_RAW_STATUS_3
);
2011 "Failed to read FLL status: %d\n",
2019 dev_err(codec
->dev
, "FLL%d lock timed out\n", fll_id
);
2027 dev_dbg(codec
->dev
, "FLL%d running %dHz->%dHz\n", fll_id
,
2033 /* Actually go much higher */
2034 #define WM5100_RATES SNDRV_PCM_RATE_8000_192000
2036 #define WM5100_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\
2037 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
2039 static struct snd_soc_dai_driver wm5100_dai
[] = {
2041 .name
= "wm5100-aif1",
2043 .stream_name
= "AIF1 Playback",
2046 .rates
= WM5100_RATES
,
2047 .formats
= WM5100_FORMATS
,
2050 .stream_name
= "AIF1 Capture",
2053 .rates
= WM5100_RATES
,
2054 .formats
= WM5100_FORMATS
,
2056 .ops
= &wm5100_dai_ops
,
2059 .name
= "wm5100-aif2",
2062 .stream_name
= "AIF2 Playback",
2065 .rates
= WM5100_RATES
,
2066 .formats
= WM5100_FORMATS
,
2069 .stream_name
= "AIF2 Capture",
2072 .rates
= WM5100_RATES
,
2073 .formats
= WM5100_FORMATS
,
2075 .ops
= &wm5100_dai_ops
,
2078 .name
= "wm5100-aif3",
2081 .stream_name
= "AIF3 Playback",
2084 .rates
= WM5100_RATES
,
2085 .formats
= WM5100_FORMATS
,
2088 .stream_name
= "AIF3 Capture",
2091 .rates
= WM5100_RATES
,
2092 .formats
= WM5100_FORMATS
,
2094 .ops
= &wm5100_dai_ops
,
2098 static int wm5100_dig_vu
[] = {
2099 WM5100_ADC_DIGITAL_VOLUME_1L
,
2100 WM5100_ADC_DIGITAL_VOLUME_1R
,
2101 WM5100_ADC_DIGITAL_VOLUME_2L
,
2102 WM5100_ADC_DIGITAL_VOLUME_2R
,
2103 WM5100_ADC_DIGITAL_VOLUME_3L
,
2104 WM5100_ADC_DIGITAL_VOLUME_3R
,
2105 WM5100_ADC_DIGITAL_VOLUME_4L
,
2106 WM5100_ADC_DIGITAL_VOLUME_4R
,
2108 WM5100_DAC_DIGITAL_VOLUME_1L
,
2109 WM5100_DAC_DIGITAL_VOLUME_1R
,
2110 WM5100_DAC_DIGITAL_VOLUME_2L
,
2111 WM5100_DAC_DIGITAL_VOLUME_2R
,
2112 WM5100_DAC_DIGITAL_VOLUME_3L
,
2113 WM5100_DAC_DIGITAL_VOLUME_3R
,
2114 WM5100_DAC_DIGITAL_VOLUME_4L
,
2115 WM5100_DAC_DIGITAL_VOLUME_4R
,
2116 WM5100_DAC_DIGITAL_VOLUME_5L
,
2117 WM5100_DAC_DIGITAL_VOLUME_5R
,
2118 WM5100_DAC_DIGITAL_VOLUME_6L
,
2119 WM5100_DAC_DIGITAL_VOLUME_6R
,
2122 static void wm5100_set_detect_mode(struct snd_soc_codec
*codec
, int the_mode
)
2124 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2125 struct wm5100_jack_mode
*mode
= &wm5100
->pdata
.jack_modes
[the_mode
];
2127 BUG_ON(the_mode
>= ARRAY_SIZE(wm5100
->pdata
.jack_modes
));
2129 gpio_set_value_cansleep(wm5100
->pdata
.hp_pol
, mode
->hp_pol
);
2130 snd_soc_update_bits(codec
, WM5100_ACCESSORY_DETECT_MODE_1
,
2131 WM5100_ACCDET_BIAS_SRC_MASK
|
2133 (mode
->bias
<< WM5100_ACCDET_BIAS_SRC_SHIFT
) |
2134 mode
->micd_src
<< WM5100_ACCDET_SRC_SHIFT
);
2135 snd_soc_update_bits(codec
, WM5100_MISC_CONTROL
,
2137 mode
->micd_src
<< WM5100_HPCOM_SRC_SHIFT
);
2139 wm5100
->jack_mode
= the_mode
;
2141 dev_dbg(codec
->dev
, "Set microphone polarity to %d\n",
2145 static void wm5100_micd_irq(struct snd_soc_codec
*codec
)
2147 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2150 val
= snd_soc_read(codec
, WM5100_MIC_DETECT_3
);
2152 dev_dbg(codec
->dev
, "Microphone event: %x\n", val
);
2154 if (!(val
& WM5100_ACCDET_VALID
)) {
2155 dev_warn(codec
->dev
, "Microphone detection state invalid\n");
2159 /* No accessory, reset everything and report removal */
2160 if (!(val
& WM5100_ACCDET_STS
)) {
2161 dev_dbg(codec
->dev
, "Jack removal detected\n");
2162 wm5100
->jack_mic
= false;
2163 wm5100
->jack_detecting
= true;
2164 snd_soc_jack_report(wm5100
->jack
, 0,
2165 SND_JACK_LINEOUT
| SND_JACK_HEADSET
|
2168 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2169 WM5100_ACCDET_RATE_MASK
,
2170 WM5100_ACCDET_RATE_MASK
);
2174 /* If the measurement is very high we've got a microphone,
2175 * either we just detected one or if we already reported then
2176 * we've got a button release event.
2179 if (wm5100
->jack_detecting
) {
2180 dev_dbg(codec
->dev
, "Microphone detected\n");
2181 wm5100
->jack_mic
= true;
2182 snd_soc_jack_report(wm5100
->jack
,
2184 SND_JACK_HEADSET
| SND_JACK_BTN_0
);
2186 /* Increase poll rate to give better responsiveness
2188 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2189 WM5100_ACCDET_RATE_MASK
,
2190 5 << WM5100_ACCDET_RATE_SHIFT
);
2192 dev_dbg(codec
->dev
, "Mic button up\n");
2193 snd_soc_jack_report(wm5100
->jack
, 0, SND_JACK_BTN_0
);
2199 /* If we detected a lower impedence during initial startup
2200 * then we probably have the wrong polarity, flip it. Don't
2201 * do this for the lowest impedences to speed up detection of
2204 if (wm5100
->jack_detecting
&& (val
& 0x3f8)) {
2205 wm5100_set_detect_mode(codec
, !wm5100
->jack_mode
);
2210 /* Don't distinguish between buttons, just report any low
2211 * impedence as BTN_0.
2214 if (wm5100
->jack_mic
) {
2215 dev_dbg(codec
->dev
, "Mic button detected\n");
2216 snd_soc_jack_report(wm5100
->jack
, SND_JACK_BTN_0
,
2218 } else if (wm5100
->jack_detecting
) {
2219 dev_dbg(codec
->dev
, "Headphone detected\n");
2220 snd_soc_jack_report(wm5100
->jack
, SND_JACK_HEADPHONE
,
2221 SND_JACK_HEADPHONE
);
2223 /* Increase the detection rate a bit for
2226 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2227 WM5100_ACCDET_RATE_MASK
,
2228 7 << WM5100_ACCDET_RATE_SHIFT
);
2233 int wm5100_detect(struct snd_soc_codec
*codec
, struct snd_soc_jack
*jack
)
2235 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2238 wm5100
->jack
= jack
;
2239 wm5100
->jack_detecting
= true;
2241 wm5100_set_detect_mode(codec
, 0);
2243 /* Slowest detection rate, gives debounce for initial
2245 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2246 WM5100_ACCDET_BIAS_STARTTIME_MASK
|
2247 WM5100_ACCDET_RATE_MASK
,
2248 (7 << WM5100_ACCDET_BIAS_STARTTIME_SHIFT
) |
2249 WM5100_ACCDET_RATE_MASK
);
2251 /* We need the charge pump to power MICBIAS */
2252 snd_soc_dapm_force_enable_pin(&codec
->dapm
, "CP2");
2253 snd_soc_dapm_force_enable_pin(&codec
->dapm
, "SYSCLK");
2254 snd_soc_dapm_sync(&codec
->dapm
);
2256 /* We start off just enabling microphone detection - even a
2257 * plain headphone will trigger detection.
2259 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2260 WM5100_ACCDET_ENA
, WM5100_ACCDET_ENA
);
2262 snd_soc_update_bits(codec
, WM5100_INTERRUPT_STATUS_3_MASK
,
2263 WM5100_IM_ACCDET_EINT
, 0);
2265 snd_soc_update_bits(codec
, WM5100_INTERRUPT_STATUS_3_MASK
,
2266 WM5100_IM_HPDET_EINT
|
2267 WM5100_IM_ACCDET_EINT
,
2268 WM5100_IM_HPDET_EINT
|
2269 WM5100_IM_ACCDET_EINT
);
2270 snd_soc_update_bits(codec
, WM5100_MIC_DETECT_1
,
2271 WM5100_ACCDET_ENA
, 0);
2272 wm5100
->jack
= NULL
;
2278 static irqreturn_t
wm5100_irq(int irq
, void *data
)
2280 struct snd_soc_codec
*codec
= data
;
2281 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2282 irqreturn_t status
= IRQ_NONE
;
2285 irq_val
= snd_soc_read(codec
, WM5100_INTERRUPT_STATUS_3
);
2287 dev_err(codec
->dev
, "Failed to read IRQ status 3: %d\n",
2291 irq_val
&= ~snd_soc_read(codec
, WM5100_INTERRUPT_STATUS_3_MASK
);
2293 snd_soc_write(codec
, WM5100_INTERRUPT_STATUS_3
, irq_val
);
2296 status
= IRQ_HANDLED
;
2298 wm5100_log_status3(codec
, irq_val
);
2300 if (irq_val
& WM5100_FLL1_LOCK_EINT
) {
2301 dev_dbg(codec
->dev
, "FLL1 locked\n");
2302 complete(&wm5100
->fll
[0].lock
);
2304 if (irq_val
& WM5100_FLL2_LOCK_EINT
) {
2305 dev_dbg(codec
->dev
, "FLL2 locked\n");
2306 complete(&wm5100
->fll
[1].lock
);
2309 if (irq_val
& WM5100_ACCDET_EINT
)
2310 wm5100_micd_irq(codec
);
2312 irq_val
= snd_soc_read(codec
, WM5100_INTERRUPT_STATUS_4
);
2314 dev_err(codec
->dev
, "Failed to read IRQ status 4: %d\n",
2318 irq_val
&= ~snd_soc_read(codec
, WM5100_INTERRUPT_STATUS_4_MASK
);
2321 status
= IRQ_HANDLED
;
2323 snd_soc_write(codec
, WM5100_INTERRUPT_STATUS_4
, irq_val
);
2325 wm5100_log_status4(codec
, irq_val
);
2330 static irqreturn_t
wm5100_edge_irq(int irq
, void *data
)
2332 irqreturn_t ret
= IRQ_NONE
;
2336 val
= wm5100_irq(irq
, data
);
2337 if (val
!= IRQ_NONE
)
2339 } while (val
!= IRQ_NONE
);
2344 #ifdef CONFIG_GPIOLIB
2345 static inline struct wm5100_priv
*gpio_to_wm5100(struct gpio_chip
*chip
)
2347 return container_of(chip
, struct wm5100_priv
, gpio_chip
);
2350 static void wm5100_gpio_set(struct gpio_chip
*chip
, unsigned offset
, int value
)
2352 struct wm5100_priv
*wm5100
= gpio_to_wm5100(chip
);
2353 struct snd_soc_codec
*codec
= wm5100
->codec
;
2355 snd_soc_update_bits(codec
, WM5100_GPIO_CTRL_1
+ offset
,
2356 WM5100_GP1_LVL
, !!value
<< WM5100_GP1_LVL_SHIFT
);
2359 static int wm5100_gpio_direction_out(struct gpio_chip
*chip
,
2360 unsigned offset
, int value
)
2362 struct wm5100_priv
*wm5100
= gpio_to_wm5100(chip
);
2363 struct snd_soc_codec
*codec
= wm5100
->codec
;
2366 val
= (1 << WM5100_GP1_FN_SHIFT
) | (!!value
<< WM5100_GP1_LVL_SHIFT
);
2368 ret
= snd_soc_update_bits(codec
, WM5100_GPIO_CTRL_1
+ offset
,
2369 WM5100_GP1_FN_MASK
| WM5100_GP1_DIR
|
2370 WM5100_GP1_LVL
, val
);
2377 static int wm5100_gpio_get(struct gpio_chip
*chip
, unsigned offset
)
2379 struct wm5100_priv
*wm5100
= gpio_to_wm5100(chip
);
2380 struct snd_soc_codec
*codec
= wm5100
->codec
;
2383 ret
= snd_soc_read(codec
, WM5100_GPIO_CTRL_1
+ offset
);
2387 return (ret
& WM5100_GP1_LVL
) != 0;
2390 static int wm5100_gpio_direction_in(struct gpio_chip
*chip
, unsigned offset
)
2392 struct wm5100_priv
*wm5100
= gpio_to_wm5100(chip
);
2393 struct snd_soc_codec
*codec
= wm5100
->codec
;
2395 return snd_soc_update_bits(codec
, WM5100_GPIO_CTRL_1
+ offset
,
2396 WM5100_GP1_FN_MASK
| WM5100_GP1_DIR
,
2397 (1 << WM5100_GP1_FN_SHIFT
) |
2398 (1 << WM5100_GP1_DIR_SHIFT
));
2401 static struct gpio_chip wm5100_template_chip
= {
2403 .owner
= THIS_MODULE
,
2404 .direction_output
= wm5100_gpio_direction_out
,
2405 .set
= wm5100_gpio_set
,
2406 .direction_input
= wm5100_gpio_direction_in
,
2407 .get
= wm5100_gpio_get
,
2411 static void wm5100_init_gpio(struct snd_soc_codec
*codec
)
2413 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2416 wm5100
->gpio_chip
= wm5100_template_chip
;
2417 wm5100
->gpio_chip
.ngpio
= 6;
2418 wm5100
->gpio_chip
.dev
= codec
->dev
;
2420 if (wm5100
->pdata
.gpio_base
)
2421 wm5100
->gpio_chip
.base
= wm5100
->pdata
.gpio_base
;
2423 wm5100
->gpio_chip
.base
= -1;
2425 ret
= gpiochip_add(&wm5100
->gpio_chip
);
2427 dev_err(codec
->dev
, "Failed to add GPIOs: %d\n", ret
);
2430 static void wm5100_free_gpio(struct snd_soc_codec
*codec
)
2432 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2435 ret
= gpiochip_remove(&wm5100
->gpio_chip
);
2437 dev_err(codec
->dev
, "Failed to remove GPIOs: %d\n", ret
);
2440 static void wm5100_init_gpio(struct snd_soc_codec
*codec
)
2444 static void wm5100_free_gpio(struct snd_soc_codec
*codec
)
2449 static int wm5100_probe(struct snd_soc_codec
*codec
)
2451 struct i2c_client
*i2c
= to_i2c_client(codec
->dev
);
2452 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2453 int ret
, i
, irq_flags
;
2455 wm5100
->codec
= codec
;
2457 ret
= snd_soc_codec_set_cache_io(codec
, 16, 16, SND_SOC_I2C
);
2459 dev_err(codec
->dev
, "Failed to set cache I/O: %d\n", ret
);
2463 for (i
= 0; i
< ARRAY_SIZE(wm5100
->core_supplies
); i
++)
2464 wm5100
->core_supplies
[i
].supply
= wm5100_core_supply_names
[i
];
2466 ret
= regulator_bulk_get(&i2c
->dev
, ARRAY_SIZE(wm5100
->core_supplies
),
2467 wm5100
->core_supplies
);
2469 dev_err(codec
->dev
, "Failed to request core supplies: %d\n",
2474 wm5100
->cpvdd
= regulator_get(&i2c
->dev
, "CPVDD");
2475 if (IS_ERR(wm5100
->cpvdd
)) {
2476 ret
= PTR_ERR(wm5100
->cpvdd
);
2477 dev_err(&i2c
->dev
, "Failed to get CPVDD: %d\n", ret
);
2481 wm5100
->dbvdd2
= regulator_get(&i2c
->dev
, "DBVDD2");
2482 if (IS_ERR(wm5100
->dbvdd2
)) {
2483 ret
= PTR_ERR(wm5100
->dbvdd2
);
2484 dev_err(&i2c
->dev
, "Failed to get DBVDD2: %d\n", ret
);
2488 wm5100
->dbvdd3
= regulator_get(&i2c
->dev
, "DBVDD3");
2489 if (IS_ERR(wm5100
->dbvdd3
)) {
2490 ret
= PTR_ERR(wm5100
->dbvdd3
);
2491 dev_err(&i2c
->dev
, "Failed to get DBVDD2: %d\n", ret
);
2495 ret
= regulator_bulk_enable(ARRAY_SIZE(wm5100
->core_supplies
),
2496 wm5100
->core_supplies
);
2498 dev_err(codec
->dev
, "Failed to enable core supplies: %d\n",
2503 if (wm5100
->pdata
.ldo_ena
) {
2504 ret
= gpio_request_one(wm5100
->pdata
.ldo_ena
,
2505 GPIOF_OUT_INIT_HIGH
, "WM5100 LDOENA");
2507 dev_err(&i2c
->dev
, "Failed to request LDOENA %d: %d\n",
2508 wm5100
->pdata
.ldo_ena
, ret
);
2514 if (wm5100
->pdata
.reset
) {
2515 ret
= gpio_request_one(wm5100
->pdata
.reset
,
2516 GPIOF_OUT_INIT_HIGH
, "WM5100 /RESET");
2518 dev_err(&i2c
->dev
, "Failed to request /RESET %d: %d\n",
2519 wm5100
->pdata
.reset
, ret
);
2524 ret
= snd_soc_read(codec
, WM5100_SOFTWARE_RESET
);
2526 dev_err(codec
->dev
, "Failed to read ID register\n");
2535 dev_err(codec
->dev
, "Device is not a WM5100, ID is %x\n", ret
);
2540 ret
= snd_soc_read(codec
, WM5100_DEVICE_REVISION
);
2542 dev_err(codec
->dev
, "Failed to read revision register\n");
2545 wm5100
->rev
= ret
& WM5100_DEVICE_REVISION_MASK
;
2547 dev_info(codec
->dev
, "revision %c\n", wm5100
->rev
+ 'A');
2549 ret
= wm5100_reset(codec
);
2551 dev_err(codec
->dev
, "Failed to issue reset\n");
2555 codec
->cache_only
= true;
2557 wm5100_init_gpio(codec
);
2559 for (i
= 0; i
< ARRAY_SIZE(wm5100_dig_vu
); i
++)
2560 snd_soc_update_bits(codec
, wm5100_dig_vu
[i
], WM5100_OUT_VU
,
2563 for (i
= 0; i
< ARRAY_SIZE(wm5100
->pdata
.in_mode
); i
++) {
2564 snd_soc_update_bits(codec
, WM5100_IN1L_CONTROL
,
2565 WM5100_IN1_MODE_MASK
|
2566 WM5100_IN1_DMIC_SUP_MASK
,
2567 (wm5100
->pdata
.in_mode
[i
] <<
2568 WM5100_IN1_MODE_SHIFT
) |
2569 (wm5100
->pdata
.dmic_sup
[i
] <<
2570 WM5100_IN1_DMIC_SUP_SHIFT
));
2573 for (i
= 0; i
< ARRAY_SIZE(wm5100
->pdata
.gpio_defaults
); i
++) {
2574 if (!wm5100
->pdata
.gpio_defaults
[i
])
2577 snd_soc_write(codec
, WM5100_GPIO_CTRL_1
+ i
,
2578 wm5100
->pdata
.gpio_defaults
[i
]);
2581 /* Don't debounce interrupts to support use of SYSCLK only */
2582 snd_soc_write(codec
, WM5100_IRQ_DEBOUNCE_1
, 0);
2583 snd_soc_write(codec
, WM5100_IRQ_DEBOUNCE_2
, 0);
2585 /* TODO: check if we're symmetric */
2588 if (wm5100
->pdata
.irq_flags
)
2589 irq_flags
= wm5100
->pdata
.irq_flags
;
2591 irq_flags
= IRQF_TRIGGER_LOW
;
2593 irq_flags
|= IRQF_ONESHOT
;
2595 if (irq_flags
& (IRQF_TRIGGER_RISING
| IRQF_TRIGGER_FALLING
))
2596 ret
= request_threaded_irq(i2c
->irq
, NULL
,
2598 irq_flags
, "wm5100", codec
);
2600 ret
= request_threaded_irq(i2c
->irq
, NULL
, wm5100_irq
,
2601 irq_flags
, "wm5100", codec
);
2604 dev_err(codec
->dev
, "Failed to request IRQ %d: %d\n",
2607 /* Enable default interrupts */
2608 snd_soc_update_bits(codec
,
2609 WM5100_INTERRUPT_STATUS_3_MASK
,
2610 WM5100_IM_SPK_SHUTDOWN_WARN_EINT
|
2611 WM5100_IM_SPK_SHUTDOWN_EINT
|
2612 WM5100_IM_ASRC2_LOCK_EINT
|
2613 WM5100_IM_ASRC1_LOCK_EINT
|
2614 WM5100_IM_FLL2_LOCK_EINT
|
2615 WM5100_IM_FLL1_LOCK_EINT
|
2616 WM5100_CLKGEN_ERR_EINT
|
2617 WM5100_CLKGEN_ERR_ASYNC_EINT
, 0);
2619 snd_soc_update_bits(codec
,
2620 WM5100_INTERRUPT_STATUS_4_MASK
,
2621 WM5100_AIF3_ERR_EINT
|
2622 WM5100_AIF2_ERR_EINT
|
2623 WM5100_AIF1_ERR_EINT
|
2624 WM5100_CTRLIF_ERR_EINT
|
2625 WM5100_ISRC2_UNDERCLOCKED_EINT
|
2626 WM5100_ISRC1_UNDERCLOCKED_EINT
|
2627 WM5100_FX_UNDERCLOCKED_EINT
|
2628 WM5100_AIF3_UNDERCLOCKED_EINT
|
2629 WM5100_AIF2_UNDERCLOCKED_EINT
|
2630 WM5100_AIF1_UNDERCLOCKED_EINT
|
2631 WM5100_ASRC_UNDERCLOCKED_EINT
|
2632 WM5100_DAC_UNDERCLOCKED_EINT
|
2633 WM5100_ADC_UNDERCLOCKED_EINT
|
2634 WM5100_MIXER_UNDERCLOCKED_EINT
, 0);
2637 snd_soc_dapm_new_controls(&codec
->dapm
,
2638 wm5100_dapm_widgets_noirq
,
2639 ARRAY_SIZE(wm5100_dapm_widgets_noirq
));
2642 if (wm5100
->pdata
.hp_pol
) {
2643 ret
= gpio_request_one(wm5100
->pdata
.hp_pol
,
2644 GPIOF_OUT_INIT_HIGH
, "WM5100 HP_POL");
2646 dev_err(&i2c
->dev
, "Failed to request HP_POL %d: %d\n",
2647 wm5100
->pdata
.hp_pol
, ret
);
2652 /* We'll get woken up again when the system has something useful
2655 if (wm5100
->pdata
.ldo_ena
)
2656 gpio_set_value_cansleep(wm5100
->pdata
.ldo_ena
, 0);
2657 regulator_bulk_disable(ARRAY_SIZE(wm5100
->core_supplies
),
2658 wm5100
->core_supplies
);
2664 free_irq(i2c
->irq
, codec
);
2665 wm5100_free_gpio(codec
);
2667 if (wm5100
->pdata
.reset
) {
2668 gpio_set_value_cansleep(wm5100
->pdata
.reset
, 1);
2669 gpio_free(wm5100
->pdata
.reset
);
2672 if (wm5100
->pdata
.ldo_ena
) {
2673 gpio_set_value_cansleep(wm5100
->pdata
.ldo_ena
, 0);
2674 gpio_free(wm5100
->pdata
.ldo_ena
);
2677 regulator_bulk_disable(ARRAY_SIZE(wm5100
->core_supplies
),
2678 wm5100
->core_supplies
);
2680 regulator_put(wm5100
->dbvdd3
);
2682 regulator_put(wm5100
->dbvdd2
);
2684 regulator_put(wm5100
->cpvdd
);
2686 regulator_bulk_free(ARRAY_SIZE(wm5100
->core_supplies
),
2687 wm5100
->core_supplies
);
2692 static int wm5100_remove(struct snd_soc_codec
*codec
)
2694 struct wm5100_priv
*wm5100
= snd_soc_codec_get_drvdata(codec
);
2695 struct i2c_client
*i2c
= to_i2c_client(codec
->dev
);
2697 wm5100_set_bias_level(codec
, SND_SOC_BIAS_OFF
);
2698 if (wm5100
->pdata
.hp_pol
) {
2699 gpio_free(wm5100
->pdata
.hp_pol
);
2702 free_irq(i2c
->irq
, codec
);
2703 wm5100_free_gpio(codec
);
2704 if (wm5100
->pdata
.reset
) {
2705 gpio_set_value_cansleep(wm5100
->pdata
.reset
, 1);
2706 gpio_free(wm5100
->pdata
.reset
);
2708 if (wm5100
->pdata
.ldo_ena
) {
2709 gpio_set_value_cansleep(wm5100
->pdata
.ldo_ena
, 0);
2710 gpio_free(wm5100
->pdata
.ldo_ena
);
2712 regulator_put(wm5100
->dbvdd3
);
2713 regulator_put(wm5100
->dbvdd2
);
2714 regulator_put(wm5100
->cpvdd
);
2715 regulator_bulk_free(ARRAY_SIZE(wm5100
->core_supplies
),
2716 wm5100
->core_supplies
);
2720 static struct snd_soc_codec_driver soc_codec_dev_wm5100
= {
2721 .probe
= wm5100_probe
,
2722 .remove
= wm5100_remove
,
2724 .set_sysclk
= wm5100_set_sysclk
,
2725 .set_pll
= wm5100_set_fll
,
2726 .set_bias_level
= wm5100_set_bias_level
,
2729 .seq_notifier
= wm5100_seq_notifier
,
2730 .controls
= wm5100_snd_controls
,
2731 .num_controls
= ARRAY_SIZE(wm5100_snd_controls
),
2732 .dapm_widgets
= wm5100_dapm_widgets
,
2733 .num_dapm_widgets
= ARRAY_SIZE(wm5100_dapm_widgets
),
2734 .dapm_routes
= wm5100_dapm_routes
,
2735 .num_dapm_routes
= ARRAY_SIZE(wm5100_dapm_routes
),
2737 .reg_cache_size
= ARRAY_SIZE(wm5100_reg_defaults
),
2738 .reg_word_size
= sizeof(u16
),
2739 .compress_type
= SND_SOC_RBTREE_COMPRESSION
,
2740 .reg_cache_default
= wm5100_reg_defaults
,
2742 .volatile_register
= wm5100_volatile_register
,
2743 .readable_register
= wm5100_readable_register
,
2746 static __devinit
int wm5100_i2c_probe(struct i2c_client
*i2c
,
2747 const struct i2c_device_id
*id
)
2749 struct wm5100_pdata
*pdata
= dev_get_platdata(&i2c
->dev
);
2750 struct wm5100_priv
*wm5100
;
2753 wm5100
= kzalloc(sizeof(struct wm5100_priv
), GFP_KERNEL
);
2757 for (i
= 0; i
< ARRAY_SIZE(wm5100
->fll
); i
++)
2758 init_completion(&wm5100
->fll
[i
].lock
);
2761 wm5100
->pdata
= *pdata
;
2763 i2c_set_clientdata(i2c
, wm5100
);
2765 ret
= snd_soc_register_codec(&i2c
->dev
,
2766 &soc_codec_dev_wm5100
, wm5100_dai
,
2767 ARRAY_SIZE(wm5100_dai
));
2769 dev_err(&i2c
->dev
, "Failed to register WM5100: %d\n", ret
);
2776 static __devexit
int wm5100_i2c_remove(struct i2c_client
*client
)
2778 snd_soc_unregister_codec(&client
->dev
);
2779 kfree(i2c_get_clientdata(client
));
2783 static const struct i2c_device_id wm5100_i2c_id
[] = {
2787 MODULE_DEVICE_TABLE(i2c
, wm5100_i2c_id
);
2789 static struct i2c_driver wm5100_i2c_driver
= {
2792 .owner
= THIS_MODULE
,
2794 .probe
= wm5100_i2c_probe
,
2795 .remove
= __devexit_p(wm5100_i2c_remove
),
2796 .id_table
= wm5100_i2c_id
,
2799 static int __init
wm5100_modinit(void)
2801 return i2c_add_driver(&wm5100_i2c_driver
);
2803 module_init(wm5100_modinit
);
2805 static void __exit
wm5100_exit(void)
2807 i2c_del_driver(&wm5100_i2c_driver
);
2809 module_exit(wm5100_exit
);
2811 MODULE_DESCRIPTION("ASoC WM5100 driver");
2812 MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
2813 MODULE_LICENSE("GPL");