Lines Matching +full:dmic +full:- +full:freq

1 // SPDX-License-Identifier: GPL-2.0-only
3 * tas2552.c - ALSA SoC Texas Instruments TAS2552 Mono Audio Amplifier
5 * Copyright (C) 2014 - 2024 Texas Instruments Incorporated -
25 #include <sound/soc-dapm.h>
27 #include <sound/tas2552-plat.h>
28 #include <dt-bindings/sound/tas2552.h>
82 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas2552_post_event()
128 SND_SOC_DAPM_INPUT("DMIC")
138 {"ASI OUT", NULL, "DMIC"}
146 if (!tas2552->component) in tas2552_sw_shutdown()
152 snd_soc_component_update_bits(tas2552->component, TAS2552_CFG_1, TAS2552_SWS, in tas2552_sw_shutdown()
160 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_setup_pll()
163 unsigned int pll_clkin = tas2552->pll_clkin; in tas2552_setup_pll()
167 if (tas2552->pll_clk_id != TAS2552_PLL_CLKIN_BCLK) in tas2552_setup_pll()
168 return -EINVAL; in tas2552_setup_pll()
171 pll_clkin += tas2552->tdm_delay; in tas2552_setup_pll()
187 * Need to fill in J and D here based on incoming freq in tas2552_setup_pll()
191 u8 pll_sel = (tas2552->pll_clk_id << 3) & TAS2552_PLL_SRC_MASK; in tas2552_setup_pll()
202 d = q + ((9999 - pll_clkin % 10000) * (d / t - q)) / 10000; in tas2552_setup_pll()
205 if (tas2552->pll_clk_id == TAS2552_PLL_CLKIN_BCLK) { in tas2552_setup_pll()
211 pll_clkin += tas2552->tdm_delay; in tas2552_setup_pll()
241 struct snd_soc_component *component = dai->component; in tas2552_hw_params()
242 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_hw_params()
249 cpf = 32 + tas2552->tdm_delay; in tas2552_hw_params()
253 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
257 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
261 cpf = 64 + tas2552->tdm_delay; in tas2552_hw_params()
264 dev_err(component->dev, "Not supported sample size: %d\n", in tas2552_hw_params()
266 return -EINVAL; in tas2552_hw_params()
313 dev_err(component->dev, "Not supported sample rate: %d\n", in tas2552_hw_params()
315 return -EINVAL; in tas2552_hw_params()
330 struct snd_soc_component *component = dai->component; in tas2552_prepare()
335 if (tas2552->dai_fmt == SND_SOC_DAIFMT_DSP_A) in tas2552_prepare()
336 delay += (tas2552->tdm_delay + 1); in tas2552_prepare()
337 else if (tas2552->dai_fmt == SND_SOC_DAIFMT_DSP_B) in tas2552_prepare()
338 delay += tas2552->tdm_delay; in tas2552_prepare()
348 struct snd_soc_component *component = dai->component; in tas2552_set_dai_fmt()
349 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_set_dai_fmt()
366 dev_vdbg(component->dev, "DAI Format master is not found\n"); in tas2552_set_dai_fmt()
367 return -EINVAL; in tas2552_set_dai_fmt()
385 dev_vdbg(component->dev, "DAI Format is not found\n"); in tas2552_set_dai_fmt()
386 return -EINVAL; in tas2552_set_dai_fmt()
388 tas2552->dai_fmt = fmt & SND_SOC_DAIFMT_FORMAT_MASK; in tas2552_set_dai_fmt()
396 unsigned int freq, int dir) in tas2552_set_dai_sysclk() argument
398 struct snd_soc_component *component = dai->component; in tas2552_set_dai_sysclk()
399 struct tas2552_data *tas2552 = dev_get_drvdata(component->dev); in tas2552_set_dai_sysclk()
405 if (freq < 512000 || freq > 24576000) { in tas2552_set_dai_sysclk()
407 dev_warn(component->dev, "Out of range PLL_CLKIN: %u\n", in tas2552_set_dai_sysclk()
408 freq); in tas2552_set_dai_sysclk()
410 freq = 0; in tas2552_set_dai_sysclk()
418 tas2552->pll_clk_id = clk_id; in tas2552_set_dai_sysclk()
419 tas2552->pll_clkin = freq; in tas2552_set_dai_sysclk()
428 tas2552->pdm_clk_id = clk_id; in tas2552_set_dai_sysclk()
429 tas2552->pdm_clk = freq; in tas2552_set_dai_sysclk()
432 dev_err(component->dev, "Invalid clk id: %d\n", clk_id); in tas2552_set_dai_sysclk()
433 return -EINVAL; in tas2552_set_dai_sysclk()
445 struct snd_soc_component *component = dai->component; in tas2552_set_dai_tdm_slot()
450 dev_err(component->dev, "tx masks need to be non 0\n"); in tas2552_set_dai_tdm_slot()
451 return -EINVAL; in tas2552_set_dai_tdm_slot()
457 dev_err(component->dev, "Invalid mask, slots must be adjacent\n"); in tas2552_set_dai_tdm_slot()
458 return -EINVAL; in tas2552_set_dai_tdm_slot()
461 tas2552->tdm_delay = lsb * slot_width; in tas2552_set_dai_tdm_slot()
463 /* DOUT in high-impedance on inactive bit clocks */ in tas2552_set_dai_tdm_slot()
473 struct snd_soc_component *component = dai->component; in tas2552_mute()
490 regcache_cache_only(tas2552->regmap, true); in tas2552_runtime_suspend()
491 regcache_mark_dirty(tas2552->regmap); in tas2552_runtime_suspend()
493 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_runtime_suspend()
502 gpiod_set_value(tas2552->enable_gpio, 1); in tas2552_runtime_resume()
506 regcache_cache_only(tas2552->regmap, false); in tas2552_runtime_resume()
507 regcache_sync(tas2552->regmap); in tas2552_runtime_resume()
535 .name = "tas2552-amplifier",
555 * DAC digital volumes. From -7 to 24 dB in 1 dB steps
557 static DECLARE_TLV_DB_SCALE(dac_tlv, -700, 100, 0);
580 tas2552->component = component; in tas2552_component_probe()
582 ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), in tas2552_component_probe()
583 tas2552->supplies); in tas2552_component_probe()
586 dev_err(component->dev, "Failed to enable supplies: %d\n", in tas2552_component_probe()
591 gpiod_set_value(tas2552->enable_gpio, 1); in tas2552_component_probe()
593 ret = pm_runtime_resume_and_get(component->dev); in tas2552_component_probe()
595 dev_err(component->dev, "Enabling device failed: %d\n", in tas2552_component_probe()
615 pm_runtime_put_noidle(component->dev); in tas2552_component_probe()
616 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_component_probe()
618 regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), in tas2552_component_probe()
619 tas2552->supplies); in tas2552_component_probe()
627 pm_runtime_put(component->dev); in tas2552_component_remove()
629 gpiod_set_value(tas2552->enable_gpio, 0); in tas2552_component_remove()
638 ret = regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), in tas2552_suspend()
639 tas2552->supplies); in tas2552_suspend()
642 dev_err(component->dev, "Failed to disable supplies: %d\n", in tas2552_suspend()
652 ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), in tas2552_resume()
653 tas2552->supplies); in tas2552_resume()
656 dev_err(component->dev, "Failed to enable supplies: %d\n", in tas2552_resume()
699 dev = &client->dev; in tas2552_probe()
700 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); in tas2552_probe()
702 return -ENOMEM; in tas2552_probe()
704 data->enable_gpio = devm_gpiod_get_optional(dev, "enable", in tas2552_probe()
706 if (IS_ERR(data->enable_gpio)) in tas2552_probe()
707 return PTR_ERR(data->enable_gpio); in tas2552_probe()
709 data->tas2552_client = client; in tas2552_probe()
710 data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config); in tas2552_probe()
711 if (IS_ERR(data->regmap)) { in tas2552_probe()
712 ret = PTR_ERR(data->regmap); in tas2552_probe()
713 dev_err(&client->dev, "Failed to allocate register map: %d\n", in tas2552_probe()
718 for (i = 0; i < ARRAY_SIZE(data->supplies); i++) in tas2552_probe()
719 data->supplies[i].supply = tas2552_supply_names[i]; in tas2552_probe()
721 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), in tas2552_probe()
722 data->supplies); in tas2552_probe()
728 pm_runtime_set_active(&client->dev); in tas2552_probe()
729 pm_runtime_set_autosuspend_delay(&client->dev, 1000); in tas2552_probe()
730 pm_runtime_use_autosuspend(&client->dev); in tas2552_probe()
731 pm_runtime_enable(&client->dev); in tas2552_probe()
732 pm_runtime_mark_last_busy(&client->dev); in tas2552_probe()
733 pm_runtime_put_sync_autosuspend(&client->dev); in tas2552_probe()
735 dev_set_drvdata(&client->dev, data); in tas2552_probe()
737 ret = devm_snd_soc_register_component(&client->dev, in tas2552_probe()
741 dev_err(&client->dev, "Failed to register component: %d\n", ret); in tas2552_probe()
742 pm_runtime_get_noresume(&client->dev); in tas2552_probe()
750 pm_runtime_disable(&client->dev); in tas2552_i2c_remove()