Lines Matching refs:rt5665

1168 	struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component);  in rt5665_headset_detect()  local
1176 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, 0x100, in rt5665_headset_detect()
1179 regmap_read(rt5665->regmap, RT5665_GPIO_STA, &val); in rt5665_headset_detect()
1181 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_headset_detect()
1184 regmap_read(rt5665->regmap, RT5665_GPIO_STA, &val); in rt5665_headset_detect()
1187 regmap_read(rt5665->regmap, RT5665_GPIO_STA, in rt5665_headset_detect()
1192 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_headset_detect()
1194 regmap_write(rt5665->regmap, RT5665_EJD_CTRL_3, 0x3424); in rt5665_headset_detect()
1195 regmap_write(rt5665->regmap, RT5665_IL_CMD_1, 0x0048); in rt5665_headset_detect()
1196 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, 0xa291); in rt5665_headset_detect()
1200 rt5665->sar_adc_value = snd_soc_component_read(rt5665->component, in rt5665_headset_detect()
1203 sar_hs_type = rt5665->pdata.sar_hs_type ? in rt5665_headset_detect()
1204 rt5665->pdata.sar_hs_type : 729; in rt5665_headset_detect()
1206 if (rt5665->sar_adc_value > sar_hs_type) { in rt5665_headset_detect()
1207 rt5665->jack_type = SND_JACK_HEADSET; in rt5665_headset_detect()
1210 rt5665->jack_type = SND_JACK_HEADPHONE; in rt5665_headset_detect()
1211 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, in rt5665_headset_detect()
1213 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, in rt5665_headset_detect()
1219 regmap_write(rt5665->regmap, RT5665_SAR_IL_CMD_1, 0x2291); in rt5665_headset_detect()
1220 regmap_update_bits(rt5665->regmap, RT5665_MICBIAS_2, 0x100, 0); in rt5665_headset_detect()
1223 if (rt5665->jack_type == SND_JACK_HEADSET) in rt5665_headset_detect()
1225 rt5665->jack_type = 0; in rt5665_headset_detect()
1228 dev_dbg(component->dev, "jack_type = %d\n", rt5665->jack_type); in rt5665_headset_detect()
1229 return rt5665->jack_type; in rt5665_headset_detect()
1234 struct rt5665_priv *rt5665 = data; in rt5665_irq() local
1237 &rt5665->jack_detect_work, msecs_to_jiffies(250)); in rt5665_irq()
1244 struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, in rt5665_jd_check_handler() local
1247 if (snd_soc_component_read(rt5665->component, RT5665_AJD1_CTRL) & 0x0010) { in rt5665_jd_check_handler()
1249 rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); in rt5665_jd_check_handler()
1251 snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, in rt5665_jd_check_handler()
1256 schedule_delayed_work(&rt5665->jd_check_work, 500); in rt5665_jd_check_handler()
1263 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_jack_detect() local
1265 switch (rt5665->pdata.jd_src) { in rt5665_set_jack_detect()
1267 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_set_jack_detect()
1269 regmap_update_bits(rt5665->regmap, RT5665_RC_CLK_CTRL, in rt5665_set_jack_detect()
1271 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_2, in rt5665_set_jack_detect()
1273 regmap_update_bits(rt5665->regmap, RT5665_IRQ_CTRL_1, 0x8, 0x8); in rt5665_set_jack_detect()
1284 rt5665->hs_jack = hs_jack; in rt5665_set_jack_detect()
1291 struct rt5665_priv *rt5665 = in rt5665_jack_detect_handler() local
1295 while (!rt5665->component) { in rt5665_jack_detect_handler()
1300 while (!snd_soc_card_is_instantiated(rt5665->component->card)) { in rt5665_jack_detect_handler()
1305 while (!rt5665->calibration_done) { in rt5665_jack_detect_handler()
1310 mutex_lock(&rt5665->calibrate_mutex); in rt5665_jack_detect_handler()
1312 val = snd_soc_component_read(rt5665->component, RT5665_AJD1_CTRL) & 0x0010; in rt5665_jack_detect_handler()
1315 if (rt5665->jack_type == 0) { in rt5665_jack_detect_handler()
1317 rt5665->jack_type = in rt5665_jack_detect_handler()
1318 rt5665_headset_detect(rt5665->component, 1); in rt5665_jack_detect_handler()
1321 rt5665->jack_type = SND_JACK_HEADSET; in rt5665_jack_detect_handler()
1322 btn_type = rt5665_button_detect(rt5665->component); in rt5665_jack_detect_handler()
1334 rt5665->jack_type |= SND_JACK_BTN_0; in rt5665_jack_detect_handler()
1339 rt5665->jack_type |= SND_JACK_BTN_1; in rt5665_jack_detect_handler()
1344 rt5665->jack_type |= SND_JACK_BTN_2; in rt5665_jack_detect_handler()
1349 rt5665->jack_type |= SND_JACK_BTN_3; in rt5665_jack_detect_handler()
1355 dev_err(rt5665->component->dev, in rt5665_jack_detect_handler()
1363 rt5665->jack_type = rt5665_headset_detect(rt5665->component, 0); in rt5665_jack_detect_handler()
1366 snd_soc_jack_report(rt5665->hs_jack, rt5665->jack_type, in rt5665_jack_detect_handler()
1371 if (rt5665->jack_type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | in rt5665_jack_detect_handler()
1373 schedule_delayed_work(&rt5665->jd_check_work, 0); in rt5665_jack_detect_handler()
1375 cancel_delayed_work_sync(&rt5665->jd_check_work); in rt5665_jack_detect_handler()
1377 mutex_unlock(&rt5665->calibrate_mutex); in rt5665_jack_detect_handler()
1479 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in set_dmic_clk() local
1482 pd = rl6231_get_pre_div(rt5665->regmap, in set_dmic_clk()
1484 idx = rl6231_calc_dmic_clk(rt5665->sysclk / pd); in set_dmic_clk()
4108 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_hw_params() local
4112 rt5665->lrck[dai->id] = params_rate(params); in rt5665_hw_params()
4113 pre_div = rl6231_get_clk_info(rt5665->sysclk, rt5665->lrck[dai->id]); in rt5665_hw_params()
4117 rt5665->sysclk, rt5665->lrck[dai->id] * 512); in rt5665_hw_params()
4119 rt5665->lrck[dai->id] * 512, 0); in rt5665_hw_params()
4129 rt5665->lrck[dai->id], pre_div, dai->id); in rt5665_hw_params()
4185 switch (rt5665->lrck[dai->id]) { in rt5665_hw_params()
4203 if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { in rt5665_hw_params()
4207 if (rt5665->master[RT5665_AIF3]) { in rt5665_hw_params()
4218 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_dai_fmt() local
4223 rt5665->master[dai->id] = 1; in rt5665_set_dai_fmt()
4227 rt5665->master[dai->id] = 0; in rt5665_set_dai_fmt()
4287 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_component_sysclk() local
4290 if (freq == rt5665->sysclk && clk_id == rt5665->sysclk_src) in rt5665_set_component_sysclk()
4313 if (rt5665->master[RT5665_AIF2_1] || rt5665->master[RT5665_AIF2_2]) { in rt5665_set_component_sysclk()
4317 if (rt5665->master[RT5665_AIF3]) { in rt5665_set_component_sysclk()
4322 rt5665->sysclk = freq; in rt5665_set_component_sysclk()
4323 rt5665->sysclk_src = clk_id; in rt5665_set_component_sysclk()
4334 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_component_pll() local
4338 if (source == rt5665->pll_src && freq_in == rt5665->pll_in && in rt5665_set_component_pll()
4339 freq_out == rt5665->pll_out) in rt5665_set_component_pll()
4345 rt5665->pll_in = 0; in rt5665_set_component_pll()
4346 rt5665->pll_out = 0; in rt5665_set_component_pll()
4390 rt5665->pll_in = freq_in; in rt5665_set_component_pll()
4391 rt5665->pll_out = freq_out; in rt5665_set_component_pll()
4392 rt5665->pll_src = source; in rt5665_set_component_pll()
4400 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_bclk_ratio() local
4404 rt5665->bclk[dai->id] = ratio; in rt5665_set_bclk_ratio()
4428 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_set_bias_level() local
4432 regmap_update_bits(rt5665->regmap, RT5665_DIG_MISC, in rt5665_set_bias_level()
4437 regmap_update_bits(rt5665->regmap, RT5665_PWR_DIG_1, in rt5665_set_bias_level()
4439 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_set_bias_level()
4441 regmap_update_bits(rt5665->regmap, RT5665_DIG_MISC, in rt5665_set_bias_level()
4445 regmap_update_bits(rt5665->regmap, RT5665_PWR_DIG_1, in rt5665_set_bias_level()
4447 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_set_bias_level()
4460 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_probe() local
4462 rt5665->component = component; in rt5665_probe()
4464 schedule_delayed_work(&rt5665->calibrate_work, msecs_to_jiffies(100)); in rt5665_probe()
4471 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_remove() local
4473 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_remove()
4475 regulator_bulk_disable(ARRAY_SIZE(rt5665->supplies), rt5665->supplies); in rt5665_remove()
4481 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_suspend() local
4483 regcache_cache_only(rt5665->regmap, true); in rt5665_suspend()
4484 regcache_mark_dirty(rt5665->regmap); in rt5665_suspend()
4490 struct rt5665_priv *rt5665 = snd_soc_component_get_drvdata(component); in rt5665_resume() local
4492 regcache_cache_only(rt5665->regmap, false); in rt5665_resume()
4493 regcache_sync(rt5665->regmap); in rt5665_resume()
4643 static int rt5665_parse_dt(struct rt5665_priv *rt5665, struct device *dev) in rt5665_parse_dt() argument
4645 rt5665->pdata.in1_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4647 rt5665->pdata.in2_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4649 rt5665->pdata.in3_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4651 rt5665->pdata.in4_diff = of_property_read_bool(dev->of_node, in rt5665_parse_dt()
4655 &rt5665->pdata.dmic1_data_pin); in rt5665_parse_dt()
4657 &rt5665->pdata.dmic2_data_pin); in rt5665_parse_dt()
4659 &rt5665->pdata.jd_src); in rt5665_parse_dt()
4664 static void rt5665_calibrate(struct rt5665_priv *rt5665) in rt5665_calibrate() argument
4668 mutex_lock(&rt5665->calibrate_mutex); in rt5665_calibrate()
4670 regcache_cache_bypass(rt5665->regmap, true); in rt5665_calibrate()
4672 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4673 regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602); in rt5665_calibrate()
4674 regmap_write(rt5665->regmap, RT5665_HP_CHARGE_PUMP_1, 0x0c26); in rt5665_calibrate()
4675 regmap_write(rt5665->regmap, RT5665_MONOMIX_IN_GAIN, 0x021f); in rt5665_calibrate()
4676 regmap_write(rt5665->regmap, RT5665_MONO_OUT, 0x480a); in rt5665_calibrate()
4677 regmap_write(rt5665->regmap, RT5665_PWR_MIXER, 0x083f); in rt5665_calibrate()
4678 regmap_write(rt5665->regmap, RT5665_PWR_DIG_1, 0x0180); in rt5665_calibrate()
4679 regmap_write(rt5665->regmap, RT5665_EJD_CTRL_1, 0x4040); in rt5665_calibrate()
4680 regmap_write(rt5665->regmap, RT5665_HP_LOGIC_CTRL_2, 0x0000); in rt5665_calibrate()
4681 regmap_write(rt5665->regmap, RT5665_DIG_MISC, 0x0001); in rt5665_calibrate()
4682 regmap_write(rt5665->regmap, RT5665_MICBIAS_2, 0x0380); in rt5665_calibrate()
4683 regmap_write(rt5665->regmap, RT5665_GLB_CLK, 0x8000); in rt5665_calibrate()
4684 regmap_write(rt5665->regmap, RT5665_ADDA_CLK_1, 0x1000); in rt5665_calibrate()
4685 regmap_write(rt5665->regmap, RT5665_CHOP_DAC, 0x3030); in rt5665_calibrate()
4686 regmap_write(rt5665->regmap, RT5665_CALIB_ADC_CTRL, 0x3c05); in rt5665_calibrate()
4687 regmap_write(rt5665->regmap, RT5665_PWR_ANLG_1, 0xaa3e); in rt5665_calibrate()
4689 regmap_write(rt5665->regmap, RT5665_PWR_ANLG_1, 0xfe7e); in rt5665_calibrate()
4690 regmap_write(rt5665->regmap, RT5665_HP_CALIB_CTRL_2, 0x0321); in rt5665_calibrate()
4692 regmap_write(rt5665->regmap, RT5665_HP_CALIB_CTRL_1, 0xfc00); in rt5665_calibrate()
4695 regmap_read(rt5665->regmap, RT5665_HP_CALIB_STA_1, &value); in rt5665_calibrate()
4703 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4704 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4711 regmap_write(rt5665->regmap, RT5665_MONO_AMP_CALIB_CTRL_1, 0x9e24); in rt5665_calibrate()
4714 regmap_read(rt5665->regmap, RT5665_MONO_AMP_CALIB_STA1, &value); in rt5665_calibrate()
4722 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4723 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4730 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_calibrate()
4731 regcache_cache_bypass(rt5665->regmap, false); in rt5665_calibrate()
4733 regcache_mark_dirty(rt5665->regmap); in rt5665_calibrate()
4734 regcache_sync(rt5665->regmap); in rt5665_calibrate()
4736 regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602); in rt5665_calibrate()
4737 regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120); in rt5665_calibrate()
4740 rt5665->calibration_done = true; in rt5665_calibrate()
4741 mutex_unlock(&rt5665->calibrate_mutex); in rt5665_calibrate()
4746 struct rt5665_priv *rt5665 = container_of(work, struct rt5665_priv, in rt5665_calibrate_handler() local
4749 while (!snd_soc_card_is_instantiated(rt5665->component->card)) { in rt5665_calibrate_handler()
4754 rt5665_calibrate(rt5665); in rt5665_calibrate_handler()
4760 struct rt5665_priv *rt5665; in rt5665_i2c_probe() local
4764 rt5665 = devm_kzalloc(&i2c->dev, sizeof(struct rt5665_priv), in rt5665_i2c_probe()
4767 if (rt5665 == NULL) in rt5665_i2c_probe()
4770 i2c_set_clientdata(i2c, rt5665); in rt5665_i2c_probe()
4773 rt5665->pdata = *pdata; in rt5665_i2c_probe()
4775 rt5665_parse_dt(rt5665, &i2c->dev); in rt5665_i2c_probe()
4777 for (i = 0; i < ARRAY_SIZE(rt5665->supplies); i++) in rt5665_i2c_probe()
4778 rt5665->supplies[i].supply = rt5665_supply_names[i]; in rt5665_i2c_probe()
4780 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5665->supplies), in rt5665_i2c_probe()
4781 rt5665->supplies); in rt5665_i2c_probe()
4787 ret = regulator_bulk_enable(ARRAY_SIZE(rt5665->supplies), in rt5665_i2c_probe()
4788 rt5665->supplies); in rt5665_i2c_probe()
4795 rt5665->gpiod_ldo1_en = devm_gpiod_get_optional(&i2c->dev, in rt5665_i2c_probe()
4798 if (IS_ERR(rt5665->gpiod_ldo1_en)) { in rt5665_i2c_probe()
4800 return PTR_ERR(rt5665->gpiod_ldo1_en); in rt5665_i2c_probe()
4806 rt5665->regmap = devm_regmap_init_i2c(i2c, &rt5665_regmap); in rt5665_i2c_probe()
4807 if (IS_ERR(rt5665->regmap)) { in rt5665_i2c_probe()
4808 ret = PTR_ERR(rt5665->regmap); in rt5665_i2c_probe()
4814 regmap_read(rt5665->regmap, RT5665_DEVICE_ID, &val); in rt5665_i2c_probe()
4821 regmap_read(rt5665->regmap, RT5665_RESET, &val); in rt5665_i2c_probe()
4824 rt5665->id = CODEC_5666; in rt5665_i2c_probe()
4828 rt5665->id = CODEC_5665; in rt5665_i2c_probe()
4832 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_i2c_probe()
4835 if (rt5665->pdata.in1_diff) in rt5665_i2c_probe()
4836 regmap_update_bits(rt5665->regmap, RT5665_IN1_IN2, in rt5665_i2c_probe()
4838 if (rt5665->pdata.in2_diff) in rt5665_i2c_probe()
4839 regmap_update_bits(rt5665->regmap, RT5665_IN1_IN2, in rt5665_i2c_probe()
4841 if (rt5665->pdata.in3_diff) in rt5665_i2c_probe()
4842 regmap_update_bits(rt5665->regmap, RT5665_IN3_IN4, in rt5665_i2c_probe()
4844 if (rt5665->pdata.in4_diff) in rt5665_i2c_probe()
4845 regmap_update_bits(rt5665->regmap, RT5665_IN3_IN4, in rt5665_i2c_probe()
4849 if (rt5665->pdata.dmic1_data_pin != RT5665_DMIC1_NULL || in rt5665_i2c_probe()
4850 rt5665->pdata.dmic2_data_pin != RT5665_DMIC2_NULL) { in rt5665_i2c_probe()
4851 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_2, in rt5665_i2c_probe()
4853 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4855 switch (rt5665->pdata.dmic1_data_pin) { in rt5665_i2c_probe()
4857 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4862 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4864 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4873 switch (rt5665->pdata.dmic2_data_pin) { in rt5665_i2c_probe()
4875 regmap_update_bits(rt5665->regmap, RT5665_DMIC_CTRL_1, in rt5665_i2c_probe()
4880 regmap_update_bits(rt5665->regmap, in rt5665_i2c_probe()
4884 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_1, in rt5665_i2c_probe()
4895 regmap_write(rt5665->regmap, RT5665_HP_LOGIC_CTRL_2, 0x0002); in rt5665_i2c_probe()
4896 regmap_update_bits(rt5665->regmap, RT5665_EJD_CTRL_1, in rt5665_i2c_probe()
4899 regmap_update_bits(rt5665->regmap, RT5665_STO1_DAC_SIL_DET, in rt5665_i2c_probe()
4902 regmap_update_bits(rt5665->regmap, RT5665_HP_CHARGE_PUMP_1, in rt5665_i2c_probe()
4906 if (rt5665->id == CODEC_5666) { in rt5665_i2c_probe()
4907 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_2, in rt5665_i2c_probe()
4909 regmap_update_bits(rt5665->regmap, RT5665_GPIO_CTRL_3, in rt5665_i2c_probe()
4914 regmap_update_bits(rt5665->regmap, RT5665_PWR_ANLG_1, in rt5665_i2c_probe()
4918 INIT_DELAYED_WORK(&rt5665->jack_detect_work, in rt5665_i2c_probe()
4920 INIT_DELAYED_WORK(&rt5665->calibrate_work, in rt5665_i2c_probe()
4922 INIT_DELAYED_WORK(&rt5665->jd_check_work, in rt5665_i2c_probe()
4925 mutex_init(&rt5665->calibrate_mutex); in rt5665_i2c_probe()
4930 | IRQF_ONESHOT, "rt5665", rt5665); in rt5665_i2c_probe()
4943 struct rt5665_priv *rt5665 = i2c_get_clientdata(client); in rt5665_i2c_shutdown() local
4945 regmap_write(rt5665->regmap, RT5665_RESET, 0); in rt5665_i2c_shutdown()