Lines Matching +full:clock +full:- +full:det +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0
3 // rt1016.c -- RT1016 ALSA SoC audio amplifier driver
23 #include <sound/soc-dapm.h>
166 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -9550, 50, 0);
179 snd_soc_dapm_to_component(source->dapm); in rt1016_is_sys_clk_from_pll()
182 if (rt1016->sysclk_src == RT1016_SCLK_S_PLL) in rt1016_is_sys_clk_from_pll()
188 /* Interface data select */
197 SOC_DAPM_ENUM("Data Swap Mux", rt1016_if_data_swap_enum);
200 SND_SOC_DAPM_MUX("Data Swap Mux", SND_SOC_NOPM, 0, 0,
211 SND_SOC_DAPM_SUPPLY("CLK Silence Det", RT1016_CLOCK_3,
222 SND_SOC_DAPM_SUPPLY("LRCK Det", RT1016_CLOCK_4, RT1016_PWR_LRCK_DET_BIT,
224 SND_SOC_DAPM_SUPPLY("BCLK Det", RT1016_CLOCK_4, RT1016_PWR_BCLK_DET_BIT,
231 SND_SOC_DAPM_SUPPLY("Silence Det", RT1016_SIL_DET,
266 { "Data Swap Mux", "L/R", "AIFRX" },
267 { "Data Swap Mux", "R/L", "AIFRX" },
268 { "Data Swap Mux", "L/L", "AIFRX" },
269 { "Data Swap Mux", "R/R", "AIFRX" },
275 { "DAC", NULL, "Silence Det" },
278 { "DAC", NULL, "LRCK Det" },
279 { "DAC", NULL, "BCLK Det" },
286 { "Silence Det", NULL, "CLK Silence Det" },
288 { "DAC", NULL, "Data Swap Mux" },
307 struct snd_soc_component *component = dai->component; in rt1016_hw_params()
312 rt1016->lrck = params_rate(params); in rt1016_hw_params()
313 pre_div = rl6231_get_clk_info(rt1016->sysclk, rt1016->lrck); in rt1016_hw_params()
315 dev_err(component->dev, "Unsupported clock rate\n"); in rt1016_hw_params()
316 return -EINVAL; in rt1016_hw_params()
321 dev_err(component->dev, "Unsupported frame size: %d\n", in rt1016_hw_params()
323 return -EINVAL; in rt1016_hw_params()
327 rt1016->bclk = rt1016->lrck * (32 << bclk_ms); in rt1016_hw_params()
329 if (bclk_ms && rt1016->master) in rt1016_hw_params()
333 dev_dbg(component->dev, "lrck is %dHz and pre_div is %d for iis %d\n", in rt1016_hw_params()
334 rt1016->lrck, pre_div, dai->id); in rt1016_hw_params()
350 return -EINVAL; in rt1016_hw_params()
365 struct snd_soc_component *component = dai->component; in rt1016_set_dai_fmt()
372 rt1016->master = 1; in rt1016_set_dai_fmt()
378 return -EINVAL; in rt1016_set_dai_fmt()
388 return -EINVAL; in rt1016_set_dai_fmt()
408 return -EINVAL; in rt1016_set_dai_fmt()
424 if (freq == rt1016->sysclk && clk_id == rt1016->sysclk_src) in rt1016_set_component_sysclk()
437 dev_err(component->dev, "Invalid clock id (%d)\n", clk_id); in rt1016_set_component_sysclk()
438 return -EINVAL; in rt1016_set_component_sysclk()
441 rt1016->sysclk = freq; in rt1016_set_component_sysclk()
442 rt1016->sysclk_src = clk_id; in rt1016_set_component_sysclk()
444 dev_dbg(component->dev, "Sysclk is %dHz and clock id is %d\n", in rt1016_set_component_sysclk()
462 dev_dbg(component->dev, "PLL disabled\n"); in rt1016_set_component_pll()
464 rt1016->pll_in = 0; in rt1016_set_component_pll()
465 rt1016->pll_out = 0; in rt1016_set_component_pll()
470 if (source == rt1016->pll_src && freq_in == rt1016->pll_in && in rt1016_set_component_pll()
471 freq_out == rt1016->pll_out) in rt1016_set_component_pll()
486 dev_err(component->dev, "Unknown PLL Source %d\n", source); in rt1016_set_component_pll()
487 return -EINVAL; in rt1016_set_component_pll()
492 dev_err(component->dev, "Unsupported input clock %d\n", freq_in); in rt1016_set_component_pll()
496 dev_dbg(component->dev, "mbypass=%d m=%d n=%d kbypass=%d k=%d\n", in rt1016_set_component_pll()
509 rt1016->pll_in = freq_in; in rt1016_set_component_pll()
510 rt1016->pll_out = freq_out; in rt1016_set_component_pll()
511 rt1016->pll_src = source; in rt1016_set_component_pll()
521 rt1016->component = component; in rt1016_probe()
530 regmap_write(rt1016->regmap, RT1016_RESET, 0); in rt1016_remove()
544 .name = "rt1016-aif",
562 regcache_cache_only(rt1016->regmap, true); in rt1016_suspend()
563 regcache_mark_dirty(rt1016->regmap); in rt1016_suspend()
572 regcache_cache_only(rt1016->regmap, false); in rt1016_resume()
573 regcache_sync(rt1016->regmap); in rt1016_resume()
638 rt1016 = devm_kzalloc(&i2c->dev, sizeof(struct rt1016_priv), in rt1016_i2c_probe()
641 return -ENOMEM; in rt1016_i2c_probe()
645 rt1016->regmap = devm_regmap_init_i2c(i2c, &rt1016_regmap); in rt1016_i2c_probe()
646 if (IS_ERR(rt1016->regmap)) { in rt1016_i2c_probe()
647 ret = PTR_ERR(rt1016->regmap); in rt1016_i2c_probe()
648 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in rt1016_i2c_probe()
653 regmap_read(rt1016->regmap, RT1016_DEVICE_ID, &val); in rt1016_i2c_probe()
655 dev_err(&i2c->dev, in rt1016_i2c_probe()
657 return -ENODEV; in rt1016_i2c_probe()
660 regmap_write(rt1016->regmap, RT1016_RESET, 0); in rt1016_i2c_probe()
662 ret = regmap_register_patch(rt1016->regmap, rt1016_patch, in rt1016_i2c_probe()
665 dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); in rt1016_i2c_probe()
667 return devm_snd_soc_register_component(&i2c->dev, in rt1016_i2c_probe()
676 regmap_write(rt1016->regmap, RT1016_RESET, 0); in rt1016_i2c_shutdown()