2 * rt5670.c -- RT5670 ALSA SoC audio codec driver
4 * Copyright 2014 Realtek Semiconductor Corp.
5 * Author: Bard Liao <bardliao@realtek.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/init.h>
15 #include <linux/delay.h>
17 #include <linux/pm_runtime.h>
18 #include <linux/i2c.h>
19 #include <linux/platform_device.h>
20 #include <linux/acpi.h>
21 #include <linux/spi/spi.h>
22 #include <linux/dmi.h>
23 #include <sound/core.h>
24 #include <sound/pcm.h>
25 #include <sound/pcm_params.h>
26 #include <sound/jack.h>
27 #include <sound/soc.h>
28 #include <sound/soc-dapm.h>
29 #include <sound/initval.h>
30 #include <sound/tlv.h>
31 #include <sound/rt5670.h>
35 #include "rt5670-dsp.h"
37 #define RT5670_DEVICE_ID 0x6271
39 #define RT5670_PR_RANGE_BASE (0xff + 1)
40 #define RT5670_PR_SPACING 0x100
42 #define RT5670_PR_BASE (RT5670_PR_RANGE_BASE + (0 * RT5670_PR_SPACING))
44 static const struct regmap_range_cfg rt5670_ranges
[] = {
45 { .name
= "PR", .range_min
= RT5670_PR_BASE
,
46 .range_max
= RT5670_PR_BASE
+ 0xf8,
47 .selector_reg
= RT5670_PRIV_INDEX
,
48 .selector_mask
= 0xff,
49 .selector_shift
= 0x0,
50 .window_start
= RT5670_PRIV_DATA
,
54 static const struct reg_sequence init_list
[] = {
55 { RT5670_PR_BASE
+ 0x14, 0x9a8a },
56 { RT5670_PR_BASE
+ 0x38, 0x3ba1 },
57 { RT5670_PR_BASE
+ 0x3d, 0x3640 },
60 static const struct reg_default rt5670_reg
[] = {
197 static bool rt5670_volatile_register(struct device
*dev
, unsigned int reg
)
201 for (i
= 0; i
< ARRAY_SIZE(rt5670_ranges
); i
++) {
202 if ((reg
>= rt5670_ranges
[i
].window_start
&&
203 reg
<= rt5670_ranges
[i
].window_start
+
204 rt5670_ranges
[i
].window_len
) ||
205 (reg
>= rt5670_ranges
[i
].range_min
&&
206 reg
<= rt5670_ranges
[i
].range_max
)) {
213 case RT5670_PDM_DATA_CTRL1
:
214 case RT5670_PDM1_DATA_CTRL4
:
215 case RT5670_PDM2_DATA_CTRL4
:
216 case RT5670_PRIV_DATA
:
218 case RT5670_CJ_CTRL1
:
219 case RT5670_CJ_CTRL2
:
220 case RT5670_CJ_CTRL3
:
221 case RT5670_A_JD_CTRL1
:
222 case RT5670_A_JD_CTRL2
:
223 case RT5670_VAD_CTRL5
:
224 case RT5670_ADC_EQ_CTRL1
:
225 case RT5670_EQ_CTRL1
:
226 case RT5670_ALC_CTRL_1
:
227 case RT5670_IRQ_CTRL2
:
228 case RT5670_INT_IRQ_ST
:
230 case RT5670_DSP_CTRL1
:
231 case RT5670_DSP_CTRL2
:
232 case RT5670_DSP_CTRL3
:
233 case RT5670_DSP_CTRL4
:
234 case RT5670_DSP_CTRL5
:
235 case RT5670_VENDOR_ID
:
236 case RT5670_VENDOR_ID1
:
237 case RT5670_VENDOR_ID2
:
244 static bool rt5670_readable_register(struct device
*dev
, unsigned int reg
)
248 for (i
= 0; i
< ARRAY_SIZE(rt5670_ranges
); i
++) {
249 if ((reg
>= rt5670_ranges
[i
].window_start
&&
250 reg
<= rt5670_ranges
[i
].window_start
+
251 rt5670_ranges
[i
].window_len
) ||
252 (reg
>= rt5670_ranges
[i
].range_min
&&
253 reg
<= rt5670_ranges
[i
].range_max
)) {
262 case RT5670_CJ_CTRL1
:
263 case RT5670_CJ_CTRL2
:
264 case RT5670_CJ_CTRL3
:
266 case RT5670_INL1_INR1_VOL
:
267 case RT5670_DAC1_DIG_VOL
:
268 case RT5670_DAC2_DIG_VOL
:
269 case RT5670_DAC_CTRL
:
270 case RT5670_STO1_ADC_DIG_VOL
:
271 case RT5670_MONO_ADC_DIG_VOL
:
272 case RT5670_STO2_ADC_DIG_VOL
:
273 case RT5670_ADC_BST_VOL1
:
274 case RT5670_ADC_BST_VOL2
:
275 case RT5670_STO2_ADC_MIXER
:
276 case RT5670_STO1_ADC_MIXER
:
277 case RT5670_MONO_ADC_MIXER
:
278 case RT5670_AD_DA_MIXER
:
279 case RT5670_STO_DAC_MIXER
:
280 case RT5670_DD_MIXER
:
281 case RT5670_DIG_MIXER
:
282 case RT5670_DSP_PATH1
:
283 case RT5670_DSP_PATH2
:
284 case RT5670_DIG_INF1_DATA
:
285 case RT5670_DIG_INF2_DATA
:
286 case RT5670_PDM_OUT_CTRL
:
287 case RT5670_PDM_DATA_CTRL1
:
288 case RT5670_PDM1_DATA_CTRL2
:
289 case RT5670_PDM1_DATA_CTRL3
:
290 case RT5670_PDM1_DATA_CTRL4
:
291 case RT5670_PDM2_DATA_CTRL2
:
292 case RT5670_PDM2_DATA_CTRL3
:
293 case RT5670_PDM2_DATA_CTRL4
:
294 case RT5670_REC_L1_MIXER
:
295 case RT5670_REC_L2_MIXER
:
296 case RT5670_REC_R1_MIXER
:
297 case RT5670_REC_R2_MIXER
:
298 case RT5670_HPO_MIXER
:
299 case RT5670_MONO_MIXER
:
300 case RT5670_OUT_L1_MIXER
:
301 case RT5670_OUT_R1_MIXER
:
302 case RT5670_LOUT_MIXER
:
303 case RT5670_PWR_DIG1
:
304 case RT5670_PWR_DIG2
:
305 case RT5670_PWR_ANLG1
:
306 case RT5670_PWR_ANLG2
:
307 case RT5670_PWR_MIXER
:
309 case RT5670_PRIV_INDEX
:
310 case RT5670_PRIV_DATA
:
311 case RT5670_I2S4_SDP
:
312 case RT5670_I2S1_SDP
:
313 case RT5670_I2S2_SDP
:
314 case RT5670_I2S3_SDP
:
315 case RT5670_ADDA_CLK1
:
316 case RT5670_ADDA_CLK2
:
317 case RT5670_DMIC_CTRL1
:
318 case RT5670_DMIC_CTRL2
:
319 case RT5670_TDM_CTRL_1
:
320 case RT5670_TDM_CTRL_2
:
321 case RT5670_TDM_CTRL_3
:
324 case RT5670_PLL_CTRL1
:
325 case RT5670_PLL_CTRL2
:
339 case RT5670_DEPOP_M1
:
340 case RT5670_DEPOP_M2
:
341 case RT5670_DEPOP_M3
:
342 case RT5670_CHARGE_PUMP
:
344 case RT5670_A_JD_CTRL1
:
345 case RT5670_A_JD_CTRL2
:
346 case RT5670_VAD_CTRL1
:
347 case RT5670_VAD_CTRL2
:
348 case RT5670_VAD_CTRL3
:
349 case RT5670_VAD_CTRL4
:
350 case RT5670_VAD_CTRL5
:
351 case RT5670_ADC_EQ_CTRL1
:
352 case RT5670_ADC_EQ_CTRL2
:
353 case RT5670_EQ_CTRL1
:
354 case RT5670_EQ_CTRL2
:
355 case RT5670_ALC_DRC_CTRL1
:
356 case RT5670_ALC_DRC_CTRL2
:
357 case RT5670_ALC_CTRL_1
:
358 case RT5670_ALC_CTRL_2
:
359 case RT5670_ALC_CTRL_3
:
361 case RT5670_IRQ_CTRL1
:
362 case RT5670_IRQ_CTRL2
:
363 case RT5670_INT_IRQ_ST
:
364 case RT5670_GPIO_CTRL1
:
365 case RT5670_GPIO_CTRL2
:
366 case RT5670_GPIO_CTRL3
:
367 case RT5670_SCRABBLE_FUN
:
368 case RT5670_SCRABBLE_CTRL
:
369 case RT5670_BASE_BACK
:
370 case RT5670_MP3_PLUS1
:
371 case RT5670_MP3_PLUS2
:
372 case RT5670_ADJ_HPF1
:
373 case RT5670_ADJ_HPF2
:
374 case RT5670_HP_CALIB_AMP_DET
:
380 case RT5670_DRC_HL_CTRL1
:
381 case RT5670_DRC_HL_CTRL2
:
382 case RT5670_ADC_MONO_HP_CTRL1
:
383 case RT5670_ADC_MONO_HP_CTRL2
:
384 case RT5670_ADC_STO2_HP_CTRL1
:
385 case RT5670_ADC_STO2_HP_CTRL2
:
386 case RT5670_JD_CTRL3
:
387 case RT5670_JD_CTRL4
:
388 case RT5670_DIG_MISC
:
389 case RT5670_DSP_CTRL1
:
390 case RT5670_DSP_CTRL2
:
391 case RT5670_DSP_CTRL3
:
392 case RT5670_DSP_CTRL4
:
393 case RT5670_DSP_CTRL5
:
394 case RT5670_GEN_CTRL2
:
395 case RT5670_GEN_CTRL3
:
396 case RT5670_VENDOR_ID
:
397 case RT5670_VENDOR_ID1
:
398 case RT5670_VENDOR_ID2
:
406 * rt5670_headset_detect - Detect headset.
407 * @codec: SoC audio codec device.
408 * @jack_insert: Jack insert or not.
410 * Detect whether is headset or not when jack inserted.
412 * Returns detect status.
415 static int rt5670_headset_detect(struct snd_soc_codec
*codec
, int jack_insert
)
418 struct snd_soc_dapm_context
*dapm
= snd_soc_codec_get_dapm(codec
);
419 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
422 snd_soc_dapm_force_enable_pin(dapm
, "Mic Det Power");
423 snd_soc_dapm_sync(dapm
);
424 snd_soc_update_bits(codec
, RT5670_GEN_CTRL3
, 0x4, 0x0);
425 snd_soc_update_bits(codec
, RT5670_CJ_CTRL2
,
426 RT5670_CBJ_DET_MODE
| RT5670_CBJ_MN_JD
,
428 snd_soc_write(codec
, RT5670_GPIO_CTRL2
, 0x0004);
429 snd_soc_update_bits(codec
, RT5670_GPIO_CTRL1
,
430 RT5670_GP1_PIN_MASK
, RT5670_GP1_PIN_IRQ
);
431 snd_soc_update_bits(codec
, RT5670_CJ_CTRL1
,
432 RT5670_CBJ_BST1_EN
, RT5670_CBJ_BST1_EN
);
433 snd_soc_write(codec
, RT5670_JD_CTRL3
, 0x00f0);
434 snd_soc_update_bits(codec
, RT5670_CJ_CTRL2
,
435 RT5670_CBJ_MN_JD
, RT5670_CBJ_MN_JD
);
436 snd_soc_update_bits(codec
, RT5670_CJ_CTRL2
,
437 RT5670_CBJ_MN_JD
, 0);
439 val
= snd_soc_read(codec
, RT5670_CJ_CTRL3
) & 0x7;
440 if (val
== 0x1 || val
== 0x2) {
441 rt5670
->jack_type
= SND_JACK_HEADSET
;
442 /* for push button */
443 snd_soc_update_bits(codec
, RT5670_INT_IRQ_ST
, 0x8, 0x8);
444 snd_soc_update_bits(codec
, RT5670_IL_CMD
, 0x40, 0x40);
445 snd_soc_read(codec
, RT5670_IL_CMD
);
447 snd_soc_update_bits(codec
, RT5670_GEN_CTRL3
, 0x4, 0x4);
448 rt5670
->jack_type
= SND_JACK_HEADPHONE
;
449 snd_soc_dapm_disable_pin(dapm
, "Mic Det Power");
450 snd_soc_dapm_sync(dapm
);
453 snd_soc_update_bits(codec
, RT5670_INT_IRQ_ST
, 0x8, 0x0);
454 snd_soc_update_bits(codec
, RT5670_GEN_CTRL3
, 0x4, 0x4);
455 rt5670
->jack_type
= 0;
456 snd_soc_dapm_disable_pin(dapm
, "Mic Det Power");
457 snd_soc_dapm_sync(dapm
);
460 return rt5670
->jack_type
;
463 void rt5670_jack_suspend(struct snd_soc_codec
*codec
)
465 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
467 rt5670
->jack_type_saved
= rt5670
->jack_type
;
468 rt5670_headset_detect(codec
, 0);
470 EXPORT_SYMBOL_GPL(rt5670_jack_suspend
);
472 void rt5670_jack_resume(struct snd_soc_codec
*codec
)
474 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
476 if (rt5670
->jack_type_saved
)
477 rt5670_headset_detect(codec
, 1);
479 EXPORT_SYMBOL_GPL(rt5670_jack_resume
);
481 static int rt5670_button_detect(struct snd_soc_codec
*codec
)
485 val
= snd_soc_read(codec
, RT5670_IL_CMD
);
486 btn_type
= val
& 0xff80;
487 snd_soc_write(codec
, RT5670_IL_CMD
, val
);
490 val
= snd_soc_read(codec
, RT5670_IL_CMD
);
491 snd_soc_write(codec
, RT5670_IL_CMD
, val
);
497 static int rt5670_irq_detection(void *data
)
499 struct rt5670_priv
*rt5670
= (struct rt5670_priv
*)data
;
500 struct snd_soc_jack_gpio
*gpio
= &rt5670
->hp_gpio
;
501 struct snd_soc_jack
*jack
= rt5670
->jack
;
502 int val
, btn_type
, report
= jack
->status
;
504 if (rt5670
->pdata
.jd_mode
== 1) /* 2 port */
505 val
= snd_soc_read(rt5670
->codec
, RT5670_A_JD_CTRL1
) & 0x0070;
507 val
= snd_soc_read(rt5670
->codec
, RT5670_A_JD_CTRL1
) & 0x0020;
511 case 0x30: /* 2 port */
512 case 0x0: /* 1 port or 2 port */
513 if (rt5670
->jack_type
== 0) {
514 report
= rt5670_headset_detect(rt5670
->codec
, 1);
515 /* for push button and jack out */
516 gpio
->debounce_time
= 25;
520 if (snd_soc_read(rt5670
->codec
, RT5670_INT_IRQ_ST
) & 0x4) {
522 report
= SND_JACK_HEADSET
;
523 btn_type
= rt5670_button_detect(rt5670
->codec
);
525 case 0x2000: /* up */
526 report
|= SND_JACK_BTN_1
;
528 case 0x0400: /* center */
529 report
|= SND_JACK_BTN_0
;
531 case 0x0080: /* down */
532 report
|= SND_JACK_BTN_2
;
535 dev_err(rt5670
->codec
->dev
,
536 "Unexpected button code 0x%04x\n",
541 if (btn_type
== 0)/* button release */
542 report
= rt5670
->jack_type
;
546 case 0x70: /* 2 port */
547 case 0x10: /* 2 port */
548 case 0x20: /* 1 port */
550 snd_soc_update_bits(rt5670
->codec
, RT5670_INT_IRQ_ST
, 0x1, 0x0);
551 rt5670_headset_detect(rt5670
->codec
, 0);
552 gpio
->debounce_time
= 150; /* for jack in */
561 int rt5670_set_jack_detect(struct snd_soc_codec
*codec
,
562 struct snd_soc_jack
*jack
)
564 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
568 rt5670
->hp_gpio
.gpiod_dev
= codec
->dev
;
569 rt5670
->hp_gpio
.name
= "headphone detect";
570 rt5670
->hp_gpio
.report
= SND_JACK_HEADSET
|
571 SND_JACK_BTN_0
| SND_JACK_BTN_1
| SND_JACK_BTN_2
;
572 rt5670
->hp_gpio
.debounce_time
= 150;
573 rt5670
->hp_gpio
.wake
= true;
574 rt5670
->hp_gpio
.data
= (struct rt5670_priv
*)rt5670
;
575 rt5670
->hp_gpio
.jack_status_check
= rt5670_irq_detection
;
577 ret
= snd_soc_jack_add_gpios(rt5670
->jack
, 1,
580 dev_err(codec
->dev
, "Adding jack GPIO failed\n");
586 EXPORT_SYMBOL_GPL(rt5670_set_jack_detect
);
588 static const DECLARE_TLV_DB_SCALE(out_vol_tlv
, -4650, 150, 0);
589 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv
, -65625, 375, 0);
590 static const DECLARE_TLV_DB_SCALE(in_vol_tlv
, -3450, 150, 0);
591 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv
, -17625, 375, 0);
592 static const DECLARE_TLV_DB_SCALE(adc_bst_tlv
, 0, 1200, 0);
594 /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */
595 static const DECLARE_TLV_DB_RANGE(bst_tlv
,
596 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0),
597 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0),
598 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0),
599 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0),
600 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0),
601 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0),
602 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0)
605 /* Interface data select */
606 static const char * const rt5670_data_select
[] = {
607 "Normal", "Swap", "left copy to right", "right copy to left"
610 static SOC_ENUM_SINGLE_DECL(rt5670_if2_dac_enum
, RT5670_DIG_INF1_DATA
,
611 RT5670_IF2_DAC_SEL_SFT
, rt5670_data_select
);
613 static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_enum
, RT5670_DIG_INF1_DATA
,
614 RT5670_IF2_ADC_SEL_SFT
, rt5670_data_select
);
616 static const struct snd_kcontrol_new rt5670_snd_controls
[] = {
617 /* Headphone Output Volume */
618 SOC_DOUBLE("HP Playback Switch", RT5670_HP_VOL
,
619 RT5670_L_MUTE_SFT
, RT5670_R_MUTE_SFT
, 1, 1),
620 SOC_DOUBLE_TLV("HP Playback Volume", RT5670_HP_VOL
,
621 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
,
624 SOC_DOUBLE("OUT Channel Switch", RT5670_LOUT1
,
625 RT5670_VOL_L_SFT
, RT5670_VOL_R_SFT
, 1, 1),
626 SOC_DOUBLE_TLV("OUT Playback Volume", RT5670_LOUT1
,
627 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
, 39, 1, out_vol_tlv
),
628 /* DAC Digital Volume */
629 SOC_DOUBLE("DAC2 Playback Switch", RT5670_DAC_CTRL
,
630 RT5670_M_DAC_L2_VOL_SFT
, RT5670_M_DAC_R2_VOL_SFT
, 1, 1),
631 SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5670_DAC1_DIG_VOL
,
632 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
,
633 175, 0, dac_vol_tlv
),
634 SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5670_DAC2_DIG_VOL
,
635 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
,
636 175, 0, dac_vol_tlv
),
637 /* IN1/IN2 Control */
638 SOC_SINGLE_TLV("IN1 Boost Volume", RT5670_CJ_CTRL1
,
639 RT5670_BST_SFT1
, 8, 0, bst_tlv
),
640 SOC_SINGLE_TLV("IN2 Boost Volume", RT5670_IN2
,
641 RT5670_BST_SFT1
, 8, 0, bst_tlv
),
642 /* INL/INR Volume Control */
643 SOC_DOUBLE_TLV("IN Capture Volume", RT5670_INL1_INR1_VOL
,
644 RT5670_INL_VOL_SFT
, RT5670_INR_VOL_SFT
,
646 /* ADC Digital Volume Control */
647 SOC_DOUBLE("ADC Capture Switch", RT5670_STO1_ADC_DIG_VOL
,
648 RT5670_L_MUTE_SFT
, RT5670_R_MUTE_SFT
, 1, 1),
649 SOC_DOUBLE_TLV("ADC Capture Volume", RT5670_STO1_ADC_DIG_VOL
,
650 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
,
651 127, 0, adc_vol_tlv
),
653 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL
,
654 RT5670_L_VOL_SFT
, RT5670_R_VOL_SFT
,
655 127, 0, adc_vol_tlv
),
657 /* ADC Boost Volume Control */
658 SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1
,
659 RT5670_STO1_ADC_L_BST_SFT
, RT5670_STO1_ADC_R_BST_SFT
,
662 SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1
,
663 RT5670_STO2_ADC_L_BST_SFT
, RT5670_STO2_ADC_R_BST_SFT
,
666 SOC_ENUM("ADC IF2 Data Switch", rt5670_if2_adc_enum
),
667 SOC_ENUM("DAC IF2 Data Switch", rt5670_if2_dac_enum
),
671 * set_dmic_clk - Set parameter of dmic.
674 * @kcontrol: The kcontrol of this widget.
677 * Choose dmic clock between 1MHz and 3MHz.
678 * It is better for clock to approximate 3MHz.
680 static int set_dmic_clk(struct snd_soc_dapm_widget
*w
,
681 struct snd_kcontrol
*kcontrol
, int event
)
683 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
684 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
687 rate
= rt5670
->sysclk
/ rl6231_get_pre_div(rt5670
->regmap
,
688 RT5670_ADDA_CLK1
, RT5670_I2S_PD1_SFT
);
689 idx
= rl6231_calc_dmic_clk(rate
);
691 dev_err(codec
->dev
, "Failed to set DMIC clock\n");
693 snd_soc_update_bits(codec
, RT5670_DMIC_CTRL1
,
694 RT5670_DMIC_CLK_MASK
, idx
<< RT5670_DMIC_CLK_SFT
);
698 static int is_sys_clk_from_pll(struct snd_soc_dapm_widget
*source
,
699 struct snd_soc_dapm_widget
*sink
)
701 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(source
->dapm
);
702 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
704 if (rt5670
->sysclk_src
== RT5670_SCLK_S_PLL1
)
710 static int is_using_asrc(struct snd_soc_dapm_widget
*source
,
711 struct snd_soc_dapm_widget
*sink
)
713 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(source
->dapm
);
714 unsigned int reg
, shift
, val
;
716 switch (source
->shift
) {
749 val
= (snd_soc_read(codec
, reg
) >> shift
) & 0xf;
762 static int can_use_asrc(struct snd_soc_dapm_widget
*source
,
763 struct snd_soc_dapm_widget
*sink
)
765 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(source
->dapm
);
766 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
768 if (rt5670
->sysclk
> rt5670
->lrck
[RT5670_AIF1
] * 384)
776 * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters
777 * @codec: SoC audio codec device.
778 * @filter_mask: mask of filters.
779 * @clk_src: clock source
781 * The ASRC function is for asynchronous MCLK and LRCK. Also, since RT5670 can
782 * only support standard 32fs or 64fs i2s format, ASRC should be enabled to
783 * support special i2s clock format such as Intel's 100fs(100 * sampling rate).
784 * ASRC function will track i2s clock and generate a corresponding system clock
785 * for codec. This function provides an API to select the clock source for a
786 * set of filters specified by the mask. And the codec driver will turn on ASRC
787 * for these filters if ASRC is selected as their clock source.
789 int rt5670_sel_asrc_clk_src(struct snd_soc_codec
*codec
,
790 unsigned int filter_mask
, unsigned int clk_src
)
792 unsigned int asrc2_mask
= 0, asrc2_value
= 0;
793 unsigned int asrc3_mask
= 0, asrc3_value
= 0;
795 if (clk_src
> RT5670_CLK_SEL_SYS3
)
798 if (filter_mask
& RT5670_DA_STEREO_FILTER
) {
799 asrc2_mask
|= RT5670_DA_STO_CLK_SEL_MASK
;
800 asrc2_value
= (asrc2_value
& ~RT5670_DA_STO_CLK_SEL_MASK
)
801 | (clk_src
<< RT5670_DA_STO_CLK_SEL_SFT
);
804 if (filter_mask
& RT5670_DA_MONO_L_FILTER
) {
805 asrc2_mask
|= RT5670_DA_MONOL_CLK_SEL_MASK
;
806 asrc2_value
= (asrc2_value
& ~RT5670_DA_MONOL_CLK_SEL_MASK
)
807 | (clk_src
<< RT5670_DA_MONOL_CLK_SEL_SFT
);
810 if (filter_mask
& RT5670_DA_MONO_R_FILTER
) {
811 asrc2_mask
|= RT5670_DA_MONOR_CLK_SEL_MASK
;
812 asrc2_value
= (asrc2_value
& ~RT5670_DA_MONOR_CLK_SEL_MASK
)
813 | (clk_src
<< RT5670_DA_MONOR_CLK_SEL_SFT
);
816 if (filter_mask
& RT5670_AD_STEREO_FILTER
) {
817 asrc2_mask
|= RT5670_AD_STO1_CLK_SEL_MASK
;
818 asrc2_value
= (asrc2_value
& ~RT5670_AD_STO1_CLK_SEL_MASK
)
819 | (clk_src
<< RT5670_AD_STO1_CLK_SEL_SFT
);
822 if (filter_mask
& RT5670_AD_MONO_L_FILTER
) {
823 asrc3_mask
|= RT5670_AD_MONOL_CLK_SEL_MASK
;
824 asrc3_value
= (asrc3_value
& ~RT5670_AD_MONOL_CLK_SEL_MASK
)
825 | (clk_src
<< RT5670_AD_MONOL_CLK_SEL_SFT
);
828 if (filter_mask
& RT5670_AD_MONO_R_FILTER
) {
829 asrc3_mask
|= RT5670_AD_MONOR_CLK_SEL_MASK
;
830 asrc3_value
= (asrc3_value
& ~RT5670_AD_MONOR_CLK_SEL_MASK
)
831 | (clk_src
<< RT5670_AD_MONOR_CLK_SEL_SFT
);
834 if (filter_mask
& RT5670_UP_RATE_FILTER
) {
835 asrc3_mask
|= RT5670_UP_CLK_SEL_MASK
;
836 asrc3_value
= (asrc3_value
& ~RT5670_UP_CLK_SEL_MASK
)
837 | (clk_src
<< RT5670_UP_CLK_SEL_SFT
);
840 if (filter_mask
& RT5670_DOWN_RATE_FILTER
) {
841 asrc3_mask
|= RT5670_DOWN_CLK_SEL_MASK
;
842 asrc3_value
= (asrc3_value
& ~RT5670_DOWN_CLK_SEL_MASK
)
843 | (clk_src
<< RT5670_DOWN_CLK_SEL_SFT
);
847 snd_soc_update_bits(codec
, RT5670_ASRC_2
,
848 asrc2_mask
, asrc2_value
);
851 snd_soc_update_bits(codec
, RT5670_ASRC_3
,
852 asrc3_mask
, asrc3_value
);
855 EXPORT_SYMBOL_GPL(rt5670_sel_asrc_clk_src
);
858 static const struct snd_kcontrol_new rt5670_sto1_adc_l_mix
[] = {
859 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER
,
860 RT5670_M_ADC_L1_SFT
, 1, 1),
861 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER
,
862 RT5670_M_ADC_L2_SFT
, 1, 1),
865 static const struct snd_kcontrol_new rt5670_sto1_adc_r_mix
[] = {
866 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER
,
867 RT5670_M_ADC_R1_SFT
, 1, 1),
868 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER
,
869 RT5670_M_ADC_R2_SFT
, 1, 1),
872 static const struct snd_kcontrol_new rt5670_sto2_adc_l_mix
[] = {
873 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER
,
874 RT5670_M_ADC_L1_SFT
, 1, 1),
875 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER
,
876 RT5670_M_ADC_L2_SFT
, 1, 1),
879 static const struct snd_kcontrol_new rt5670_sto2_adc_r_mix
[] = {
880 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER
,
881 RT5670_M_ADC_R1_SFT
, 1, 1),
882 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER
,
883 RT5670_M_ADC_R2_SFT
, 1, 1),
886 static const struct snd_kcontrol_new rt5670_mono_adc_l_mix
[] = {
887 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER
,
888 RT5670_M_MONO_ADC_L1_SFT
, 1, 1),
889 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER
,
890 RT5670_M_MONO_ADC_L2_SFT
, 1, 1),
893 static const struct snd_kcontrol_new rt5670_mono_adc_r_mix
[] = {
894 SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER
,
895 RT5670_M_MONO_ADC_R1_SFT
, 1, 1),
896 SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER
,
897 RT5670_M_MONO_ADC_R2_SFT
, 1, 1),
900 static const struct snd_kcontrol_new rt5670_dac_l_mix
[] = {
901 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER
,
902 RT5670_M_ADCMIX_L_SFT
, 1, 1),
903 SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER
,
904 RT5670_M_DAC1_L_SFT
, 1, 1),
907 static const struct snd_kcontrol_new rt5670_dac_r_mix
[] = {
908 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER
,
909 RT5670_M_ADCMIX_R_SFT
, 1, 1),
910 SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER
,
911 RT5670_M_DAC1_R_SFT
, 1, 1),
914 static const struct snd_kcontrol_new rt5670_sto_dac_l_mix
[] = {
915 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER
,
916 RT5670_M_DAC_L1_SFT
, 1, 1),
917 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_STO_DAC_MIXER
,
918 RT5670_M_DAC_L2_SFT
, 1, 1),
919 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER
,
920 RT5670_M_DAC_R1_STO_L_SFT
, 1, 1),
923 static const struct snd_kcontrol_new rt5670_sto_dac_r_mix
[] = {
924 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER
,
925 RT5670_M_DAC_R1_SFT
, 1, 1),
926 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_STO_DAC_MIXER
,
927 RT5670_M_DAC_R2_SFT
, 1, 1),
928 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER
,
929 RT5670_M_DAC_L1_STO_R_SFT
, 1, 1),
932 static const struct snd_kcontrol_new rt5670_mono_dac_l_mix
[] = {
933 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_DD_MIXER
,
934 RT5670_M_DAC_L1_MONO_L_SFT
, 1, 1),
935 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER
,
936 RT5670_M_DAC_L2_MONO_L_SFT
, 1, 1),
937 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER
,
938 RT5670_M_DAC_R2_MONO_L_SFT
, 1, 1),
941 static const struct snd_kcontrol_new rt5670_mono_dac_r_mix
[] = {
942 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_DD_MIXER
,
943 RT5670_M_DAC_R1_MONO_R_SFT
, 1, 1),
944 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER
,
945 RT5670_M_DAC_R2_MONO_R_SFT
, 1, 1),
946 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER
,
947 RT5670_M_DAC_L2_MONO_R_SFT
, 1, 1),
950 static const struct snd_kcontrol_new rt5670_dig_l_mix
[] = {
951 SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5670_DIG_MIXER
,
952 RT5670_M_STO_L_DAC_L_SFT
, 1, 1),
953 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER
,
954 RT5670_M_DAC_L2_DAC_L_SFT
, 1, 1),
955 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER
,
956 RT5670_M_DAC_R2_DAC_L_SFT
, 1, 1),
959 static const struct snd_kcontrol_new rt5670_dig_r_mix
[] = {
960 SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5670_DIG_MIXER
,
961 RT5670_M_STO_R_DAC_R_SFT
, 1, 1),
962 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER
,
963 RT5670_M_DAC_R2_DAC_R_SFT
, 1, 1),
964 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER
,
965 RT5670_M_DAC_L2_DAC_R_SFT
, 1, 1),
968 /* Analog Input Mixer */
969 static const struct snd_kcontrol_new rt5670_rec_l_mix
[] = {
970 SOC_DAPM_SINGLE("INL Switch", RT5670_REC_L2_MIXER
,
971 RT5670_M_IN_L_RM_L_SFT
, 1, 1),
972 SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_L2_MIXER
,
973 RT5670_M_BST2_RM_L_SFT
, 1, 1),
974 SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_L2_MIXER
,
975 RT5670_M_BST1_RM_L_SFT
, 1, 1),
978 static const struct snd_kcontrol_new rt5670_rec_r_mix
[] = {
979 SOC_DAPM_SINGLE("INR Switch", RT5670_REC_R2_MIXER
,
980 RT5670_M_IN_R_RM_R_SFT
, 1, 1),
981 SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_R2_MIXER
,
982 RT5670_M_BST2_RM_R_SFT
, 1, 1),
983 SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_R2_MIXER
,
984 RT5670_M_BST1_RM_R_SFT
, 1, 1),
987 static const struct snd_kcontrol_new rt5670_out_l_mix
[] = {
988 SOC_DAPM_SINGLE("BST1 Switch", RT5670_OUT_L1_MIXER
,
989 RT5670_M_BST1_OM_L_SFT
, 1, 1),
990 SOC_DAPM_SINGLE("INL Switch", RT5670_OUT_L1_MIXER
,
991 RT5670_M_IN_L_OM_L_SFT
, 1, 1),
992 SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_OUT_L1_MIXER
,
993 RT5670_M_DAC_L2_OM_L_SFT
, 1, 1),
994 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_OUT_L1_MIXER
,
995 RT5670_M_DAC_L1_OM_L_SFT
, 1, 1),
998 static const struct snd_kcontrol_new rt5670_out_r_mix
[] = {
999 SOC_DAPM_SINGLE("BST2 Switch", RT5670_OUT_R1_MIXER
,
1000 RT5670_M_BST2_OM_R_SFT
, 1, 1),
1001 SOC_DAPM_SINGLE("INR Switch", RT5670_OUT_R1_MIXER
,
1002 RT5670_M_IN_R_OM_R_SFT
, 1, 1),
1003 SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_OUT_R1_MIXER
,
1004 RT5670_M_DAC_R2_OM_R_SFT
, 1, 1),
1005 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_OUT_R1_MIXER
,
1006 RT5670_M_DAC_R1_OM_R_SFT
, 1, 1),
1009 static const struct snd_kcontrol_new rt5670_hpo_mix
[] = {
1010 SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER
,
1011 RT5670_M_DAC1_HM_SFT
, 1, 1),
1012 SOC_DAPM_SINGLE("HPVOL Switch", RT5670_HPO_MIXER
,
1013 RT5670_M_HPVOL_HM_SFT
, 1, 1),
1016 static const struct snd_kcontrol_new rt5670_hpvoll_mix
[] = {
1017 SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER
,
1018 RT5670_M_DACL1_HML_SFT
, 1, 1),
1019 SOC_DAPM_SINGLE("INL Switch", RT5670_HPO_MIXER
,
1020 RT5670_M_INL1_HML_SFT
, 1, 1),
1023 static const struct snd_kcontrol_new rt5670_hpvolr_mix
[] = {
1024 SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER
,
1025 RT5670_M_DACR1_HMR_SFT
, 1, 1),
1026 SOC_DAPM_SINGLE("INR Switch", RT5670_HPO_MIXER
,
1027 RT5670_M_INR1_HMR_SFT
, 1, 1),
1030 static const struct snd_kcontrol_new rt5670_lout_mix
[] = {
1031 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_LOUT_MIXER
,
1032 RT5670_M_DAC_L1_LM_SFT
, 1, 1),
1033 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_LOUT_MIXER
,
1034 RT5670_M_DAC_R1_LM_SFT
, 1, 1),
1035 SOC_DAPM_SINGLE("OUTMIX L Switch", RT5670_LOUT_MIXER
,
1036 RT5670_M_OV_L_LM_SFT
, 1, 1),
1037 SOC_DAPM_SINGLE("OUTMIX R Switch", RT5670_LOUT_MIXER
,
1038 RT5670_M_OV_R_LM_SFT
, 1, 1),
1041 static const struct snd_kcontrol_new rt5670_hpl_mix
[] = {
1042 SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_HPO_MIXER
,
1043 RT5670_M_DACL1_HML_SFT
, 1, 1),
1044 SOC_DAPM_SINGLE("INL1 Switch", RT5670_HPO_MIXER
,
1045 RT5670_M_INL1_HML_SFT
, 1, 1),
1048 static const struct snd_kcontrol_new rt5670_hpr_mix
[] = {
1049 SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_HPO_MIXER
,
1050 RT5670_M_DACR1_HMR_SFT
, 1, 1),
1051 SOC_DAPM_SINGLE("INR1 Switch", RT5670_HPO_MIXER
,
1052 RT5670_M_INR1_HMR_SFT
, 1, 1),
1055 static const struct snd_kcontrol_new lout_l_enable_control
=
1056 SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1
,
1057 RT5670_L_MUTE_SFT
, 1, 1);
1059 static const struct snd_kcontrol_new lout_r_enable_control
=
1060 SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1
,
1061 RT5670_R_MUTE_SFT
, 1, 1);
1063 /* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */
1064 static const char * const rt5670_dac1_src
[] = {
1065 "IF1 DAC", "IF2 DAC"
1068 static SOC_ENUM_SINGLE_DECL(rt5670_dac1l_enum
, RT5670_AD_DA_MIXER
,
1069 RT5670_DAC1_L_SEL_SFT
, rt5670_dac1_src
);
1071 static const struct snd_kcontrol_new rt5670_dac1l_mux
=
1072 SOC_DAPM_ENUM("DAC1 L source", rt5670_dac1l_enum
);
1074 static SOC_ENUM_SINGLE_DECL(rt5670_dac1r_enum
, RT5670_AD_DA_MIXER
,
1075 RT5670_DAC1_R_SEL_SFT
, rt5670_dac1_src
);
1077 static const struct snd_kcontrol_new rt5670_dac1r_mux
=
1078 SOC_DAPM_ENUM("DAC1 R source", rt5670_dac1r_enum
);
1080 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1081 /* TODO Use SOC_VALUE_ENUM_SINGLE_DECL */
1082 static const char * const rt5670_dac12_src
[] = {
1083 "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC",
1084 "Bass", "VAD_ADC", "IF4 DAC"
1087 static SOC_ENUM_SINGLE_DECL(rt5670_dac2l_enum
, RT5670_DAC_CTRL
,
1088 RT5670_DAC2_L_SEL_SFT
, rt5670_dac12_src
);
1090 static const struct snd_kcontrol_new rt5670_dac_l2_mux
=
1091 SOC_DAPM_ENUM("DAC2 L source", rt5670_dac2l_enum
);
1093 static const char * const rt5670_dacr2_src
[] = {
1094 "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC"
1097 static SOC_ENUM_SINGLE_DECL(rt5670_dac2r_enum
, RT5670_DAC_CTRL
,
1098 RT5670_DAC2_R_SEL_SFT
, rt5670_dacr2_src
);
1100 static const struct snd_kcontrol_new rt5670_dac_r2_mux
=
1101 SOC_DAPM_ENUM("DAC2 R source", rt5670_dac2r_enum
);
1103 /*RxDP source*/ /* MX-2D [15:13] */
1104 static const char * const rt5670_rxdp_src
[] = {
1105 "IF2 DAC", "IF1 DAC", "STO1 ADC Mixer", "STO2 ADC Mixer",
1106 "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1"
1109 static SOC_ENUM_SINGLE_DECL(rt5670_rxdp_enum
, RT5670_DSP_PATH1
,
1110 RT5670_RXDP_SEL_SFT
, rt5670_rxdp_src
);
1112 static const struct snd_kcontrol_new rt5670_rxdp_mux
=
1113 SOC_DAPM_ENUM("DAC2 L source", rt5670_rxdp_enum
);
1116 static const char * const rt5670_dsp_bypass_src
[] = {
1120 static SOC_ENUM_SINGLE_DECL(rt5670_dsp_ul_enum
, RT5670_DSP_PATH1
,
1121 RT5670_DSP_UL_SFT
, rt5670_dsp_bypass_src
);
1123 static const struct snd_kcontrol_new rt5670_dsp_ul_mux
=
1124 SOC_DAPM_ENUM("DSP UL source", rt5670_dsp_ul_enum
);
1126 static SOC_ENUM_SINGLE_DECL(rt5670_dsp_dl_enum
, RT5670_DSP_PATH1
,
1127 RT5670_DSP_DL_SFT
, rt5670_dsp_bypass_src
);
1129 static const struct snd_kcontrol_new rt5670_dsp_dl_mux
=
1130 SOC_DAPM_ENUM("DSP DL source", rt5670_dsp_dl_enum
);
1132 /* Stereo2 ADC source */
1134 static const char * const rt5670_stereo2_adc_lr_src
[] = {
1138 static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_lr_enum
, RT5670_STO2_ADC_MIXER
,
1139 RT5670_STO2_ADC_SRC_SFT
, rt5670_stereo2_adc_lr_src
);
1141 static const struct snd_kcontrol_new rt5670_sto2_adc_lr_mux
=
1142 SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5670_stereo2_adc_lr_enum
);
1144 /* Stereo1 ADC source */
1145 /* MX-27 MX-26 [12] */
1146 static const char * const rt5670_stereo_adc1_src
[] = {
1150 static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc1_enum
, RT5670_STO1_ADC_MIXER
,
1151 RT5670_ADC_1_SRC_SFT
, rt5670_stereo_adc1_src
);
1153 static const struct snd_kcontrol_new rt5670_sto_adc_l1_mux
=
1154 SOC_DAPM_ENUM("Stereo1 ADC L1 source", rt5670_stereo1_adc1_enum
);
1156 static const struct snd_kcontrol_new rt5670_sto_adc_r1_mux
=
1157 SOC_DAPM_ENUM("Stereo1 ADC R1 source", rt5670_stereo1_adc1_enum
);
1159 static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc1_enum
, RT5670_STO2_ADC_MIXER
,
1160 RT5670_ADC_1_SRC_SFT
, rt5670_stereo_adc1_src
);
1162 static const struct snd_kcontrol_new rt5670_sto2_adc_l1_mux
=
1163 SOC_DAPM_ENUM("Stereo2 ADC L1 source", rt5670_stereo2_adc1_enum
);
1165 static const struct snd_kcontrol_new rt5670_sto2_adc_r1_mux
=
1166 SOC_DAPM_ENUM("Stereo2 ADC R1 source", rt5670_stereo2_adc1_enum
);
1168 /* MX-27 MX-26 [11] */
1169 static const char * const rt5670_stereo_adc2_src
[] = {
1173 static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc2_enum
, RT5670_STO1_ADC_MIXER
,
1174 RT5670_ADC_2_SRC_SFT
, rt5670_stereo_adc2_src
);
1176 static const struct snd_kcontrol_new rt5670_sto_adc_l2_mux
=
1177 SOC_DAPM_ENUM("Stereo1 ADC L2 source", rt5670_stereo1_adc2_enum
);
1179 static const struct snd_kcontrol_new rt5670_sto_adc_r2_mux
=
1180 SOC_DAPM_ENUM("Stereo1 ADC R2 source", rt5670_stereo1_adc2_enum
);
1182 static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc2_enum
, RT5670_STO2_ADC_MIXER
,
1183 RT5670_ADC_2_SRC_SFT
, rt5670_stereo_adc2_src
);
1185 static const struct snd_kcontrol_new rt5670_sto2_adc_l2_mux
=
1186 SOC_DAPM_ENUM("Stereo2 ADC L2 source", rt5670_stereo2_adc2_enum
);
1188 static const struct snd_kcontrol_new rt5670_sto2_adc_r2_mux
=
1189 SOC_DAPM_ENUM("Stereo2 ADC R2 source", rt5670_stereo2_adc2_enum
);
1191 /* MX-27 MX26 [10] */
1192 static const char * const rt5670_stereo_adc_src
[] = {
1193 "ADC1L ADC2R", "ADC3"
1196 static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc_enum
, RT5670_STO1_ADC_MIXER
,
1197 RT5670_ADC_SRC_SFT
, rt5670_stereo_adc_src
);
1199 static const struct snd_kcontrol_new rt5670_sto_adc_mux
=
1200 SOC_DAPM_ENUM("Stereo1 ADC source", rt5670_stereo1_adc_enum
);
1202 static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_enum
, RT5670_STO2_ADC_MIXER
,
1203 RT5670_ADC_SRC_SFT
, rt5670_stereo_adc_src
);
1205 static const struct snd_kcontrol_new rt5670_sto2_adc_mux
=
1206 SOC_DAPM_ENUM("Stereo2 ADC source", rt5670_stereo2_adc_enum
);
1208 /* MX-27 MX-26 [9:8] */
1209 static const char * const rt5670_stereo_dmic_src
[] = {
1210 "DMIC1", "DMIC2", "DMIC3"
1213 static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_dmic_enum
, RT5670_STO1_ADC_MIXER
,
1214 RT5670_DMIC_SRC_SFT
, rt5670_stereo_dmic_src
);
1216 static const struct snd_kcontrol_new rt5670_sto1_dmic_mux
=
1217 SOC_DAPM_ENUM("Stereo1 DMIC source", rt5670_stereo1_dmic_enum
);
1219 static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_dmic_enum
, RT5670_STO2_ADC_MIXER
,
1220 RT5670_DMIC_SRC_SFT
, rt5670_stereo_dmic_src
);
1222 static const struct snd_kcontrol_new rt5670_sto2_dmic_mux
=
1223 SOC_DAPM_ENUM("Stereo2 DMIC source", rt5670_stereo2_dmic_enum
);
1226 static const char * const rt5670_stereo_dmic3_src
[] = {
1230 static SOC_ENUM_SINGLE_DECL(rt5670_stereo_dmic3_enum
, RT5670_STO1_ADC_MIXER
,
1231 RT5670_DMIC3_SRC_SFT
, rt5670_stereo_dmic3_src
);
1233 static const struct snd_kcontrol_new rt5670_sto_dmic3_mux
=
1234 SOC_DAPM_ENUM("Stereo DMIC3 source", rt5670_stereo_dmic3_enum
);
1236 /* Mono ADC source */
1238 static const char * const rt5670_mono_adc_l1_src
[] = {
1239 "Mono DAC MIXL", "ADC1"
1242 static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l1_enum
, RT5670_MONO_ADC_MIXER
,
1243 RT5670_MONO_ADC_L1_SRC_SFT
, rt5670_mono_adc_l1_src
);
1245 static const struct snd_kcontrol_new rt5670_mono_adc_l1_mux
=
1246 SOC_DAPM_ENUM("Mono ADC1 left source", rt5670_mono_adc_l1_enum
);
1248 static const char * const rt5670_mono_adc_l2_src
[] = {
1249 "Mono DAC MIXL", "DMIC"
1252 static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l2_enum
, RT5670_MONO_ADC_MIXER
,
1253 RT5670_MONO_ADC_L2_SRC_SFT
, rt5670_mono_adc_l2_src
);
1255 static const struct snd_kcontrol_new rt5670_mono_adc_l2_mux
=
1256 SOC_DAPM_ENUM("Mono ADC2 left source", rt5670_mono_adc_l2_enum
);
1259 static const char * const rt5670_mono_dmic_src
[] = {
1260 "DMIC1", "DMIC2", "DMIC3"
1263 static SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_l_enum
, RT5670_MONO_ADC_MIXER
,
1264 RT5670_MONO_DMIC_L_SRC_SFT
, rt5670_mono_dmic_src
);
1266 static const struct snd_kcontrol_new rt5670_mono_dmic_l_mux
=
1267 SOC_DAPM_ENUM("Mono DMIC left source", rt5670_mono_dmic_l_enum
);
1269 static SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_r_enum
, RT5670_MONO_ADC_MIXER
,
1270 RT5670_MONO_DMIC_R_SRC_SFT
, rt5670_mono_dmic_src
);
1272 static const struct snd_kcontrol_new rt5670_mono_dmic_r_mux
=
1273 SOC_DAPM_ENUM("Mono DMIC Right source", rt5670_mono_dmic_r_enum
);
1275 static const char * const rt5670_mono_adc_r1_src
[] = {
1276 "Mono DAC MIXR", "ADC2"
1279 static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r1_enum
, RT5670_MONO_ADC_MIXER
,
1280 RT5670_MONO_ADC_R1_SRC_SFT
, rt5670_mono_adc_r1_src
);
1282 static const struct snd_kcontrol_new rt5670_mono_adc_r1_mux
=
1283 SOC_DAPM_ENUM("Mono ADC1 right source", rt5670_mono_adc_r1_enum
);
1285 static const char * const rt5670_mono_adc_r2_src
[] = {
1286 "Mono DAC MIXR", "DMIC"
1289 static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r2_enum
, RT5670_MONO_ADC_MIXER
,
1290 RT5670_MONO_ADC_R2_SRC_SFT
, rt5670_mono_adc_r2_src
);
1292 static const struct snd_kcontrol_new rt5670_mono_adc_r2_mux
=
1293 SOC_DAPM_ENUM("Mono ADC2 right source", rt5670_mono_adc_r2_enum
);
1296 static const char * const rt5670_txdp_slot_src
[] = {
1297 "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7"
1300 static SOC_ENUM_SINGLE_DECL(rt5670_txdp_slot_enum
, RT5670_DSP_PATH1
,
1301 RT5670_TXDP_SLOT_SEL_SFT
, rt5670_txdp_slot_src
);
1303 static const struct snd_kcontrol_new rt5670_txdp_slot_mux
=
1304 SOC_DAPM_ENUM("TxDP Slot source", rt5670_txdp_slot_enum
);
1307 static const char * const rt5670_if1_adc2_in_src
[] = {
1308 "IF_ADC2", "VAD_ADC"
1311 static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in_enum
, RT5670_DIG_INF1_DATA
,
1312 RT5670_IF1_ADC2_IN_SFT
, rt5670_if1_adc2_in_src
);
1314 static const struct snd_kcontrol_new rt5670_if1_adc2_in_mux
=
1315 SOC_DAPM_ENUM("IF1 ADC2 IN source", rt5670_if1_adc2_in_enum
);
1318 static const char * const rt5670_if2_adc_in_src
[] = {
1319 "IF_ADC1", "IF_ADC2", "IF_ADC3", "TxDC_DAC", "TxDP_ADC", "VAD_ADC"
1322 static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_in_enum
, RT5670_DIG_INF1_DATA
,
1323 RT5670_IF2_ADC_IN_SFT
, rt5670_if2_adc_in_src
);
1325 static const struct snd_kcontrol_new rt5670_if2_adc_in_mux
=
1326 SOC_DAPM_ENUM("IF2 ADC IN source", rt5670_if2_adc_in_enum
);
1329 static const char * const rt5670_if4_adc_in_src
[] = {
1330 "IF_ADC1", "IF_ADC2", "IF_ADC3"
1333 static SOC_ENUM_SINGLE_DECL(rt5670_if4_adc_in_enum
, RT5670_DIG_INF2_DATA
,
1334 RT5670_IF4_ADC_IN_SFT
, rt5670_if4_adc_in_src
);
1336 static const struct snd_kcontrol_new rt5670_if4_adc_in_mux
=
1337 SOC_DAPM_ENUM("IF4 ADC IN source", rt5670_if4_adc_in_enum
);
1339 /* MX-31 [15] [13] [11] [9] */
1340 static const char * const rt5670_pdm_src
[] = {
1341 "Mono DAC", "Stereo DAC"
1344 static SOC_ENUM_SINGLE_DECL(rt5670_pdm1_l_enum
, RT5670_PDM_OUT_CTRL
,
1345 RT5670_PDM1_L_SFT
, rt5670_pdm_src
);
1347 static const struct snd_kcontrol_new rt5670_pdm1_l_mux
=
1348 SOC_DAPM_ENUM("PDM1 L source", rt5670_pdm1_l_enum
);
1350 static SOC_ENUM_SINGLE_DECL(rt5670_pdm1_r_enum
, RT5670_PDM_OUT_CTRL
,
1351 RT5670_PDM1_R_SFT
, rt5670_pdm_src
);
1353 static const struct snd_kcontrol_new rt5670_pdm1_r_mux
=
1354 SOC_DAPM_ENUM("PDM1 R source", rt5670_pdm1_r_enum
);
1356 static SOC_ENUM_SINGLE_DECL(rt5670_pdm2_l_enum
, RT5670_PDM_OUT_CTRL
,
1357 RT5670_PDM2_L_SFT
, rt5670_pdm_src
);
1359 static const struct snd_kcontrol_new rt5670_pdm2_l_mux
=
1360 SOC_DAPM_ENUM("PDM2 L source", rt5670_pdm2_l_enum
);
1362 static SOC_ENUM_SINGLE_DECL(rt5670_pdm2_r_enum
, RT5670_PDM_OUT_CTRL
,
1363 RT5670_PDM2_R_SFT
, rt5670_pdm_src
);
1365 static const struct snd_kcontrol_new rt5670_pdm2_r_mux
=
1366 SOC_DAPM_ENUM("PDM2 R source", rt5670_pdm2_r_enum
);
1369 static const char * const rt5670_if1_adc1_in1_src
[] = {
1370 "IF_ADC1", "IF1_ADC3"
1373 static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in1_enum
, RT5670_DIG_MISC
,
1374 RT5670_IF1_ADC1_IN1_SFT
, rt5670_if1_adc1_in1_src
);
1376 static const struct snd_kcontrol_new rt5670_if1_adc1_in1_mux
=
1377 SOC_DAPM_ENUM("IF1 ADC1 IN1 source", rt5670_if1_adc1_in1_enum
);
1380 static const char * const rt5670_if1_adc1_in2_src
[] = {
1381 "IF1_ADC1_IN1", "IF1_ADC4"
1384 static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in2_enum
, RT5670_DIG_MISC
,
1385 RT5670_IF1_ADC1_IN2_SFT
, rt5670_if1_adc1_in2_src
);
1387 static const struct snd_kcontrol_new rt5670_if1_adc1_in2_mux
=
1388 SOC_DAPM_ENUM("IF1 ADC1 IN2 source", rt5670_if1_adc1_in2_enum
);
1391 static const char * const rt5670_if1_adc2_in1_src
[] = {
1392 "IF1_ADC2_IN", "IF1_ADC4"
1395 static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in1_enum
, RT5670_DIG_MISC
,
1396 RT5670_IF1_ADC2_IN1_SFT
, rt5670_if1_adc2_in1_src
);
1398 static const struct snd_kcontrol_new rt5670_if1_adc2_in1_mux
=
1399 SOC_DAPM_ENUM("IF1 ADC2 IN1 source", rt5670_if1_adc2_in1_enum
);
1402 static const char * const rt5670_vad_adc_src
[] = {
1403 "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L"
1406 static SOC_ENUM_SINGLE_DECL(rt5670_vad_adc_enum
, RT5670_VAD_CTRL4
,
1407 RT5670_VAD_SEL_SFT
, rt5670_vad_adc_src
);
1409 static const struct snd_kcontrol_new rt5670_vad_adc_mux
=
1410 SOC_DAPM_ENUM("VAD ADC source", rt5670_vad_adc_enum
);
1412 static int rt5670_hp_power_event(struct snd_soc_dapm_widget
*w
,
1413 struct snd_kcontrol
*kcontrol
, int event
)
1415 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
1416 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
1419 case SND_SOC_DAPM_POST_PMU
:
1420 regmap_update_bits(rt5670
->regmap
, RT5670_CHARGE_PUMP
,
1421 RT5670_PM_HP_MASK
, RT5670_PM_HP_HV
);
1422 regmap_update_bits(rt5670
->regmap
, RT5670_GEN_CTRL2
,
1424 /* headphone amp power on */
1425 regmap_update_bits(rt5670
->regmap
, RT5670_PWR_ANLG1
,
1426 RT5670_PWR_HA
| RT5670_PWR_FV1
|
1427 RT5670_PWR_FV2
, RT5670_PWR_HA
|
1428 RT5670_PWR_FV1
| RT5670_PWR_FV2
);
1429 /* depop parameters */
1430 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M2
, 0x3100);
1431 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x8009);
1432 regmap_write(rt5670
->regmap
, RT5670_PR_BASE
+
1433 RT5670_HP_DCC_INT1
, 0x9f00);
1435 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x8019);
1437 case SND_SOC_DAPM_PRE_PMD
:
1438 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x0004);
1448 static int rt5670_hp_event(struct snd_soc_dapm_widget
*w
,
1449 struct snd_kcontrol
*kcontrol
, int event
)
1451 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
1452 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
1455 case SND_SOC_DAPM_POST_PMU
:
1456 /* headphone unmute sequence */
1457 regmap_write(rt5670
->regmap
, RT5670_PR_BASE
+
1458 RT5670_MAMP_INT_REG2
, 0xb400);
1459 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M3
, 0x0772);
1460 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x805d);
1461 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x831d);
1462 regmap_update_bits(rt5670
->regmap
, RT5670_GEN_CTRL2
,
1464 regmap_update_bits(rt5670
->regmap
, RT5670_HP_VOL
,
1465 RT5670_L_MUTE
| RT5670_R_MUTE
, 0);
1467 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x8019);
1470 case SND_SOC_DAPM_PRE_PMD
:
1471 /* headphone mute sequence */
1472 regmap_write(rt5670
->regmap
, RT5670_PR_BASE
+
1473 RT5670_MAMP_INT_REG2
, 0xb400);
1474 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M3
, 0x0772);
1475 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x803d);
1477 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x831d);
1479 regmap_update_bits(rt5670
->regmap
, RT5670_HP_VOL
,
1480 RT5670_L_MUTE
| RT5670_R_MUTE
,
1481 RT5670_L_MUTE
| RT5670_R_MUTE
);
1483 regmap_update_bits(rt5670
->regmap
,
1484 RT5670_GEN_CTRL2
, 0x0300, 0x0);
1485 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M1
, 0x8019);
1486 regmap_write(rt5670
->regmap
, RT5670_DEPOP_M3
, 0x0707);
1487 regmap_write(rt5670
->regmap
, RT5670_PR_BASE
+
1488 RT5670_MAMP_INT_REG2
, 0xfc00);
1498 static int rt5670_bst1_event(struct snd_soc_dapm_widget
*w
,
1499 struct snd_kcontrol
*kcontrol
, int event
)
1501 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
1504 case SND_SOC_DAPM_POST_PMU
:
1505 snd_soc_update_bits(codec
, RT5670_PWR_ANLG2
,
1506 RT5670_PWR_BST1_P
, RT5670_PWR_BST1_P
);
1509 case SND_SOC_DAPM_PRE_PMD
:
1510 snd_soc_update_bits(codec
, RT5670_PWR_ANLG2
,
1511 RT5670_PWR_BST1_P
, 0);
1521 static int rt5670_bst2_event(struct snd_soc_dapm_widget
*w
,
1522 struct snd_kcontrol
*kcontrol
, int event
)
1524 struct snd_soc_codec
*codec
= snd_soc_dapm_to_codec(w
->dapm
);
1527 case SND_SOC_DAPM_POST_PMU
:
1528 snd_soc_update_bits(codec
, RT5670_PWR_ANLG2
,
1529 RT5670_PWR_BST2_P
, RT5670_PWR_BST2_P
);
1532 case SND_SOC_DAPM_PRE_PMD
:
1533 snd_soc_update_bits(codec
, RT5670_PWR_ANLG2
,
1534 RT5670_PWR_BST2_P
, 0);
1544 static const struct snd_soc_dapm_widget rt5670_dapm_widgets
[] = {
1545 SND_SOC_DAPM_SUPPLY("PLL1", RT5670_PWR_ANLG2
,
1546 RT5670_PWR_PLL_BIT
, 0, NULL
, 0),
1547 SND_SOC_DAPM_SUPPLY("I2S DSP", RT5670_PWR_DIG2
,
1548 RT5670_PWR_I2S_DSP_BIT
, 0, NULL
, 0),
1549 SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5670_PWR_VOL
,
1550 RT5670_PWR_MIC_DET_BIT
, 0, NULL
, 0),
1553 SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5670_ASRC_1
,
1555 SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5670_ASRC_1
,
1557 SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5670_ASRC_1
,
1559 SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5670_ASRC_1
,
1561 SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1
,
1563 SND_SOC_DAPM_SUPPLY_S("DMIC STO1 ASRC", 1, RT5670_ASRC_1
,
1565 SND_SOC_DAPM_SUPPLY_S("DMIC STO2 ASRC", 1, RT5670_ASRC_1
,
1567 SND_SOC_DAPM_SUPPLY_S("DMIC MONO L ASRC", 1, RT5670_ASRC_1
,
1569 SND_SOC_DAPM_SUPPLY_S("DMIC MONO R ASRC", 1, RT5670_ASRC_1
,
1571 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5670_ASRC_1
,
1573 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5670_ASRC_1
,
1575 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1
,
1577 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1
,
1582 SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5670_PWR_ANLG2
,
1583 RT5670_PWR_MB1_BIT
, 0, NULL
, 0),
1586 SND_SOC_DAPM_INPUT("DMIC L1"),
1587 SND_SOC_DAPM_INPUT("DMIC R1"),
1588 SND_SOC_DAPM_INPUT("DMIC L2"),
1589 SND_SOC_DAPM_INPUT("DMIC R2"),
1590 SND_SOC_DAPM_INPUT("DMIC L3"),
1591 SND_SOC_DAPM_INPUT("DMIC R3"),
1593 SND_SOC_DAPM_INPUT("IN1P"),
1594 SND_SOC_DAPM_INPUT("IN1N"),
1595 SND_SOC_DAPM_INPUT("IN2P"),
1596 SND_SOC_DAPM_INPUT("IN2N"),
1598 SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1599 SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1600 SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1602 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM
, 0, 0,
1603 set_dmic_clk
, SND_SOC_DAPM_PRE_PMU
),
1604 SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5670_DMIC_CTRL1
,
1605 RT5670_DMIC_1_EN_SFT
, 0, NULL
, 0),
1606 SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5670_DMIC_CTRL1
,
1607 RT5670_DMIC_2_EN_SFT
, 0, NULL
, 0),
1608 SND_SOC_DAPM_SUPPLY("DMIC3 Power", RT5670_DMIC_CTRL1
,
1609 RT5670_DMIC_3_EN_SFT
, 0, NULL
, 0),
1611 SND_SOC_DAPM_PGA_E("BST1", RT5670_PWR_ANLG2
, RT5670_PWR_BST1_BIT
,
1612 0, NULL
, 0, rt5670_bst1_event
,
1613 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMU
),
1614 SND_SOC_DAPM_PGA_E("BST2", RT5670_PWR_ANLG2
, RT5670_PWR_BST2_BIT
,
1615 0, NULL
, 0, rt5670_bst2_event
,
1616 SND_SOC_DAPM_PRE_PMD
| SND_SOC_DAPM_POST_PMU
),
1618 SND_SOC_DAPM_PGA("INL VOL", RT5670_PWR_VOL
,
1619 RT5670_PWR_IN_L_BIT
, 0, NULL
, 0),
1620 SND_SOC_DAPM_PGA("INR VOL", RT5670_PWR_VOL
,
1621 RT5670_PWR_IN_R_BIT
, 0, NULL
, 0),
1624 SND_SOC_DAPM_MIXER("RECMIXL", RT5670_PWR_MIXER
, RT5670_PWR_RM_L_BIT
, 0,
1625 rt5670_rec_l_mix
, ARRAY_SIZE(rt5670_rec_l_mix
)),
1626 SND_SOC_DAPM_MIXER("RECMIXR", RT5670_PWR_MIXER
, RT5670_PWR_RM_R_BIT
, 0,
1627 rt5670_rec_r_mix
, ARRAY_SIZE(rt5670_rec_r_mix
)),
1629 SND_SOC_DAPM_ADC("ADC 1", NULL
, SND_SOC_NOPM
, 0, 0),
1630 SND_SOC_DAPM_ADC("ADC 2", NULL
, SND_SOC_NOPM
, 0, 0),
1632 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1634 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5670_PWR_DIG1
,
1635 RT5670_PWR_ADC_L_BIT
, 0, NULL
, 0),
1636 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5670_PWR_DIG1
,
1637 RT5670_PWR_ADC_R_BIT
, 0, NULL
, 0),
1638 SND_SOC_DAPM_SUPPLY("ADC clock", RT5670_PR_BASE
+
1639 RT5670_CHOP_DAC_ADC
, 12, 0, NULL
, 0),
1641 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM
, 0, 0,
1642 &rt5670_sto1_dmic_mux
),
1643 SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM
, 0, 0,
1644 &rt5670_sto_adc_l2_mux
),
1645 SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM
, 0, 0,
1646 &rt5670_sto_adc_r2_mux
),
1647 SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM
, 0, 0,
1648 &rt5670_sto_adc_l1_mux
),
1649 SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM
, 0, 0,
1650 &rt5670_sto_adc_r1_mux
),
1651 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM
, 0, 0,
1652 &rt5670_sto2_dmic_mux
),
1653 SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM
, 0, 0,
1654 &rt5670_sto2_adc_l2_mux
),
1655 SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM
, 0, 0,
1656 &rt5670_sto2_adc_r2_mux
),
1657 SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM
, 0, 0,
1658 &rt5670_sto2_adc_l1_mux
),
1659 SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM
, 0, 0,
1660 &rt5670_sto2_adc_r1_mux
),
1661 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM
, 0, 0,
1662 &rt5670_sto2_adc_lr_mux
),
1663 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM
, 0, 0,
1664 &rt5670_mono_dmic_l_mux
),
1665 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM
, 0, 0,
1666 &rt5670_mono_dmic_r_mux
),
1667 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM
, 0, 0,
1668 &rt5670_mono_adc_l2_mux
),
1669 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM
, 0, 0,
1670 &rt5670_mono_adc_l1_mux
),
1671 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM
, 0, 0,
1672 &rt5670_mono_adc_r1_mux
),
1673 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM
, 0, 0,
1674 &rt5670_mono_adc_r2_mux
),
1676 SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5670_PWR_DIG2
,
1677 RT5670_PWR_ADC_S1F_BIT
, 0, NULL
, 0),
1678 SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5670_PWR_DIG2
,
1679 RT5670_PWR_ADC_S2F_BIT
, 0, NULL
, 0),
1680 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", RT5670_STO1_ADC_DIG_VOL
,
1681 RT5670_L_MUTE_SFT
, 1, rt5670_sto1_adc_l_mix
,
1682 ARRAY_SIZE(rt5670_sto1_adc_l_mix
)),
1683 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", RT5670_STO1_ADC_DIG_VOL
,
1684 RT5670_R_MUTE_SFT
, 1, rt5670_sto1_adc_r_mix
,
1685 ARRAY_SIZE(rt5670_sto1_adc_r_mix
)),
1686 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM
, 0, 0,
1687 rt5670_sto2_adc_l_mix
,
1688 ARRAY_SIZE(rt5670_sto2_adc_l_mix
)),
1689 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM
, 0, 0,
1690 rt5670_sto2_adc_r_mix
,
1691 ARRAY_SIZE(rt5670_sto2_adc_r_mix
)),
1692 SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2
,
1693 RT5670_PWR_ADC_MF_L_BIT
, 0, NULL
, 0),
1694 SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL
,
1695 RT5670_L_MUTE_SFT
, 1, rt5670_mono_adc_l_mix
,
1696 ARRAY_SIZE(rt5670_mono_adc_l_mix
)),
1697 SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2
,
1698 RT5670_PWR_ADC_MF_R_BIT
, 0, NULL
, 0),
1699 SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL
,
1700 RT5670_R_MUTE_SFT
, 1, rt5670_mono_adc_r_mix
,
1701 ARRAY_SIZE(rt5670_mono_adc_r_mix
)),
1704 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1705 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1706 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1707 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1708 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1709 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1710 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1711 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1712 SND_SOC_DAPM_PGA("VAD_ADC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1713 SND_SOC_DAPM_PGA("IF_ADC1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1714 SND_SOC_DAPM_PGA("IF_ADC2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1715 SND_SOC_DAPM_PGA("IF_ADC3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1716 SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1717 SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1718 SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1719 SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1722 SND_SOC_DAPM_PGA("TxDP_ADC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1723 SND_SOC_DAPM_PGA("TxDP_ADC_L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1724 SND_SOC_DAPM_PGA("TxDP_ADC_R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1725 SND_SOC_DAPM_PGA("TxDC_DAC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1727 SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM
, 0, 0,
1728 &rt5670_txdp_slot_mux
),
1730 SND_SOC_DAPM_MUX("DSP UL Mux", SND_SOC_NOPM
, 0, 0,
1731 &rt5670_dsp_ul_mux
),
1732 SND_SOC_DAPM_MUX("DSP DL Mux", SND_SOC_NOPM
, 0, 0,
1733 &rt5670_dsp_dl_mux
),
1735 SND_SOC_DAPM_MUX("RxDP Mux", SND_SOC_NOPM
, 0, 0,
1739 SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM
, 0, 0,
1740 &rt5670_if2_adc_in_mux
),
1742 /* Digital Interface */
1743 SND_SOC_DAPM_SUPPLY("I2S1", RT5670_PWR_DIG1
,
1744 RT5670_PWR_I2S1_BIT
, 0, NULL
, 0),
1745 SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1746 SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1747 SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1748 SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1749 SND_SOC_DAPM_PGA("IF1 DAC2 L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1750 SND_SOC_DAPM_PGA("IF1 DAC2 R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1751 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1752 SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1753 SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1754 SND_SOC_DAPM_SUPPLY("I2S2", RT5670_PWR_DIG1
,
1755 RT5670_PWR_I2S2_BIT
, 0, NULL
, 0),
1756 SND_SOC_DAPM_PGA("IF2 DAC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1757 SND_SOC_DAPM_PGA("IF2 DAC L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1758 SND_SOC_DAPM_PGA("IF2 DAC R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1759 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1760 SND_SOC_DAPM_PGA("IF2 ADC L", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1761 SND_SOC_DAPM_PGA("IF2 ADC R", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1763 /* Digital Interface Select */
1764 SND_SOC_DAPM_MUX("IF1 ADC1 IN1 Mux", SND_SOC_NOPM
, 0, 0,
1765 &rt5670_if1_adc1_in1_mux
),
1766 SND_SOC_DAPM_MUX("IF1 ADC1 IN2 Mux", SND_SOC_NOPM
, 0, 0,
1767 &rt5670_if1_adc1_in2_mux
),
1768 SND_SOC_DAPM_MUX("IF1 ADC2 IN Mux", SND_SOC_NOPM
, 0, 0,
1769 &rt5670_if1_adc2_in_mux
),
1770 SND_SOC_DAPM_MUX("IF1 ADC2 IN1 Mux", SND_SOC_NOPM
, 0, 0,
1771 &rt5670_if1_adc2_in1_mux
),
1772 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM
, 0, 0,
1773 &rt5670_vad_adc_mux
),
1775 /* Audio Interface */
1776 SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM
, 0, 0),
1777 SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM
, 0, 0),
1778 SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM
, 0, 0),
1779 SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0,
1780 RT5670_GPIO_CTRL1
, RT5670_I2S2_PIN_SFT
, 1),
1783 SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1786 /* DAC mixer before sound effect */
1787 SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM
, 0, 0,
1788 rt5670_dac_l_mix
, ARRAY_SIZE(rt5670_dac_l_mix
)),
1789 SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM
, 0, 0,
1790 rt5670_dac_r_mix
, ARRAY_SIZE(rt5670_dac_r_mix
)),
1791 SND_SOC_DAPM_PGA("DAC MIX", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1793 /* DAC2 channel Mux */
1794 SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM
, 0, 0,
1795 &rt5670_dac_l2_mux
),
1796 SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM
, 0, 0,
1797 &rt5670_dac_r2_mux
),
1798 SND_SOC_DAPM_PGA("DAC L2 Volume", RT5670_PWR_DIG1
,
1799 RT5670_PWR_DAC_L2_BIT
, 0, NULL
, 0),
1800 SND_SOC_DAPM_PGA("DAC R2 Volume", RT5670_PWR_DIG1
,
1801 RT5670_PWR_DAC_R2_BIT
, 0, NULL
, 0),
1803 SND_SOC_DAPM_MUX("DAC1 L Mux", SND_SOC_NOPM
, 0, 0, &rt5670_dac1l_mux
),
1804 SND_SOC_DAPM_MUX("DAC1 R Mux", SND_SOC_NOPM
, 0, 0, &rt5670_dac1r_mux
),
1807 SND_SOC_DAPM_SUPPLY("DAC Stereo1 Filter", RT5670_PWR_DIG2
,
1808 RT5670_PWR_DAC_S1F_BIT
, 0, NULL
, 0),
1809 SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5670_PWR_DIG2
,
1810 RT5670_PWR_DAC_MF_L_BIT
, 0, NULL
, 0),
1811 SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5670_PWR_DIG2
,
1812 RT5670_PWR_DAC_MF_R_BIT
, 0, NULL
, 0),
1813 SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM
, 0, 0,
1814 rt5670_sto_dac_l_mix
,
1815 ARRAY_SIZE(rt5670_sto_dac_l_mix
)),
1816 SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM
, 0, 0,
1817 rt5670_sto_dac_r_mix
,
1818 ARRAY_SIZE(rt5670_sto_dac_r_mix
)),
1819 SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM
, 0, 0,
1820 rt5670_mono_dac_l_mix
,
1821 ARRAY_SIZE(rt5670_mono_dac_l_mix
)),
1822 SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM
, 0, 0,
1823 rt5670_mono_dac_r_mix
,
1824 ARRAY_SIZE(rt5670_mono_dac_r_mix
)),
1825 SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM
, 0, 0,
1827 ARRAY_SIZE(rt5670_dig_l_mix
)),
1828 SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM
, 0, 0,
1830 ARRAY_SIZE(rt5670_dig_r_mix
)),
1833 SND_SOC_DAPM_SUPPLY("DAC L1 Power", RT5670_PWR_DIG1
,
1834 RT5670_PWR_DAC_L1_BIT
, 0, NULL
, 0),
1835 SND_SOC_DAPM_SUPPLY("DAC R1 Power", RT5670_PWR_DIG1
,
1836 RT5670_PWR_DAC_R1_BIT
, 0, NULL
, 0),
1837 SND_SOC_DAPM_DAC("DAC L1", NULL
, SND_SOC_NOPM
, 0, 0),
1838 SND_SOC_DAPM_DAC("DAC R1", NULL
, SND_SOC_NOPM
, 0, 0),
1839 SND_SOC_DAPM_DAC("DAC L2", NULL
, RT5670_PWR_DIG1
,
1840 RT5670_PWR_DAC_L2_BIT
, 0),
1842 SND_SOC_DAPM_DAC("DAC R2", NULL
, RT5670_PWR_DIG1
,
1843 RT5670_PWR_DAC_R2_BIT
, 0),
1846 SND_SOC_DAPM_MIXER("OUT MIXL", RT5670_PWR_MIXER
, RT5670_PWR_OM_L_BIT
,
1847 0, rt5670_out_l_mix
, ARRAY_SIZE(rt5670_out_l_mix
)),
1848 SND_SOC_DAPM_MIXER("OUT MIXR", RT5670_PWR_MIXER
, RT5670_PWR_OM_R_BIT
,
1849 0, rt5670_out_r_mix
, ARRAY_SIZE(rt5670_out_r_mix
)),
1851 SND_SOC_DAPM_MIXER("HPOVOL MIXL", RT5670_PWR_VOL
,
1852 RT5670_PWR_HV_L_BIT
, 0,
1853 rt5670_hpvoll_mix
, ARRAY_SIZE(rt5670_hpvoll_mix
)),
1854 SND_SOC_DAPM_MIXER("HPOVOL MIXR", RT5670_PWR_VOL
,
1855 RT5670_PWR_HV_R_BIT
, 0,
1856 rt5670_hpvolr_mix
, ARRAY_SIZE(rt5670_hpvolr_mix
)),
1857 SND_SOC_DAPM_PGA("DAC 1", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1858 SND_SOC_DAPM_PGA("DAC 2", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1859 SND_SOC_DAPM_PGA("HPOVOL", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1861 /* HPO/LOUT/Mono Mixer */
1862 SND_SOC_DAPM_MIXER("HPO MIX", SND_SOC_NOPM
, 0, 0,
1863 rt5670_hpo_mix
, ARRAY_SIZE(rt5670_hpo_mix
)),
1864 SND_SOC_DAPM_MIXER("LOUT MIX", RT5670_PWR_ANLG1
, RT5670_PWR_LM_BIT
,
1865 0, rt5670_lout_mix
, ARRAY_SIZE(rt5670_lout_mix
)),
1866 SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM
, 0, 0,
1867 rt5670_hp_power_event
, SND_SOC_DAPM_POST_PMU
|
1868 SND_SOC_DAPM_PRE_PMD
),
1869 SND_SOC_DAPM_SUPPLY("HP L Amp", RT5670_PWR_ANLG1
,
1870 RT5670_PWR_HP_L_BIT
, 0, NULL
, 0),
1871 SND_SOC_DAPM_SUPPLY("HP R Amp", RT5670_PWR_ANLG1
,
1872 RT5670_PWR_HP_R_BIT
, 0, NULL
, 0),
1873 SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM
, 0, 0,
1874 rt5670_hp_event
, SND_SOC_DAPM_PRE_PMD
|
1875 SND_SOC_DAPM_POST_PMU
),
1876 SND_SOC_DAPM_SWITCH("LOUT L Playback", SND_SOC_NOPM
, 0, 0,
1877 &lout_l_enable_control
),
1878 SND_SOC_DAPM_SWITCH("LOUT R Playback", SND_SOC_NOPM
, 0, 0,
1879 &lout_r_enable_control
),
1880 SND_SOC_DAPM_PGA("LOUT Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1883 SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5670_PWR_DIG2
,
1884 RT5670_PWR_PDM1_BIT
, 0, NULL
, 0),
1886 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL
,
1887 RT5670_M_PDM1_L_SFT
, 1, &rt5670_pdm1_l_mux
),
1888 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL
,
1889 RT5670_M_PDM1_R_SFT
, 1, &rt5670_pdm1_r_mux
),
1892 SND_SOC_DAPM_OUTPUT("HPOL"),
1893 SND_SOC_DAPM_OUTPUT("HPOR"),
1894 SND_SOC_DAPM_OUTPUT("LOUTL"),
1895 SND_SOC_DAPM_OUTPUT("LOUTR"),
1898 static const struct snd_soc_dapm_widget rt5670_specific_dapm_widgets
[] = {
1899 SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5670_PWR_DIG2
,
1900 RT5670_PWR_PDM2_BIT
, 0, NULL
, 0),
1901 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL
,
1902 RT5670_M_PDM2_L_SFT
, 1, &rt5670_pdm2_l_mux
),
1903 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL
,
1904 RT5670_M_PDM2_R_SFT
, 1, &rt5670_pdm2_r_mux
),
1905 SND_SOC_DAPM_OUTPUT("PDM1L"),
1906 SND_SOC_DAPM_OUTPUT("PDM1R"),
1907 SND_SOC_DAPM_OUTPUT("PDM2L"),
1908 SND_SOC_DAPM_OUTPUT("PDM2R"),
1911 static const struct snd_soc_dapm_widget rt5672_specific_dapm_widgets
[] = {
1912 SND_SOC_DAPM_PGA("SPO Amp", SND_SOC_NOPM
, 0, 0, NULL
, 0),
1913 SND_SOC_DAPM_OUTPUT("SPOLP"),
1914 SND_SOC_DAPM_OUTPUT("SPOLN"),
1915 SND_SOC_DAPM_OUTPUT("SPORP"),
1916 SND_SOC_DAPM_OUTPUT("SPORN"),
1919 static const struct snd_soc_dapm_route rt5670_dapm_routes
[] = {
1920 { "ADC Stereo1 Filter", NULL
, "ADC STO1 ASRC", is_using_asrc
},
1921 { "ADC Stereo2 Filter", NULL
, "ADC STO2 ASRC", is_using_asrc
},
1922 { "ADC Mono Left Filter", NULL
, "ADC MONO L ASRC", is_using_asrc
},
1923 { "ADC Mono Right Filter", NULL
, "ADC MONO R ASRC", is_using_asrc
},
1924 { "DAC Mono Left Filter", NULL
, "DAC MONO L ASRC", is_using_asrc
},
1925 { "DAC Mono Right Filter", NULL
, "DAC MONO R ASRC", is_using_asrc
},
1926 { "DAC Stereo1 Filter", NULL
, "DAC STO ASRC", is_using_asrc
},
1927 { "Stereo1 DMIC Mux", NULL
, "DMIC STO1 ASRC", can_use_asrc
},
1928 { "Stereo2 DMIC Mux", NULL
, "DMIC STO2 ASRC", can_use_asrc
},
1929 { "Mono DMIC L Mux", NULL
, "DMIC MONO L ASRC", can_use_asrc
},
1930 { "Mono DMIC R Mux", NULL
, "DMIC MONO R ASRC", can_use_asrc
},
1932 { "I2S1", NULL
, "I2S1 ASRC", can_use_asrc
},
1933 { "I2S2", NULL
, "I2S2 ASRC", can_use_asrc
},
1935 { "DMIC1", NULL
, "DMIC L1" },
1936 { "DMIC1", NULL
, "DMIC R1" },
1937 { "DMIC2", NULL
, "DMIC L2" },
1938 { "DMIC2", NULL
, "DMIC R2" },
1939 { "DMIC3", NULL
, "DMIC L3" },
1940 { "DMIC3", NULL
, "DMIC R3" },
1942 { "BST1", NULL
, "IN1P" },
1943 { "BST1", NULL
, "IN1N" },
1944 { "BST1", NULL
, "Mic Det Power" },
1945 { "BST2", NULL
, "IN2P" },
1946 { "BST2", NULL
, "IN2N" },
1948 { "INL VOL", NULL
, "IN2P" },
1949 { "INR VOL", NULL
, "IN2N" },
1951 { "RECMIXL", "INL Switch", "INL VOL" },
1952 { "RECMIXL", "BST2 Switch", "BST2" },
1953 { "RECMIXL", "BST1 Switch", "BST1" },
1955 { "RECMIXR", "INR Switch", "INR VOL" },
1956 { "RECMIXR", "BST2 Switch", "BST2" },
1957 { "RECMIXR", "BST1 Switch", "BST1" },
1959 { "ADC 1", NULL
, "RECMIXL" },
1960 { "ADC 1", NULL
, "ADC 1 power" },
1961 { "ADC 1", NULL
, "ADC clock" },
1962 { "ADC 2", NULL
, "RECMIXR" },
1963 { "ADC 2", NULL
, "ADC 2 power" },
1964 { "ADC 2", NULL
, "ADC clock" },
1966 { "DMIC L1", NULL
, "DMIC CLK" },
1967 { "DMIC L1", NULL
, "DMIC1 Power" },
1968 { "DMIC R1", NULL
, "DMIC CLK" },
1969 { "DMIC R1", NULL
, "DMIC1 Power" },
1970 { "DMIC L2", NULL
, "DMIC CLK" },
1971 { "DMIC L2", NULL
, "DMIC2 Power" },
1972 { "DMIC R2", NULL
, "DMIC CLK" },
1973 { "DMIC R2", NULL
, "DMIC2 Power" },
1974 { "DMIC L3", NULL
, "DMIC CLK" },
1975 { "DMIC L3", NULL
, "DMIC3 Power" },
1976 { "DMIC R3", NULL
, "DMIC CLK" },
1977 { "DMIC R3", NULL
, "DMIC3 Power" },
1979 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
1980 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
1981 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
1983 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
1984 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
1985 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
1987 { "Mono DMIC L Mux", "DMIC1", "DMIC L1" },
1988 { "Mono DMIC L Mux", "DMIC2", "DMIC L2" },
1989 { "Mono DMIC L Mux", "DMIC3", "DMIC L3" },
1991 { "Mono DMIC R Mux", "DMIC1", "DMIC R1" },
1992 { "Mono DMIC R Mux", "DMIC2", "DMIC R2" },
1993 { "Mono DMIC R Mux", "DMIC3", "DMIC R3" },
1995 { "ADC 1_2", NULL
, "ADC 1" },
1996 { "ADC 1_2", NULL
, "ADC 2" },
1998 { "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC Mux" },
1999 { "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
2000 { "Stereo1 ADC L1 Mux", "ADC", "ADC 1_2" },
2001 { "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
2003 { "Stereo1 ADC R1 Mux", "ADC", "ADC 1_2" },
2004 { "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
2005 { "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2006 { "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
2008 { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
2009 { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2010 { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2011 { "Mono ADC L1 Mux", "ADC1", "ADC 1" },
2013 { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2014 { "Mono ADC R1 Mux", "ADC2", "ADC 2" },
2015 { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
2016 { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2018 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" },
2019 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" },
2020 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" },
2021 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" },
2023 { "Stereo1 ADC MIXL", NULL
, "Sto1 ADC MIXL" },
2024 { "Stereo1 ADC MIXL", NULL
, "ADC Stereo1 Filter" },
2025 { "ADC Stereo1 Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2027 { "Stereo1 ADC MIXR", NULL
, "Sto1 ADC MIXR" },
2028 { "Stereo1 ADC MIXR", NULL
, "ADC Stereo1 Filter" },
2029 { "ADC Stereo1 Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2031 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2032 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2033 { "Mono ADC MIXL", NULL
, "ADC Mono Left Filter" },
2034 { "ADC Mono Left Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2036 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2037 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2038 { "Mono ADC MIXR", NULL
, "ADC Mono Right Filter" },
2039 { "ADC Mono Right Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2041 { "Stereo2 ADC L2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2042 { "Stereo2 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
2043 { "Stereo2 ADC L1 Mux", "ADC", "ADC 1_2" },
2044 { "Stereo2 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
2046 { "Stereo2 ADC R1 Mux", "ADC", "ADC 1_2" },
2047 { "Stereo2 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
2048 { "Stereo2 ADC R2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2049 { "Stereo2 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
2051 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux" },
2052 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux" },
2053 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux" },
2054 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux" },
2056 { "Sto2 ADC LR MIX", NULL
, "Sto2 ADC MIXL" },
2057 { "Sto2 ADC LR MIX", NULL
, "Sto2 ADC MIXR" },
2059 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
2060 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
2062 { "Stereo2 ADC MIXL", NULL
, "Stereo2 ADC LR Mux" },
2063 { "Stereo2 ADC MIXL", NULL
, "ADC Stereo2 Filter" },
2064 { "ADC Stereo2 Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2066 { "Stereo2 ADC MIXR", NULL
, "Sto2 ADC MIXR" },
2067 { "Stereo2 ADC MIXR", NULL
, "ADC Stereo2 Filter" },
2068 { "ADC Stereo2 Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2070 { "VAD ADC Mux", "Sto1 ADC L", "Stereo1 ADC MIXL" },
2071 { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" },
2072 { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" },
2073 { "VAD ADC Mux", "Sto2 ADC L", "Sto2 ADC MIXL" },
2075 { "VAD_ADC", NULL
, "VAD ADC Mux" },
2077 { "IF_ADC1", NULL
, "Stereo1 ADC MIXL" },
2078 { "IF_ADC1", NULL
, "Stereo1 ADC MIXR" },
2079 { "IF_ADC2", NULL
, "Mono ADC MIXL" },
2080 { "IF_ADC2", NULL
, "Mono ADC MIXR" },
2081 { "IF_ADC3", NULL
, "Stereo2 ADC MIXL" },
2082 { "IF_ADC3", NULL
, "Stereo2 ADC MIXR" },
2084 { "IF1 ADC1 IN1 Mux", "IF_ADC1", "IF_ADC1" },
2085 { "IF1 ADC1 IN1 Mux", "IF1_ADC3", "IF1_ADC3" },
2087 { "IF1 ADC1 IN2 Mux", "IF1_ADC1_IN1", "IF1 ADC1 IN1 Mux" },
2088 { "IF1 ADC1 IN2 Mux", "IF1_ADC4", "IF1_ADC4" },
2090 { "IF1 ADC2 IN Mux", "IF_ADC2", "IF_ADC2" },
2091 { "IF1 ADC2 IN Mux", "VAD_ADC", "VAD_ADC" },
2093 { "IF1 ADC2 IN1 Mux", "IF1_ADC2_IN", "IF1 ADC2 IN Mux" },
2094 { "IF1 ADC2 IN1 Mux", "IF1_ADC4", "IF1_ADC4" },
2096 { "IF1_ADC1" , NULL
, "IF1 ADC1 IN2 Mux" },
2097 { "IF1_ADC2" , NULL
, "IF1 ADC2 IN1 Mux" },
2099 { "Stereo1 ADC MIX", NULL
, "Stereo1 ADC MIXL" },
2100 { "Stereo1 ADC MIX", NULL
, "Stereo1 ADC MIXR" },
2101 { "Stereo2 ADC MIX", NULL
, "Sto2 ADC MIXL" },
2102 { "Stereo2 ADC MIX", NULL
, "Sto2 ADC MIXR" },
2103 { "Mono ADC MIX", NULL
, "Mono ADC MIXL" },
2104 { "Mono ADC MIX", NULL
, "Mono ADC MIXR" },
2106 { "RxDP Mux", "IF2 DAC", "IF2 DAC" },
2107 { "RxDP Mux", "IF1 DAC", "IF1 DAC2" },
2108 { "RxDP Mux", "STO1 ADC Mixer", "Stereo1 ADC MIX" },
2109 { "RxDP Mux", "STO2 ADC Mixer", "Stereo2 ADC MIX" },
2110 { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" },
2111 { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" },
2112 { "RxDP Mux", "DAC1", "DAC MIX" },
2114 { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" },
2115 { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" },
2116 { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" },
2117 { "TDM Data Mux", "Slot 6-7", "IF2 DAC" },
2119 { "DSP UL Mux", "Bypass", "TDM Data Mux" },
2120 { "DSP UL Mux", NULL
, "I2S DSP" },
2121 { "DSP DL Mux", "Bypass", "RxDP Mux" },
2122 { "DSP DL Mux", NULL
, "I2S DSP" },
2124 { "TxDP_ADC_L", NULL
, "DSP UL Mux" },
2125 { "TxDP_ADC_R", NULL
, "DSP UL Mux" },
2126 { "TxDC_DAC", NULL
, "DSP DL Mux" },
2128 { "TxDP_ADC", NULL
, "TxDP_ADC_L" },
2129 { "TxDP_ADC", NULL
, "TxDP_ADC_R" },
2131 { "IF1 ADC", NULL
, "I2S1" },
2132 { "IF1 ADC", NULL
, "IF1_ADC1" },
2133 { "IF1 ADC", NULL
, "IF1_ADC2" },
2134 { "IF1 ADC", NULL
, "IF_ADC3" },
2135 { "IF1 ADC", NULL
, "TxDP_ADC" },
2137 { "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" },
2138 { "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" },
2139 { "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" },
2140 { "IF2 ADC Mux", "TxDC_DAC", "TxDC_DAC" },
2141 { "IF2 ADC Mux", "TxDP_ADC", "TxDP_ADC" },
2142 { "IF2 ADC Mux", "VAD_ADC", "VAD_ADC" },
2144 { "IF2 ADC L", NULL
, "IF2 ADC Mux" },
2145 { "IF2 ADC R", NULL
, "IF2 ADC Mux" },
2147 { "IF2 ADC", NULL
, "I2S2" },
2148 { "IF2 ADC", NULL
, "IF2 ADC L" },
2149 { "IF2 ADC", NULL
, "IF2 ADC R" },
2151 { "AIF1TX", NULL
, "IF1 ADC" },
2152 { "AIF2TX", NULL
, "IF2 ADC" },
2154 { "IF1 DAC1", NULL
, "AIF1RX" },
2155 { "IF1 DAC2", NULL
, "AIF1RX" },
2156 { "IF2 DAC", NULL
, "AIF2RX" },
2158 { "IF1 DAC1", NULL
, "I2S1" },
2159 { "IF1 DAC2", NULL
, "I2S1" },
2160 { "IF2 DAC", NULL
, "I2S2" },
2162 { "IF1 DAC2 L", NULL
, "IF1 DAC2" },
2163 { "IF1 DAC2 R", NULL
, "IF1 DAC2" },
2164 { "IF1 DAC1 L", NULL
, "IF1 DAC1" },
2165 { "IF1 DAC1 R", NULL
, "IF1 DAC1" },
2166 { "IF2 DAC L", NULL
, "IF2 DAC" },
2167 { "IF2 DAC R", NULL
, "IF2 DAC" },
2169 { "DAC1 L Mux", "IF1 DAC", "IF1 DAC1 L" },
2170 { "DAC1 L Mux", "IF2 DAC", "IF2 DAC L" },
2172 { "DAC1 R Mux", "IF1 DAC", "IF1 DAC1 R" },
2173 { "DAC1 R Mux", "IF2 DAC", "IF2 DAC R" },
2175 { "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL" },
2176 { "DAC1 MIXL", "DAC1 Switch", "DAC1 L Mux" },
2177 { "DAC1 MIXL", NULL
, "DAC Stereo1 Filter" },
2178 { "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR" },
2179 { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" },
2180 { "DAC1 MIXR", NULL
, "DAC Stereo1 Filter" },
2182 { "DAC Stereo1 Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2183 { "DAC Mono Left Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2184 { "DAC Mono Right Filter", NULL
, "PLL1", is_sys_clk_from_pll
},
2186 { "DAC MIX", NULL
, "DAC1 MIXL" },
2187 { "DAC MIX", NULL
, "DAC1 MIXR" },
2189 { "Audio DSP", NULL
, "DAC1 MIXL" },
2190 { "Audio DSP", NULL
, "DAC1 MIXR" },
2192 { "DAC L2 Mux", "IF1 DAC", "IF1 DAC2 L" },
2193 { "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" },
2194 { "DAC L2 Mux", "TxDC DAC", "TxDC_DAC" },
2195 { "DAC L2 Mux", "VAD_ADC", "VAD_ADC" },
2196 { "DAC L2 Volume", NULL
, "DAC L2 Mux" },
2197 { "DAC L2 Volume", NULL
, "DAC Mono Left Filter" },
2199 { "DAC R2 Mux", "IF1 DAC", "IF1 DAC2 R" },
2200 { "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" },
2201 { "DAC R2 Mux", "TxDC DAC", "TxDC_DAC" },
2202 { "DAC R2 Mux", "TxDP ADC", "TxDP_ADC" },
2203 { "DAC R2 Volume", NULL
, "DAC R2 Mux" },
2204 { "DAC R2 Volume", NULL
, "DAC Mono Right Filter" },
2206 { "Stereo DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
2207 { "Stereo DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" },
2208 { "Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2209 { "Stereo DAC MIXL", NULL
, "DAC Stereo1 Filter" },
2210 { "Stereo DAC MIXL", NULL
, "DAC L1 Power" },
2211 { "Stereo DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
2212 { "Stereo DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" },
2213 { "Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2214 { "Stereo DAC MIXR", NULL
, "DAC Stereo1 Filter" },
2215 { "Stereo DAC MIXR", NULL
, "DAC R1 Power" },
2217 { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" },
2218 { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2219 { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" },
2220 { "Mono DAC MIXL", NULL
, "DAC Mono Left Filter" },
2221 { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" },
2222 { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2223 { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" },
2224 { "Mono DAC MIXR", NULL
, "DAC Mono Right Filter" },
2226 { "DAC MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" },
2227 { "DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" },
2228 { "DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" },
2229 { "DAC MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" },
2230 { "DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" },
2231 { "DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" },
2233 { "DAC L1", NULL
, "DAC L1 Power" },
2234 { "DAC L1", NULL
, "Stereo DAC MIXL" },
2235 { "DAC R1", NULL
, "DAC R1 Power" },
2236 { "DAC R1", NULL
, "Stereo DAC MIXR" },
2237 { "DAC L2", NULL
, "Mono DAC MIXL" },
2238 { "DAC R2", NULL
, "Mono DAC MIXR" },
2240 { "OUT MIXL", "BST1 Switch", "BST1" },
2241 { "OUT MIXL", "INL Switch", "INL VOL" },
2242 { "OUT MIXL", "DAC L2 Switch", "DAC L2" },
2243 { "OUT MIXL", "DAC L1 Switch", "DAC L1" },
2245 { "OUT MIXR", "BST2 Switch", "BST2" },
2246 { "OUT MIXR", "INR Switch", "INR VOL" },
2247 { "OUT MIXR", "DAC R2 Switch", "DAC R2" },
2248 { "OUT MIXR", "DAC R1 Switch", "DAC R1" },
2250 { "HPOVOL MIXL", "DAC1 Switch", "DAC L1" },
2251 { "HPOVOL MIXL", "INL Switch", "INL VOL" },
2252 { "HPOVOL MIXR", "DAC1 Switch", "DAC R1" },
2253 { "HPOVOL MIXR", "INR Switch", "INR VOL" },
2255 { "DAC 2", NULL
, "DAC L2" },
2256 { "DAC 2", NULL
, "DAC R2" },
2257 { "DAC 1", NULL
, "DAC L1" },
2258 { "DAC 1", NULL
, "DAC R1" },
2259 { "HPOVOL", NULL
, "HPOVOL MIXL" },
2260 { "HPOVOL", NULL
, "HPOVOL MIXR" },
2261 { "HPO MIX", "DAC1 Switch", "DAC 1" },
2262 { "HPO MIX", "HPVOL Switch", "HPOVOL" },
2264 { "LOUT MIX", "DAC L1 Switch", "DAC L1" },
2265 { "LOUT MIX", "DAC R1 Switch", "DAC R1" },
2266 { "LOUT MIX", "OUTMIX L Switch", "OUT MIXL" },
2267 { "LOUT MIX", "OUTMIX R Switch", "OUT MIXR" },
2269 { "PDM1 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
2270 { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" },
2271 { "PDM1 L Mux", NULL
, "PDM1 Power" },
2272 { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
2273 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
2274 { "PDM1 R Mux", NULL
, "PDM1 Power" },
2276 { "HP Amp", NULL
, "HPO MIX" },
2277 { "HP Amp", NULL
, "Mic Det Power" },
2278 { "HPOL", NULL
, "HP Amp" },
2279 { "HPOL", NULL
, "HP L Amp" },
2280 { "HPOL", NULL
, "Improve HP Amp Drv" },
2281 { "HPOR", NULL
, "HP Amp" },
2282 { "HPOR", NULL
, "HP R Amp" },
2283 { "HPOR", NULL
, "Improve HP Amp Drv" },
2285 { "LOUT Amp", NULL
, "LOUT MIX" },
2286 { "LOUT L Playback", "Switch", "LOUT Amp" },
2287 { "LOUT R Playback", "Switch", "LOUT Amp" },
2288 { "LOUTL", NULL
, "LOUT L Playback" },
2289 { "LOUTR", NULL
, "LOUT R Playback" },
2290 { "LOUTL", NULL
, "Improve HP Amp Drv" },
2291 { "LOUTR", NULL
, "Improve HP Amp Drv" },
2294 static const struct snd_soc_dapm_route rt5670_specific_dapm_routes
[] = {
2295 { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
2296 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
2297 { "PDM2 L Mux", NULL
, "PDM2 Power" },
2298 { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
2299 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
2300 { "PDM2 R Mux", NULL
, "PDM2 Power" },
2301 { "PDM1L", NULL
, "PDM1 L Mux" },
2302 { "PDM1R", NULL
, "PDM1 R Mux" },
2303 { "PDM2L", NULL
, "PDM2 L Mux" },
2304 { "PDM2R", NULL
, "PDM2 R Mux" },
2307 static const struct snd_soc_dapm_route rt5672_specific_dapm_routes
[] = {
2308 { "SPO Amp", NULL
, "PDM1 L Mux" },
2309 { "SPO Amp", NULL
, "PDM1 R Mux" },
2310 { "SPOLP", NULL
, "SPO Amp" },
2311 { "SPOLN", NULL
, "SPO Amp" },
2312 { "SPORP", NULL
, "SPO Amp" },
2313 { "SPORN", NULL
, "SPO Amp" },
2316 static int rt5670_hw_params(struct snd_pcm_substream
*substream
,
2317 struct snd_pcm_hw_params
*params
, struct snd_soc_dai
*dai
)
2319 struct snd_soc_codec
*codec
= dai
->codec
;
2320 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2321 unsigned int val_len
= 0, val_clk
, mask_clk
;
2322 int pre_div
, bclk_ms
, frame_size
;
2324 rt5670
->lrck
[dai
->id
] = params_rate(params
);
2325 pre_div
= rl6231_get_clk_info(rt5670
->sysclk
, rt5670
->lrck
[dai
->id
]);
2327 dev_err(codec
->dev
, "Unsupported clock setting %d for DAI %d\n",
2328 rt5670
->lrck
[dai
->id
], dai
->id
);
2331 frame_size
= snd_soc_params_to_frame_size(params
);
2332 if (frame_size
< 0) {
2333 dev_err(codec
->dev
, "Unsupported frame size: %d\n", frame_size
);
2336 bclk_ms
= frame_size
> 32;
2337 rt5670
->bclk
[dai
->id
] = rt5670
->lrck
[dai
->id
] * (32 << bclk_ms
);
2339 dev_dbg(dai
->dev
, "bclk is %dHz and lrck is %dHz\n",
2340 rt5670
->bclk
[dai
->id
], rt5670
->lrck
[dai
->id
]);
2341 dev_dbg(dai
->dev
, "bclk_ms is %d and pre_div is %d for iis %d\n",
2342 bclk_ms
, pre_div
, dai
->id
);
2344 switch (params_width(params
)) {
2348 val_len
|= RT5670_I2S_DL_20
;
2351 val_len
|= RT5670_I2S_DL_24
;
2354 val_len
|= RT5670_I2S_DL_8
;
2362 mask_clk
= RT5670_I2S_BCLK_MS1_MASK
| RT5670_I2S_PD1_MASK
;
2363 val_clk
= bclk_ms
<< RT5670_I2S_BCLK_MS1_SFT
|
2364 pre_div
<< RT5670_I2S_PD1_SFT
;
2365 snd_soc_update_bits(codec
, RT5670_I2S1_SDP
,
2366 RT5670_I2S_DL_MASK
, val_len
);
2367 snd_soc_update_bits(codec
, RT5670_ADDA_CLK1
, mask_clk
, val_clk
);
2370 mask_clk
= RT5670_I2S_BCLK_MS2_MASK
| RT5670_I2S_PD2_MASK
;
2371 val_clk
= bclk_ms
<< RT5670_I2S_BCLK_MS2_SFT
|
2372 pre_div
<< RT5670_I2S_PD2_SFT
;
2373 snd_soc_update_bits(codec
, RT5670_I2S2_SDP
,
2374 RT5670_I2S_DL_MASK
, val_len
);
2375 snd_soc_update_bits(codec
, RT5670_ADDA_CLK1
, mask_clk
, val_clk
);
2378 dev_err(codec
->dev
, "Invalid dai->id: %d\n", dai
->id
);
2385 static int rt5670_set_dai_fmt(struct snd_soc_dai
*dai
, unsigned int fmt
)
2387 struct snd_soc_codec
*codec
= dai
->codec
;
2388 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2389 unsigned int reg_val
= 0;
2391 switch (fmt
& SND_SOC_DAIFMT_MASTER_MASK
) {
2392 case SND_SOC_DAIFMT_CBM_CFM
:
2393 rt5670
->master
[dai
->id
] = 1;
2395 case SND_SOC_DAIFMT_CBS_CFS
:
2396 reg_val
|= RT5670_I2S_MS_S
;
2397 rt5670
->master
[dai
->id
] = 0;
2403 switch (fmt
& SND_SOC_DAIFMT_INV_MASK
) {
2404 case SND_SOC_DAIFMT_NB_NF
:
2406 case SND_SOC_DAIFMT_IB_NF
:
2407 reg_val
|= RT5670_I2S_BP_INV
;
2413 switch (fmt
& SND_SOC_DAIFMT_FORMAT_MASK
) {
2414 case SND_SOC_DAIFMT_I2S
:
2416 case SND_SOC_DAIFMT_LEFT_J
:
2417 reg_val
|= RT5670_I2S_DF_LEFT
;
2419 case SND_SOC_DAIFMT_DSP_A
:
2420 reg_val
|= RT5670_I2S_DF_PCM_A
;
2422 case SND_SOC_DAIFMT_DSP_B
:
2423 reg_val
|= RT5670_I2S_DF_PCM_B
;
2431 snd_soc_update_bits(codec
, RT5670_I2S1_SDP
,
2432 RT5670_I2S_MS_MASK
| RT5670_I2S_BP_MASK
|
2433 RT5670_I2S_DF_MASK
, reg_val
);
2436 snd_soc_update_bits(codec
, RT5670_I2S2_SDP
,
2437 RT5670_I2S_MS_MASK
| RT5670_I2S_BP_MASK
|
2438 RT5670_I2S_DF_MASK
, reg_val
);
2441 dev_err(codec
->dev
, "Invalid dai->id: %d\n", dai
->id
);
2447 static int rt5670_set_dai_sysclk(struct snd_soc_dai
*dai
,
2448 int clk_id
, unsigned int freq
, int dir
)
2450 struct snd_soc_codec
*codec
= dai
->codec
;
2451 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2452 unsigned int reg_val
= 0;
2455 case RT5670_SCLK_S_MCLK
:
2456 reg_val
|= RT5670_SCLK_SRC_MCLK
;
2458 case RT5670_SCLK_S_PLL1
:
2459 reg_val
|= RT5670_SCLK_SRC_PLL1
;
2461 case RT5670_SCLK_S_RCCLK
:
2462 reg_val
|= RT5670_SCLK_SRC_RCCLK
;
2465 dev_err(codec
->dev
, "Invalid clock id (%d)\n", clk_id
);
2468 snd_soc_update_bits(codec
, RT5670_GLB_CLK
,
2469 RT5670_SCLK_SRC_MASK
, reg_val
);
2470 rt5670
->sysclk
= freq
;
2471 if (clk_id
!= RT5670_SCLK_S_RCCLK
)
2472 rt5670
->sysclk_src
= clk_id
;
2474 dev_dbg(dai
->dev
, "Sysclk is %dHz and clock id is %d\n", freq
, clk_id
);
2479 static int rt5670_set_dai_pll(struct snd_soc_dai
*dai
, int pll_id
, int source
,
2480 unsigned int freq_in
, unsigned int freq_out
)
2482 struct snd_soc_codec
*codec
= dai
->codec
;
2483 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2484 struct rl6231_pll_code pll_code
;
2487 if (source
== rt5670
->pll_src
&& freq_in
== rt5670
->pll_in
&&
2488 freq_out
== rt5670
->pll_out
)
2491 if (!freq_in
|| !freq_out
) {
2492 dev_dbg(codec
->dev
, "PLL disabled\n");
2495 rt5670
->pll_out
= 0;
2496 snd_soc_update_bits(codec
, RT5670_GLB_CLK
,
2497 RT5670_SCLK_SRC_MASK
, RT5670_SCLK_SRC_MCLK
);
2502 case RT5670_PLL1_S_MCLK
:
2503 snd_soc_update_bits(codec
, RT5670_GLB_CLK
,
2504 RT5670_PLL1_SRC_MASK
, RT5670_PLL1_SRC_MCLK
);
2506 case RT5670_PLL1_S_BCLK1
:
2507 case RT5670_PLL1_S_BCLK2
:
2508 case RT5670_PLL1_S_BCLK3
:
2509 case RT5670_PLL1_S_BCLK4
:
2512 snd_soc_update_bits(codec
, RT5670_GLB_CLK
,
2513 RT5670_PLL1_SRC_MASK
, RT5670_PLL1_SRC_BCLK1
);
2516 snd_soc_update_bits(codec
, RT5670_GLB_CLK
,
2517 RT5670_PLL1_SRC_MASK
, RT5670_PLL1_SRC_BCLK2
);
2520 dev_err(codec
->dev
, "Invalid dai->id: %d\n", dai
->id
);
2525 dev_err(codec
->dev
, "Unknown PLL source %d\n", source
);
2529 ret
= rl6231_pll_calc(freq_in
, freq_out
, &pll_code
);
2531 dev_err(codec
->dev
, "Unsupport input clock %d\n", freq_in
);
2535 dev_dbg(codec
->dev
, "bypass=%d m=%d n=%d k=%d\n",
2536 pll_code
.m_bp
, (pll_code
.m_bp
? 0 : pll_code
.m_code
),
2537 pll_code
.n_code
, pll_code
.k_code
);
2539 snd_soc_write(codec
, RT5670_PLL_CTRL1
,
2540 pll_code
.n_code
<< RT5670_PLL_N_SFT
| pll_code
.k_code
);
2541 snd_soc_write(codec
, RT5670_PLL_CTRL2
,
2542 (pll_code
.m_bp
? 0 : pll_code
.m_code
) << RT5670_PLL_M_SFT
|
2543 pll_code
.m_bp
<< RT5670_PLL_M_BP_SFT
);
2545 rt5670
->pll_in
= freq_in
;
2546 rt5670
->pll_out
= freq_out
;
2547 rt5670
->pll_src
= source
;
2552 static int rt5670_set_tdm_slot(struct snd_soc_dai
*dai
, unsigned int tx_mask
,
2553 unsigned int rx_mask
, int slots
, int slot_width
)
2555 struct snd_soc_codec
*codec
= dai
->codec
;
2556 unsigned int val
= 0;
2558 if (rx_mask
|| tx_mask
)
2577 switch (slot_width
) {
2593 snd_soc_update_bits(codec
, RT5670_TDM_CTRL_1
, 0x7c00, val
);
2598 static int rt5670_set_bias_level(struct snd_soc_codec
*codec
,
2599 enum snd_soc_bias_level level
)
2601 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2604 case SND_SOC_BIAS_PREPARE
:
2605 if (SND_SOC_BIAS_STANDBY
== snd_soc_codec_get_bias_level(codec
)) {
2606 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2607 RT5670_PWR_VREF1
| RT5670_PWR_MB
|
2608 RT5670_PWR_BG
| RT5670_PWR_VREF2
,
2609 RT5670_PWR_VREF1
| RT5670_PWR_MB
|
2610 RT5670_PWR_BG
| RT5670_PWR_VREF2
);
2612 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2613 RT5670_PWR_FV1
| RT5670_PWR_FV2
,
2614 RT5670_PWR_FV1
| RT5670_PWR_FV2
);
2615 snd_soc_update_bits(codec
, RT5670_CHARGE_PUMP
,
2616 RT5670_OSW_L_MASK
| RT5670_OSW_R_MASK
,
2617 RT5670_OSW_L_DIS
| RT5670_OSW_R_DIS
);
2618 snd_soc_update_bits(codec
, RT5670_DIG_MISC
, 0x1, 0x1);
2619 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2620 RT5670_LDO_SEL_MASK
, 0x3);
2623 case SND_SOC_BIAS_STANDBY
:
2624 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2625 RT5670_PWR_VREF1
| RT5670_PWR_VREF2
|
2626 RT5670_PWR_FV1
| RT5670_PWR_FV2
, 0);
2627 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2628 RT5670_LDO_SEL_MASK
, 0x1);
2630 case SND_SOC_BIAS_OFF
:
2631 if (rt5670
->pdata
.jd_mode
)
2632 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2633 RT5670_PWR_VREF1
| RT5670_PWR_MB
|
2634 RT5670_PWR_BG
| RT5670_PWR_VREF2
|
2635 RT5670_PWR_FV1
| RT5670_PWR_FV2
,
2636 RT5670_PWR_MB
| RT5670_PWR_BG
);
2638 snd_soc_update_bits(codec
, RT5670_PWR_ANLG1
,
2639 RT5670_PWR_VREF1
| RT5670_PWR_MB
|
2640 RT5670_PWR_BG
| RT5670_PWR_VREF2
|
2641 RT5670_PWR_FV1
| RT5670_PWR_FV2
, 0);
2643 snd_soc_update_bits(codec
, RT5670_DIG_MISC
, 0x1, 0x0);
2653 static int rt5670_probe(struct snd_soc_codec
*codec
)
2655 struct snd_soc_dapm_context
*dapm
= snd_soc_codec_get_dapm(codec
);
2656 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2658 switch (snd_soc_read(codec
, RT5670_RESET
) & RT5670_ID_MASK
) {
2659 case RT5670_ID_5670
:
2660 case RT5670_ID_5671
:
2661 snd_soc_dapm_new_controls(dapm
,
2662 rt5670_specific_dapm_widgets
,
2663 ARRAY_SIZE(rt5670_specific_dapm_widgets
));
2664 snd_soc_dapm_add_routes(dapm
,
2665 rt5670_specific_dapm_routes
,
2666 ARRAY_SIZE(rt5670_specific_dapm_routes
));
2668 case RT5670_ID_5672
:
2669 snd_soc_dapm_new_controls(dapm
,
2670 rt5672_specific_dapm_widgets
,
2671 ARRAY_SIZE(rt5672_specific_dapm_widgets
));
2672 snd_soc_dapm_add_routes(dapm
,
2673 rt5672_specific_dapm_routes
,
2674 ARRAY_SIZE(rt5672_specific_dapm_routes
));
2678 "The driver is for RT5670 RT5671 or RT5672 only\n");
2681 rt5670
->codec
= codec
;
2686 static int rt5670_remove(struct snd_soc_codec
*codec
)
2688 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2690 regmap_write(rt5670
->regmap
, RT5670_RESET
, 0);
2691 snd_soc_jack_free_gpios(rt5670
->jack
, 1, &rt5670
->hp_gpio
);
2696 static int rt5670_suspend(struct snd_soc_codec
*codec
)
2698 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2700 regcache_cache_only(rt5670
->regmap
, true);
2701 regcache_mark_dirty(rt5670
->regmap
);
2705 static int rt5670_resume(struct snd_soc_codec
*codec
)
2707 struct rt5670_priv
*rt5670
= snd_soc_codec_get_drvdata(codec
);
2709 regcache_cache_only(rt5670
->regmap
, false);
2710 regcache_sync(rt5670
->regmap
);
2715 #define rt5670_suspend NULL
2716 #define rt5670_resume NULL
2719 #define RT5670_STEREO_RATES SNDRV_PCM_RATE_8000_96000
2720 #define RT5670_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
2721 SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
2723 static const struct snd_soc_dai_ops rt5670_aif_dai_ops
= {
2724 .hw_params
= rt5670_hw_params
,
2725 .set_fmt
= rt5670_set_dai_fmt
,
2726 .set_sysclk
= rt5670_set_dai_sysclk
,
2727 .set_tdm_slot
= rt5670_set_tdm_slot
,
2728 .set_pll
= rt5670_set_dai_pll
,
2731 static struct snd_soc_dai_driver rt5670_dai
[] = {
2733 .name
= "rt5670-aif1",
2736 .stream_name
= "AIF1 Playback",
2739 .rates
= RT5670_STEREO_RATES
,
2740 .formats
= RT5670_FORMATS
,
2743 .stream_name
= "AIF1 Capture",
2746 .rates
= RT5670_STEREO_RATES
,
2747 .formats
= RT5670_FORMATS
,
2749 .ops
= &rt5670_aif_dai_ops
,
2752 .name
= "rt5670-aif2",
2755 .stream_name
= "AIF2 Playback",
2758 .rates
= RT5670_STEREO_RATES
,
2759 .formats
= RT5670_FORMATS
,
2762 .stream_name
= "AIF2 Capture",
2765 .rates
= RT5670_STEREO_RATES
,
2766 .formats
= RT5670_FORMATS
,
2768 .ops
= &rt5670_aif_dai_ops
,
2772 static struct snd_soc_codec_driver soc_codec_dev_rt5670
= {
2773 .probe
= rt5670_probe
,
2774 .remove
= rt5670_remove
,
2775 .suspend
= rt5670_suspend
,
2776 .resume
= rt5670_resume
,
2777 .set_bias_level
= rt5670_set_bias_level
,
2778 .idle_bias_off
= true,
2779 .controls
= rt5670_snd_controls
,
2780 .num_controls
= ARRAY_SIZE(rt5670_snd_controls
),
2781 .dapm_widgets
= rt5670_dapm_widgets
,
2782 .num_dapm_widgets
= ARRAY_SIZE(rt5670_dapm_widgets
),
2783 .dapm_routes
= rt5670_dapm_routes
,
2784 .num_dapm_routes
= ARRAY_SIZE(rt5670_dapm_routes
),
2787 static const struct regmap_config rt5670_regmap
= {
2790 .use_single_rw
= true,
2791 .max_register
= RT5670_VENDOR_ID2
+ 1 + (ARRAY_SIZE(rt5670_ranges
) *
2793 .volatile_reg
= rt5670_volatile_register
,
2794 .readable_reg
= rt5670_readable_register
,
2795 .cache_type
= REGCACHE_RBTREE
,
2796 .reg_defaults
= rt5670_reg
,
2797 .num_reg_defaults
= ARRAY_SIZE(rt5670_reg
),
2798 .ranges
= rt5670_ranges
,
2799 .num_ranges
= ARRAY_SIZE(rt5670_ranges
),
2802 static const struct i2c_device_id rt5670_i2c_id
[] = {
2808 MODULE_DEVICE_TABLE(i2c
, rt5670_i2c_id
);
2811 static const struct acpi_device_id rt5670_acpi_match
[] = {
2815 MODULE_DEVICE_TABLE(acpi
, rt5670_acpi_match
);
2818 static const struct dmi_system_id dmi_platform_intel_braswell
[] = {
2820 .ident
= "Intel Braswell",
2822 DMI_MATCH(DMI_SYS_VENDOR
, "Intel Corporation"),
2823 DMI_MATCH(DMI_BOARD_NAME
, "Braswell CRB"),
2829 static int rt5670_i2c_probe(struct i2c_client
*i2c
,
2830 const struct i2c_device_id
*id
)
2832 struct rt5670_platform_data
*pdata
= dev_get_platdata(&i2c
->dev
);
2833 struct rt5670_priv
*rt5670
;
2837 rt5670
= devm_kzalloc(&i2c
->dev
,
2838 sizeof(struct rt5670_priv
),
2843 i2c_set_clientdata(i2c
, rt5670
);
2846 rt5670
->pdata
= *pdata
;
2848 if (dmi_check_system(dmi_platform_intel_braswell
)) {
2849 rt5670
->pdata
.dmic_en
= true;
2850 rt5670
->pdata
.dmic1_data_pin
= RT5670_DMIC_DATA_IN2P
;
2851 rt5670
->pdata
.dev_gpio
= true;
2852 rt5670
->pdata
.jd_mode
= 1;
2855 rt5670
->regmap
= devm_regmap_init_i2c(i2c
, &rt5670_regmap
);
2856 if (IS_ERR(rt5670
->regmap
)) {
2857 ret
= PTR_ERR(rt5670
->regmap
);
2858 dev_err(&i2c
->dev
, "Failed to allocate register map: %d\n",
2863 regmap_read(rt5670
->regmap
, RT5670_VENDOR_ID2
, &val
);
2864 if (val
!= RT5670_DEVICE_ID
) {
2866 "Device with ID register %#x is not rt5670/72\n", val
);
2870 regmap_write(rt5670
->regmap
, RT5670_RESET
, 0);
2871 regmap_update_bits(rt5670
->regmap
, RT5670_PWR_ANLG1
,
2872 RT5670_PWR_HP_L
| RT5670_PWR_HP_R
|
2873 RT5670_PWR_VREF2
, RT5670_PWR_VREF2
);
2876 regmap_write(rt5670
->regmap
, RT5670_RESET
, 0);
2878 regmap_read(rt5670
->regmap
, RT5670_VENDOR_ID
, &val
);
2880 regmap_write(rt5670
->regmap
, RT5670_GPIO_CTRL3
, 0x0980);
2882 regmap_write(rt5670
->regmap
, RT5670_GPIO_CTRL3
, 0x0d00);
2884 ret
= regmap_register_patch(rt5670
->regmap
, init_list
,
2885 ARRAY_SIZE(init_list
));
2887 dev_warn(&i2c
->dev
, "Failed to apply regmap patch: %d\n", ret
);
2889 if (rt5670
->pdata
.in2_diff
)
2890 regmap_update_bits(rt5670
->regmap
, RT5670_IN2
,
2891 RT5670_IN_DF2
, RT5670_IN_DF2
);
2893 if (rt5670
->pdata
.dev_gpio
) {
2894 /* for push button */
2895 regmap_write(rt5670
->regmap
, RT5670_IL_CMD
, 0x0000);
2896 regmap_write(rt5670
->regmap
, RT5670_IL_CMD2
, 0x0010);
2897 regmap_write(rt5670
->regmap
, RT5670_IL_CMD3
, 0x0014);
2899 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
2900 RT5670_GP1_PIN_MASK
, RT5670_GP1_PIN_IRQ
);
2901 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL2
,
2902 RT5670_GP1_PF_MASK
, RT5670_GP1_PF_OUT
);
2903 regmap_update_bits(rt5670
->regmap
, RT5670_DIG_MISC
, 0x8, 0x8);
2906 if (rt5670
->pdata
.jd_mode
) {
2907 regmap_update_bits(rt5670
->regmap
, RT5670_GLB_CLK
,
2908 RT5670_SCLK_SRC_MASK
, RT5670_SCLK_SRC_RCCLK
);
2910 rt5670
->sysclk_src
= RT5670_SCLK_S_RCCLK
;
2911 regmap_update_bits(rt5670
->regmap
, RT5670_PWR_ANLG1
,
2912 RT5670_PWR_MB
, RT5670_PWR_MB
);
2913 regmap_update_bits(rt5670
->regmap
, RT5670_PWR_ANLG2
,
2914 RT5670_PWR_JD1
, RT5670_PWR_JD1
);
2915 regmap_update_bits(rt5670
->regmap
, RT5670_IRQ_CTRL1
,
2916 RT5670_JD1_1_EN_MASK
, RT5670_JD1_1_EN
);
2917 regmap_update_bits(rt5670
->regmap
, RT5670_JD_CTRL3
,
2918 RT5670_JD_TRI_CBJ_SEL_MASK
|
2919 RT5670_JD_TRI_HPO_SEL_MASK
,
2920 RT5670_JD_CBJ_JD1_1
| RT5670_JD_HPO_JD1_1
);
2921 switch (rt5670
->pdata
.jd_mode
) {
2923 regmap_update_bits(rt5670
->regmap
, RT5670_A_JD_CTRL1
,
2924 RT5670_JD1_MODE_MASK
,
2928 regmap_update_bits(rt5670
->regmap
, RT5670_A_JD_CTRL1
,
2929 RT5670_JD1_MODE_MASK
,
2933 regmap_update_bits(rt5670
->regmap
, RT5670_A_JD_CTRL1
,
2934 RT5670_JD1_MODE_MASK
,
2942 if (rt5670
->pdata
.dmic_en
) {
2943 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
2944 RT5670_GP2_PIN_MASK
,
2945 RT5670_GP2_PIN_DMIC1_SCL
);
2947 switch (rt5670
->pdata
.dmic1_data_pin
) {
2948 case RT5670_DMIC_DATA_IN2P
:
2949 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL1
,
2950 RT5670_DMIC_1_DP_MASK
,
2951 RT5670_DMIC_1_DP_IN2P
);
2954 case RT5670_DMIC_DATA_GPIO6
:
2955 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL1
,
2956 RT5670_DMIC_1_DP_MASK
,
2957 RT5670_DMIC_1_DP_GPIO6
);
2958 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
2959 RT5670_GP6_PIN_MASK
,
2960 RT5670_GP6_PIN_DMIC1_SDA
);
2963 case RT5670_DMIC_DATA_GPIO7
:
2964 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL1
,
2965 RT5670_DMIC_1_DP_MASK
,
2966 RT5670_DMIC_1_DP_GPIO7
);
2967 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
2968 RT5670_GP7_PIN_MASK
,
2969 RT5670_GP7_PIN_DMIC1_SDA
);
2976 switch (rt5670
->pdata
.dmic2_data_pin
) {
2977 case RT5670_DMIC_DATA_IN3N
:
2978 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL1
,
2979 RT5670_DMIC_2_DP_MASK
,
2980 RT5670_DMIC_2_DP_IN3N
);
2983 case RT5670_DMIC_DATA_GPIO8
:
2984 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL1
,
2985 RT5670_DMIC_2_DP_MASK
,
2986 RT5670_DMIC_2_DP_GPIO8
);
2987 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
2988 RT5670_GP8_PIN_MASK
,
2989 RT5670_GP8_PIN_DMIC2_SDA
);
2996 switch (rt5670
->pdata
.dmic3_data_pin
) {
2997 case RT5670_DMIC_DATA_GPIO5
:
2998 regmap_update_bits(rt5670
->regmap
, RT5670_DMIC_CTRL2
,
2999 RT5670_DMIC_3_DP_MASK
,
3000 RT5670_DMIC_3_DP_GPIO5
);
3001 regmap_update_bits(rt5670
->regmap
, RT5670_GPIO_CTRL1
,
3002 RT5670_GP5_PIN_MASK
,
3003 RT5670_GP5_PIN_DMIC3_SDA
);
3006 case RT5670_DMIC_DATA_GPIO9
:
3007 case RT5670_DMIC_DATA_GPIO10
:
3009 "Always use GPIO5 as DMIC3 data pin\n");
3018 pm_runtime_enable(&i2c
->dev
);
3019 pm_request_idle(&i2c
->dev
);
3021 ret
= snd_soc_register_codec(&i2c
->dev
, &soc_codec_dev_rt5670
,
3022 rt5670_dai
, ARRAY_SIZE(rt5670_dai
));
3026 pm_runtime_put(&i2c
->dev
);
3030 pm_runtime_disable(&i2c
->dev
);
3035 static int rt5670_i2c_remove(struct i2c_client
*i2c
)
3037 pm_runtime_disable(&i2c
->dev
);
3038 snd_soc_unregister_codec(&i2c
->dev
);
3043 static struct i2c_driver rt5670_i2c_driver
= {
3046 .acpi_match_table
= ACPI_PTR(rt5670_acpi_match
),
3048 .probe
= rt5670_i2c_probe
,
3049 .remove
= rt5670_i2c_remove
,
3050 .id_table
= rt5670_i2c_id
,
3053 module_i2c_driver(rt5670_i2c_driver
);
3055 MODULE_DESCRIPTION("ASoC RT5670 driver");
3056 MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>");
3057 MODULE_LICENSE("GPL v2");