Lines Matching refs:rt5682s
64 static void rt5682s_apply_patch_list(struct rt5682s_priv *rt5682s, in rt5682s_apply_patch_list() argument
69 ret = regmap_multi_reg_write(rt5682s->regmap, patch_list, ARRAY_SIZE(patch_list)); in rt5682s_apply_patch_list()
622 static void rt5682s_reset(struct rt5682s_priv *rt5682s) in rt5682s_reset() argument
624 regmap_write(rt5682s->regmap, RT5682S_RESET, 0); in rt5682s_reset()
649 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_sar_power_mode() local
651 mutex_lock(&rt5682s->sar_mutex); in rt5682s_sar_power_mode()
698 mutex_unlock(&rt5682s->sar_mutex); in rt5682s_sar_power_mode()
742 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_headset_detect() local
809 if (!rt5682s->wclk_enabled) { in rt5682s_headset_detect()
830 struct rt5682s_priv *rt5682s = in rt5682s_jack_detect_handler() local
835 if (!rt5682s->component || in rt5682s_jack_detect_handler()
836 !snd_soc_card_is_instantiated(rt5682s->component->card)) { in rt5682s_jack_detect_handler()
839 &rt5682s->jack_detect_work, msecs_to_jiffies(15)); in rt5682s_jack_detect_handler()
843 dapm = snd_soc_component_get_dapm(rt5682s->component); in rt5682s_jack_detect_handler()
846 mutex_lock(&rt5682s->calibrate_mutex); in rt5682s_jack_detect_handler()
847 mutex_lock(&rt5682s->wclk_mutex); in rt5682s_jack_detect_handler()
849 val = snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL) in rt5682s_jack_detect_handler()
853 if (rt5682s->jack_type == 0) { in rt5682s_jack_detect_handler()
855 rt5682s->jack_type = rt5682s_headset_detect(rt5682s->component, 1); in rt5682s_jack_detect_handler()
856 rt5682s->irq_work_delay_time = 0; in rt5682s_jack_detect_handler()
857 } else if ((rt5682s->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) { in rt5682s_jack_detect_handler()
859 rt5682s->jack_type = SND_JACK_HEADSET; in rt5682s_jack_detect_handler()
860 btn_type = rt5682s_button_detect(rt5682s->component); in rt5682s_jack_detect_handler()
872 rt5682s->jack_type |= SND_JACK_BTN_0; in rt5682s_jack_detect_handler()
877 rt5682s->jack_type |= SND_JACK_BTN_1; in rt5682s_jack_detect_handler()
882 rt5682s->jack_type |= SND_JACK_BTN_2; in rt5682s_jack_detect_handler()
887 rt5682s->jack_type |= SND_JACK_BTN_3; in rt5682s_jack_detect_handler()
892 dev_err(rt5682s->component->dev, in rt5682s_jack_detect_handler()
899 rt5682s->jack_type = rt5682s_headset_detect(rt5682s->component, 0); in rt5682s_jack_detect_handler()
900 rt5682s->irq_work_delay_time = 50; in rt5682s_jack_detect_handler()
903 mutex_unlock(&rt5682s->wclk_mutex); in rt5682s_jack_detect_handler()
904 mutex_unlock(&rt5682s->calibrate_mutex); in rt5682s_jack_detect_handler()
907 snd_soc_jack_report(rt5682s->hs_jack, rt5682s->jack_type, in rt5682s_jack_detect_handler()
911 if (rt5682s->jack_type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | in rt5682s_jack_detect_handler()
913 schedule_delayed_work(&rt5682s->jd_check_work, 0); in rt5682s_jack_detect_handler()
915 cancel_delayed_work_sync(&rt5682s->jd_check_work); in rt5682s_jack_detect_handler()
920 struct rt5682s_priv *rt5682s = in rt5682s_jd_check_handler() local
923 if (snd_soc_component_read(rt5682s->component, RT5682S_AJD1_CTRL) & RT5682S_JDH_RS_MASK) { in rt5682s_jd_check_handler()
925 schedule_delayed_work(&rt5682s->jack_detect_work, 0); in rt5682s_jd_check_handler()
927 schedule_delayed_work(&rt5682s->jd_check_work, 500); in rt5682s_jd_check_handler()
933 struct rt5682s_priv *rt5682s = data; in rt5682s_irq() local
935 mod_delayed_work(system_power_efficient_wq, &rt5682s->jack_detect_work, in rt5682s_irq()
936 msecs_to_jiffies(rt5682s->irq_work_delay_time)); in rt5682s_irq()
944 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_jack_detect() local
947 rt5682s->hs_jack = hs_jack; in rt5682s_set_jack_detect()
950 regmap_update_bits(rt5682s->regmap, RT5682S_IRQ_CTRL_2, in rt5682s_set_jack_detect()
952 regmap_update_bits(rt5682s->regmap, RT5682S_RC_CLK_CTRL, in rt5682s_set_jack_detect()
954 cancel_delayed_work_sync(&rt5682s->jack_detect_work); in rt5682s_set_jack_detect()
959 switch (rt5682s->pdata.jd_src) { in rt5682s_set_jack_detect()
961 regmap_update_bits(rt5682s->regmap, RT5682S_CBJ_CTRL_5, in rt5682s_set_jack_detect()
963 regmap_update_bits(rt5682s->regmap, RT5682S_CBJ_CTRL_2, in rt5682s_set_jack_detect()
965 regmap_update_bits(rt5682s->regmap, RT5682S_CBJ_CTRL_1, in rt5682s_set_jack_detect()
970 regmap_update_bits(rt5682s->regmap, RT5682S_SAR_IL_CMD_1, in rt5682s_set_jack_detect()
972 regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1, in rt5682s_set_jack_detect()
974 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_ANLG_3, in rt5682s_set_jack_detect()
976 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_ANLG_2, in rt5682s_set_jack_detect()
978 regmap_update_bits(rt5682s->regmap, RT5682S_RC_CLK_CTRL, in rt5682s_set_jack_detect()
980 regmap_update_bits(rt5682s->regmap, RT5682S_IRQ_CTRL_2, in rt5682s_set_jack_detect()
983 regmap_update_bits(rt5682s->regmap, RT5682S_4BTN_IL_CMD_4, in rt5682s_set_jack_detect()
986 regmap_update_bits(rt5682s->regmap, RT5682S_4BTN_IL_CMD_5, in rt5682s_set_jack_detect()
989 regmap_update_bits(rt5682s->regmap, RT5682S_4BTN_IL_CMD_6, in rt5682s_set_jack_detect()
992 regmap_update_bits(rt5682s->regmap, RT5682S_4BTN_IL_CMD_7, in rt5682s_set_jack_detect()
997 &rt5682s->jack_detect_work, msecs_to_jiffies(250)); in rt5682s_set_jack_detect()
1001 regmap_update_bits(rt5682s->regmap, RT5682S_IRQ_CTRL_2, in rt5682s_set_jack_detect()
1003 regmap_update_bits(rt5682s->regmap, RT5682S_RC_CLK_CTRL, in rt5682s_set_jack_detect()
1084 static int rt5682s_div_sel(struct rt5682s_priv *rt5682s, in rt5682s_div_sel() argument
1089 if (rt5682s->sysclk < target) { in rt5682s_div_sel()
1090 dev_err(rt5682s->component->dev, in rt5682s_div_sel()
1091 "sysclk rate %d is too low\n", rt5682s->sysclk); in rt5682s_div_sel()
1096 dev_dbg(rt5682s->component->dev, "div[%d]=%d\n", i, div[i]); in rt5682s_div_sel()
1097 if (target * div[i] == rt5682s->sysclk) in rt5682s_div_sel()
1099 if (target * div[i + 1] > rt5682s->sysclk) { in rt5682s_div_sel()
1100 dev_dbg(rt5682s->component->dev, in rt5682s_div_sel()
1101 "can't find div for sysclk %d\n", rt5682s->sysclk); in rt5682s_div_sel()
1106 if (target * div[i] < rt5682s->sysclk) in rt5682s_div_sel()
1107 dev_err(rt5682s->component->dev, in rt5682s_div_sel()
1108 "sysclk rate %d is too high\n", rt5682s->sysclk); in rt5682s_div_sel()
1143 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in set_dmic_clk() local
1147 if (rt5682s->pdata.dmic_clk_rate) in set_dmic_clk()
1148 dmic_clk_rate = rt5682s->pdata.dmic_clk_rate; in set_dmic_clk()
1150 idx = rt5682s_div_sel(rt5682s, dmic_clk_rate, div, ARRAY_SIZE(div)); in set_dmic_clk()
1159 static int rt5682s_set_pllb_power(struct rt5682s_priv *rt5682s, int on) in rt5682s_set_pllb_power() argument
1161 struct snd_soc_component *component = rt5682s->component; in rt5682s_set_pllb_power()
1182 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in set_pllb_event() local
1185 if (rt5682s->wclk_enabled) in set_pllb_event()
1191 rt5682s_set_pllb_power(rt5682s, on); in set_pllb_event()
1196 static void rt5682s_set_filter_clk(struct rt5682s_priv *rt5682s, int reg, int ref) in rt5682s_set_filter_clk() argument
1198 struct snd_soc_component *component = rt5682s->component; in rt5682s_set_filter_clk()
1203 idx = rt5682s_div_sel(rt5682s, ref, div_f, ARRAY_SIZE(div_f)); in rt5682s_set_filter_clk()
1210 if (rt5682s->sysclk <= 12288000 * div_o[idx]) in rt5682s_set_filter_clk()
1223 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in set_filter_clk() local
1230 ref = 256 * rt5682s->lrck[RT5682S_AIF2]; in set_filter_clk()
1232 ref = 256 * rt5682s->lrck[RT5682S_AIF1]; in set_filter_clk()
1239 rt5682s_set_filter_clk(rt5682s, reg, ref); in set_filter_clk()
1248 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in set_dmic_power() local
1251 if (rt5682s->pdata.dmic_delay) in set_dmic_power()
1252 delay = rt5682s->pdata.dmic_delay; in set_dmic_power()
1268 if (!rt5682s->jack_type && !rt5682s->wclk_enabled) { in set_dmic_power()
1278 static void rt5682s_set_i2s(struct rt5682s_priv *rt5682s, int id, int on) in rt5682s_set_i2s() argument
1280 struct snd_soc_component *component = rt5682s->component; in rt5682s_set_i2s()
1301 if (on && rt5682s->master[id]) { in rt5682s_set_i2s()
1302 pre_div = get_clk_info(rt5682s->sysclk, rt5682s->lrck[id]); in rt5682s_set_i2s()
1309 rt5682s->lrck[id], pre_div, id); in rt5682s_set_i2s()
1320 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in set_i2s_event() local
1326 if (!snd_soc_dapm_widget_name_cmp(w, "I2S1") && !rt5682s->wclk_enabled) in set_i2s_event()
1327 rt5682s_set_i2s(rt5682s, RT5682S_AIF1, on); in set_i2s_event()
1329 rt5682s_set_i2s(rt5682s, RT5682S_AIF2, on); in set_i2s_event()
1338 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in is_sys_clk_from_plla() local
1340 if ((rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL1) || in is_sys_clk_from_plla()
1341 (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2 && rt5682s->pll_comb == USE_PLLAB)) in is_sys_clk_from_plla()
1351 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in is_sys_clk_from_pllb() local
1353 if (rt5682s->sysclk_src == RT5682S_CLK_SRC_PLL2) in is_sys_clk_from_pllb()
1437 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_stereo1_adc_mixl_event() local
1440 if (rt5682s->pdata.amic_delay) in rt5682s_stereo1_adc_mixl_event()
1441 delay = rt5682s->pdata.amic_delay; in rt5682s_stereo1_adc_mixl_event()
1462 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in sar_power_event() local
1464 if ((rt5682s->jack_type & SND_JACK_HEADSET) != SND_JACK_HEADSET) in sar_power_event()
2064 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_hw_params() local
2068 rt5682s->lrck[dai->id] = params_rate(params); in rt5682s_hw_params()
2131 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_dai_fmt() local
2136 rt5682s->master[dai->id] = 1; in rt5682s_set_dai_fmt()
2139 rt5682s->master[dai->id] = 0; in rt5682s_set_dai_fmt()
2196 tdm_ctrl | rt5682s->master[dai->id]); in rt5682s_set_dai_fmt()
2199 if (rt5682s->master[dai->id] == 0) in rt5682s_set_dai_fmt()
2215 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_component_sysclk() local
2218 if (freq == rt5682s->sysclk && clk_id == rt5682s->sysclk_src) in rt5682s_set_component_sysclk()
2246 rt5682s->sysclk = freq; in rt5682s_set_component_sysclk()
2247 rt5682s->sysclk_src = clk_id; in rt5682s_set_component_sysclk()
2333 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_component_pll() local
2336 if (source == rt5682s->pll_src[pll_id] && freq_in == rt5682s->pll_in[pll_id] && in rt5682s_set_component_pll()
2337 freq_out == rt5682s->pll_out[pll_id]) in rt5682s_set_component_pll()
2342 rt5682s->pll_in[pll_id] = 0; in rt5682s_set_component_pll()
2343 rt5682s->pll_out[pll_id] = 0; in rt5682s_set_component_pll()
2363 rt5682s->pll_comb = find_pll_inter_combination(freq_in, freq_out, in rt5682s_set_component_pll()
2366 if ((pll_id == RT5682S_PLL1 && rt5682s->pll_comb == USE_PLLA) || in rt5682s_set_component_pll()
2367 (pll_id == RT5682S_PLL2 && (rt5682s->pll_comb == USE_PLLB || in rt5682s_set_component_pll()
2368 rt5682s->pll_comb == USE_PLLAB))) { in rt5682s_set_component_pll()
2371 pll_id + 1, freq_in, freq_out, rt5682s->pll_comb); in rt5682s_set_component_pll()
2375 pll_id + 1, freq_in, freq_out, rt5682s->pll_comb); in rt5682s_set_component_pll()
2379 if (rt5682s->pll_comb == USE_PLLA || rt5682s->pll_comb == USE_PLLAB) { in rt5682s_set_component_pll()
2395 if (rt5682s->pll_comb == USE_PLLB || rt5682s->pll_comb == USE_PLLAB) { in rt5682s_set_component_pll()
2415 if (rt5682s->pll_comb == USE_PLLB) in rt5682s_set_component_pll()
2419 rt5682s->pll_in[pll_id] = freq_in; in rt5682s_set_component_pll()
2420 rt5682s->pll_out[pll_id] = freq_out; in rt5682s_set_component_pll()
2421 rt5682s->pll_src[pll_id] = source; in rt5682s_set_component_pll()
2430 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_bclk1_ratio() local
2432 rt5682s->bclk[dai->id] = ratio; in rt5682s_set_bclk1_ratio()
2462 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_bclk2_ratio() local
2464 rt5682s->bclk[dai->id] = ratio; in rt5682s_set_bclk2_ratio()
2486 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_set_bias_level() local
2490 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_1, in rt5682s_set_bias_level()
2495 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_1, in rt5682s_set_bias_level()
2499 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_1, RT5682S_PWR_LDO, 0); in rt5682s_set_bias_level()
2500 if (!rt5682s->wclk_enabled) in rt5682s_set_bias_level()
2501 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_1, in rt5682s_set_bias_level()
2516 static bool rt5682s_clk_check(struct rt5682s_priv *rt5682s) in rt5682s_clk_check() argument
2518 if (!rt5682s->master[RT5682S_AIF1]) { in rt5682s_clk_check()
2519 dev_dbg(rt5682s->component->dev, "dai clk fmt not set correctly\n"); in rt5682s_clk_check()
2527 struct rt5682s_priv *rt5682s = in rt5682s_wclk_prepare() local
2529 struct snd_soc_component *component = rt5682s->component; in rt5682s_wclk_prepare()
2532 if (!rt5682s_clk_check(rt5682s)) in rt5682s_wclk_prepare()
2535 mutex_lock(&rt5682s->wclk_mutex); in rt5682s_wclk_prepare()
2547 rt5682s_set_i2s(rt5682s, RT5682S_AIF1, 1); in rt5682s_wclk_prepare()
2551 ref = 256 * rt5682s->lrck[RT5682S_AIF1]; in rt5682s_wclk_prepare()
2552 rt5682s_set_filter_clk(rt5682s, reg, ref); in rt5682s_wclk_prepare()
2553 rt5682s_set_pllb_power(rt5682s, 1); in rt5682s_wclk_prepare()
2555 rt5682s->wclk_enabled = 1; in rt5682s_wclk_prepare()
2557 mutex_unlock(&rt5682s->wclk_mutex); in rt5682s_wclk_prepare()
2564 struct rt5682s_priv *rt5682s = in rt5682s_wclk_unprepare() local
2566 struct snd_soc_component *component = rt5682s->component; in rt5682s_wclk_unprepare()
2568 if (!rt5682s_clk_check(rt5682s)) in rt5682s_wclk_unprepare()
2571 mutex_lock(&rt5682s->wclk_mutex); in rt5682s_wclk_unprepare()
2573 if (!rt5682s->jack_type) in rt5682s_wclk_unprepare()
2578 rt5682s_set_i2s(rt5682s, RT5682S_AIF1, 0); in rt5682s_wclk_unprepare()
2583 rt5682s_set_pllb_power(rt5682s, 0); in rt5682s_wclk_unprepare()
2585 rt5682s->wclk_enabled = 0; in rt5682s_wclk_unprepare()
2587 mutex_unlock(&rt5682s->wclk_mutex); in rt5682s_wclk_unprepare()
2593 struct rt5682s_priv *rt5682s = in rt5682s_wclk_recalc_rate() local
2595 struct snd_soc_component *component = rt5682s->component; in rt5682s_wclk_recalc_rate()
2598 if (!rt5682s_clk_check(rt5682s)) in rt5682s_wclk_recalc_rate()
2603 if (rt5682s->lrck[RT5682S_AIF1] != CLK_48 && in rt5682s_wclk_recalc_rate()
2604 rt5682s->lrck[RT5682S_AIF1] != CLK_44) { in rt5682s_wclk_recalc_rate()
2610 return rt5682s->lrck[RT5682S_AIF1]; in rt5682s_wclk_recalc_rate()
2616 struct rt5682s_priv *rt5682s = in rt5682s_wclk_round_rate() local
2618 struct snd_soc_component *component = rt5682s->component; in rt5682s_wclk_round_rate()
2621 if (!rt5682s_clk_check(rt5682s)) in rt5682s_wclk_round_rate()
2639 struct rt5682s_priv *rt5682s = in rt5682s_wclk_set_rate() local
2641 struct snd_soc_component *component = rt5682s->component; in rt5682s_wclk_set_rate()
2646 if (!rt5682s_clk_check(rt5682s)) in rt5682s_wclk_set_rate()
2677 rt5682s->lrck[RT5682S_AIF1] = rate; in rt5682s_wclk_set_rate()
2685 struct rt5682s_priv *rt5682s = in rt5682s_bclk_recalc_rate() local
2687 struct snd_soc_component *component = rt5682s->component; in rt5682s_bclk_recalc_rate()
2725 struct rt5682s_priv *rt5682s = in rt5682s_bclk_round_rate() local
2729 if (!*parent_rate || !rt5682s_clk_check(rt5682s)) in rt5682s_bclk_round_rate()
2747 struct rt5682s_priv *rt5682s = in rt5682s_bclk_set_rate() local
2749 struct snd_soc_component *component = rt5682s->component; in rt5682s_bclk_set_rate()
2753 if (!rt5682s_clk_check(rt5682s)) in rt5682s_bclk_set_rate()
2785 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_register_dai_clks() local
2786 struct rt5682s_platform_data *pdata = &rt5682s->pdata; in rt5682s_register_dai_clks()
2795 dai_clk_hw = &rt5682s->dai_clks_hw[i]; in rt5682s_register_dai_clks()
2800 if (rt5682s->mclk) { in rt5682s_register_dai_clks()
2810 parent = &rt5682s->dai_clks_hw[RT5682S_DAI_WCLK_IDX]; in rt5682s_register_dai_clks()
2847 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_dai_probe_clks() local
2851 rt5682s->mclk = devm_clk_get_optional(component->dev, "mclk"); in rt5682s_dai_probe_clks()
2852 if (IS_ERR(rt5682s->mclk)) in rt5682s_dai_probe_clks()
2853 return PTR_ERR(rt5682s->mclk); in rt5682s_dai_probe_clks()
2861 rt5682s->lrck[RT5682S_AIF1] = CLK_48; in rt5682s_dai_probe_clks()
2874 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_probe() local
2876 rt5682s->component = component; in rt5682s_probe()
2883 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_remove() local
2885 rt5682s_reset(rt5682s); in rt5682s_remove()
2891 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_suspend() local
2893 if (rt5682s->irq) in rt5682s_suspend()
2894 disable_irq(rt5682s->irq); in rt5682s_suspend()
2896 cancel_delayed_work_sync(&rt5682s->jack_detect_work); in rt5682s_suspend()
2897 cancel_delayed_work_sync(&rt5682s->jd_check_work); in rt5682s_suspend()
2899 if (rt5682s->hs_jack) in rt5682s_suspend()
2900 rt5682s->jack_type = rt5682s_headset_detect(component, 0); in rt5682s_suspend()
2902 regcache_cache_only(rt5682s->regmap, true); in rt5682s_suspend()
2903 regcache_mark_dirty(rt5682s->regmap); in rt5682s_suspend()
2910 struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component); in rt5682s_resume() local
2912 regcache_cache_only(rt5682s->regmap, false); in rt5682s_resume()
2913 regcache_sync(rt5682s->regmap); in rt5682s_resume()
2915 if (rt5682s->hs_jack) { in rt5682s_resume()
2917 &rt5682s->jack_detect_work, msecs_to_jiffies(0)); in rt5682s_resume()
2920 if (rt5682s->irq) in rt5682s_resume()
2921 enable_irq(rt5682s->irq); in rt5682s_resume()
2962 static int rt5682s_parse_dt(struct rt5682s_priv *rt5682s, struct device *dev) in rt5682s_parse_dt() argument
2965 &rt5682s->pdata.dmic1_data_pin); in rt5682s_parse_dt()
2967 &rt5682s->pdata.dmic1_clk_pin); in rt5682s_parse_dt()
2969 &rt5682s->pdata.jd_src); in rt5682s_parse_dt()
2971 &rt5682s->pdata.dmic_clk_rate); in rt5682s_parse_dt()
2973 &rt5682s->pdata.dmic_delay); in rt5682s_parse_dt()
2975 &rt5682s->pdata.amic_delay); in rt5682s_parse_dt()
2977 &rt5682s->pdata.ldo_dacref); in rt5682s_parse_dt()
2980 rt5682s->pdata.dai_clk_names, in rt5682s_parse_dt()
2983 rt5682s->pdata.dai_clk_names[RT5682S_DAI_WCLK_IDX], in rt5682s_parse_dt()
2984 rt5682s->pdata.dai_clk_names[RT5682S_DAI_BCLK_IDX]); in rt5682s_parse_dt()
2986 rt5682s->pdata.dmic_clk_driving_high = device_property_read_bool(dev, in rt5682s_parse_dt()
2992 static void rt5682s_calibrate(struct rt5682s_priv *rt5682s) in rt5682s_calibrate() argument
2996 mutex_lock(&rt5682s->calibrate_mutex); in rt5682s_calibrate()
2998 regmap_write(rt5682s->regmap, RT5682S_PWR_ANLG_1, 0xaa80); in rt5682s_calibrate()
3000 regmap_write(rt5682s->regmap, RT5682S_PWR_ANLG_1, 0xfa80); in rt5682s_calibrate()
3001 regmap_write(rt5682s->regmap, RT5682S_PWR_DIG_1, 0x01c0); in rt5682s_calibrate()
3002 regmap_write(rt5682s->regmap, RT5682S_MICBIAS_2, 0x0380); in rt5682s_calibrate()
3003 regmap_write(rt5682s->regmap, RT5682S_GLB_CLK, 0x8000); in rt5682s_calibrate()
3004 regmap_write(rt5682s->regmap, RT5682S_ADDA_CLK_1, 0x1001); in rt5682s_calibrate()
3005 regmap_write(rt5682s->regmap, RT5682S_CHOP_DAC_2, 0x3030); in rt5682s_calibrate()
3006 regmap_write(rt5682s->regmap, RT5682S_CHOP_ADC, 0xb000); in rt5682s_calibrate()
3007 regmap_write(rt5682s->regmap, RT5682S_STO1_ADC_MIXER, 0x686c); in rt5682s_calibrate()
3008 regmap_write(rt5682s->regmap, RT5682S_CAL_REC, 0x5151); in rt5682s_calibrate()
3009 regmap_write(rt5682s->regmap, RT5682S_HP_CALIB_CTRL_2, 0x0321); in rt5682s_calibrate()
3010 regmap_write(rt5682s->regmap, RT5682S_HP_LOGIC_CTRL_2, 0x0004); in rt5682s_calibrate()
3011 regmap_write(rt5682s->regmap, RT5682S_HP_CALIB_CTRL_1, 0x7c00); in rt5682s_calibrate()
3012 regmap_write(rt5682s->regmap, RT5682S_HP_CALIB_CTRL_1, 0xfc00); in rt5682s_calibrate()
3015 regmap_read(rt5682s->regmap, RT5682S_HP_CALIB_ST_1, &value); in rt5682s_calibrate()
3023 dev_err(rt5682s->component->dev, "HP Calibration Failure\n"); in rt5682s_calibrate()
3026 regmap_write(rt5682s->regmap, RT5682S_MICBIAS_2, 0x0180); in rt5682s_calibrate()
3027 regmap_write(rt5682s->regmap, RT5682S_CAL_REC, 0x5858); in rt5682s_calibrate()
3028 regmap_write(rt5682s->regmap, RT5682S_STO1_ADC_MIXER, 0xc0c4); in rt5682s_calibrate()
3029 regmap_write(rt5682s->regmap, RT5682S_HP_CALIB_CTRL_2, 0x0320); in rt5682s_calibrate()
3030 regmap_write(rt5682s->regmap, RT5682S_PWR_DIG_1, 0x00c0); in rt5682s_calibrate()
3031 regmap_write(rt5682s->regmap, RT5682S_PWR_ANLG_1, 0x0800); in rt5682s_calibrate()
3032 regmap_write(rt5682s->regmap, RT5682S_GLB_CLK, 0x0000); in rt5682s_calibrate()
3034 mutex_unlock(&rt5682s->calibrate_mutex); in rt5682s_calibrate()
3086 struct rt5682s_priv *rt5682s = data; in rt5682s_i2c_disable_regulators() local
3087 struct device *dev = regmap_get_device(rt5682s->regmap); in rt5682s_i2c_disable_regulators()
3090 ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_AVDD].consumer); in rt5682s_i2c_disable_regulators()
3094 ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_DBVDD].consumer); in rt5682s_i2c_disable_regulators()
3098 ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_LDO1_IN].consumer); in rt5682s_i2c_disable_regulators()
3104 ret = regulator_disable(rt5682s->supplies[RT5682S_SUPPLY_MICVDD].consumer); in rt5682s_i2c_disable_regulators()
3112 struct rt5682s_priv *rt5682s; in rt5682s_i2c_probe() local
3116 rt5682s = devm_kzalloc(&i2c->dev, sizeof(struct rt5682s_priv), GFP_KERNEL); in rt5682s_i2c_probe()
3117 if (!rt5682s) in rt5682s_i2c_probe()
3120 i2c_set_clientdata(i2c, rt5682s); in rt5682s_i2c_probe()
3122 rt5682s->pdata = i2s_default_platform_data; in rt5682s_i2c_probe()
3125 rt5682s->pdata = *pdata; in rt5682s_i2c_probe()
3127 rt5682s_parse_dt(rt5682s, &i2c->dev); in rt5682s_i2c_probe()
3129 rt5682s->regmap = devm_regmap_init_i2c(i2c, &rt5682s_regmap); in rt5682s_i2c_probe()
3130 if (IS_ERR(rt5682s->regmap)) { in rt5682s_i2c_probe()
3131 ret = PTR_ERR(rt5682s->regmap); in rt5682s_i2c_probe()
3136 for (i = 0; i < ARRAY_SIZE(rt5682s->supplies); i++) in rt5682s_i2c_probe()
3137 rt5682s->supplies[i].supply = rt5682s_supply_names[i]; in rt5682s_i2c_probe()
3140 ARRAY_SIZE(rt5682s->supplies), rt5682s->supplies); in rt5682s_i2c_probe()
3146 ret = devm_add_action_or_reset(&i2c->dev, rt5682s_i2c_disable_regulators, rt5682s); in rt5682s_i2c_probe()
3150 ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_MICVDD].consumer); in rt5682s_i2c_probe()
3157 ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_AVDD].consumer); in rt5682s_i2c_probe()
3163 ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_DBVDD].consumer); in rt5682s_i2c_probe()
3169 ret = regulator_enable(rt5682s->supplies[RT5682S_SUPPLY_LDO1_IN].consumer); in rt5682s_i2c_probe()
3175 rt5682s->ldo1_en = devm_gpiod_get_optional(&i2c->dev, in rt5682s_i2c_probe()
3178 if (IS_ERR(rt5682s->ldo1_en)) { in rt5682s_i2c_probe()
3180 return PTR_ERR(rt5682s->ldo1_en); in rt5682s_i2c_probe()
3186 regmap_read(rt5682s->regmap, RT5682S_DEVICE_ID, &val); in rt5682s_i2c_probe()
3192 rt5682s_reset(rt5682s); in rt5682s_i2c_probe()
3193 rt5682s_apply_patch_list(rt5682s, &i2c->dev); in rt5682s_i2c_probe()
3195 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_DIG_2, in rt5682s_i2c_probe()
3199 mutex_init(&rt5682s->calibrate_mutex); in rt5682s_i2c_probe()
3200 mutex_init(&rt5682s->sar_mutex); in rt5682s_i2c_probe()
3201 mutex_init(&rt5682s->wclk_mutex); in rt5682s_i2c_probe()
3202 rt5682s_calibrate(rt5682s); in rt5682s_i2c_probe()
3204 regmap_update_bits(rt5682s->regmap, RT5682S_MICBIAS_2, in rt5682s_i2c_probe()
3207 regmap_update_bits(rt5682s->regmap, RT5682S_PWR_ANLG_1, in rt5682s_i2c_probe()
3209 regmap_update_bits(rt5682s->regmap, RT5682S_HP_LOGIC_CTRL_2, in rt5682s_i2c_probe()
3211 regmap_update_bits(rt5682s->regmap, RT5682S_HP_CHARGE_PUMP_2, in rt5682s_i2c_probe()
3213 regmap_update_bits(rt5682s->regmap, RT5682S_HP_AMP_DET_CTL_1, in rt5682s_i2c_probe()
3217 switch (rt5682s->pdata.dmic1_data_pin) { in rt5682s_i2c_probe()
3221 regmap_update_bits(rt5682s->regmap, RT5682S_DMIC_CTRL_1, in rt5682s_i2c_probe()
3223 regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1, in rt5682s_i2c_probe()
3227 regmap_update_bits(rt5682s->regmap, RT5682S_DMIC_CTRL_1, in rt5682s_i2c_probe()
3229 regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1, in rt5682s_i2c_probe()
3238 switch (rt5682s->pdata.dmic1_clk_pin) { in rt5682s_i2c_probe()
3242 regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1, in rt5682s_i2c_probe()
3246 regmap_update_bits(rt5682s->regmap, RT5682S_GPIO_CTRL_1, in rt5682s_i2c_probe()
3248 if (rt5682s->pdata.dmic_clk_driving_high) in rt5682s_i2c_probe()
3249 regmap_update_bits(rt5682s->regmap, RT5682S_PAD_DRIVING_CTRL, in rt5682s_i2c_probe()
3258 switch (rt5682s->pdata.ldo_dacref) { in rt5682s_i2c_probe()
3262 regmap_update_bits(rt5682s->regmap, RT5682S_BIAS_CUR_CTRL_7, in rt5682s_i2c_probe()
3266 regmap_update_bits(rt5682s->regmap, RT5682S_BIAS_CUR_CTRL_7, in rt5682s_i2c_probe()
3270 regmap_update_bits(rt5682s->regmap, RT5682S_BIAS_CUR_CTRL_7, in rt5682s_i2c_probe()
3278 INIT_DELAYED_WORK(&rt5682s->jack_detect_work, rt5682s_jack_detect_handler); in rt5682s_i2c_probe()
3279 INIT_DELAYED_WORK(&rt5682s->jd_check_work, rt5682s_jd_check_handler); in rt5682s_i2c_probe()
3284 "rt5682s", rt5682s); in rt5682s_i2c_probe()
3286 rt5682s->irq = i2c->irq; in rt5682s_i2c_probe()
3297 struct rt5682s_priv *rt5682s = i2c_get_clientdata(client); in rt5682s_i2c_shutdown() local
3300 cancel_delayed_work_sync(&rt5682s->jack_detect_work); in rt5682s_i2c_shutdown()
3301 cancel_delayed_work_sync(&rt5682s->jd_check_work); in rt5682s_i2c_shutdown()
3303 rt5682s_reset(rt5682s); in rt5682s_i2c_shutdown()