Lines Matching +full:adc +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5670.c -- RT5670 ALSA SoC audio codec driver
25 #include <sound/soc-dapm.h>
31 #include "rt5670-dsp.h"
50 MODULE_PARM_DESC(quirk, "Board-specific quirk override");
422 * rt5670_headset_detect - Detect headset.
457 rt5670->jack_type = SND_JACK_HEADSET; in rt5670_headset_detect()
464 rt5670->jack_type = SND_JACK_HEADPHONE; in rt5670_headset_detect()
471 rt5670->jack_type = 0; in rt5670_headset_detect()
476 return rt5670->jack_type; in rt5670_headset_detect()
483 rt5670->jack_type_saved = rt5670->jack_type; in rt5670_jack_suspend()
492 if (rt5670->jack_type_saved) in rt5670_jack_resume()
516 struct snd_soc_jack_gpio *gpio = &rt5670->hp_gpio; in rt5670_irq_detection()
517 struct snd_soc_jack *jack = rt5670->jack; in rt5670_irq_detection()
518 int val, btn_type, report = jack->status; in rt5670_irq_detection()
520 if (rt5670->jd_mode == 1) /* 2 port */ in rt5670_irq_detection()
521 val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0070; in rt5670_irq_detection()
523 val = snd_soc_component_read(rt5670->component, RT5670_A_JD_CTRL1) & 0x0020; in rt5670_irq_detection()
529 if (rt5670->jack_type == 0) { in rt5670_irq_detection()
530 report = rt5670_headset_detect(rt5670->component, 1); in rt5670_irq_detection()
532 gpio->debounce_time = 25; in rt5670_irq_detection()
536 if (snd_soc_component_read(rt5670->component, RT5670_INT_IRQ_ST) & 0x4) { in rt5670_irq_detection()
539 btn_type = rt5670_button_detect(rt5670->component); in rt5670_irq_detection()
551 dev_err(rt5670->component->dev, in rt5670_irq_detection()
558 report = rt5670->jack_type; in rt5670_irq_detection()
566 snd_soc_component_update_bits(rt5670->component, RT5670_INT_IRQ_ST, 0x1, 0x0); in rt5670_irq_detection()
567 rt5670_headset_detect(rt5670->component, 0); in rt5670_irq_detection()
568 gpio->debounce_time = 150; /* for jack in */ in rt5670_irq_detection()
583 rt5670->jack = jack; in rt5670_set_jack_detect()
584 rt5670->hp_gpio.gpiod_dev = component->dev; in rt5670_set_jack_detect()
585 rt5670->hp_gpio.name = "headset"; in rt5670_set_jack_detect()
586 rt5670->hp_gpio.report = SND_JACK_HEADSET | in rt5670_set_jack_detect()
588 rt5670->hp_gpio.debounce_time = 150; in rt5670_set_jack_detect()
589 rt5670->hp_gpio.wake = true; in rt5670_set_jack_detect()
590 rt5670->hp_gpio.data = (struct rt5670_priv *)rt5670; in rt5670_set_jack_detect()
591 rt5670->hp_gpio.jack_status_check = rt5670_irq_detection; in rt5670_set_jack_detect()
593 ret = snd_soc_jack_add_gpios(rt5670->jack, 1, in rt5670_set_jack_detect()
594 &rt5670->hp_gpio); in rt5670_set_jack_detect()
596 dev_err(component->dev, "Adding jack GPIO failed\n"); in rt5670_set_jack_detect()
604 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
605 static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
606 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
607 static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
633 * For reliable output-mute LED control we need a "DAC1 Playback Switch" control.
636 * DAPM-mixer DAC1 input are enabled.
642 if (rt5670->dac1_mixl_dac1_switch && rt5670->dac1_playback_switch_l) in rt5670_update_ad_da_mixer_dac1_m_bits()
645 if (rt5670->dac1_mixr_dac1_switch && rt5670->dac1_playback_switch_r) in rt5670_update_ad_da_mixer_dac1_m_bits()
648 regmap_update_bits(rt5670->regmap, RT5670_AD_DA_MIXER, in rt5670_update_ad_da_mixer_dac1_m_bits()
658 ucontrol->value.integer.value[0] = rt5670->dac1_playback_switch_l; in rt5670_dac1_playback_switch_get()
659 ucontrol->value.integer.value[1] = rt5670->dac1_playback_switch_r; in rt5670_dac1_playback_switch_get()
670 if (rt5670->dac1_playback_switch_l == ucontrol->value.integer.value[0] && in rt5670_dac1_playback_switch_put()
671 rt5670->dac1_playback_switch_r == ucontrol->value.integer.value[1]) in rt5670_dac1_playback_switch_put()
674 rt5670->dac1_playback_switch_l = ucontrol->value.integer.value[0]; in rt5670_dac1_playback_switch_put()
675 rt5670->dac1_playback_switch_r = ucontrol->value.integer.value[1]; in rt5670_dac1_playback_switch_put()
710 /* ADC Digital Volume Control */
711 SOC_DOUBLE("ADC Capture Switch", RT5670_STO1_ADC_DIG_VOL,
713 SOC_DOUBLE_TLV("ADC Capture Volume", RT5670_STO1_ADC_DIG_VOL,
717 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL,
721 /* ADC Boost Volume Control */
722 SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1,
726 SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1,
730 SOC_ENUM("ADC IF2 Data Switch", rt5670_if2_adc_enum),
735 * set_dmic_clk - Set parameter of dmic.
747 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
751 rate = rt5670->sysclk / rl6231_get_pre_div(rt5670->regmap, in set_dmic_clk()
755 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
765 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_sys_clk_from_pll()
768 if (rt5670->sysclk_src == RT5670_SCLK_S_PLL1) in is_sys_clk_from_pll()
777 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in is_using_asrc()
780 switch (source->shift) { in is_using_asrc()
829 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in can_use_asrc()
832 if (rt5670->sysclk > rt5670->lrck[RT5670_AIF1] * 384) in can_use_asrc()
840 * rt5670_sel_asrc_clk_src - select ASRC clock source for a set of filters
860 return -EINVAL; in rt5670_sel_asrc_clk_src()
968 struct soc_mixer_control *mc = (struct soc_mixer_control *)kcontrol->private_value; in rt5670_put_dac1_mix_dac1_switch()
973 if (mc->shift == 0) in rt5670_put_dac1_mix_dac1_switch()
974 rt5670->dac1_mixl_dac1_switch = ucontrol->value.integer.value[0]; in rt5670_put_dac1_mix_dac1_switch()
976 rt5670->dac1_mixr_dac1_switch = ucontrol->value.integer.value[0]; in rt5670_put_dac1_mix_dac1_switch()
993 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER,
999 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER,
1139 /* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */
1156 /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */
1170 "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC"
1179 /*RxDP source*/ /* MX-2D [15:13] */
1181 "IF2 DAC", "IF1 DAC", "STO1 ADC Mixer", "STO2 ADC Mixer",
1182 "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1"
1191 /* MX-2D [1] [0] */
1208 /* Stereo2 ADC source */
1209 /* MX-26 [15] */
1218 SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5670_stereo2_adc_lr_enum);
1220 /* Stereo1 ADC source */
1221 /* MX-27 MX-26 [12] */
1223 "DAC MIX", "ADC"
1230 SOC_DAPM_ENUM("Stereo1 ADC 1 Mux", rt5670_stereo1_adc1_enum);
1236 SOC_DAPM_ENUM("Stereo2 ADC 1 Mux", rt5670_stereo2_adc1_enum);
1239 /* MX-27 MX-26 [11] */
1248 SOC_DAPM_ENUM("Stereo1 ADC 2 Mux", rt5670_stereo1_adc2_enum);
1254 SOC_DAPM_ENUM("Stereo2 ADC 2 Mux", rt5670_stereo2_adc2_enum);
1256 /* MX-27 MX-26 [9:8] */
1273 /* Mono ADC source */
1274 /* MX-28 [12] */
1284 /* MX-28 [11] */
1295 /* MX-28 [9:8] */
1305 /* MX-28 [1:0] */
1311 /* MX-28 [4] */
1321 /* MX-28 [3] */
1332 /* MX-2D [3:2] */
1334 "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7"
1343 /* MX-2F [15] */
1354 /* MX-2F [14:12] */
1363 SOC_DAPM_ENUM("IF2 ADC IN source", rt5670_if2_adc_in_enum);
1365 /* MX-31 [15] [13] [11] [9] */
1394 /* MX-FA [12] */
1405 /* MX-FA [11] */
1416 /* MX-FA [10] */
1427 /* MX-9D [9:8] */
1429 "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L"
1436 SOC_DAPM_ENUM("VAD ADC source", rt5670_vad_adc_enum);
1441 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_power_event()
1446 regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, in rt5670_hp_power_event()
1448 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_power_event()
1451 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_hp_power_event()
1456 regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); in rt5670_hp_power_event()
1457 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); in rt5670_hp_power_event()
1458 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_power_event()
1461 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_power_event()
1464 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); in rt5670_hp_power_event()
1477 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_hp_event()
1483 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1485 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1486 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); in rt5670_hp_event()
1487 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1488 regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, in rt5670_hp_event()
1490 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1493 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1498 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1500 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); in rt5670_hp_event()
1501 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); in rt5670_hp_event()
1503 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); in rt5670_hp_event()
1505 regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, in rt5670_hp_event()
1509 regmap_update_bits(rt5670->regmap, in rt5670_hp_event()
1511 regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); in rt5670_hp_event()
1512 regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); in rt5670_hp_event()
1513 regmap_write(rt5670->regmap, RT5670_PR_BASE + in rt5670_hp_event()
1527 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_spk_event()
1530 if (!rt5670->gpio1_is_ext_spk_en) in rt5670_spk_event()
1535 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1540 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_spk_event()
1554 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst1_event()
1577 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5670_bst2_event()
1624 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5670_ASRC_1,
1626 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5670_ASRC_1,
1628 SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1,
1630 SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1,
1682 SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0),
1683 SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM, 0, 0),
1685 SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0),
1687 SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5670_PWR_DIG1,
1689 SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5670_PWR_DIG1,
1691 SND_SOC_DAPM_SUPPLY("ADC clock", RT5670_PR_BASE +
1693 /* ADC Mux */
1694 SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0,
1696 SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
1698 SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
1700 SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
1702 SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
1704 SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0,
1706 SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
1708 SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
1710 SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
1712 SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
1714 SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0,
1716 SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0,
1718 SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0,
1720 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
1722 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
1724 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
1726 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
1728 /* ADC Mixer */
1729 SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5670_PWR_DIG2,
1731 SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5670_PWR_DIG2,
1733 SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", SND_SOC_NOPM, 0, 0,
1735 SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", SND_SOC_NOPM, 0, 0,
1737 SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0,
1740 SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0,
1743 SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2,
1745 SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL,
1748 SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2,
1750 SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL,
1754 /* ADC PGA */
1755 SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
1756 SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
1757 SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0),
1758 SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0),
1759 SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1760 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1761 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1762 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
1777 SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM, 0, 0,
1780 SND_SOC_DAPM_MUX("DSP UL Mux", SND_SOC_NOPM, 0, 0,
1782 SND_SOC_DAPM_MUX("DSP DL Mux", SND_SOC_NOPM, 0, 0,
1785 SND_SOC_DAPM_MUX("RxDP Mux", SND_SOC_NOPM, 0, 0,
1788 /* IF2 Mux */
1789 SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 0, 0,
1801 SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
1802 SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
1803 SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
1809 SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
1810 SND_SOC_DAPM_PGA("IF2 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0),
1811 SND_SOC_DAPM_PGA("IF2 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0),
1814 SND_SOC_DAPM_MUX("IF1 ADC1 IN1 Mux", SND_SOC_NOPM, 0, 0,
1816 SND_SOC_DAPM_MUX("IF1 ADC1 IN2 Mux", SND_SOC_NOPM, 0, 0,
1818 SND_SOC_DAPM_MUX("IF1 ADC2 IN Mux", SND_SOC_NOPM, 0, 0,
1820 SND_SOC_DAPM_MUX("IF1 ADC2 IN1 Mux", SND_SOC_NOPM, 0, 0,
1822 SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0,
1843 /* DAC2 channel Mux */
1844 SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0,
1846 SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0,
1853 SND_SOC_DAPM_MUX("DAC1 L Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1l_mux),
1854 SND_SOC_DAPM_MUX("DAC1 R Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1r_mux),
1936 SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL,
1938 SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL,
1951 SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL,
1953 SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL,
1972 { "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc },
1973 { "ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc },
1974 { "ADC Mono Left Filter", NULL, "ADC MONO L ASRC", is_using_asrc },
1975 { "ADC Mono Right Filter", NULL, "ADC MONO R ASRC", is_using_asrc },
1979 { "Stereo1 DMIC Mux", NULL, "DMIC STO1 ASRC", can_use_asrc },
1980 { "Stereo2 DMIC Mux", NULL, "DMIC STO2 ASRC", can_use_asrc },
1981 { "Mono DMIC L Mux", NULL, "DMIC MONO L ASRC", can_use_asrc },
1982 { "Mono DMIC R Mux", NULL, "DMIC MONO R ASRC", can_use_asrc },
2011 { "ADC 1", NULL, "RECMIXL" },
2012 { "ADC 1", NULL, "ADC 1 power" },
2013 { "ADC 1", NULL, "ADC clock" },
2014 { "ADC 2", NULL, "RECMIXR" },
2015 { "ADC 2", NULL, "ADC 2 power" },
2016 { "ADC 2", NULL, "ADC clock" },
2031 { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" },
2032 { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" },
2033 { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" },
2035 { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" },
2036 { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" },
2037 { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" },
2039 { "Mono DMIC L Mux", "DMIC1", "DMIC L1" },
2040 { "Mono DMIC L Mux", "DMIC2", "DMIC L2" },
2041 { "Mono DMIC L Mux", "DMIC3", "DMIC L3" },
2043 { "Mono DMIC R Mux", "DMIC1", "DMIC R1" },
2044 { "Mono DMIC R Mux", "DMIC2", "DMIC R2" },
2045 { "Mono DMIC R Mux", "DMIC3", "DMIC R3" },
2047 { "ADC 1_2", NULL, "ADC 1" },
2048 { "ADC 1_2", NULL, "ADC 2" },
2050 { "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2051 { "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
2052 { "Stereo1 ADC L1 Mux", "ADC", "ADC 1_2" },
2053 { "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
2055 { "Stereo1 ADC R1 Mux", "ADC", "ADC 1_2" },
2056 { "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
2057 { "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC Mux" },
2058 { "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
2060 { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" },
2061 { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2062 { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" },
2063 { "Mono ADC L1 Mux", "ADC1", "ADC 1" },
2065 { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2066 { "Mono ADC R1 Mux", "ADC2", "ADC 2" },
2067 { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" },
2068 { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" },
2070 { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" },
2071 { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" },
2072 { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" },
2073 { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" },
2075 { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" },
2076 { "Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter" },
2078 { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" },
2079 { "Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter" },
2080 { "ADC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll },
2082 { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" },
2083 { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" },
2084 { "Mono ADC MIXL", NULL, "ADC Mono Left Filter" },
2085 { "ADC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll },
2087 { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" },
2088 { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" },
2089 { "Mono ADC MIXR", NULL, "ADC Mono Right Filter" },
2090 { "ADC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll },
2092 { "Stereo2 ADC L2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2093 { "Stereo2 ADC L2 Mux", "DAC MIX", "DAC MIXL" },
2094 { "Stereo2 ADC L1 Mux", "ADC", "ADC 1_2" },
2095 { "Stereo2 ADC L1 Mux", "DAC MIX", "DAC MIXL" },
2097 { "Stereo2 ADC R1 Mux", "ADC", "ADC 1_2" },
2098 { "Stereo2 ADC R1 Mux", "DAC MIX", "DAC MIXR" },
2099 { "Stereo2 ADC R2 Mux", "DMIC", "Stereo2 DMIC Mux" },
2100 { "Stereo2 ADC R2 Mux", "DAC MIX", "DAC MIXR" },
2102 { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux" },
2103 { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux" },
2104 { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux" },
2105 { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux" },
2107 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" },
2108 { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" },
2110 { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" },
2111 { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" },
2113 { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" },
2114 { "Stereo2 ADC MIXL", NULL, "ADC Stereo2 Filter" },
2116 { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" },
2117 { "Stereo2 ADC MIXR", NULL, "ADC Stereo2 Filter" },
2118 { "ADC Stereo2 Filter", NULL, "PLL1", is_sys_clk_from_pll },
2120 { "VAD ADC Mux", "Sto1 ADC L", "Stereo1 ADC MIXL" },
2121 { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" },
2122 { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" },
2123 { "VAD ADC Mux", "Sto2 ADC L", "Sto2 ADC MIXL" },
2125 { "VAD_ADC", NULL, "VAD ADC Mux" },
2127 { "IF_ADC1", NULL, "Stereo1 ADC MIXL" },
2128 { "IF_ADC1", NULL, "Stereo1 ADC MIXR" },
2129 { "IF_ADC2", NULL, "Mono ADC MIXL" },
2130 { "IF_ADC2", NULL, "Mono ADC MIXR" },
2131 { "IF_ADC3", NULL, "Stereo2 ADC MIXL" },
2132 { "IF_ADC3", NULL, "Stereo2 ADC MIXR" },
2134 { "IF1 ADC1 IN1 Mux", "IF_ADC1", "IF_ADC1" },
2135 { "IF1 ADC1 IN1 Mux", "IF1_ADC3", "IF1_ADC3" },
2137 { "IF1 ADC1 IN2 Mux", "IF1_ADC1_IN1", "IF1 ADC1 IN1 Mux" },
2138 { "IF1 ADC1 IN2 Mux", "IF1_ADC4", "TxDP_ADC" },
2140 { "IF1 ADC2 IN Mux", "IF_ADC2", "IF_ADC2" },
2141 { "IF1 ADC2 IN Mux", "VAD_ADC", "VAD_ADC" },
2143 { "IF1 ADC2 IN1 Mux", "IF1_ADC2_IN", "IF1 ADC2 IN Mux" },
2144 { "IF1 ADC2 IN1 Mux", "IF1_ADC4", "TxDP_ADC" },
2146 { "IF1_ADC1" , NULL, "IF1 ADC1 IN2 Mux" },
2147 { "IF1_ADC2" , NULL, "IF1 ADC2 IN1 Mux" },
2149 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" },
2150 { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" },
2151 { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXL" },
2152 { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXR" },
2153 { "Mono ADC MIX", NULL, "Mono ADC MIXL" },
2154 { "Mono ADC MIX", NULL, "Mono ADC MIXR" },
2156 { "RxDP Mux", "IF2 DAC", "IF2 DAC" },
2157 { "RxDP Mux", "IF1 DAC", "IF1 DAC2" },
2158 { "RxDP Mux", "STO1 ADC Mixer", "Stereo1 ADC MIX" },
2159 { "RxDP Mux", "STO2 ADC Mixer", "Stereo2 ADC MIX" },
2160 { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" },
2161 { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" },
2162 { "RxDP Mux", "DAC1", "DAC MIX" },
2164 { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" },
2165 { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" },
2166 { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" },
2167 { "TDM Data Mux", "Slot 6-7", "IF2 DAC" },
2169 { "DSP UL Mux", "Bypass", "TDM Data Mux" },
2170 { "DSP UL Mux", NULL, "I2S DSP" },
2171 { "DSP DL Mux", "Bypass", "RxDP Mux" },
2172 { "DSP DL Mux", NULL, "I2S DSP" },
2174 { "TxDP_ADC_L", NULL, "DSP UL Mux" },
2175 { "TxDP_ADC_R", NULL, "DSP UL Mux" },
2176 { "TxDC_DAC", NULL, "DSP DL Mux" },
2181 { "IF1 ADC", NULL, "I2S1" },
2182 { "IF1 ADC", NULL, "IF1_ADC1" },
2183 { "IF1 ADC", NULL, "IF1_ADC2" },
2184 { "IF1 ADC", NULL, "IF_ADC3" },
2185 { "IF1 ADC", NULL, "TxDP_ADC" },
2187 { "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" },
2188 { "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" },
2189 { "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" },
2190 { "IF2 ADC Mux", "TxDC_DAC", "TxDC_DAC" },
2191 { "IF2 ADC Mux", "TxDP_ADC", "TxDP_ADC" },
2192 { "IF2 ADC Mux", "VAD_ADC", "VAD_ADC" },
2194 { "IF2 ADC L", NULL, "IF2 ADC Mux" },
2195 { "IF2 ADC R", NULL, "IF2 ADC Mux" },
2197 { "IF2 ADC", NULL, "I2S2" },
2198 { "IF2 ADC", NULL, "IF2 ADC L" },
2199 { "IF2 ADC", NULL, "IF2 ADC R" },
2201 { "AIF1TX", NULL, "IF1 ADC" },
2202 { "AIF2TX", NULL, "IF2 ADC" },
2219 { "DAC1 L Mux", "IF1 DAC", "IF1 DAC1 L" },
2220 { "DAC1 L Mux", "IF2 DAC", "IF2 DAC L" },
2222 { "DAC1 R Mux", "IF1 DAC", "IF1 DAC1 R" },
2223 { "DAC1 R Mux", "IF2 DAC", "IF2 DAC R" },
2225 { "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL" },
2226 { "DAC1 MIXL", "DAC1 Switch", "DAC1 L Mux" },
2228 { "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR" },
2229 { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" },
2242 { "DAC L2 Mux", "IF1 DAC", "IF1 DAC2 L" },
2243 { "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" },
2244 { "DAC L2 Mux", "TxDC DAC", "TxDC_DAC" },
2245 { "DAC L2 Mux", "VAD_ADC", "VAD_ADC" },
2246 { "DAC L2 Volume", NULL, "DAC L2 Mux" },
2249 { "DAC R2 Mux", "IF1 DAC", "IF1 DAC2 R" },
2250 { "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" },
2251 { "DAC R2 Mux", "TxDC DAC", "TxDC_DAC" },
2252 { "DAC R2 Mux", "TxDP ADC", "TxDP_ADC" },
2253 { "DAC R2 Volume", NULL, "DAC R2 Mux" },
2319 { "PDM1 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
2320 { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" },
2321 { "PDM1 L Mux", NULL, "PDM1 Power" },
2322 { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
2323 { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" },
2324 { "PDM1 R Mux", NULL, "PDM1 Power" },
2345 { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" },
2346 { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" },
2347 { "PDM2 L Mux", NULL, "PDM2 Power" },
2348 { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" },
2349 { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" },
2350 { "PDM2 R Mux", NULL, "PDM2 Power" },
2351 { "PDM1L", NULL, "PDM1 L Mux" },
2352 { "PDM1R", NULL, "PDM1 R Mux" },
2353 { "PDM2L", NULL, "PDM2 L Mux" },
2354 { "PDM2R", NULL, "PDM2 R Mux" },
2358 { "SPO Amp", NULL, "PDM1 L Mux" },
2359 { "SPO Amp", NULL, "PDM1 R Mux" },
2369 struct snd_soc_component *component = dai->component; in rt5670_hw_params()
2374 rt5670->lrck[dai->id] = params_rate(params); in rt5670_hw_params()
2375 pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); in rt5670_hw_params()
2377 dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", in rt5670_hw_params()
2378 rt5670->lrck[dai->id], dai->id); in rt5670_hw_params()
2379 return -EINVAL; in rt5670_hw_params()
2383 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5670_hw_params()
2384 return -EINVAL; in rt5670_hw_params()
2387 rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); in rt5670_hw_params()
2389 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5670_hw_params()
2390 rt5670->bclk[dai->id], rt5670->lrck[dai->id]); in rt5670_hw_params()
2391 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5670_hw_params()
2392 bclk_ms, pre_div, dai->id); in rt5670_hw_params()
2407 return -EINVAL; in rt5670_hw_params()
2410 switch (dai->id) { in rt5670_hw_params()
2428 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_hw_params()
2429 return -EINVAL; in rt5670_hw_params()
2437 struct snd_soc_component *component = dai->component; in rt5670_set_dai_fmt()
2443 rt5670->master[dai->id] = 1; in rt5670_set_dai_fmt()
2447 rt5670->master[dai->id] = 0; in rt5670_set_dai_fmt()
2450 return -EINVAL; in rt5670_set_dai_fmt()
2460 return -EINVAL; in rt5670_set_dai_fmt()
2476 return -EINVAL; in rt5670_set_dai_fmt()
2479 switch (dai->id) { in rt5670_set_dai_fmt()
2491 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_fmt()
2492 return -EINVAL; in rt5670_set_dai_fmt()
2514 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5670_set_codec_sysclk()
2515 return -EINVAL; in rt5670_set_codec_sysclk()
2519 rt5670->sysclk = freq; in rt5670_set_codec_sysclk()
2521 rt5670->sysclk_src = clk_id; in rt5670_set_codec_sysclk()
2523 dev_dbg(component->dev, "Sysclk : %dHz clock id : %d\n", freq, clk_id); in rt5670_set_codec_sysclk()
2531 struct snd_soc_component *component = dai->component; in rt5670_set_dai_pll()
2536 if (source == rt5670->pll_src && freq_in == rt5670->pll_in && in rt5670_set_dai_pll()
2537 freq_out == rt5670->pll_out) in rt5670_set_dai_pll()
2541 dev_dbg(component->dev, "PLL disabled\n"); in rt5670_set_dai_pll()
2543 rt5670->pll_in = 0; in rt5670_set_dai_pll()
2544 rt5670->pll_out = 0; in rt5670_set_dai_pll()
2559 switch (dai->id) { in rt5670_set_dai_pll()
2569 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5670_set_dai_pll()
2570 return -EINVAL; in rt5670_set_dai_pll()
2574 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5670_set_dai_pll()
2575 return -EINVAL; in rt5670_set_dai_pll()
2580 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt5670_set_dai_pll()
2584 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5670_set_dai_pll()
2594 rt5670->pll_in = freq_in; in rt5670_set_dai_pll()
2595 rt5670->pll_out = freq_out; in rt5670_set_dai_pll()
2596 rt5670->pll_src = source; in rt5670_set_dai_pll()
2604 struct snd_soc_component *component = dai->component; in rt5670_set_tdm_slot()
2623 return -EINVAL; in rt5670_set_tdm_slot()
2639 return -EINVAL; in rt5670_set_tdm_slot()
2649 struct snd_soc_component *component = dai->component; in rt5670_set_bclk_ratio()
2651 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt5670_set_bclk_ratio()
2652 if (dai->id != RT5670_AIF1) in rt5670_set_bclk_ratio()
2698 if (rt5670->jd_mode) in rt5670_set_bias_level()
2744 dev_err(component->dev, in rt5670_probe()
2746 return -ENODEV; in rt5670_probe()
2748 rt5670->component = component; in rt5670_probe()
2757 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_remove()
2758 snd_soc_jack_free_gpios(rt5670->jack, 1, &rt5670->hp_gpio); in rt5670_remove()
2766 regcache_cache_only(rt5670->regmap, true); in rt5670_suspend()
2767 regcache_mark_dirty(rt5670->regmap); in rt5670_suspend()
2775 regcache_cache_only(rt5670->regmap, false); in rt5670_resume()
2776 regcache_sync(rt5670->regmap); in rt5670_resume()
2799 .name = "rt5670-aif1",
2819 .name = "rt5670-aif2",
2893 rt5670_quirk = (unsigned long)id->driver_data; in rt5670_quirk_cb()
3036 return "cfg-spk:2 cfg-mic:dmics12"; in rt5670_components()
3038 return "cfg-spk:2 cfg-mic:dmic1"; in rt5670_components()
3040 return "cfg-spk:2 cfg-mic:dmic2"; in rt5670_components()
3042 return "cfg-spk:2 cfg-mic:dmic3"; in rt5670_components()
3054 rt5670 = devm_kzalloc(&i2c->dev, in rt5670_i2c_probe()
3058 return -ENOMEM; in rt5670_i2c_probe()
3064 dev_info(&i2c->dev, "Overriding quirk 0x%x => 0x%x\n", in rt5670_i2c_probe()
3070 rt5670->gpio1_is_irq = true; in rt5670_i2c_probe()
3071 dev_info(&i2c->dev, "quirk GPIO1 is IRQ\n"); in rt5670_i2c_probe()
3074 rt5670->gpio1_is_ext_spk_en = true; in rt5670_i2c_probe()
3075 dev_info(&i2c->dev, "quirk GPIO1 is external speaker enable\n"); in rt5670_i2c_probe()
3078 rt5670->in2_diff = true; in rt5670_i2c_probe()
3079 dev_info(&i2c->dev, "quirk IN2_DIFF\n"); in rt5670_i2c_probe()
3082 rt5670->dmic_en = true; in rt5670_i2c_probe()
3083 dev_info(&i2c->dev, "quirk DMIC enabled\n"); in rt5670_i2c_probe()
3086 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_IN2P; in rt5670_i2c_probe()
3087 dev_info(&i2c->dev, "quirk DMIC1 on IN2P pin\n"); in rt5670_i2c_probe()
3090 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO6; in rt5670_i2c_probe()
3091 dev_info(&i2c->dev, "quirk DMIC1 on GPIO6 pin\n"); in rt5670_i2c_probe()
3094 rt5670->dmic1_data_pin = RT5670_DMIC_DATA_GPIO7; in rt5670_i2c_probe()
3095 dev_info(&i2c->dev, "quirk DMIC1 on GPIO7 pin\n"); in rt5670_i2c_probe()
3098 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_IN3N; in rt5670_i2c_probe()
3099 dev_info(&i2c->dev, "quirk DMIC2 on INR pin\n"); in rt5670_i2c_probe()
3102 rt5670->dmic2_data_pin = RT5670_DMIC_DATA_GPIO8; in rt5670_i2c_probe()
3103 dev_info(&i2c->dev, "quirk DMIC2 on GPIO8 pin\n"); in rt5670_i2c_probe()
3106 rt5670->dmic3_data_pin = RT5670_DMIC_DATA_GPIO5; in rt5670_i2c_probe()
3107 dev_info(&i2c->dev, "quirk DMIC3 on GPIO5 pin\n"); in rt5670_i2c_probe()
3111 rt5670->jd_mode = 1; in rt5670_i2c_probe()
3112 dev_info(&i2c->dev, "quirk JD mode 1\n"); in rt5670_i2c_probe()
3115 rt5670->jd_mode = 2; in rt5670_i2c_probe()
3116 dev_info(&i2c->dev, "quirk JD mode 2\n"); in rt5670_i2c_probe()
3119 rt5670->jd_mode = 3; in rt5670_i2c_probe()
3120 dev_info(&i2c->dev, "quirk JD mode 3\n"); in rt5670_i2c_probe()
3127 rt5670->dac1_playback_switch_l = true; in rt5670_i2c_probe()
3128 rt5670->dac1_playback_switch_r = true; in rt5670_i2c_probe()
3129 /* The Power-On-Reset values for the DAC1 mixer have the DAC1 input enabled. */ in rt5670_i2c_probe()
3130 rt5670->dac1_mixl_dac1_switch = true; in rt5670_i2c_probe()
3131 rt5670->dac1_mixr_dac1_switch = true; in rt5670_i2c_probe()
3133 rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); in rt5670_i2c_probe()
3134 if (IS_ERR(rt5670->regmap)) { in rt5670_i2c_probe()
3135 ret = PTR_ERR(rt5670->regmap); in rt5670_i2c_probe()
3136 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5670_i2c_probe()
3141 regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); in rt5670_i2c_probe()
3143 dev_err(&i2c->dev, in rt5670_i2c_probe()
3145 return -ENODEV; in rt5670_i2c_probe()
3148 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3149 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3154 regmap_write(rt5670->regmap, RT5670_RESET, 0); in rt5670_i2c_probe()
3156 regmap_read(rt5670->regmap, RT5670_VENDOR_ID, &val); in rt5670_i2c_probe()
3158 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0980); in rt5670_i2c_probe()
3160 regmap_write(rt5670->regmap, RT5670_GPIO_CTRL3, 0x0d00); in rt5670_i2c_probe()
3162 ret = regmap_register_patch(rt5670->regmap, init_list, in rt5670_i2c_probe()
3165 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5670_i2c_probe()
3167 regmap_update_bits(rt5670->regmap, RT5670_DIG_MISC, in rt5670_i2c_probe()
3170 if (rt5670->in2_diff) in rt5670_i2c_probe()
3171 regmap_update_bits(rt5670->regmap, RT5670_IN2, in rt5670_i2c_probe()
3174 if (rt5670->gpio1_is_irq) { in rt5670_i2c_probe()
3176 regmap_write(rt5670->regmap, RT5670_IL_CMD, 0x0000); in rt5670_i2c_probe()
3177 regmap_write(rt5670->regmap, RT5670_IL_CMD2, 0x0010); in rt5670_i2c_probe()
3178 regmap_write(rt5670->regmap, RT5670_IL_CMD3, 0x0014); in rt5670_i2c_probe()
3180 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3182 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3186 if (rt5670->gpio1_is_ext_spk_en) { in rt5670_i2c_probe()
3187 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3189 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, in rt5670_i2c_probe()
3193 if (rt5670->jd_mode) { in rt5670_i2c_probe()
3194 regmap_update_bits(rt5670->regmap, RT5670_GLB_CLK, in rt5670_i2c_probe()
3196 rt5670->sysclk = 0; in rt5670_i2c_probe()
3197 rt5670->sysclk_src = RT5670_SCLK_S_RCCLK; in rt5670_i2c_probe()
3198 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, in rt5670_i2c_probe()
3200 regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, in rt5670_i2c_probe()
3202 regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, in rt5670_i2c_probe()
3204 regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, in rt5670_i2c_probe()
3208 switch (rt5670->jd_mode) { in rt5670_i2c_probe()
3210 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3215 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3220 regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, in rt5670_i2c_probe()
3229 if (rt5670->dmic_en) { in rt5670_i2c_probe()
3230 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3234 switch (rt5670->dmic1_data_pin) { in rt5670_i2c_probe()
3236 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3242 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3245 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3251 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3254 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3263 switch (rt5670->dmic2_data_pin) { in rt5670_i2c_probe()
3265 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3271 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, in rt5670_i2c_probe()
3274 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3283 switch (rt5670->dmic3_data_pin) { in rt5670_i2c_probe()
3285 regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, in rt5670_i2c_probe()
3288 regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, in rt5670_i2c_probe()
3295 dev_err(&i2c->dev, in rt5670_i2c_probe()
3305 pm_runtime_enable(&i2c->dev); in rt5670_i2c_probe()
3306 pm_request_idle(&i2c->dev); in rt5670_i2c_probe()
3308 ret = devm_snd_soc_register_component(&i2c->dev, in rt5670_i2c_probe()
3316 pm_runtime_disable(&i2c->dev); in rt5670_i2c_probe()
3323 pm_runtime_disable(&i2c->dev); in rt5670_i2c_remove()