Lines Matching +full:micbias2 +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0-only
3 * rt5663.c -- RT5663 ALSA SoC audio codec driver
24 #include <sound/soc-dapm.h>
1373 static const DECLARE_TLV_DB_SCALE(rt5663_hp_vol_tlv, -2400, 150, 0);
1374 static const DECLARE_TLV_DB_SCALE(rt5663_v2_hp_vol_tlv, -2250, 150, 0);
1375 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6525, 75, 0);
1376 static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -1725, 75, 0);
1405 /* reset in-line command */ in rt5663_enable_push_button_irq()
1412 switch (rt5663->codec_ver) { in rt5663_enable_push_button_irq()
1424 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_enable_push_button_irq()
1427 switch (rt5663->codec_ver) { in rt5663_enable_push_button_irq()
1439 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_enable_push_button_irq()
1443 /* reset in-line command */ in rt5663_enable_push_button_irq()
1454 * rt5663_v2_jack_detect - Detect headset.
1469 dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); in rt5663_v2_jack_detect()
1475 snd_soc_dapm_force_enable_pin(dapm, "MICBIAS2"); in rt5663_v2_jack_detect()
1488 dev_dbg(component->dev, "%s: MX-0011 val=%x sleep %d\n", in rt5663_v2_jack_detect()
1492 dev_dbg(component->dev, "%s val = %d\n", __func__, val); in rt5663_v2_jack_detect()
1496 rt5663->jack_type = SND_JACK_HEADSET; in rt5663_v2_jack_detect()
1501 snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); in rt5663_v2_jack_detect()
1505 rt5663->jack_type = SND_JACK_HEADPHONE; in rt5663_v2_jack_detect()
1511 if (rt5663->jack_type == SND_JACK_HEADSET) { in rt5663_v2_jack_detect()
1514 snd_soc_dapm_disable_pin(dapm, "MICBIAS2"); in rt5663_v2_jack_detect()
1519 rt5663->jack_type = 0; in rt5663_v2_jack_detect()
1522 dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); in rt5663_v2_jack_detect()
1523 return rt5663->jack_type; in rt5663_v2_jack_detect()
1527 * rt5663_jack_detect - Detect headset.
1540 dev_dbg(component->dev, "%s jack_insert:%d\n", __func__, jack_insert); in rt5663_jack_detect()
1587 regmap_read(rt5663->regmap, RT5663_INT_ST_2, &val); in rt5663_jack_detect()
1599 dev_dbg(component->dev, "%s val = %d\n", __func__, val); in rt5663_jack_detect()
1608 rt5663->jack_type = SND_JACK_HEADSET; in rt5663_jack_detect()
1611 if (rt5663->pdata.impedance_sensing_num) in rt5663_jack_detect()
1614 if (rt5663->pdata.dc_offset_l_manual_mic) { in rt5663_jack_detect()
1615 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, in rt5663_jack_detect()
1616 rt5663->pdata.dc_offset_l_manual_mic >> in rt5663_jack_detect()
1618 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, in rt5663_jack_detect()
1619 rt5663->pdata.dc_offset_l_manual_mic & in rt5663_jack_detect()
1623 if (rt5663->pdata.dc_offset_r_manual_mic) { in rt5663_jack_detect()
1624 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, in rt5663_jack_detect()
1625 rt5663->pdata.dc_offset_r_manual_mic >> in rt5663_jack_detect()
1627 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, in rt5663_jack_detect()
1628 rt5663->pdata.dc_offset_r_manual_mic & in rt5663_jack_detect()
1633 rt5663->jack_type = SND_JACK_HEADPHONE; in rt5663_jack_detect()
1638 if (rt5663->pdata.impedance_sensing_num) in rt5663_jack_detect()
1641 if (rt5663->pdata.dc_offset_l_manual) { in rt5663_jack_detect()
1642 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_2, in rt5663_jack_detect()
1643 rt5663->pdata.dc_offset_l_manual >> 16); in rt5663_jack_detect()
1644 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_3, in rt5663_jack_detect()
1645 rt5663->pdata.dc_offset_l_manual & in rt5663_jack_detect()
1649 if (rt5663->pdata.dc_offset_r_manual) { in rt5663_jack_detect()
1650 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_5, in rt5663_jack_detect()
1651 rt5663->pdata.dc_offset_r_manual >> 16); in rt5663_jack_detect()
1652 regmap_write(rt5663->regmap, RT5663_MIC_DECRO_6, in rt5663_jack_detect()
1653 rt5663->pdata.dc_offset_r_manual & in rt5663_jack_detect()
1659 if (rt5663->jack_type == SND_JACK_HEADSET) in rt5663_jack_detect()
1661 rt5663->jack_type = 0; in rt5663_jack_detect()
1667 dev_dbg(component->dev, "jack_type = %d\n", rt5663->jack_type); in rt5663_jack_detect()
1668 return rt5663->jack_type; in rt5663_jack_detect()
1676 for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { in rt5663_impedance_sensing()
1677 if (rt5663->imp_table[i].vol == 7) in rt5663_impedance_sensing()
1681 if (rt5663->jack_type == SND_JACK_HEADSET) { in rt5663_impedance_sensing()
1683 rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); in rt5663_impedance_sensing()
1685 rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); in rt5663_impedance_sensing()
1687 rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); in rt5663_impedance_sensing()
1689 rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); in rt5663_impedance_sensing()
1692 rt5663->imp_table[i].dc_offset_l_manual >> 16); in rt5663_impedance_sensing()
1694 rt5663->imp_table[i].dc_offset_l_manual & 0xffff); in rt5663_impedance_sensing()
1696 rt5663->imp_table[i].dc_offset_r_manual >> 16); in rt5663_impedance_sensing()
1698 rt5663->imp_table[i].dc_offset_r_manual & 0xffff); in rt5663_impedance_sensing()
1808 for (i = 0; i < rt5663->pdata.impedance_sensing_num; i++) { in rt5663_impedance_sensing()
1809 if (value >= rt5663->imp_table[i].imp_min && in rt5663_impedance_sensing()
1810 value <= rt5663->imp_table[i].imp_max) in rt5663_impedance_sensing()
1815 rt5663->imp_table[i].vol); in rt5663_impedance_sensing()
1817 rt5663->imp_table[i].vol); in rt5663_impedance_sensing()
1819 if (rt5663->jack_type == SND_JACK_HEADSET) { in rt5663_impedance_sensing()
1821 rt5663->imp_table[i].dc_offset_l_manual_mic >> 16); in rt5663_impedance_sensing()
1823 rt5663->imp_table[i].dc_offset_l_manual_mic & 0xffff); in rt5663_impedance_sensing()
1825 rt5663->imp_table[i].dc_offset_r_manual_mic >> 16); in rt5663_impedance_sensing()
1827 rt5663->imp_table[i].dc_offset_r_manual_mic & 0xffff); in rt5663_impedance_sensing()
1830 rt5663->imp_table[i].dc_offset_l_manual >> 16); in rt5663_impedance_sensing()
1832 rt5663->imp_table[i].dc_offset_l_manual & 0xffff); in rt5663_impedance_sensing()
1834 rt5663->imp_table[i].dc_offset_r_manual >> 16); in rt5663_impedance_sensing()
1836 rt5663->imp_table[i].dc_offset_r_manual & 0xffff); in rt5663_impedance_sensing()
1847 dev_dbg(component->dev, "%s: val=0x%x\n", __func__, val); in rt5663_button_detect()
1858 dev_dbg(regmap_get_device(rt5663->regmap), "%s IRQ queue work\n", in rt5663_irq()
1861 queue_delayed_work(system_wq, &rt5663->jack_detect_work, in rt5663_irq()
1872 rt5663->hs_jack = hs_jack; in rt5663_set_jack_detect()
1884 dev_dbg(component->dev, "%s val=%x\n", __func__, val); in rt5663_check_jd_status()
1887 switch (rt5663->codec_ver) { in rt5663_check_jd_status()
1893 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_check_jd_status()
1903 struct snd_soc_component *component = rt5663->component; in rt5663_jack_detect_work()
1911 if (rt5663->jack_type == 0) { in rt5663_jack_detect_work()
1913 switch (rt5663->codec_ver) { in rt5663_jack_detect_work()
1916 rt5663->component, 1); in rt5663_jack_detect_work()
1919 report = rt5663_jack_detect(rt5663->component, 1); in rt5663_jack_detect_work()
1920 if (rt5663->pdata.impedance_sensing_num) in rt5663_jack_detect_work()
1921 rt5663_impedance_sensing(rt5663->component); in rt5663_jack_detect_work()
1924 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_jack_detect_work()
1932 btn_type = rt5663_button_detect(rt5663->component); in rt5663_jack_detect_work()
1965 dev_err(rt5663->component->dev, in rt5663_jack_detect_work()
1972 report = rt5663->jack_type; in rt5663_jack_detect_work()
1974 &rt5663->jd_unplug_work); in rt5663_jack_detect_work()
1977 &rt5663->jd_unplug_work, in rt5663_jack_detect_work()
1983 switch (rt5663->codec_ver) { in rt5663_jack_detect_work()
1985 report = rt5663_v2_jack_detect(rt5663->component, 0); in rt5663_jack_detect_work()
1988 report = rt5663_jack_detect(rt5663->component, 0); in rt5663_jack_detect_work()
1991 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_jack_detect_work()
1994 dev_dbg(component->dev, "%s jack report: 0x%04x\n", __func__, report); in rt5663_jack_detect_work()
1995 snd_soc_jack_report(rt5663->hs_jack, report, SND_JACK_HEADSET | in rt5663_jack_detect_work()
2004 struct snd_soc_component *component = rt5663->component; in rt5663_jd_unplug_work()
2011 switch (rt5663->codec_ver) { in rt5663_jd_unplug_work()
2013 rt5663_v2_jack_detect(rt5663->component, 0); in rt5663_jd_unplug_work()
2016 rt5663_jack_detect(rt5663->component, 0); in rt5663_jd_unplug_work()
2019 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_jd_unplug_work()
2022 snd_soc_jack_report(rt5663->hs_jack, 0, SND_JACK_HEADSET | in rt5663_jd_unplug_work()
2026 queue_delayed_work(system_wq, &rt5663->jd_unplug_work, in rt5663_jd_unplug_work()
2073 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_is_sys_clk_from_pll()
2087 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_is_using_asrc()
2090 if (rt5663->codec_ver == CODEC_VER_1) { in rt5663_is_using_asrc()
2091 switch (w->shift) { in rt5663_is_using_asrc()
2104 switch (w->shift) { in rt5663_is_using_asrc()
2129 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in rt5663_i2s_use_asrc()
2135 switch (rt5663->codec_ver) { in rt5663_i2s_use_asrc()
2145 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_i2s_use_asrc()
2150 if (rt5663->sysclk > rt5663->lrck * 384) in rt5663_i2s_use_asrc()
2153 dev_err(component->dev, "sysclk < 384 x fs, disable i2s asrc\n"); in rt5663_i2s_use_asrc()
2159 * rt5663_sel_asrc_clk_src - select ASRC clock source for a set of filters
2187 return -EINVAL; in rt5663_sel_asrc_clk_src()
2196 switch (rt5663->codec_ver) { in rt5663_sel_asrc_clk_src()
2206 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_sel_asrc_clk_src()
2321 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_hp_event()
2326 if (rt5663->codec_ver == CODEC_VER_1) { in rt5663_hp_event()
2354 if (rt5663->codec_ver == CODEC_VER_1) { in rt5663_hp_event()
2379 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_charge_pump_event()
2384 if (rt5663->codec_ver == CODEC_VER_0) { in rt5663_charge_pump_event()
2393 if (rt5663->codec_ver == CODEC_VER_0) { in rt5663_charge_pump_event()
2409 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_bst2_power()
2433 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in rt5663_pre_div_power()
2460 SND_SOC_DAPM_MICBIAS("MICBIAS2", RT5663_PWR_ANLG_2,
2689 { "MICBIAS2", NULL, "LDO2" },
2765 struct snd_soc_component *component = dai->component; in rt5663_hw_params()
2770 rt5663->lrck = params_rate(params); in rt5663_hw_params()
2772 dev_dbg(dai->dev, "bclk is %dHz and sysclk is %dHz\n", in rt5663_hw_params()
2773 rt5663->lrck, rt5663->sysclk); in rt5663_hw_params()
2775 pre_div = rl6231_get_clk_info(rt5663->sysclk, rt5663->lrck); in rt5663_hw_params()
2777 dev_err(component->dev, "Unsupported clock setting %d for DAI %d\n", in rt5663_hw_params()
2778 rt5663->lrck, dai->id); in rt5663_hw_params()
2779 return -EINVAL; in rt5663_hw_params()
2782 dev_dbg(dai->dev, "pre_div is %d for iis %d\n", pre_div, dai->id); in rt5663_hw_params()
2798 return -EINVAL; in rt5663_hw_params()
2812 struct snd_soc_component *component = dai->component; in rt5663_set_dai_fmt()
2822 return -EINVAL; in rt5663_set_dai_fmt()
2832 return -EINVAL; in rt5663_set_dai_fmt()
2848 return -EINVAL; in rt5663_set_dai_fmt()
2860 struct snd_soc_component *component = dai->component; in rt5663_set_dai_sysclk()
2864 if (freq == rt5663->sysclk && clk_id == rt5663->sysclk_src) in rt5663_set_dai_sysclk()
2878 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt5663_set_dai_sysclk()
2879 return -EINVAL; in rt5663_set_dai_sysclk()
2883 rt5663->sysclk = freq; in rt5663_set_dai_sysclk()
2884 rt5663->sysclk_src = clk_id; in rt5663_set_dai_sysclk()
2886 dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", in rt5663_set_dai_sysclk()
2895 struct snd_soc_component *component = dai->component; in rt5663_set_dai_pll()
2901 if (source == rt5663->pll_src && freq_in == rt5663->pll_in && in rt5663_set_dai_pll()
2902 freq_out == rt5663->pll_out) in rt5663_set_dai_pll()
2906 dev_dbg(component->dev, "PLL disabled\n"); in rt5663_set_dai_pll()
2908 rt5663->pll_in = 0; in rt5663_set_dai_pll()
2909 rt5663->pll_out = 0; in rt5663_set_dai_pll()
2915 switch (rt5663->codec_ver) { in rt5663_set_dai_pll()
2925 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_set_dai_pll()
2926 return -EINVAL; in rt5663_set_dai_pll()
2937 dev_err(component->dev, "Unknown PLL source %d\n", source); in rt5663_set_dai_pll()
2938 return -EINVAL; in rt5663_set_dai_pll()
2944 dev_err(component->dev, "Unsupport input clock %d\n", freq_in); in rt5663_set_dai_pll()
2948 dev_dbg(component->dev, "bypass=%d m=%d n=%d k=%d\n", pll_code.m_bp, in rt5663_set_dai_pll()
2958 rt5663->pll_in = freq_in; in rt5663_set_dai_pll()
2959 rt5663->pll_out = freq_out; in rt5663_set_dai_pll()
2960 rt5663->pll_src = source; in rt5663_set_dai_pll()
2968 struct snd_soc_component *component = dai->component; in rt5663_set_tdm_slot()
2991 return -EINVAL; in rt5663_set_tdm_slot()
3010 return -EINVAL; in rt5663_set_tdm_slot()
3013 switch (rt5663->codec_ver) { in rt5663_set_tdm_slot()
3021 dev_err(component->dev, "Unknown CODEC Version\n"); in rt5663_set_tdm_slot()
3022 return -EINVAL; in rt5663_set_tdm_slot()
3034 struct snd_soc_component *component = dai->component; in rt5663_set_bclk_ratio()
3038 dev_dbg(component->dev, "%s ratio = %d\n", __func__, ratio); in rt5663_set_bclk_ratio()
3040 if (rt5663->codec_ver == CODEC_VER_1) in rt5663_set_bclk_ratio()
3067 dev_err(component->dev, "Invalid ratio!\n"); in rt5663_set_bclk_ratio()
3068 return -EINVAL; in rt5663_set_bclk_ratio()
3087 if (rt5663->codec_ver == CODEC_VER_1) { in rt5663_set_bias_level()
3100 if (rt5663->codec_ver == CODEC_VER_1) in rt5663_set_bias_level()
3110 if (rt5663->codec_ver == CODEC_VER_1) { in rt5663_set_bias_level()
3120 if (rt5663->jack_type != SND_JACK_HEADSET) in rt5663_set_bias_level()
3145 rt5663->component = component; in rt5663_probe()
3147 switch (rt5663->codec_ver) { in rt5663_probe()
3168 if (!rt5663->imp_table) in rt5663_probe()
3181 regmap_write(rt5663->regmap, RT5663_RESET, 0); in rt5663_remove()
3189 regcache_cache_only(rt5663->regmap, true); in rt5663_suspend()
3190 regcache_mark_dirty(rt5663->regmap); in rt5663_suspend()
3199 regcache_cache_only(rt5663->regmap, false); in rt5663_resume()
3200 regcache_sync(rt5663->regmap); in rt5663_resume()
3226 .name = "rt5663-aif",
3324 regmap_write(rt5663->regmap, RT5663_BIAS_CUR_8, 0xa402); in rt5663_v2_calibrate()
3325 regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x0100); in rt5663_v2_calibrate()
3326 regmap_write(rt5663->regmap, RT5663_RECMIX, 0x4040); in rt5663_v2_calibrate()
3327 regmap_write(rt5663->regmap, RT5663_DIG_MISC, 0x0001); in rt5663_v2_calibrate()
3328 regmap_write(rt5663->regmap, RT5663_RC_CLK, 0x0380); in rt5663_v2_calibrate()
3329 regmap_write(rt5663->regmap, RT5663_GLB_CLK, 0x8000); in rt5663_v2_calibrate()
3330 regmap_write(rt5663->regmap, RT5663_ADDA_CLK_1, 0x1000); in rt5663_v2_calibrate()
3331 regmap_write(rt5663->regmap, RT5663_CHOP_DAC_L, 0x3030); in rt5663_v2_calibrate()
3332 regmap_write(rt5663->regmap, RT5663_CALIB_ADC, 0x3c05); in rt5663_v2_calibrate()
3333 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xa23e); in rt5663_v2_calibrate()
3335 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xf23e); in rt5663_v2_calibrate()
3336 regmap_write(rt5663->regmap, RT5663_HP_CALIB_2, 0x0321); in rt5663_v2_calibrate()
3337 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1, 0xfc00); in rt5663_v2_calibrate()
3345 regmap_write(rt5663->regmap, RT5663_RESET, 0x0000); in rt5663_calibrate()
3347 regmap_write(rt5663->regmap, RT5663_ANA_BIAS_CUR_4, 0x00a1); in rt5663_calibrate()
3348 regmap_write(rt5663->regmap, RT5663_RC_CLK, 0x0380); in rt5663_calibrate()
3349 regmap_write(rt5663->regmap, RT5663_GLB_CLK, 0x8000); in rt5663_calibrate()
3350 regmap_write(rt5663->regmap, RT5663_ADDA_CLK_1, 0x1000); in rt5663_calibrate()
3351 regmap_write(rt5663->regmap, RT5663_VREF_RECMIX, 0x0032); in rt5663_calibrate()
3352 regmap_write(rt5663->regmap, RT5663_HP_IMP_SEN_19, 0x000c); in rt5663_calibrate()
3353 regmap_write(rt5663->regmap, RT5663_DUMMY_1, 0x0324); in rt5663_calibrate()
3354 regmap_write(rt5663->regmap, RT5663_DIG_MISC, 0x8001); in rt5663_calibrate()
3355 regmap_write(rt5663->regmap, RT5663_VREFADJ_OP, 0x0f28); in rt5663_calibrate()
3356 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xa23b); in rt5663_calibrate()
3358 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0xf23b); in rt5663_calibrate()
3359 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x8000); in rt5663_calibrate()
3360 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x0008); in rt5663_calibrate()
3361 regmap_write(rt5663->regmap, RT5663_PRE_DIV_GATING_1, 0xffff); in rt5663_calibrate()
3362 regmap_write(rt5663->regmap, RT5663_PRE_DIV_GATING_2, 0xffff); in rt5663_calibrate()
3363 regmap_write(rt5663->regmap, RT5663_CBJ_1, 0x8c10); in rt5663_calibrate()
3364 regmap_write(rt5663->regmap, RT5663_IL_CMD_2, 0x00c1); in rt5663_calibrate()
3365 regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_1, 0xb880); in rt5663_calibrate()
3366 regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_2, 0x4110); in rt5663_calibrate()
3367 regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_2, 0x4118); in rt5663_calibrate()
3371 regmap_read(rt5663->regmap, RT5663_INT_ST_2, &value); in rt5663_calibrate()
3381 regmap_write(rt5663->regmap, RT5663_HP_IMP_SEN_19, 0x0000); in rt5663_calibrate()
3382 regmap_write(rt5663->regmap, RT5663_DEPOP_2, 0x3003); in rt5663_calibrate()
3383 regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x0038); in rt5663_calibrate()
3384 regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x003b); in rt5663_calibrate()
3385 regmap_write(rt5663->regmap, RT5663_PWR_DIG_2, 0x8400); in rt5663_calibrate()
3386 regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x8df8); in rt5663_calibrate()
3387 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x8003); in rt5663_calibrate()
3388 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_3, 0x018c); in rt5663_calibrate()
3389 regmap_write(rt5663->regmap, RT5663_HP_CHARGE_PUMP_1, 0x1e32); in rt5663_calibrate()
3390 regmap_write(rt5663->regmap, RT5663_DUMMY_2, 0x8089); in rt5663_calibrate()
3391 regmap_write(rt5663->regmap, RT5663_DACREF_LDO, 0x3b0b); in rt5663_calibrate()
3393 regmap_write(rt5663->regmap, RT5663_STO_DAC_MIXER, 0x0000); in rt5663_calibrate()
3394 regmap_write(rt5663->regmap, RT5663_BYPASS_STO_DAC, 0x000c); in rt5663_calibrate()
3395 regmap_write(rt5663->regmap, RT5663_HP_BIAS, 0xafaa); in rt5663_calibrate()
3396 regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_1, 0x2224); in rt5663_calibrate()
3397 regmap_write(rt5663->regmap, RT5663_HP_OUT_EN, 0x8088); in rt5663_calibrate()
3398 regmap_write(rt5663->regmap, RT5663_STO_DRE_9, 0x0017); in rt5663_calibrate()
3399 regmap_write(rt5663->regmap, RT5663_STO_DRE_10, 0x0017); in rt5663_calibrate()
3400 regmap_write(rt5663->regmap, RT5663_STO1_ADC_MIXER, 0x4040); in rt5663_calibrate()
3401 regmap_write(rt5663->regmap, RT5663_CHOP_ADC, 0x3000); in rt5663_calibrate()
3402 regmap_write(rt5663->regmap, RT5663_RECMIX, 0x0005); in rt5663_calibrate()
3403 regmap_write(rt5663->regmap, RT5663_ADDA_RST, 0xc000); in rt5663_calibrate()
3404 regmap_write(rt5663->regmap, RT5663_STO1_HPF_ADJ1, 0x3320); in rt5663_calibrate()
3405 regmap_write(rt5663->regmap, RT5663_HP_CALIB_2, 0x00c9); in rt5663_calibrate()
3406 regmap_write(rt5663->regmap, RT5663_DUMMY_1, 0x004c); in rt5663_calibrate()
3407 regmap_write(rt5663->regmap, RT5663_ANA_BIAS_CUR_1, 0x1111); in rt5663_calibrate()
3408 regmap_write(rt5663->regmap, RT5663_BIAS_CUR_8, 0x4402); in rt5663_calibrate()
3409 regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_2, 0x3311); in rt5663_calibrate()
3410 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1, 0x0069); in rt5663_calibrate()
3411 regmap_write(rt5663->regmap, RT5663_HP_CALIB_3, 0x06ce); in rt5663_calibrate()
3412 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0x6800); in rt5663_calibrate()
3413 regmap_write(rt5663->regmap, RT5663_CHARGE_PUMP_2, 0x1100); in rt5663_calibrate()
3414 regmap_write(rt5663->regmap, RT5663_HP_CALIB_7, 0x0057); in rt5663_calibrate()
3415 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0xe800); in rt5663_calibrate()
3419 regmap_read(rt5663->regmap, RT5663_HP_CALIB_1_1, &value); in rt5663_calibrate()
3430 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0x6200); in rt5663_calibrate()
3431 regmap_write(rt5663->regmap, RT5663_HP_CALIB_7, 0x0059); in rt5663_calibrate()
3432 regmap_write(rt5663->regmap, RT5663_HP_CALIB_1_1, 0xe200); in rt5663_calibrate()
3436 regmap_read(rt5663->regmap, RT5663_HP_CALIB_1_1, &value); in rt5663_calibrate()
3447 regmap_write(rt5663->regmap, RT5663_EM_JACK_TYPE_1, 0xb8e0); in rt5663_calibrate()
3449 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_1, 0x003b); in rt5663_calibrate()
3451 regmap_write(rt5663->regmap, RT5663_PWR_DIG_1, 0x0000); in rt5663_calibrate()
3453 regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x000b); in rt5663_calibrate()
3455 regmap_write(rt5663->regmap, RT5663_DEPOP_1, 0x0008); in rt5663_calibrate()
3457 regmap_write(rt5663->regmap, RT5663_PWR_ANLG_2, 0x0000); in rt5663_calibrate()
3466 &rt5663->pdata.dc_offset_l_manual); in rt5663_parse_dp()
3468 &rt5663->pdata.dc_offset_r_manual); in rt5663_parse_dp()
3470 &rt5663->pdata.dc_offset_l_manual_mic); in rt5663_parse_dp()
3472 &rt5663->pdata.dc_offset_r_manual_mic); in rt5663_parse_dp()
3474 &rt5663->pdata.impedance_sensing_num); in rt5663_parse_dp()
3476 if (rt5663->pdata.impedance_sensing_num) { in rt5663_parse_dp()
3478 rt5663->pdata.impedance_sensing_num; in rt5663_parse_dp()
3479 rt5663->imp_table = devm_kzalloc(dev, table_size, GFP_KERNEL); in rt5663_parse_dp()
3482 (u32 *)rt5663->imp_table, table_size); in rt5663_parse_dp()
3491 struct rt5663_platform_data *pdata = dev_get_platdata(&i2c->dev); in rt5663_i2c_probe()
3497 rt5663 = devm_kzalloc(&i2c->dev, sizeof(struct rt5663_priv), in rt5663_i2c_probe()
3501 return -ENOMEM; in rt5663_i2c_probe()
3506 rt5663->pdata = *pdata; in rt5663_i2c_probe()
3508 rt5663_parse_dp(rt5663, &i2c->dev); in rt5663_i2c_probe()
3510 for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) in rt5663_i2c_probe()
3511 rt5663->supplies[i].supply = rt5663_supply_names[i]; in rt5663_i2c_probe()
3513 ret = devm_regulator_bulk_get(&i2c->dev, in rt5663_i2c_probe()
3514 ARRAY_SIZE(rt5663->supplies), in rt5663_i2c_probe()
3515 rt5663->supplies); in rt5663_i2c_probe()
3517 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in rt5663_i2c_probe()
3522 for (i = 0; i < ARRAY_SIZE(rt5663->supplies); i++) { in rt5663_i2c_probe()
3523 ret = regulator_set_load(rt5663->supplies[i].consumer, in rt5663_i2c_probe()
3526 dev_err(&i2c->dev, in rt5663_i2c_probe()
3528 rt5663->supplies[i].supply, ret); in rt5663_i2c_probe()
3533 ret = regulator_bulk_enable(ARRAY_SIZE(rt5663->supplies), in rt5663_i2c_probe()
3534 rt5663->supplies); in rt5663_i2c_probe()
3537 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in rt5663_i2c_probe()
3545 dev_err(&i2c->dev, "Failed to allocate temp register map: %d\n", in rt5663_i2c_probe()
3552 dev_err(&i2c->dev, in rt5663_i2c_probe()
3561 rt5663->regmap = devm_regmap_init_i2c(i2c, &rt5663_v2_regmap); in rt5663_i2c_probe()
3562 rt5663->codec_ver = CODEC_VER_1; in rt5663_i2c_probe()
3565 rt5663->regmap = devm_regmap_init_i2c(i2c, &rt5663_regmap); in rt5663_i2c_probe()
3566 rt5663->codec_ver = CODEC_VER_0; in rt5663_i2c_probe()
3569 dev_err(&i2c->dev, in rt5663_i2c_probe()
3572 ret = -ENODEV; in rt5663_i2c_probe()
3576 if (IS_ERR(rt5663->regmap)) { in rt5663_i2c_probe()
3577 ret = PTR_ERR(rt5663->regmap); in rt5663_i2c_probe()
3578 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt5663_i2c_probe()
3584 regmap_write(rt5663->regmap, RT5663_RESET, 0); in rt5663_i2c_probe()
3585 regcache_cache_bypass(rt5663->regmap, true); in rt5663_i2c_probe()
3586 switch (rt5663->codec_ver) { in rt5663_i2c_probe()
3594 dev_err(&i2c->dev, "%s:Unknown codec type\n", __func__); in rt5663_i2c_probe()
3596 regcache_cache_bypass(rt5663->regmap, false); in rt5663_i2c_probe()
3597 regmap_write(rt5663->regmap, RT5663_RESET, 0); in rt5663_i2c_probe()
3598 dev_dbg(&i2c->dev, "calibrate done\n"); in rt5663_i2c_probe()
3600 switch (rt5663->codec_ver) { in rt5663_i2c_probe()
3604 ret = regmap_register_patch(rt5663->regmap, rt5663_patch_list, in rt5663_i2c_probe()
3607 dev_warn(&i2c->dev, in rt5663_i2c_probe()
3611 dev_err(&i2c->dev, "%s:Unknown codec type\n", __func__); in rt5663_i2c_probe()
3615 regmap_update_bits(rt5663->regmap, RT5663_GPIO_1, RT5663_GP1_PIN_MASK, in rt5663_i2c_probe()
3618 regmap_update_bits(rt5663->regmap, RT5663_IL_CMD_5, in rt5663_i2c_probe()
3621 switch (rt5663->codec_ver) { in rt5663_i2c_probe()
3623 regmap_write(rt5663->regmap, RT5663_BIAS_CUR_8, 0xa402); in rt5663_i2c_probe()
3625 regmap_update_bits(rt5663->regmap, RT5663_AUTO_1MRC_CLK, in rt5663_i2c_probe()
3628 regmap_update_bits(rt5663->regmap, RT5663_PWR_ANLG_2, in rt5663_i2c_probe()
3630 regmap_update_bits(rt5663->regmap, RT5663_IRQ_1, in rt5663_i2c_probe()
3633 regmap_update_bits(rt5663->regmap, RT5663_HP_LOGIC_2, in rt5663_i2c_probe()
3635 regmap_update_bits(rt5663->regmap, RT5663_RECMIX, in rt5663_i2c_probe()
3640 regmap_update_bits(rt5663->regmap, RT5663_GPIO_2, in rt5663_i2c_probe()
3642 regmap_update_bits(rt5663->regmap, RT5663_GPIO_3, in rt5663_i2c_probe()
3644 regmap_update_bits(rt5663->regmap, RT5663_PWR_ANLG_1, in rt5663_i2c_probe()
3649 regmap_update_bits(rt5663->regmap, RT5663_DIG_MISC, in rt5663_i2c_probe()
3651 regmap_update_bits(rt5663->regmap, RT5663_AUTO_1MRC_CLK, in rt5663_i2c_probe()
3653 regmap_update_bits(rt5663->regmap, RT5663_IRQ_1, in rt5663_i2c_probe()
3655 regmap_update_bits(rt5663->regmap, RT5663_GPIO_1, in rt5663_i2c_probe()
3657 regmap_write(rt5663->regmap, RT5663_VREF_RECMIX, 0x0032); in rt5663_i2c_probe()
3658 regmap_update_bits(rt5663->regmap, RT5663_GPIO_2, in rt5663_i2c_probe()
3661 regmap_update_bits(rt5663->regmap, RT5663_RECMIX, in rt5663_i2c_probe()
3663 regmap_update_bits(rt5663->regmap, RT5663_TDM_2, in rt5663_i2c_probe()
3668 dev_err(&i2c->dev, "%s:Unknown codec type\n", __func__); in rt5663_i2c_probe()
3671 INIT_DELAYED_WORK(&rt5663->jack_detect_work, rt5663_jack_detect_work); in rt5663_i2c_probe()
3672 INIT_DELAYED_WORK(&rt5663->jd_unplug_work, rt5663_jd_unplug_work); in rt5663_i2c_probe()
3674 if (i2c->irq) { in rt5663_i2c_probe()
3675 ret = request_irq(i2c->irq, rt5663_irq, in rt5663_i2c_probe()
3679 dev_err(&i2c->dev, "%s Failed to reguest IRQ: %d\n", in rt5663_i2c_probe()
3685 ret = devm_snd_soc_register_component(&i2c->dev, in rt5663_i2c_probe()
3700 if (i2c->irq) in rt5663_i2c_probe()
3701 free_irq(i2c->irq, rt5663); in rt5663_i2c_probe()
3703 regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies); in rt5663_i2c_probe()
3711 if (i2c->irq) in rt5663_i2c_remove()
3712 free_irq(i2c->irq, rt5663); in rt5663_i2c_remove()
3714 regulator_bulk_disable(ARRAY_SIZE(rt5663->supplies), rt5663->supplies); in rt5663_i2c_remove()
3723 regmap_write(rt5663->regmap, RT5663_RESET, 0); in rt5663_i2c_shutdown()