Lines Matching refs:rt5668

898 	struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component);  in rt5668_headset_detect()  local
922 rt5668->jack_type = SND_JACK_HEADSET; in rt5668_headset_detect()
926 rt5668->jack_type = SND_JACK_HEADPHONE; in rt5668_headset_detect()
936 rt5668->jack_type = 0; in rt5668_headset_detect()
939 dev_dbg(component->dev, "jack_type = %d\n", rt5668->jack_type); in rt5668_headset_detect()
940 return rt5668->jack_type; in rt5668_headset_detect()
945 struct rt5668_priv *rt5668 = data; in rt5668_irq() local
948 &rt5668->jack_detect_work, msecs_to_jiffies(250)); in rt5668_irq()
955 struct rt5668_priv *rt5668 = container_of(work, struct rt5668_priv, in rt5668_jd_check_handler() local
958 if (snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL) in rt5668_jd_check_handler()
961 rt5668->jack_type = rt5668_headset_detect(rt5668->component, 0); in rt5668_jd_check_handler()
963 snd_soc_jack_report(rt5668->hs_jack, rt5668->jack_type, in rt5668_jd_check_handler()
968 schedule_delayed_work(&rt5668->jd_check_work, 500); in rt5668_jd_check_handler()
975 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_jack_detect() local
977 switch (rt5668->pdata.jd_src) { in rt5668_set_jack_detect()
986 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_set_jack_detect()
988 regmap_update_bits(rt5668->regmap, RT5668_RC_CLK_CTRL, in rt5668_set_jack_detect()
992 regmap_update_bits(rt5668->regmap, RT5668_PWR_ANLG_2, in rt5668_set_jack_detect()
995 regmap_update_bits(rt5668->regmap, RT5668_IRQ_CTRL_2, in rt5668_set_jack_detect()
999 &rt5668->jack_detect_work, msecs_to_jiffies(250)); in rt5668_set_jack_detect()
1003 regmap_update_bits(rt5668->regmap, RT5668_IRQ_CTRL_2, in rt5668_set_jack_detect()
1005 regmap_update_bits(rt5668->regmap, RT5668_RC_CLK_CTRL, in rt5668_set_jack_detect()
1014 rt5668->hs_jack = hs_jack; in rt5668_set_jack_detect()
1021 struct rt5668_priv *rt5668 = in rt5668_jack_detect_handler() local
1025 if (!rt5668->component || in rt5668_jack_detect_handler()
1026 !snd_soc_card_is_instantiated(rt5668->component->card)) { in rt5668_jack_detect_handler()
1029 &rt5668->jack_detect_work, msecs_to_jiffies(15)); in rt5668_jack_detect_handler()
1033 mutex_lock(&rt5668->calibrate_mutex); in rt5668_jack_detect_handler()
1035 val = snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL) in rt5668_jack_detect_handler()
1039 if (rt5668->jack_type == 0) { in rt5668_jack_detect_handler()
1041 rt5668->jack_type = in rt5668_jack_detect_handler()
1042 rt5668_headset_detect(rt5668->component, 1); in rt5668_jack_detect_handler()
1045 rt5668->jack_type = SND_JACK_HEADSET; in rt5668_jack_detect_handler()
1046 btn_type = rt5668_button_detect(rt5668->component); in rt5668_jack_detect_handler()
1058 rt5668->jack_type |= SND_JACK_BTN_0; in rt5668_jack_detect_handler()
1063 rt5668->jack_type |= SND_JACK_BTN_1; in rt5668_jack_detect_handler()
1068 rt5668->jack_type |= SND_JACK_BTN_2; in rt5668_jack_detect_handler()
1073 rt5668->jack_type |= SND_JACK_BTN_3; in rt5668_jack_detect_handler()
1079 dev_err(rt5668->component->dev, in rt5668_jack_detect_handler()
1087 rt5668->jack_type = rt5668_headset_detect(rt5668->component, 0); in rt5668_jack_detect_handler()
1090 snd_soc_jack_report(rt5668->hs_jack, rt5668->jack_type, in rt5668_jack_detect_handler()
1095 if (rt5668->jack_type & (SND_JACK_BTN_0 | SND_JACK_BTN_1 | in rt5668_jack_detect_handler()
1097 schedule_delayed_work(&rt5668->jd_check_work, 0); in rt5668_jack_detect_handler()
1099 cancel_delayed_work_sync(&rt5668->jd_check_work); in rt5668_jack_detect_handler()
1101 mutex_unlock(&rt5668->calibrate_mutex); in rt5668_jack_detect_handler()
1130 static int rt5668_div_sel(struct rt5668_priv *rt5668, in rt5668_div_sel() argument
1135 if (rt5668->sysclk < target) { in rt5668_div_sel()
1137 rt5668->sysclk); in rt5668_div_sel()
1143 if (target * div[i] == rt5668->sysclk) in rt5668_div_sel()
1145 if (target * div[i + 1] > rt5668->sysclk) { in rt5668_div_sel()
1147 rt5668->sysclk); in rt5668_div_sel()
1152 if (target * div[i] < rt5668->sysclk) in rt5668_div_sel()
1154 rt5668->sysclk); in rt5668_div_sel()
1175 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in set_dmic_clk() local
1179 idx = rt5668_div_sel(rt5668, 1500000, div, ARRAY_SIZE(div)); in set_dmic_clk()
1192 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in set_filter_clk() local
1200 ref = 256 * rt5668->lrck[RT5668_AIF2]; in set_filter_clk()
1202 ref = 256 * rt5668->lrck[RT5668_AIF1]; in set_filter_clk()
1204 idx = rt5668_div_sel(rt5668, ref, div, ARRAY_SIZE(div)); in set_filter_clk()
1923 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_hw_params() local
1927 rt5668->lrck[dai->id] = params_rate(params); in rt5668_hw_params()
1928 pre_div = rl6231_get_clk_info(rt5668->sysclk, rt5668->lrck[dai->id]); in rt5668_hw_params()
1938 rt5668->lrck[dai->id], pre_div, dai->id); in rt5668_hw_params()
1967 if (rt5668->master[RT5668_AIF1]) { in rt5668_hw_params()
1984 if (rt5668->master[RT5668_AIF2]) { in rt5668_hw_params()
2009 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_dai_fmt() local
2014 rt5668->master[dai->id] = 1; in rt5668_set_dai_fmt()
2017 rt5668->master[dai->id] = 0; in rt5668_set_dai_fmt()
2074 tdm_ctrl | rt5668->master[dai->id]); in rt5668_set_dai_fmt()
2077 if (rt5668->master[dai->id] == 0) in rt5668_set_dai_fmt()
2093 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_component_sysclk() local
2096 if (freq == rt5668->sysclk && clk_id == rt5668->sysclk_src) in rt5668_set_component_sysclk()
2123 if (rt5668->master[RT5668_AIF2]) { in rt5668_set_component_sysclk()
2129 rt5668->sysclk = freq; in rt5668_set_component_sysclk()
2130 rt5668->sysclk_src = clk_id; in rt5668_set_component_sysclk()
2142 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_component_pll() local
2146 if (source == rt5668->pll_src && freq_in == rt5668->pll_in && in rt5668_set_component_pll()
2147 freq_out == rt5668->pll_out) in rt5668_set_component_pll()
2153 rt5668->pll_in = 0; in rt5668_set_component_pll()
2154 rt5668->pll_out = 0; in rt5668_set_component_pll()
2190 rt5668->pll_in = freq_in; in rt5668_set_component_pll()
2191 rt5668->pll_out = freq_out; in rt5668_set_component_pll()
2192 rt5668->pll_src = source; in rt5668_set_component_pll()
2200 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_bclk_ratio() local
2202 rt5668->bclk[dai->id] = ratio; in rt5668_set_bclk_ratio()
2226 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_set_bias_level() local
2230 regmap_update_bits(rt5668->regmap, RT5668_PWR_ANLG_1, in rt5668_set_bias_level()
2233 regmap_update_bits(rt5668->regmap, RT5668_PWR_DIG_1, in rt5668_set_bias_level()
2239 regmap_update_bits(rt5668->regmap, RT5668_PWR_ANLG_1, in rt5668_set_bias_level()
2241 regmap_update_bits(rt5668->regmap, RT5668_PWR_DIG_1, in rt5668_set_bias_level()
2245 regmap_update_bits(rt5668->regmap, RT5668_PWR_DIG_1, in rt5668_set_bias_level()
2247 regmap_update_bits(rt5668->regmap, RT5668_PWR_ANLG_1, in rt5668_set_bias_level()
2260 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_probe() local
2262 rt5668->component = component; in rt5668_probe()
2269 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_remove() local
2271 rt5668_reset(rt5668->regmap); in rt5668_remove()
2277 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_suspend() local
2279 regcache_cache_only(rt5668->regmap, true); in rt5668_suspend()
2280 regcache_mark_dirty(rt5668->regmap); in rt5668_suspend()
2286 struct rt5668_priv *rt5668 = snd_soc_component_get_drvdata(component); in rt5668_resume() local
2288 regcache_cache_only(rt5668->regmap, false); in rt5668_resume()
2289 regcache_sync(rt5668->regmap); in rt5668_resume()
2386 static int rt5668_parse_dt(struct rt5668_priv *rt5668, struct device *dev) in rt5668_parse_dt() argument
2390 &rt5668->pdata.dmic1_data_pin); in rt5668_parse_dt()
2392 &rt5668->pdata.dmic1_clk_pin); in rt5668_parse_dt()
2394 &rt5668->pdata.jd_src); in rt5668_parse_dt()
2399 static void rt5668_calibrate(struct rt5668_priv *rt5668) in rt5668_calibrate() argument
2403 mutex_lock(&rt5668->calibrate_mutex); in rt5668_calibrate()
2405 rt5668_reset(rt5668->regmap); in rt5668_calibrate()
2406 regmap_write(rt5668->regmap, RT5668_PWR_ANLG_1, 0xa2bf); in rt5668_calibrate()
2408 regmap_write(rt5668->regmap, RT5668_PWR_ANLG_1, 0xf2bf); in rt5668_calibrate()
2409 regmap_write(rt5668->regmap, RT5668_MICBIAS_2, 0x0380); in rt5668_calibrate()
2410 regmap_write(rt5668->regmap, RT5668_PWR_DIG_1, 0x8001); in rt5668_calibrate()
2411 regmap_write(rt5668->regmap, RT5668_TEST_MODE_CTRL_1, 0x0000); in rt5668_calibrate()
2412 regmap_write(rt5668->regmap, RT5668_STO1_DAC_MIXER, 0x2080); in rt5668_calibrate()
2413 regmap_write(rt5668->regmap, RT5668_STO1_ADC_MIXER, 0x4040); in rt5668_calibrate()
2414 regmap_write(rt5668->regmap, RT5668_DEPOP_1, 0x0069); in rt5668_calibrate()
2415 regmap_write(rt5668->regmap, RT5668_CHOP_DAC, 0x3000); in rt5668_calibrate()
2416 regmap_write(rt5668->regmap, RT5668_HP_CTRL_2, 0x6000); in rt5668_calibrate()
2417 regmap_write(rt5668->regmap, RT5668_HP_CHARGE_PUMP_1, 0x0f26); in rt5668_calibrate()
2418 regmap_write(rt5668->regmap, RT5668_CALIB_ADC_CTRL, 0x7f05); in rt5668_calibrate()
2419 regmap_write(rt5668->regmap, RT5668_STO1_ADC_MIXER, 0x686c); in rt5668_calibrate()
2420 regmap_write(rt5668->regmap, RT5668_CAL_REC, 0x0d0d); in rt5668_calibrate()
2421 regmap_write(rt5668->regmap, RT5668_HP_CALIB_CTRL_9, 0x000f); in rt5668_calibrate()
2422 regmap_write(rt5668->regmap, RT5668_PWR_DIG_1, 0x8d01); in rt5668_calibrate()
2423 regmap_write(rt5668->regmap, RT5668_HP_CALIB_CTRL_2, 0x0321); in rt5668_calibrate()
2424 regmap_write(rt5668->regmap, RT5668_HP_LOGIC_CTRL_2, 0x0004); in rt5668_calibrate()
2425 regmap_write(rt5668->regmap, RT5668_HP_CALIB_CTRL_1, 0x7c00); in rt5668_calibrate()
2426 regmap_write(rt5668->regmap, RT5668_HP_CALIB_CTRL_3, 0x06a1); in rt5668_calibrate()
2427 regmap_write(rt5668->regmap, RT5668_A_DAC1_MUX, 0x0311); in rt5668_calibrate()
2428 regmap_write(rt5668->regmap, RT5668_RESET_HPF_CTRL, 0x0000); in rt5668_calibrate()
2429 regmap_write(rt5668->regmap, RT5668_ADC_STO1_HP_CTRL_1, 0x3320); in rt5668_calibrate()
2431 regmap_write(rt5668->regmap, RT5668_HP_CALIB_CTRL_1, 0xfc00); in rt5668_calibrate()
2434 regmap_read(rt5668->regmap, RT5668_HP_CALIB_STA_1, &value); in rt5668_calibrate()
2445 regmap_write(rt5668->regmap, RT5668_STO1_ADC_MIXER, 0xc0c4); in rt5668_calibrate()
2446 regmap_write(rt5668->regmap, RT5668_PWR_DIG_1, 0x0000); in rt5668_calibrate()
2448 mutex_unlock(&rt5668->calibrate_mutex); in rt5668_calibrate()
2455 struct rt5668_priv *rt5668; in rt5668_i2c_probe() local
2459 rt5668 = devm_kzalloc(&i2c->dev, sizeof(struct rt5668_priv), in rt5668_i2c_probe()
2462 if (rt5668 == NULL) in rt5668_i2c_probe()
2465 i2c_set_clientdata(i2c, rt5668); in rt5668_i2c_probe()
2468 rt5668->pdata = *pdata; in rt5668_i2c_probe()
2470 rt5668_parse_dt(rt5668, &i2c->dev); in rt5668_i2c_probe()
2472 rt5668->regmap = devm_regmap_init_i2c(i2c, &rt5668_regmap); in rt5668_i2c_probe()
2473 if (IS_ERR(rt5668->regmap)) { in rt5668_i2c_probe()
2474 ret = PTR_ERR(rt5668->regmap); in rt5668_i2c_probe()
2480 for (i = 0; i < ARRAY_SIZE(rt5668->supplies); i++) in rt5668_i2c_probe()
2481 rt5668->supplies[i].supply = rt5668_supply_names[i]; in rt5668_i2c_probe()
2483 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(rt5668->supplies), in rt5668_i2c_probe()
2484 rt5668->supplies); in rt5668_i2c_probe()
2490 ret = regulator_bulk_enable(ARRAY_SIZE(rt5668->supplies), in rt5668_i2c_probe()
2491 rt5668->supplies); in rt5668_i2c_probe()
2497 rt5668->ldo1_en = devm_gpiod_get_optional(&i2c->dev, in rt5668_i2c_probe()
2500 if (IS_ERR(rt5668->ldo1_en)) { in rt5668_i2c_probe()
2502 return PTR_ERR(rt5668->ldo1_en); in rt5668_i2c_probe()
2508 regmap_write(rt5668->regmap, RT5668_I2C_MODE, 0x1); in rt5668_i2c_probe()
2511 regmap_read(rt5668->regmap, RT5668_DEVICE_ID, &val); in rt5668_i2c_probe()
2517 rt5668_reset(rt5668->regmap); in rt5668_i2c_probe()
2519 rt5668_calibrate(rt5668); in rt5668_i2c_probe()
2521 regmap_write(rt5668->regmap, RT5668_DEPOP_1, 0x0000); in rt5668_i2c_probe()
2524 if (rt5668->pdata.dmic1_data_pin != RT5668_DMIC1_NULL) { in rt5668_i2c_probe()
2525 switch (rt5668->pdata.dmic1_data_pin) { in rt5668_i2c_probe()
2527 regmap_update_bits(rt5668->regmap, RT5668_DMIC_CTRL_1, in rt5668_i2c_probe()
2529 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_i2c_probe()
2534 regmap_update_bits(rt5668->regmap, RT5668_DMIC_CTRL_1, in rt5668_i2c_probe()
2536 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_i2c_probe()
2545 switch (rt5668->pdata.dmic1_clk_pin) { in rt5668_i2c_probe()
2547 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_i2c_probe()
2552 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_i2c_probe()
2562 regmap_update_bits(rt5668->regmap, RT5668_PWR_ANLG_1, in rt5668_i2c_probe()
2565 regmap_write(rt5668->regmap, RT5668_MICBIAS_2, 0x0380); in rt5668_i2c_probe()
2566 regmap_update_bits(rt5668->regmap, RT5668_GPIO_CTRL_1, in rt5668_i2c_probe()
2569 regmap_write(rt5668->regmap, RT5668_TEST_MODE_CTRL_1, 0x0000); in rt5668_i2c_probe()
2571 INIT_DELAYED_WORK(&rt5668->jack_detect_work, in rt5668_i2c_probe()
2573 INIT_DELAYED_WORK(&rt5668->jd_check_work, in rt5668_i2c_probe()
2576 mutex_init(&rt5668->calibrate_mutex); in rt5668_i2c_probe()
2581 | IRQF_ONESHOT, "rt5668", rt5668); in rt5668_i2c_probe()
2593 struct rt5668_priv *rt5668 = i2c_get_clientdata(client); in rt5668_i2c_shutdown() local
2595 rt5668_reset(rt5668->regmap); in rt5668_i2c_shutdown()