Lines Matching +full:adc +full:- +full:mux
1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5651.c -- RT5651 ALSA SoC audio codec driver
23 #include <sound/soc-dapm.h>
287 static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0);
288 static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0);
289 static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0);
290 static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000);
342 /* ADC Digital Volume Control */
343 SOC_DOUBLE("ADC Capture Switch", RT5651_ADC_DIG_VOL,
345 SOC_DOUBLE_TLV("ADC Capture Volume", RT5651_ADC_DIG_VOL,
348 SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5651_ADC_DATA,
351 /* ADC Boost Volume Control */
352 SOC_DOUBLE_TLV("ADC Boost Gain", RT5651_ADC_BST_VOL,
364 SOC_ENUM("ADC IF2 Data Switch", rt5651_if2_adc_enum),
369 * set_dmic_clk - Set parameter of dmic.
379 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in set_dmic_clk()
383 rate = rt5651->sysclk / rl6231_get_pre_div(rt5651->regmap, in set_dmic_clk()
387 dev_err(component->dev, "Failed to set DMIC clock\n"); in set_dmic_clk()
425 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5651_AD_DA_MIXER,
432 SOC_DAPM_SINGLE("Stereo ADC Switch", RT5651_AD_DA_MIXER,
575 /* Stereo ADC source */
576 static const char * const rt5651_stereo1_adc1_src[] = {"DD MIX", "ADC"};
583 SOC_DAPM_ENUM("Stereo1 ADC L1 source", rt5651_stereo1_adc1_enum);
586 SOC_DAPM_ENUM("Stereo1 ADC R1 source", rt5651_stereo1_adc1_enum);
595 SOC_DAPM_ENUM("Stereo1 ADC L2 source", rt5651_stereo1_adc2_enum);
598 SOC_DAPM_ENUM("Stereo1 ADC R2 source", rt5651_stereo1_adc2_enum);
600 /* Mono ADC source */
662 SOC_DAPM_ENUM("IF2 ADC channel source", rt5651_if2_adc_src_enum);
684 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_amp_power_event()
690 regmap_update_bits(rt5651->regmap, RT5651_PR_BASE + in rt5651_amp_power_event()
692 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M2, in rt5651_amp_power_event()
694 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M1, in rt5651_amp_power_event()
698 regmap_write(rt5651->regmap, RT5651_PR_BASE + in rt5651_amp_power_event()
701 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
703 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
707 regmap_update_bits(rt5651->regmap, RT5651_PWR_ANLG1, in rt5651_amp_power_event()
722 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_hp_event()
728 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M2, in rt5651_hp_event()
731 regmap_update_bits(rt5651->regmap, RT5651_CHARGE_PUMP, in rt5651_hp_event()
734 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M3, in rt5651_hp_event()
741 regmap_write(rt5651->regmap, RT5651_PR_BASE + in rt5651_hp_event()
743 regmap_update_bits(rt5651->regmap, RT5651_DEPOP_M1, in rt5651_hp_event()
746 regmap_update_bits(rt5651->regmap, RT5651_PR_BASE + in rt5651_hp_event()
748 rt5651->hp_mute = false; in rt5651_hp_event()
752 rt5651->hp_mute = true; in rt5651_hp_event()
767 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_hp_post_event()
772 if (!rt5651->hp_mute) in rt5651_hp_post_event()
787 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst1_event()
810 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst2_event()
833 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5651_bst3_event()
863 SND_SOC_DAPM_SUPPLY_S("ADC ASRC", 1, RT5651_PLL_MODE_2,
910 SND_SOC_DAPM_ADC("ADC L", NULL, SND_SOC_NOPM, 0, 0),
911 SND_SOC_DAPM_ADC("ADC R", NULL, SND_SOC_NOPM, 0, 0),
912 SND_SOC_DAPM_SUPPLY("ADC L Power", RT5651_PWR_DIG1,
914 SND_SOC_DAPM_SUPPLY("ADC R Power", RT5651_PWR_DIG1,
916 /* ADC Mux */
917 SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
919 SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
921 SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
923 SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
925 SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0,
927 SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0,
929 SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0,
931 SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0,
933 /* ADC Mixer */
938 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0,
941 SND_SOC_DAPM_MIXER("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0,
944 SND_SOC_DAPM_MIXER("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0,
947 SND_SOC_DAPM_MIXER("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0,
966 SND_SOC_DAPM_MUX("IF2 ADC", SND_SOC_NOPM, 0, 0,
971 SND_SOC_DAPM_MUX("PDM L Mux", RT5651_PDM_CTL,
973 SND_SOC_DAPM_MUX("PDM R Mux", RT5651_PDM_CTL,
991 /* DAC2 channel Mux */
992 SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, &rt5651_dac_l2_mux),
993 SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, &rt5651_dac_r2_mux),
1113 {"ADC L", NULL, "RECMIXL"},
1114 {"ADC L", NULL, "ADC L Power"},
1115 {"ADC R", NULL, "RECMIXR"},
1116 {"ADC R", NULL, "ADC R Power"},
1121 {"Stereo1 ADC L2 Mux", "DMIC", "DMIC L1"},
1122 {"Stereo1 ADC L2 Mux", "DD MIX", "DD MIXL"},
1123 {"Stereo1 ADC L1 Mux", "ADC", "ADC L"},
1124 {"Stereo1 ADC L1 Mux", "DD MIX", "DD MIXL"},
1126 {"Stereo1 ADC R1 Mux", "ADC", "ADC R"},
1127 {"Stereo1 ADC R1 Mux", "DD MIX", "DD MIXR"},
1128 {"Stereo1 ADC R2 Mux", "DMIC", "DMIC R1"},
1129 {"Stereo1 ADC R2 Mux", "DD MIX", "DD MIXR"},
1131 {"Stereo2 ADC L2 Mux", "DMIC L", "DMIC L1"},
1132 {"Stereo2 ADC L2 Mux", "DD MIXL", "DD MIXL"},
1133 {"Stereo2 ADC L1 Mux", "DD MIXL", "DD MIXL"},
1134 {"Stereo2 ADC L1 Mux", "ADCL", "ADC L"},
1136 {"Stereo2 ADC R1 Mux", "DD MIXR", "DD MIXR"},
1137 {"Stereo2 ADC R1 Mux", "ADCR", "ADC R"},
1138 {"Stereo2 ADC R2 Mux", "DMIC R", "DMIC R1"},
1139 {"Stereo2 ADC R2 Mux", "DD MIXR", "DD MIXR"},
1141 {"Stereo1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux"},
1142 {"Stereo1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux"},
1143 {"Stereo1 ADC MIXL", NULL, "Stereo1 Filter"},
1144 {"Stereo1 Filter", NULL, "ADC ASRC"},
1146 {"Stereo1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux"},
1147 {"Stereo1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux"},
1148 {"Stereo1 ADC MIXR", NULL, "Stereo1 Filter"},
1150 {"Stereo2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux"},
1151 {"Stereo2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux"},
1152 {"Stereo2 ADC MIXL", NULL, "Stereo2 Filter"},
1153 {"Stereo2 Filter", NULL, "ADC ASRC"},
1155 {"Stereo2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux"},
1156 {"Stereo2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux"},
1157 {"Stereo2 ADC MIXR", NULL, "Stereo2 Filter"},
1159 {"IF1 ADC2", NULL, "Stereo2 ADC MIXL"},
1160 {"IF1 ADC2", NULL, "Stereo2 ADC MIXR"},
1161 {"IF1 ADC1", NULL, "Stereo1 ADC MIXL"},
1162 {"IF1 ADC1", NULL, "Stereo1 ADC MIXR"},
1166 {"IF2 ADC", "IF1 ADC1", "IF1 ADC1"},
1167 {"IF2 ADC", "IF1 ADC2", "IF1 ADC2"},
1168 {"IF2 ADC", NULL, "I2S2"},
1172 {"AIF2TX", NULL, "IF2 ADC"},
1186 {"DAC MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL"},
1188 {"DAC MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR"},
1194 {"DAC L2 Mux", "IF1", "IF1 DAC2 L"},
1195 {"DAC L2 Mux", "IF2", "IF2 DAC L"},
1196 {"DAC L2 Volume", NULL, "DAC L2 Mux"},
1198 {"DAC R2 Mux", "IF1", "IF1 DAC2 R"},
1199 {"DAC R2 Mux", "IF2", "IF2 DAC R"},
1200 {"DAC R2 Volume", NULL, "DAC R2 Mux"},
1213 {"PDM L Mux", "Stereo DAC MIX", "Stereo DAC MIXL"},
1214 {"PDM L Mux", "DD MIX", "DAC MIXL"},
1215 {"PDM R Mux", "Stereo DAC MIX", "Stereo DAC MIXR"},
1216 {"PDM R Mux", "DD MIX", "DAC MIXR"},
1277 {"PDML", NULL, "PDM L Mux"},
1278 {"PDMR", NULL, "PDM R Mux"},
1284 struct snd_soc_component *component = dai->component; in rt5651_hw_params()
1289 rt5651->lrck[dai->id] = params_rate(params); in rt5651_hw_params()
1290 pre_div = rl6231_get_clk_info(rt5651->sysclk, rt5651->lrck[dai->id]); in rt5651_hw_params()
1293 dev_err(component->dev, "Unsupported clock setting\n"); in rt5651_hw_params()
1294 return -EINVAL; in rt5651_hw_params()
1298 dev_err(component->dev, "Unsupported frame size: %d\n", frame_size); in rt5651_hw_params()
1299 return -EINVAL; in rt5651_hw_params()
1302 rt5651->bclk[dai->id] = rt5651->lrck[dai->id] * (32 << bclk_ms); in rt5651_hw_params()
1304 dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", in rt5651_hw_params()
1305 rt5651->bclk[dai->id], rt5651->lrck[dai->id]); in rt5651_hw_params()
1306 dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", in rt5651_hw_params()
1307 bclk_ms, pre_div, dai->id); in rt5651_hw_params()
1322 return -EINVAL; in rt5651_hw_params()
1325 switch (dai->id) { in rt5651_hw_params()
1341 dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); in rt5651_hw_params()
1342 return -EINVAL; in rt5651_hw_params()
1350 struct snd_soc_component *component = dai->component; in rt5651_set_dai_fmt()
1356 rt5651->master[dai->id] = 1; in rt5651_set_dai_fmt()
1360 rt5651->master[dai->id] = 0; in rt5651_set_dai_fmt()
1363 return -EINVAL; in rt5651_set_dai_fmt()
1373 return -EINVAL; in rt5651_set_dai_fmt()
1389 return -EINVAL; in rt5651_set_dai_fmt()
1392 switch (dai->id) { in rt5651_set_dai_fmt()
1404 dev_err(component->dev, "Wrong dai->id: %d\n", dai->id); in rt5651_set_dai_fmt()
1405 return -EINVAL; in rt5651_set_dai_fmt()
1413 struct snd_soc_component *component = dai->component; in rt5651_set_dai_sysclk()
1418 if (freq == rt5651->sysclk && clk_id == rt5651->sysclk_src) in rt5651_set_dai_sysclk()
1433 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5651_set_dai_sysclk()
1434 return -EINVAL; in rt5651_set_dai_sysclk()
1440 rt5651->sysclk = freq; in rt5651_set_dai_sysclk()
1441 rt5651->sysclk_src = clk_id; in rt5651_set_dai_sysclk()
1443 dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); in rt5651_set_dai_sysclk()
1451 struct snd_soc_component *component = dai->component; in rt5651_set_dai_pll()
1456 if (source == rt5651->pll_src && freq_in == rt5651->pll_in && in rt5651_set_dai_pll()
1457 freq_out == rt5651->pll_out) in rt5651_set_dai_pll()
1461 dev_dbg(component->dev, "PLL disabled\n"); in rt5651_set_dai_pll()
1463 rt5651->pll_in = 0; in rt5651_set_dai_pll()
1464 rt5651->pll_out = 0; in rt5651_set_dai_pll()
1484 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5651_set_dai_pll()
1485 return -EINVAL; in rt5651_set_dai_pll()
1490 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt5651_set_dai_pll()
1494 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", in rt5651_set_dai_pll()
1504 rt5651->pll_in = freq_in; in rt5651_set_dai_pll()
1505 rt5651->pll_out = freq_out; in rt5651_set_dai_pll()
1506 rt5651->pll_src = source; in rt5651_set_dai_pll()
1543 /* Do not touch the LDO voltage select bits on bias-off */ in rt5651_set_bias_level()
1546 /* Leave PLL1 and jack-detect power as is, all others off */ in rt5651_set_bias_level()
1565 /* OVCD is unreliable when used with RCCLK as sysclk-source */ in rt5651_enable_micbias1_for_ovcd()
1589 rt5651->ovcd_irq_enabled = true; in rt5651_enable_micbias1_ovcd_irq()
1598 rt5651->ovcd_irq_enabled = false; in rt5651_disable_micbias1_ovcd_irq()
1612 dev_dbg(component->dev, "irq ctrl2 %#04x\n", val); in rt5651_micbias1_ovcd()
1622 if (rt5651->gpiod_hp_det) { in rt5651_jack_inserted()
1623 val = gpiod_get_value_cansleep(rt5651->gpiod_hp_det); in rt5651_jack_inserted()
1624 dev_dbg(component->dev, "jack-detect gpio %d\n", val); in rt5651_jack_inserted()
1629 dev_dbg(component->dev, "irq status %#04x\n", val); in rt5651_jack_inserted()
1631 switch (rt5651->jd_src) { in rt5651_jack_inserted()
1645 if (rt5651->jd_active_high) in rt5651_jack_inserted()
1651 /* Jack detect and button-press timings */
1664 rt5651->poll_count = 0; in rt5651_start_button_press_work()
1665 rt5651->press_count = 0; in rt5651_start_button_press_work()
1666 rt5651->release_count = 0; in rt5651_start_button_press_work()
1667 rt5651->pressed = false; in rt5651_start_button_press_work()
1668 rt5651->press_reported = false; in rt5651_start_button_press_work()
1670 schedule_delayed_work(&rt5651->bp_work, msecs_to_jiffies(BP_POLL_TIME)); in rt5651_start_button_press_work()
1677 struct snd_soc_component *component = rt5651->component; in rt5651_button_press_work()
1684 rt5651->release_count = 0; in rt5651_button_press_work()
1685 rt5651->press_count++; in rt5651_button_press_work()
1687 if (rt5651->press_count >= BP_THRESHOLD) in rt5651_button_press_work()
1688 rt5651->pressed = true; in rt5651_button_press_work()
1691 rt5651->press_count = 0; in rt5651_button_press_work()
1692 rt5651->release_count++; in rt5651_button_press_work()
1697 * at least JACK_UNPLUG_TIME milli-seconds before reporting a press. in rt5651_button_press_work()
1699 rt5651->poll_count++; in rt5651_button_press_work()
1700 if (rt5651->poll_count < (JACK_UNPLUG_TIME / BP_POLL_TIME)) { in rt5651_button_press_work()
1701 schedule_delayed_work(&rt5651->bp_work, in rt5651_button_press_work()
1706 if (rt5651->pressed && !rt5651->press_reported) { in rt5651_button_press_work()
1707 dev_dbg(component->dev, "headset button press\n"); in rt5651_button_press_work()
1708 snd_soc_jack_report(rt5651->hp_jack, SND_JACK_BTN_0, in rt5651_button_press_work()
1710 rt5651->press_reported = true; in rt5651_button_press_work()
1713 if (rt5651->release_count >= BP_THRESHOLD) { in rt5651_button_press_work()
1714 if (rt5651->press_reported) { in rt5651_button_press_work()
1715 dev_dbg(component->dev, "headset button release\n"); in rt5651_button_press_work()
1716 snd_soc_jack_report(rt5651->hp_jack, 0, SND_JACK_BTN_0); in rt5651_button_press_work()
1718 /* Re-enable OVCD IRQ to detect next press */ in rt5651_button_press_work()
1723 schedule_delayed_work(&rt5651->bp_work, msecs_to_jiffies(BP_POLL_TIME)); in rt5651_button_press_work()
1738 /* Clear any previous over-current status flag */ in rt5651_detect_headset()
1753 dev_dbg(component->dev, "mic-gnd shorted\n"); in rt5651_detect_headset()
1759 dev_dbg(component->dev, "mic-gnd open\n"); in rt5651_detect_headset()
1767 …dev_err(component->dev, "Error detecting headset vs headphones, bad contact?, assuming headphones\… in rt5651_detect_headset()
1773 if (!rt5651->hp_jack) in rt5651_support_button_press()
1776 /* Button press support only works with internal jack-detection */ in rt5651_support_button_press()
1777 return (rt5651->hp_jack->status & SND_JACK_MICROPHONE) && in rt5651_support_button_press()
1778 rt5651->gpiod_hp_det == NULL; in rt5651_support_button_press()
1785 struct snd_soc_component *component = rt5651->component; in rt5651_jack_detect_work()
1790 if (rt5651->hp_jack->status & SND_JACK_HEADPHONE) { in rt5651_jack_detect_work()
1791 if (rt5651->hp_jack->status & SND_JACK_MICROPHONE) { in rt5651_jack_detect_work()
1792 cancel_delayed_work_sync(&rt5651->bp_work); in rt5651_jack_detect_work()
1796 snd_soc_jack_report(rt5651->hp_jack, 0, in rt5651_jack_detect_work()
1798 dev_dbg(component->dev, "jack unplugged\n"); in rt5651_jack_detect_work()
1800 } else if (!(rt5651->hp_jack->status & SND_JACK_HEADPHONE)) { in rt5651_jack_detect_work()
1802 WARN_ON(rt5651->ovcd_irq_enabled); in rt5651_jack_detect_work()
1805 dev_dbg(component->dev, "detect report %#02x\n", report); in rt5651_jack_detect_work()
1806 snd_soc_jack_report(rt5651->hp_jack, report, SND_JACK_HEADSET); in rt5651_jack_detect_work()
1814 } else if (rt5651->ovcd_irq_enabled && rt5651_micbias1_ovcd(component)) { in rt5651_jack_detect_work()
1815 dev_dbg(component->dev, "OVCD IRQ\n"); in rt5651_jack_detect_work()
1830 * If the jack-detect IRQ flag goes high (unplug) after our in rt5651_jack_detect_work()
1833 * we react to edges, we miss the unplug event -> recheck. in rt5651_jack_detect_work()
1835 queue_work(system_long_wq, &rt5651->jack_detect_work); in rt5651_jack_detect_work()
1843 queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); in rt5651_irq()
1852 cancel_work_sync(&rt5651->jack_detect_work); in rt5651_cancel_work()
1853 cancel_delayed_work_sync(&rt5651->bp_work); in rt5651_cancel_work()
1864 switch (rt5651->jd_src) { in rt5651_enable_jack_detect()
1866 rt5651->gpiod_hp_det = gpiod_hp_det; in rt5651_enable_jack_detect()
1867 if (!rt5651->gpiod_hp_det) in rt5651_enable_jack_detect()
1874 /* active-low is normal, set inv flag for active-high */ in rt5651_enable_jack_detect()
1875 if (rt5651->jd_active_high) in rt5651_enable_jack_detect()
1889 /* active-low is normal, set inv flag for active-high */ in rt5651_enable_jack_detect()
1890 if (rt5651->jd_active_high) in rt5651_enable_jack_detect()
1904 /* active-low is normal, set inv flag for active-high */ in rt5651_enable_jack_detect()
1905 if (rt5651->jd_active_high) in rt5651_enable_jack_detect()
1917 dev_err(component->dev, "Currently only JD1_1 / JD1_2 / JD2 are supported\n"); in rt5651_enable_jack_detect()
1931 /* Set OVCD threshold current and scale-factor */ in rt5651_enable_jack_detect()
1933 0xa800 | rt5651->ovcd_sf); in rt5651_enable_jack_detect()
1941 rt5651->ovcd_th | in rt5651_enable_jack_detect()
1946 * The over-current-detect is only reliable in detecting the absence in rt5651_enable_jack_detect()
1947 * of over-current, when the mic-contact in the jack is short-circuited, in rt5651_enable_jack_detect()
1948 * the hardware periodically retries if it can apply the bias-current in rt5651_enable_jack_detect()
1949 * leading to the ovcd status flip-flopping 1-0-1 with it being 0 about in rt5651_enable_jack_detect()
1957 rt5651->hp_jack = hp_jack; in rt5651_enable_jack_detect()
1963 enable_irq(rt5651->irq); in rt5651_enable_jack_detect()
1965 queue_work(system_power_efficient_wq, &rt5651->jack_detect_work); in rt5651_enable_jack_detect()
1972 disable_irq(rt5651->irq); in rt5651_disable_jack_detect()
1978 snd_soc_jack_report(rt5651->hp_jack, 0, SND_JACK_BTN_0); in rt5651_disable_jack_detect()
1981 rt5651->hp_jack = NULL; in rt5651_disable_jack_detect()
1996 * Note on some platforms the platform code may need to add device-properties,
1999 * rather then from the i2c driver's probe function, so that the platform-code
2007 if (device_property_read_bool(component->dev, "realtek,in2-differential")) in rt5651_apply_properties()
2011 if (device_property_read_bool(component->dev, "realtek,dmic-en")) in rt5651_apply_properties()
2015 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
2016 "realtek,jack-detect-source", &val) == 0) in rt5651_apply_properties()
2017 rt5651->jd_src = val; in rt5651_apply_properties()
2019 if (device_property_read_bool(component->dev, "realtek,jack-detect-not-inverted")) in rt5651_apply_properties()
2020 rt5651->jd_active_high = true; in rt5651_apply_properties()
2024 * threshold and scale-factor are 2000µA and 0.75. For an effective in rt5651_apply_properties()
2027 rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; in rt5651_apply_properties()
2028 rt5651->ovcd_sf = RT5651_MIC_OVCD_SF_0P75; in rt5651_apply_properties()
2030 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
2031 "realtek,over-current-threshold-microamp", &val) == 0) { in rt5651_apply_properties()
2034 rt5651->ovcd_th = RT5651_MIC1_OVTH_600UA; in rt5651_apply_properties()
2037 rt5651->ovcd_th = RT5651_MIC1_OVTH_1500UA; in rt5651_apply_properties()
2040 rt5651->ovcd_th = RT5651_MIC1_OVTH_2000UA; in rt5651_apply_properties()
2043 …dev_warn(component->dev, "Warning: Invalid over-current-threshold-microamp value: %d, defaulting t… in rt5651_apply_properties()
2048 if (device_property_read_u32(component->dev, in rt5651_apply_properties()
2049 "realtek,over-current-scale-factor", &val) == 0) { in rt5651_apply_properties()
2051 rt5651->ovcd_sf = val << RT5651_MIC_OVCD_SF_SFT; in rt5651_apply_properties()
2053 …dev_warn(component->dev, "Warning: Invalid over-current-scale-factor value: %d, defaulting to 0.75… in rt5651_apply_properties()
2062 rt5651->component = component; in rt5651_probe()
2079 regcache_cache_only(rt5651->regmap, true); in rt5651_suspend()
2080 regcache_mark_dirty(rt5651->regmap); in rt5651_suspend()
2088 regcache_cache_only(rt5651->regmap, false); in rt5651_resume()
2111 .name = "rt5651-aif1",
2130 .name = "rt5651-aif2",
2208 * Note this function MUST not look at device-properties, see the comment
2217 rt5651 = devm_kzalloc(&i2c->dev, sizeof(*rt5651), in rt5651_i2c_probe()
2220 return -ENOMEM; in rt5651_i2c_probe()
2224 rt5651->regmap = devm_regmap_init_i2c(i2c, &rt5651_regmap); in rt5651_i2c_probe()
2225 if (IS_ERR(rt5651->regmap)) { in rt5651_i2c_probe()
2226 ret = PTR_ERR(rt5651->regmap); in rt5651_i2c_probe()
2227 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5651_i2c_probe()
2232 err = regmap_read(rt5651->regmap, RT5651_DEVICE_ID, &ret); in rt5651_i2c_probe()
2237 dev_err(&i2c->dev, in rt5651_i2c_probe()
2239 return -ENODEV; in rt5651_i2c_probe()
2242 regmap_write(rt5651->regmap, RT5651_RESET, 0); in rt5651_i2c_probe()
2244 ret = regmap_register_patch(rt5651->regmap, init_list, in rt5651_i2c_probe()
2247 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt5651_i2c_probe()
2249 rt5651->irq = i2c->irq; in rt5651_i2c_probe()
2250 rt5651->hp_mute = true; in rt5651_i2c_probe()
2252 INIT_DELAYED_WORK(&rt5651->bp_work, rt5651_button_press_work); in rt5651_i2c_probe()
2253 INIT_WORK(&rt5651->jack_detect_work, rt5651_jack_detect_work); in rt5651_i2c_probe()
2255 /* Make sure work is stopped on probe-error / remove */ in rt5651_i2c_probe()
2256 ret = devm_add_action_or_reset(&i2c->dev, rt5651_cancel_work, rt5651); in rt5651_i2c_probe()
2260 ret = devm_request_irq(&i2c->dev, rt5651->irq, rt5651_irq, in rt5651_i2c_probe()
2264 dev_warn(&i2c->dev, "Failed to request IRQ %d: %d\n", in rt5651_i2c_probe()
2265 rt5651->irq, ret); in rt5651_i2c_probe()
2266 rt5651->irq = -ENXIO; in rt5651_i2c_probe()
2269 ret = devm_snd_soc_register_component(&i2c->dev, in rt5651_i2c_probe()