Lines Matching +full:adc +full:- +full:channel +full:- +full:clk +full:- +full:src
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5665.c -- RT5665/RT5658 ALSA SoC audio codec driver
27 #include <sound/soc-dapm.h>
888 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -2250, 150, 0);
889 static const DECLARE_TLV_DB_SCALE(mono_vol_tlv, -1400, 150, 0);
890 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
891 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0);
892 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
893 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0);
895 static const DECLARE_TLV_DB_SCALE(in_bst_tlv, -1200, 75, 0);
956 SOC_DAPM_ENUM("IF1_1 01 ADC Swap Mux", rt5665_if1_1_01_adc_enum);
959 SOC_DAPM_ENUM("IF1_1 23 ADC Swap Mux", rt5665_if1_1_23_adc_enum);
962 SOC_DAPM_ENUM("IF1_1 45 ADC Swap Mux", rt5665_if1_1_45_adc_enum);
965 SOC_DAPM_ENUM("IF1_1 67 ADC Swap Mux", rt5665_if1_1_67_adc_enum);
968 SOC_DAPM_ENUM("IF1_2 01 ADC Swap Mux", rt5665_if1_2_01_adc_enum);
983 SOC_DAPM_ENUM("IF2_1 ADC Swap Source", rt5665_if2_1_adc_enum);
989 SOC_DAPM_ENUM("IF2_2 ADC Swap Source", rt5665_if2_2_adc_enum);
995 SOC_DAPM_ENUM("IF3 ADC Swap Source", rt5665_if3_adc_enum);
1030 * rt5665_sel_asrc_clk_src - select ASRC clock source for a set of filters
1062 return -EINVAL; in rt5665_sel_asrc_clk_src()
1159 * rt5665_headset_detect - Detect headset.
1177 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, 0x100, in rt5665_headset_detect()
1180 regmap_read(rt5665->regmap, RT5665_GPIO_STA, &val); in rt5665_headset_detect()
1182 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_headset_detect()
1185 regmap_read(rt5665->regmap, RT5665_GPIO_STA, &val); in rt5665_headset_detect()
1188 regmap_read(rt5665->regmap, RT5665_GPIO_STA, in rt5665_headset_detect()
1193 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_headset_detect()
1195 regmap_write(rt5665->regmap, RT5665_EJD_CTRL_3, 0x3424); in rt5665_headset_detect()
1196 regmap_write(rt5665->regmap, RT5665_IL_CMD_1, 0x0048); in rt5665_headset_detect()
1197 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, 0xa291); in rt5665_headset_detect()
1201 rt5665->sar_adc_value = snd_soc_component_read(rt5665->component, in rt5665_headset_detect()
1204 sar_hs_type = rt5665->pdata.sar_hs_type ? in rt5665_headset_detect()
1205 rt5665->pdata.sar_hs_type : 729; in rt5665_headset_detect()
1207 if (rt5665->sar_adc_value > sar_hs_type) { in rt5665_headset_detect()
1208 rt5665->jack_type = SND_JACK_HEADSET; in rt5665_headset_detect()
1211 rt5665->jack_type = SND_JACK_HEADPHONE; in rt5665_headset_detect()
1212 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, in rt5665_headset_detect()
1214 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, in rt5665_headset_detect()
1220 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, 0x2291); in rt5665_headset_detect()
1221 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, 0x100, 0); in rt5665_headset_detect()
1224 if (rt5665->jack_type == SND_JACK_HEADSET) in rt5665_headset_detect()
1226 rt5665->jack_type = 0; in rt5665_headset_detect()
1229 dev_dbg(component->dev, "jack_type = %d\n", rt5665->jack_type); in rt5665_headset_detect()
1230 return rt5665->jack_type; in rt5665_headset_detect()
1238 &rt5665->jack_detect_work, msecs_to_jiffies(250)); in rt5665_irq()
1248 if (snd_soc_component_read(rt5665->component, RT5665_AJD1_CTRL) & 0x0010) { in rt5665_jd_check_handler()
1250 rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); in rt5665_jd_check_handler()
1252 snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, in rt5665_jd_check_handler()
1257 schedule_delayed_work(&rt5665->jd_check_work, 500); in rt5665_jd_check_handler()
1266 switch (rt5665->pdata.jd_src) { in rt5665_set_jack_detect()
1268 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_set_jack_detect()
1270 regmap_update_bits(rt5665->regmap, RT5665_RC_CLK_CTRL, in rt5665_set_jack_detect()
1272 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_2, in rt5665_set_jack_detect()
1274 regmap_update_bits(rt5665->regmap, RT5665_IRQ_CTRL_1, 0x8, 0x8); in rt5665_set_jack_detect()
1281 dev_warn(component->dev, "Wrong JD source\n"); in rt5665_set_jack_detect()
1285 rt5665->hs_jack = hs_jack; in rt5665_set_jack_detect()
1296 while (!rt5665->component) { in rt5665_jack_detect_handler()
1301 while (!rt5665->component->card->instantiated) { in rt5665_jack_detect_handler()
1306 while (!rt5665->calibration_done) { in rt5665_jack_detect_handler()
1311 mutex_lock(&rt5665->calibrate_mutex); in rt5665_jack_detect_handler()
1313 val = snd_soc_component_read(rt5665->component, RT5665_AJD1_CTRL) & 0x0010; in rt5665_jack_detect_handler()
1316 if (rt5665->jack_type == 0) { in rt5665_jack_detect_handler()
1318 rt5665->jack_type = in rt5665_jack_detect_handler()
1319 rt5665_headset_detect(rt5665->component, 1); in rt5665_jack_detect_handler()
1322 rt5665->jack_type = SND_JACK_HEADSET; in rt5665_jack_detect_handler()
1323 btn_type = rt5665_button_detect(rt5665->component); in rt5665_jack_detect_handler()
1335 rt5665->jack_type |= SND_JACK_BTN_0; in rt5665_jack_detect_handler()
1340 rt5665->jack_type |= SND_JACK_BTN_1; in rt5665_jack_detect_handler()
1345 rt5665->jack_type |= SND_JACK_BTN_2; in rt5665_jack_detect_handler()
1350 rt5665->jack_type |= SND_JACK_BTN_3; in rt5665_jack_detect_handler()
1356 dev_err(rt5665->component->dev, in rt5665_jack_detect_handler()
1364 rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); in rt5665_jack_detect_handler()
1367 snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, in rt5665_jack_detect_handler()
1372 if (rt5665->jack_type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | in rt5665_jack_detect_handler()
1374 schedule_delayed_work(&rt5665->jd_check_work, 0); in rt5665_jack_detect_handler()
1376 cancel_delayed_work_sync(&rt5665->jd_check_work); in rt5665_jack_detect_handler()
1378 mutex_unlock(&rt5665->calibrate_mutex); in rt5665_jack_detect_handler()
1433 /* ADC Digital Volume Control */
1434 SOC_DOUBLE("STO1 ADC Capture Switch", RT5665_STO1_ADC_DIG_VOL,
1436 SOC_DOUBLE_TLV("STO1 ADC Capture Volume", RT5665_STO1_ADC_DIG_VOL,
1438 SOC_DOUBLE("Mono ADC Capture Switch", RT5665_MONO_ADC_DIG_VOL,
1440 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5665_MONO_ADC_DIG_VOL,
1442 SOC_DOUBLE("STO2 ADC Capture Switch", RT5665_STO2_ADC_DIG_VOL,
1444 SOC_DOUBLE_TLV("STO2 ADC Capture Volume", RT5665_STO2_ADC_DIG_VOL,
1447 /* ADC Boost Volume Control */
1448 SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5665_STO1_ADC_BOOST,
1452 SOC_DOUBLE_TLV("Mono ADC Boost Gain Volume", RT5665_MONO_ADC_BOOST,
1456 SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5665_STO2_ADC_BOOST,
1460 /* I2S3 CLK Source */
1461 SOC_ENUM("I2S1 Master Clk Sel", rt5665_enum[0]),
1462 SOC_ENUM("I2S2 Master Clk Sel", rt5665_enum[1]),
1463 SOC_ENUM("I2S3 Master Clk Sel", rt5665_enum[2]),
1467 * set_dmic_clk - Set parameter of dmic.
1479 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
1483 pd = rl6231_get_pre_div(rt5665->regmap, in set_dmic_clk()
1485 idx = rl6231_calc_dmic_clk(rt5665->sysclk / pd); in set_dmic_clk()
1488 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
1499 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_charge_pump_event()
1523 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in is_sys_clk_from_pll()
1537 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in is_using_asrc()
1539 switch (w->shift) { in is_using_asrc()
1635 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5665_AD_DA_MIXER,
1642 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5665_AD_DA_MIXER,
1838 /*MX-17 [6:4], MX-17 [2:0]*/
1840 "IF1 DAC2", "IF2_1 DAC", "IF2_2 DAC", "IF3 DAC", "Mono ADC MIX"
1858 /*MX-1B [6:4], MX-1B [2:0]*/
1860 "IF1 DAC2", "IF2_1 DAC", "IF2_2 DAC", "IF3 DAC", "STO2 ADC MIX"
1878 /* MX-26 [13] [5] */
1880 "DD Mux", "ADC"
1897 /* STO1 ADC Source */
1898 /* MX-26 [11:10] [3:2] */
1918 /* MX-26 [12] [4] */
1938 /* MX-26 [8] */
1950 /* MX-26 [9] */
1962 /* MX-26 [1:0] */
1974 /* MONO ADC L2 Source */
1975 /* MX-27 [12] */
1985 SOC_DAPM_ENUM("Mono ADC L2 Source", rt5665_mono_adc_l2_enum);
1988 /* MONO ADC L1 Source */
1989 /* MX-27 [13] */
1991 "DD Mux", "ADC"
1999 SOC_DAPM_ENUM("Mono ADC L1 Source", rt5665_mono_adc_l1_enum);
2001 /* MX-27 [9][1]*/
2020 /* MONO ADC L Source, MONO ADC R Source*/
2021 /* MX-27 [11:10], MX-27 [3:2] */
2031 SOC_DAPM_ENUM("Mono ADC L Source", rt5665_mono_adc_l_enum);
2038 SOC_DAPM_ENUM("Mono ADC R Source", rt5665_mono_adcr_enum);
2041 /* MX-27 [8] */
2053 /* MONO ADC R2 Source */
2054 /* MX-27 [4] */
2064 SOC_DAPM_ENUM("Mono ADC R2 Source", rt5665_mono_adc_r2_enum);
2066 /* MONO ADC R1 Source */
2067 /* MX-27 [5] */
2069 "DD Mux", "ADC"
2077 SOC_DAPM_ENUM("Mono ADC R1 Source", rt5665_mono_adc_r1_enum);
2080 /* MX-27 [0] */
2094 /* MX-28 [13] [5] */
2096 "DD Mux", "ADC"
2113 /* STO2 ADC Source */
2114 /* MX-28 [11:10] [3:2] */
2134 /* MX-28 [12] [4] */
2154 /* MX-28 [8] */
2166 /* MX-28 [9] */
2178 /* MX-28 [1] */
2191 /* MX-29 [11:10], MX-29 [9:8]*/
2211 /* MX-2D [13:12], MX-2D [9:8]*/
2231 /* MX-2D [5:4], MX-2D [1:0]*/
2251 /* MX-2E [5:4], MX-2E [0]*/
2270 /* Interface2 ADC Data Input*/
2271 /* MX-2F [14:12] */
2273 "STO1 ADC", "STO2 ADC", "MONO ADC", "IF1 DAC1",
2282 SOC_DAPM_ENUM("IF2_1 ADC IN Source", rt5665_if2_1_adc_in_enum);
2284 /* MX-2F [6:4] */
2286 "STO1 ADC", "STO2 ADC", "MONO ADC", "IF1 DAC1",
2295 SOC_DAPM_ENUM("IF2_1 ADC IN Source", rt5665_if2_2_adc_in_enum);
2297 /* Interface3 ADC Data Input*/
2298 /* MX-30 [6:4] */
2300 "STO1 ADC", "STO2 ADC", "MONO ADC", "IF1 DAC1",
2309 SOC_DAPM_ENUM("IF3 ADC IN Source", rt5665_if3_adc_in_enum);
2312 /* MX-31 [11:10] [9:8] */
2333 /* MX-7a[10] */
2335 "STO1 ADC", "IF2_1 DAC",
2345 /* MX-7a[9] */
2347 "STO2 ADC", "IF2_2 DAC",
2357 /* MX-7a[8] */
2359 "MONO ADC", "IF3 DAC",
2369 /* MX-7b[10] */
2371 "STO1 ADC", "IF1 DAC",
2381 /* MX-7b[9] */
2383 "STO2 ADC", "IF2_1 DAC",
2393 /* MX-7b[8] */
2395 "MONO ADC", "IF2_2 DAC",
2405 /* MX-7b[7] */
2417 /* MX-7a[4:0] MX-7b[4:0] */
2430 SOC_DAPM_ENUM("TDM1 ADC Mux", rt5665_tdm1_adc_data_enum);
2474 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_mono_event()
2506 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_hp_event()
2532 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_lout_event()
2572 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_set_verf()
2576 switch (w->shift) { in rt5665_set_verf()
2599 switch (w->shift) { in rt5665_set_verf()
2630 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5665_i2s_pin_event()
2633 switch (w->shift) { in rt5665_i2s_pin_event()
2710 SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5665_ASRC_1,
2712 SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5665_ASRC_1,
2714 SND_SOC_DAPM_SUPPLY_S("ADC Mono L ASRC", 1, RT5665_ASRC_1,
2716 SND_SOC_DAPM_SUPPLY_S("ADC Mono R ASRC", 1, RT5665_ASRC_1,
2753 SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0,
2834 /* ADC Mux */
2839 SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2841 SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2843 SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2845 SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2847 SND_SOC_DAPM_MUX("Stereo1 ADC L Mux", SND_SOC_NOPM, 0, 0,
2849 SND_SOC_DAPM_MUX("Stereo1 ADC R Mux", SND_SOC_NOPM, 0, 0,
2855 SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2857 SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2859 SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2861 SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2867 SND_SOC_DAPM_MUX("Mono ADC L Mux", SND_SOC_NOPM, 0, 0,
2869 SND_SOC_DAPM_MUX("Mono ADC R Mux", SND_SOC_NOPM, 0, 0,
2879 SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
2881 SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
2883 SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
2885 SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
2887 SND_SOC_DAPM_MUX("Stereo2 ADC L Mux", SND_SOC_NOPM, 0, 0,
2889 SND_SOC_DAPM_MUX("Stereo2 ADC R Mux", SND_SOC_NOPM, 0, 0,
2895 /* ADC Mixer */
2896 SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5665_PWR_DIG_2,
2898 SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5665_PWR_DIG_2,
2900 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", RT5665_STO1_ADC_DIG_VOL,
2903 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", RT5665_STO1_ADC_DIG_VOL,
2906 SND_SOC_DAPM_MIXER("Stereo2 ADC MIXL", RT5665_STO2_ADC_DIG_VOL,
2909 SND_SOC_DAPM_MIXER("Stereo2 ADC MIXR", RT5665_STO2_ADC_DIG_VOL,
2912 SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5665_PWR_DIG_2,
2914 SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5665_MONO_ADC_DIG_VOL,
2917 SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5665_PWR_DIG_2,
2919 SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5665_MONO_ADC_DIG_VOL,
2923 /* ADC PGA */
2924 SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2925 SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2926 SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0),
2958 SND_SOC_DAPM_PGA("IF2_1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2959 SND_SOC_DAPM_PGA("IF2_2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2964 SND_SOC_DAPM_PGA("IF3 ADC", SND_SOC_NOPM, 0, 0, NULL, 0),
2998 SND_SOC_DAPM_MUX("IF2_1 ADC Mux", SND_SOC_NOPM, 0, 0,
3000 SND_SOC_DAPM_MUX("IF2_2 ADC Mux", SND_SOC_NOPM, 0, 0,
3002 SND_SOC_DAPM_MUX("IF3 ADC Mux", SND_SOC_NOPM, 0, 0,
3004 SND_SOC_DAPM_MUX("IF1_1 0 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3006 SND_SOC_DAPM_MUX("IF1_1 1 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3008 SND_SOC_DAPM_MUX("IF1_1 2 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3010 SND_SOC_DAPM_MUX("IF1_1 3 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3012 SND_SOC_DAPM_MUX("IF1_1 4 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3014 SND_SOC_DAPM_MUX("IF1_1 5 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3016 SND_SOC_DAPM_MUX("IF1_1 6 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3018 SND_SOC_DAPM_MUX("IF1_1 7 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3020 SND_SOC_DAPM_MUX("IF1_2 0 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3022 SND_SOC_DAPM_MUX("IF1_2 1 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3024 SND_SOC_DAPM_MUX("IF1_2 2 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3026 SND_SOC_DAPM_MUX("IF1_2 3 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3028 SND_SOC_DAPM_MUX("IF1_2 4 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3030 SND_SOC_DAPM_MUX("IF1_2 5 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3032 SND_SOC_DAPM_MUX("IF1_2 6 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3034 SND_SOC_DAPM_MUX("IF1_2 7 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3038 SND_SOC_DAPM_MUX("IF2_1 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3042 SND_SOC_DAPM_MUX("IF2_2 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3046 SND_SOC_DAPM_MUX("IF3 ADC Swap Mux", SND_SOC_NOPM, 0, 0,
3104 /* DAC channel Mux */
3222 /* CLK DET */
3246 {"ADC Stereo1 Filter", NULL, "PLL", is_sys_clk_from_pll},
3247 {"ADC Stereo2 Filter", NULL, "PLL", is_sys_clk_from_pll},
3248 {"ADC Mono Left Filter", NULL, "PLL", is_sys_clk_from_pll},
3249 {"ADC Mono Right Filter", NULL, "PLL", is_sys_clk_from_pll},
3256 {"ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc},
3257 {"ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc},
3258 {"ADC Mono Left Filter", NULL, "ADC Mono L ASRC", is_using_asrc},
3259 {"ADC Mono Right Filter", NULL, "ADC Mono R ASRC", is_using_asrc},
3378 {"DMIC L1", NULL, "DMIC CLK"},
3380 {"DMIC R1", NULL, "DMIC CLK"},
3382 {"DMIC L2", NULL, "DMIC CLK"},
3384 {"DMIC R2", NULL, "DMIC CLK"},
3405 {"Stereo1 ADC L Mux", "ADC1 L", "ADC1 L"},
3406 {"Stereo1 ADC L Mux", "ADC1 R", "ADC1 R"},
3407 {"Stereo1 ADC L Mux", "ADC2 L", "ADC2 L"},
3408 {"Stereo1 ADC L Mux", "ADC2 R", "ADC2 R"},
3409 {"Stereo1 ADC R Mux", "ADC1 L", "ADC1 L"},
3410 {"Stereo1 ADC R Mux", "ADC1 R", "ADC1 R"},
3411 {"Stereo1 ADC R Mux", "ADC2 L", "ADC2 L"},
3412 {"Stereo1 ADC R Mux", "ADC2 R", "ADC2 R"},
3420 {"Stereo1 ADC L1 Mux", "ADC", "Stereo1 ADC L Mux"},
3421 {"Stereo1 ADC L1 Mux", "DD Mux", "Stereo1 DD L Mux"},
3422 {"Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC L Mux"},
3423 {"Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL"},
3425 {"Stereo1 ADC R1 Mux", "ADC", "Stereo1 ADC R Mux"},
3426 {"Stereo1 ADC R1 Mux", "DD Mux", "Stereo1 DD R Mux"},
3427 {"Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC R Mux"},
3428 {"Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR"},
3430 {"Mono ADC L Mux", "ADC1 L", "ADC1 L"},
3431 {"Mono ADC L Mux", "ADC1 R", "ADC1 R"},
3432 {"Mono ADC L Mux", "ADC2 L", "ADC2 L"},
3433 {"Mono ADC L Mux", "ADC2 R", "ADC2 R"},
3435 {"Mono ADC R Mux", "ADC1 L", "ADC1 L"},
3436 {"Mono ADC R Mux", "ADC1 R", "ADC1 R"},
3437 {"Mono ADC R Mux", "ADC2 L", "ADC2 L"},
3438 {"Mono ADC R Mux", "ADC2 R", "ADC2 R"},
3446 {"Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux"},
3447 {"Mono ADC L2 Mux", "DAC MIXL", "DAC MIXL"},
3448 {"Mono ADC L1 Mux", "DD Mux", "Mono DD L Mux"},
3449 {"Mono ADC L1 Mux", "ADC", "Mono ADC L Mux"},
3451 {"Mono ADC R1 Mux", "DD Mux", "Mono DD R Mux"},
3452 {"Mono ADC R1 Mux", "ADC", "Mono ADC R Mux"},
3453 {"Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux"},
3454 {"Mono ADC R2 Mux", "DAC MIXR", "DAC MIXR"},
3456 {"Stereo2 ADC L Mux", "ADC1 L", "ADC1 L"},
3457 {"Stereo2 ADC L Mux", "ADC2 L", "ADC2 L"},
3458 {"Stereo2 ADC L Mux", "ADC1 R", "ADC1 R"},
3459 {"Stereo2 ADC R Mux", "ADC1 L", "ADC1 L"},
3460 {"Stereo2 ADC R Mux", "ADC2 L", "ADC2 L"},
3461 {"Stereo2 ADC R Mux", "ADC1 R", "ADC1 R"},
3469 {"Stereo2 ADC L1 Mux", "ADC", "Stereo2 ADC L Mux"},
3470 {"Stereo2 ADC L1 Mux", "DD Mux", "Stereo2 DD L Mux"},
3471 {"Stereo2 ADC L2 Mux", "DMIC", "Stereo2 DMIC L Mux"},
3472 {"Stereo2 ADC L2 Mux", "DAC MIX", "DAC MIXL"},
3474 {"Stereo2 ADC R1 Mux", "ADC", "Stereo2 ADC R Mux"},
3475 {"Stereo2 ADC R1 Mux", "DD Mux", "Stereo2 DD R Mux"},
3476 {"Stereo2 ADC R2 Mux", "DMIC", "Stereo2 DMIC R Mux"},
3477 {"Stereo2 ADC R2 Mux", "DAC MIX", "DAC MIXR"},
3479 {"Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux"},
3480 {"Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux"},
3481 {"Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter"},
3483 {"Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux"},
3484 {"Stereo1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux"},
3485 {"Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter"},
3487 {"Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux"},
3488 {"Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux"},
3489 {"Mono ADC MIXL", NULL, "ADC Mono Left Filter"},
3491 {"Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux"},
3492 {"Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux"},
3493 {"Mono ADC MIXR", NULL, "ADC Mono Right Filter"},
3495 {"Stereo2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux"},
3496 {"Stereo2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux"},
3497 {"Stereo2 ADC MIXL", NULL, "ADC Stereo2 Filter"},
3499 {"Stereo2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux"},
3500 {"Stereo2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux"},
3501 {"Stereo2 ADC MIXR", NULL, "ADC Stereo2 Filter"},
3503 {"Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL"},
3504 {"Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR"},
3505 {"Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXL"},
3506 {"Stereo2 ADC MIX", NULL, "Stereo2 ADC MIXR"},
3507 {"Mono ADC MIX", NULL, "Mono ADC MIXL"},
3508 {"Mono ADC MIX", NULL, "Mono ADC MIXR"},
3510 {"IF1_1_ADC1 Mux", "STO1 ADC", "Stereo1 ADC MIX"},
3512 {"IF1_1_ADC2 Mux", "STO2 ADC", "Stereo2 ADC MIX"},
3514 {"IF1_1_ADC3 Mux", "MONO ADC", "Mono ADC MIX"},
3518 {"IF1_2_ADC1 Mux", "STO1 ADC", "Stereo1 ADC MIX"},
3520 {"IF1_2_ADC2 Mux", "STO2 ADC", "Stereo2 ADC MIX"},
3522 {"IF1_2_ADC3 Mux", "MONO ADC", "Mono ADC MIX"},
3736 {"IF1_1 0 ADC Swap Mux", "L/R", "TDM1 slot 01 Data Mux"},
3737 {"IF1_1 0 ADC Swap Mux", "L/L", "TDM1 slot 01 Data Mux"},
3738 {"IF1_1 1 ADC Swap Mux", "R/L", "TDM1 slot 01 Data Mux"},
3739 {"IF1_1 1 ADC Swap Mux", "R/R", "TDM1 slot 01 Data Mux"},
3740 {"IF1_1 2 ADC Swap Mux", "L/R", "TDM1 slot 23 Data Mux"},
3741 {"IF1_1 2 ADC Swap Mux", "R/L", "TDM1 slot 23 Data Mux"},
3742 {"IF1_1 3 ADC Swap Mux", "L/L", "TDM1 slot 23 Data Mux"},
3743 {"IF1_1 3 ADC Swap Mux", "R/R", "TDM1 slot 23 Data Mux"},
3744 {"IF1_1 4 ADC Swap Mux", "L/R", "TDM1 slot 45 Data Mux"},
3745 {"IF1_1 4 ADC Swap Mux", "R/L", "TDM1 slot 45 Data Mux"},
3746 {"IF1_1 5 ADC Swap Mux", "L/L", "TDM1 slot 45 Data Mux"},
3747 {"IF1_1 5 ADC Swap Mux", "R/R", "TDM1 slot 45 Data Mux"},
3748 {"IF1_1 6 ADC Swap Mux", "L/R", "TDM1 slot 67 Data Mux"},
3749 {"IF1_1 6 ADC Swap Mux", "R/L", "TDM1 slot 67 Data Mux"},
3750 {"IF1_1 7 ADC Swap Mux", "L/L", "TDM1 slot 67 Data Mux"},
3751 {"IF1_1 7 ADC Swap Mux", "R/R", "TDM1 slot 67 Data Mux"},
3752 {"IF1_2 0 ADC Swap Mux", "L/R", "TDM2 slot 01 Data Mux"},
3753 {"IF1_2 0 ADC Swap Mux", "R/L", "TDM2 slot 01 Data Mux"},
3754 {"IF1_2 1 ADC Swap Mux", "L/L", "TDM2 slot 01 Data Mux"},
3755 {"IF1_2 1 ADC Swap Mux", "R/R", "TDM2 slot 01 Data Mux"},
3756 {"IF1_2 2 ADC Swap Mux", "L/R", "TDM2 slot 23 Data Mux"},
3757 {"IF1_2 2 ADC Swap Mux", "R/L", "TDM2 slot 23 Data Mux"},
3758 {"IF1_2 3 ADC Swap Mux", "L/L", "TDM2 slot 23 Data Mux"},
3759 {"IF1_2 3 ADC Swap Mux", "R/R", "TDM2 slot 23 Data Mux"},
3760 {"IF1_2 4 ADC Swap Mux", "L/R", "TDM2 slot 45 Data Mux"},
3761 {"IF1_2 4 ADC Swap Mux", "R/L", "TDM2 slot 45 Data Mux"},
3762 {"IF1_2 5 ADC Swap Mux", "L/L", "TDM2 slot 45 Data Mux"},
3763 {"IF1_2 5 ADC Swap Mux", "R/R", "TDM2 slot 45 Data Mux"},
3764 {"IF1_2 6 ADC Swap Mux", "L/R", "TDM2 slot 67 Data Mux"},
3765 {"IF1_2 6 ADC Swap Mux", "R/L", "TDM2 slot 67 Data Mux"},
3766 {"IF1_2 7 ADC Swap Mux", "L/L", "TDM2 slot 67 Data Mux"},
3767 {"IF1_2 7 ADC Swap Mux", "R/R", "TDM2 slot 67 Data Mux"},
3769 {"IF2_1 ADC Mux", "STO1 ADC", "Stereo1 ADC MIX"},
3770 {"IF2_1 ADC Mux", "STO2 ADC", "Stereo2 ADC MIX"},
3771 {"IF2_1 ADC Mux", "MONO ADC", "Mono ADC MIX"},
3772 {"IF2_1 ADC Mux", "IF1 DAC1", "IF1 DAC1"},
3773 {"IF2_1 ADC Mux", "IF1 DAC2", "IF1 DAC2"},
3774 {"IF2_1 ADC Mux", "IF2_2 DAC", "IF2_2 DAC"},
3775 {"IF2_1 ADC Mux", "IF3 DAC", "IF3 DAC"},
3776 {"IF2_1 ADC Mux", "DAC1 MIX", "DAC1 MIX"},
3777 {"IF2_1 ADC", NULL, "IF2_1 ADC Mux"},
3778 {"IF2_1 ADC", NULL, "I2S2_1"},
3780 {"IF2_2 ADC Mux", "STO1 ADC", "Stereo1 ADC MIX"},
3781 {"IF2_2 ADC Mux", "STO2 ADC", "Stereo2 ADC MIX"},
3782 {"IF2_2 ADC Mux", "MONO ADC", "Mono ADC MIX"},
3783 {"IF2_2 ADC Mux", "IF1 DAC1", "IF1 DAC1"},
3784 {"IF2_2 ADC Mux", "IF1 DAC2", "IF1 DAC2"},
3785 {"IF2_2 ADC Mux", "IF2_1 DAC", "IF2_1 DAC"},
3786 {"IF2_2 ADC Mux", "IF3 DAC", "IF3 DAC"},
3787 {"IF2_2 ADC Mux", "DAC1 MIX", "DAC1 MIX"},
3788 {"IF2_2 ADC", NULL, "IF2_2 ADC Mux"},
3789 {"IF2_2 ADC", NULL, "I2S2_2"},
3791 {"IF3 ADC Mux", "STO1 ADC", "Stereo1 ADC MIX"},
3792 {"IF3 ADC Mux", "STO2 ADC", "Stereo2 ADC MIX"},
3793 {"IF3 ADC Mux", "MONO ADC", "Mono ADC MIX"},
3794 {"IF3 ADC Mux", "IF1 DAC1", "IF1 DAC1"},
3795 {"IF3 ADC Mux", "IF1 DAC2", "IF1 DAC2"},
3796 {"IF3 ADC Mux", "IF2_1 DAC", "IF2_1 DAC"},
3797 {"IF3 ADC Mux", "IF2_2 DAC", "IF2_2 DAC"},
3798 {"IF3 ADC Mux", "DAC1 MIX", "DAC1 MIX"},
3799 {"IF3 ADC", NULL, "IF3 ADC Mux"},
3800 {"IF3 ADC", NULL, "I2S3"},
3802 {"AIF1_1TX slot 0", NULL, "IF1_1 0 ADC Swap Mux"},
3803 {"AIF1_1TX slot 1", NULL, "IF1_1 1 ADC Swap Mux"},
3804 {"AIF1_1TX slot 2", NULL, "IF1_1 2 ADC Swap Mux"},
3805 {"AIF1_1TX slot 3", NULL, "IF1_1 3 ADC Swap Mux"},
3806 {"AIF1_1TX slot 4", NULL, "IF1_1 4 ADC Swap Mux"},
3807 {"AIF1_1TX slot 5", NULL, "IF1_1 5 ADC Swap Mux"},
3808 {"AIF1_1TX slot 6", NULL, "IF1_1 6 ADC Swap Mux"},
3809 {"AIF1_1TX slot 7", NULL, "IF1_1 7 ADC Swap Mux"},
3810 {"AIF1_2TX slot 0", NULL, "IF1_2 0 ADC Swap Mux"},
3811 {"AIF1_2TX slot 1", NULL, "IF1_2 1 ADC Swap Mux"},
3812 {"AIF1_2TX slot 2", NULL, "IF1_2 2 ADC Swap Mux"},
3813 {"AIF1_2TX slot 3", NULL, "IF1_2 3 ADC Swap Mux"},
3814 {"AIF1_2TX slot 4", NULL, "IF1_2 4 ADC Swap Mux"},
3815 {"AIF1_2TX slot 5", NULL, "IF1_2 5 ADC Swap Mux"},
3816 {"AIF1_2TX slot 6", NULL, "IF1_2 6 ADC Swap Mux"},
3817 {"AIF1_2TX slot 7", NULL, "IF1_2 7 ADC Swap Mux"},
3818 {"IF2_1 ADC Swap Mux", "L/R", "IF2_1 ADC"},
3819 {"IF2_1 ADC Swap Mux", "R/L", "IF2_1 ADC"},
3820 {"IF2_1 ADC Swap Mux", "L/L", "IF2_1 ADC"},
3821 {"IF2_1 ADC Swap Mux", "R/R", "IF2_1 ADC"},
3822 {"AIF2_1TX", NULL, "IF2_1 ADC Swap Mux"},
3823 {"IF2_2 ADC Swap Mux", "L/R", "IF2_2 ADC"},
3824 {"IF2_2 ADC Swap Mux", "R/L", "IF2_2 ADC"},
3825 {"IF2_2 ADC Swap Mux", "L/L", "IF2_2 ADC"},
3826 {"IF2_2 ADC Swap Mux", "R/R", "IF2_2 ADC"},
3827 {"AIF2_2TX", NULL, "IF2_2 ADC Swap Mux"},
3828 {"IF3 ADC Swap Mux", "L/R", "IF3 ADC"},
3829 {"IF3 ADC Swap Mux", "R/L", "IF3 ADC"},
3830 {"IF3 ADC Swap Mux", "L/L", "IF3 ADC"},
3831 {"IF3 ADC Swap Mux", "R/R", "IF3 ADC"},
3832 {"AIF3TX", NULL, "IF3 ADC Swap Mux"},
3885 {"DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL"},
3887 {"DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR"},
3897 {"DAC L2 Mux", "Mono ADC MIX", "Mono ADC MIXL"},
3904 {"DAC R2 Mux", "Mono ADC MIX", "Mono ADC MIXR"},
3911 {"DAC L3 Mux", "STO2 ADC MIX", "Stereo2 ADC MIXL"},
3918 {"DAC R3 Mux", "STO2 ADC MIX", "Stereo2 ADC MIXR"},
4052 struct snd_soc_component *component = dai->component; in rt5665_set_tdm_slot()
4074 return -EINVAL; in rt5665_set_tdm_slot()
4093 return -EINVAL; in rt5665_set_tdm_slot()
4108 struct snd_soc_component *component = dai->component; in rt5665_hw_params()
4113 rt5665->lrck[dai->id] = params_rate(params); in rt5665_hw_params()
4114 pre_div = rl6231_get_clk_info(rt5665->sysclk, rt5665->lrck[dai->id]); in rt5665_hw_params()
4116 dev_warn(component->dev, "Force using PLL"); in rt5665_hw_params()
4118 rt5665->sysclk, rt5665->lrck[dai->id] * 512); in rt5665_hw_params()
4120 rt5665->lrck[dai->id] * 512, 0); in rt5665_hw_params()
4125 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5665_hw_params()
4126 return -EINVAL; in rt5665_hw_params()
4129 dev_dbg(dai->dev, "lrck is %dHz and pre_div is %d for iis %d\n", in rt5665_hw_params()
4130 rt5665->lrck[dai->id], pre_div, dai->id); in rt5665_hw_params()
4148 return -EINVAL; in rt5665_hw_params()
4151 switch (dai->id) { in rt5665_hw_params()
4179 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5665_hw_params()
4180 return -EINVAL; in rt5665_hw_params()
4186 switch (rt5665->lrck[dai->id]) { in rt5665_hw_params()
4204 if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { in rt5665_hw_params()
4208 if (rt5665->master[RT5665_AIF3]) { in rt5665_hw_params()
4218 struct snd_soc_component *component = dai->component; in rt5665_set_dai_fmt()
4224 rt5665->master[dai->id] = 1; in rt5665_set_dai_fmt()
4228 rt5665->master[dai->id] = 0; in rt5665_set_dai_fmt()
4231 return -EINVAL; in rt5665_set_dai_fmt()
4241 return -EINVAL; in rt5665_set_dai_fmt()
4257 return -EINVAL; in rt5665_set_dai_fmt()
4260 switch (dai->id) { in rt5665_set_dai_fmt()
4279 dev_err(component->dev, "Invalid dai->id: %d\n", dai->id); in rt5665_set_dai_fmt()
4280 return -EINVAL; in rt5665_set_dai_fmt()
4289 unsigned int reg_val = 0, src = 0; in rt5665_set_component_sysclk() local
4291 if (freq == rt5665->sysclk && clk_id == rt5665->sysclk_src) in rt5665_set_component_sysclk()
4297 src = RT5665_CLK_SRC_MCLK; in rt5665_set_component_sysclk()
4301 src = RT5665_CLK_SRC_PLL1; in rt5665_set_component_sysclk()
4305 src = RT5665_CLK_SRC_RCCLK; in rt5665_set_component_sysclk()
4308 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5665_set_component_sysclk()
4309 return -EINVAL; in rt5665_set_component_sysclk()
4314 if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { in rt5665_set_component_sysclk()
4316 RT5665_I2S2_SRC_MASK, src << RT5665_I2S2_SRC_SFT); in rt5665_set_component_sysclk()
4318 if (rt5665->master[RT5665_AIF3]) { in rt5665_set_component_sysclk()
4320 RT5665_I2S3_SRC_MASK, src << RT5665_I2S3_SRC_SFT); in rt5665_set_component_sysclk()
4323 rt5665->sysclk = freq; in rt5665_set_component_sysclk()
4324 rt5665->sysclk_src = clk_id; in rt5665_set_component_sysclk()
4326 dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5665_set_component_sysclk()
4339 if (source == rt5665->pll_src && freq_in == rt5665->pll_in && in rt5665_set_component_pll()
4340 freq_out == rt5665->pll_out) in rt5665_set_component_pll()
4344 dev_dbg(component->dev, "PLL disabled\n"); in rt5665_set_component_pll()
4346 rt5665->pll_in = 0; in rt5665_set_component_pll()
4347 rt5665->pll_out = 0; in rt5665_set_component_pll()
4371 dev_err(component->dev, "Unknown PLL Source %d\n", source); in rt5665_set_component_pll()
4372 return -EINVAL; in rt5665_set_component_pll()
4377 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5665_set_component_pll()
4381 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5665_set_component_pll()
4391 rt5665->pll_in = freq_in; in rt5665_set_component_pll()
4392 rt5665->pll_out = freq_out; in rt5665_set_component_pll()
4393 rt5665->pll_src = source; in rt5665_set_component_pll()
4400 struct snd_soc_component *component = dai->component; in rt5665_set_bclk_ratio()
4403 dev_dbg(component->dev, "%s ratio=%d\n", __func__, ratio); in rt5665_set_bclk_ratio()
4405 rt5665->bclk[dai->id] = ratio; in rt5665_set_bclk_ratio()
4408 switch (dai->id) { in rt5665_set_bclk_ratio()
4433 regmap_update_bits(rt5665->regmap, RT5665_DIG_MISC, in rt5665_set_bias_level()
4438 regmap_update_bits(rt5665->regmap, RT5665_PWR_DIG_1, in rt5665_set_bias_level()
4440 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_set_bias_level()
4442 regmap_update_bits(rt5665->regmap, RT5665_DIG_MISC, in rt5665_set_bias_level()
4446 regmap_update_bits(rt5665->regmap, RT5665_PWR_DIG_1, in rt5665_set_bias_level()
4448 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_set_bias_level()
4463 rt5665->component = component; in rt5665_probe()
4465 schedule_delayed_work(&rt5665->calibrate_work, msecs_to_jiffies(100)); in rt5665_probe()
4474 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_remove()
4482 regcache_cache_only(rt5665->regmap, true); in rt5665_suspend()
4483 regcache_mark_dirty(rt5665->regmap); in rt5665_suspend()
4491 regcache_cache_only(rt5665->regmap, false); in rt5665_resume()
4492 regcache_sync(rt5665->regmap); in rt5665_resume()
4514 .name = "rt5665-aif1_1",
4533 .name = "rt5665-aif1_2",
4545 .name = "rt5665-aif2_1",
4564 .name = "rt5665-aif2_2",
4583 .name = "rt5665-aif3",
4645 rt5665->pdata.in1_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4646 "realtek,in1-differential"); in rt5665_parse_dt()
4647 rt5665->pdata.in2_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4648 "realtek,in2-differential"); in rt5665_parse_dt()
4649 rt5665->pdata.in3_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4650 "realtek,in3-differential"); in rt5665_parse_dt()
4651 rt5665->pdata.in4_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4652 "realtek,in4-differential"); in rt5665_parse_dt()
4654 of_property_read_u32(dev->of_node, "realtek,dmic1-data-pin", in rt5665_parse_dt()
4655 &rt5665->pdata.dmic1_data_pin); in rt5665_parse_dt()
4656 of_property_read_u32(dev->of_node, "realtek,dmic2-data-pin", in rt5665_parse_dt()
4657 &rt5665->pdata.dmic2_data_pin); in rt5665_parse_dt()
4658 of_property_read_u32(dev->of_node, "realtek,jd-src", in rt5665_parse_dt()
4659 &rt5665->pdata.jd_src); in rt5665_parse_dt()
4661 rt5665->pdata.ldo1_en = of_get_named_gpio(dev->of_node, in rt5665_parse_dt()
4662 "realtek,ldo1-en-gpios", 0); in rt5665_parse_dt()
4671 mutex_lock(&rt5665->calibrate_mutex); in rt5665_calibrate()
4673 regcache_cache_bypass(rt5665->regmap, true); in rt5665_calibrate()
4675 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4676 regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602); in rt5665_calibrate()
4677 regmap_write(rt5665->regmap, RT5665_HP_CHARGE_PUMP_1, 0x0c26); in rt5665_calibrate()
4678 regmap_write(rt5665->regmap, RT5665_MONOMIX_IN_GAIN, 0x021f); in rt5665_calibrate()
4679 regmap_write(rt5665->regmap, RT5665_MONO_OUT, 0x480a); in rt5665_calibrate()
4680 regmap_write(rt5665->regmap, RT5665_PWR_MIXER, 0x083f); in rt5665_calibrate()
4681 regmap_write(rt5665->regmap, RT5665_PWR_DIG_1, 0x0180); in rt5665_calibrate()
4682 regmap_write(rt5665->regmap, RT5665_EJD_CTRL_1, 0x4040); in rt5665_calibrate()
4683 regmap_write(rt5665->regmap, RT5665_HP_LOGIC_CTRL_2, 0x0000); in rt5665_calibrate()
4684 regmap_write(rt5665->regmap, RT5665_DIG_MISC, 0x0001); in rt5665_calibrate()
4685 regmap_write(rt5665->regmap, RT5665_MICBIAS_2, 0x0380); in rt5665_calibrate()
4686 regmap_write(rt5665->regmap, RT5665_GLB_CLK, 0x8000); in rt5665_calibrate()
4687 regmap_write(rt5665->regmap, RT5665_ADDA_CLK_1, 0x1000); in rt5665_calibrate()
4688 regmap_write(rt5665->regmap, RT5665_CHOP_DAC, 0x3030); in rt5665_calibrate()
4689 regmap_write(rt5665->regmap, RT5665_CALIB_ADC_CTRL, 0x3c05); in rt5665_calibrate()
4690 regmap_write(rt5665->regmap, RT5665_PWR_ANLG_1, 0xaa3e); in rt5665_calibrate()
4692 regmap_write(rt5665->regmap, RT5665_PWR_ANLG_1, 0xfe7e); in rt5665_calibrate()
4693 regmap_write(rt5665->regmap, RT5665_HP_CALIB_CTRL_2, 0x0321); in rt5665_calibrate()
4695 regmap_write(rt5665->regmap, RT5665_HP_CALIB_CTRL_1, 0xfc00); in rt5665_calibrate()
4698 regmap_read(rt5665->regmap, RT5665_HP_CALIB_STA_1, &value); in rt5665_calibrate()
4706 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4707 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4714 regmap_write(rt5665->regmap, RT5665_MONO_AMP_CALIB_CTRL_1, 0x9e24); in rt5665_calibrate()
4717 regmap_read(rt5665->regmap, RT5665_MONO_AMP_CALIB_STA1, &value); in rt5665_calibrate()
4725 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4726 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4733 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4734 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4736 regcache_mark_dirty(rt5665->regmap); in rt5665_calibrate()
4737 regcache_sync(rt5665->regmap); in rt5665_calibrate()
4739 regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602); in rt5665_calibrate()
4740 regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120); in rt5665_calibrate()
4743 rt5665->calibration_done = true; in rt5665_calibrate()
4744 mutex_unlock(&rt5665->calibrate_mutex); in rt5665_calibrate()
4752 while (!rt5665->component->card->instantiated) { in rt5665_calibrate_handler()
4763 struct rt5665_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt5665_i2c_probe()
4768 rt5665 = devm_kzalloc(&i2c->dev, sizeof(struct rt5665_priv), in rt5665_i2c_probe()
4772 return -ENOMEM; in rt5665_i2c_probe()
4777 rt5665->pdata = *pdata; in rt5665_i2c_probe()
4779 rt5665_parse_dt(rt5665, &i2c->dev); in rt5665_i2c_probe()
4781 for (i = 0; i < ARRAY_SIZE(rt5665->supplies); i++) in rt5665_i2c_probe()
4782 rt5665->supplies[i].supply = rt5665_supply_names[i]; in rt5665_i2c_probe()
4784 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5665->supplies), in rt5665_i2c_probe()
4785 rt5665->supplies); in rt5665_i2c_probe()
4787 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in rt5665_i2c_probe()
4791 ret = regulator_bulk_enable(ARRAY_SIZE(rt5665->supplies), in rt5665_i2c_probe()
4792 rt5665->supplies); in rt5665_i2c_probe()
4794 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in rt5665_i2c_probe()
4798 if (gpio_is_valid(rt5665->pdata.ldo1_en)) { in rt5665_i2c_probe()
4799 if (devm_gpio_request_one(&i2c->dev, rt5665->pdata.ldo1_en, in rt5665_i2c_probe()
4801 dev_err(&i2c->dev, "Fail gpio_request gpio_ldo\n"); in rt5665_i2c_probe()
4807 rt5665->regmap = devm_regmap_init_i2c(i2c, &rt5665_regmap); in rt5665_i2c_probe()
4808 if (IS_ERR(rt5665->regmap)) { in rt5665_i2c_probe()
4809 ret = PTR_ERR(rt5665->regmap); in rt5665_i2c_probe()
4810 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5665_i2c_probe()
4815 regmap_read(rt5665->regmap, RT5665_DEVICE_ID, &val); in rt5665_i2c_probe()
4817 dev_err(&i2c->dev, in rt5665_i2c_probe()
4819 return -ENODEV; in rt5665_i2c_probe()
4822 regmap_read(rt5665->regmap, RT5665_RESET, &val); in rt5665_i2c_probe()
4825 rt5665->id = CODEC_5666; in rt5665_i2c_probe()
4829 rt5665->id = CODEC_5665; in rt5665_i2c_probe()
4833 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_i2c_probe()
4836 if (rt5665->pdata.in1_diff) in rt5665_i2c_probe()
4837 regmap_update_bits(rt5665->regmap, RT5665_IN1_IN2, in rt5665_i2c_probe()
4839 if (rt5665->pdata.in2_diff) in rt5665_i2c_probe()
4840 regmap_update_bits(rt5665->regmap, RT5665_IN1_IN2, in rt5665_i2c_probe()
4842 if (rt5665->pdata.in3_diff) in rt5665_i2c_probe()
4843 regmap_update_bits(rt5665->regmap, RT5665_IN3_IN4, in rt5665_i2c_probe()
4845 if (rt5665->pdata.in4_diff) in rt5665_i2c_probe()
4846 regmap_update_bits(rt5665->regmap, RT5665_IN3_IN4, in rt5665_i2c_probe()
4850 if (rt5665->pdata.dmic1_data_pin != RT5665_DMIC1_NULL || in rt5665_i2c_probe()
4851 rt5665->pdata.dmic2_data_pin != RT5665_DMIC2_NULL) { in rt5665_i2c_probe()
4852 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_2, in rt5665_i2c_probe()
4854 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4856 switch (rt5665->pdata.dmic1_data_pin) { in rt5665_i2c_probe()
4858 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4863 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4865 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4870 dev_dbg(&i2c->dev, "no DMIC1\n"); in rt5665_i2c_probe()
4874 switch (rt5665->pdata.dmic2_data_pin) { in rt5665_i2c_probe()
4876 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4881 regmap_update_bits(rt5665->regmap, in rt5665_i2c_probe()
4885 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4890 dev_dbg(&i2c->dev, "no DMIC2\n"); in rt5665_i2c_probe()
4896 regmap_write(rt5665->regmap, RT5665_HP_LOGIC_CTRL_2, 0x0002); in rt5665_i2c_probe()
4897 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_i2c_probe()
4900 regmap_update_bits(rt5665->regmap, RT5665_STO1_DAC_SIL_DET, in rt5665_i2c_probe()
4903 regmap_update_bits(rt5665->regmap, RT5665_HP_CHARGE_PUMP_1, in rt5665_i2c_probe()
4907 if (rt5665->id == CODEC_5666) { in rt5665_i2c_probe()
4908 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_2, in rt5665_i2c_probe()
4910 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_3, in rt5665_i2c_probe()
4915 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_i2c_probe()
4919 INIT_DELAYED_WORK(&rt5665->jack_detect_work, in rt5665_i2c_probe()
4921 INIT_DELAYED_WORK(&rt5665->calibrate_work, in rt5665_i2c_probe()
4923 INIT_DELAYED_WORK(&rt5665->jd_check_work, in rt5665_i2c_probe()
4926 mutex_init(&rt5665->calibrate_mutex); in rt5665_i2c_probe()
4928 if (i2c->irq) { in rt5665_i2c_probe()
4929 ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, in rt5665_i2c_probe()
4933 dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); in rt5665_i2c_probe()
4937 return devm_snd_soc_register_component(&i2c->dev, in rt5665_i2c_probe()
4946 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_i2c_shutdown()