Lines Matching +full:sm8250 +full:- +full:lpass +full:- +full:tx +full:- +full:macro

1 // SPDX-License-Identifier: GPL-2.0-only
2 // Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
5 #include <linux/clk-provider.h>
16 #include <sound/soc-dapm.h>
19 #include "lpass-macro-common.h"
21 /* VA macro registers */
165 static const DECLARE_TLV_DB_SCALE(digital_gain, -8400, 100, -8400);
208 struct clk *macro; member
255 /* VA macro */
443 struct regmap *regmap = va->regmap; in va_clk_rsc_fs_gen_request()
476 struct regmap *regmap = va->regmap; in va_macro_mclk_enable()
492 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in va_macro_mclk_event()
497 return clk_prepare_enable(va->fsgen); in va_macro_mclk_event()
499 clk_disable_unprepare(va->fsgen); in va_macro_mclk_event()
511 snd_soc_dapm_to_component(widget->dapm); in va_macro_put_dec_enum()
512 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in va_macro_put_dec_enum()
516 val = ucontrol->value.enumerated.item[0]; in va_macro_put_dec_enum()
518 switch (e->reg) { in va_macro_put_dec_enum()
532 dev_err(component->dev, "%s: e->reg: 0x%x not expected\n", in va_macro_put_dec_enum()
533 __func__, e->reg); in va_macro_put_dec_enum()
534 return -EINVAL; in va_macro_put_dec_enum()
551 snd_soc_dapm_to_component(widget->dapm); in va_macro_tx_mixer_get()
553 (struct soc_mixer_control *)kcontrol->private_value; in va_macro_tx_mixer_get()
554 u32 dai_id = widget->shift; in va_macro_tx_mixer_get()
555 u32 dec_id = mc->shift; in va_macro_tx_mixer_get()
558 if (test_bit(dec_id, &va->active_ch_mask[dai_id])) in va_macro_tx_mixer_get()
559 ucontrol->value.integer.value[0] = 1; in va_macro_tx_mixer_get()
561 ucontrol->value.integer.value[0] = 0; in va_macro_tx_mixer_get()
572 snd_soc_dapm_to_component(widget->dapm); in va_macro_tx_mixer_put()
575 (struct soc_mixer_control *)kcontrol->private_value; in va_macro_tx_mixer_put()
576 u32 dai_id = widget->shift; in va_macro_tx_mixer_put()
577 u32 dec_id = mc->shift; in va_macro_tx_mixer_put()
578 u32 enable = ucontrol->value.integer.value[0]; in va_macro_tx_mixer_put()
582 set_bit(dec_id, &va->active_ch_mask[dai_id]); in va_macro_tx_mixer_put()
583 va->active_ch_cnt[dai_id]++; in va_macro_tx_mixer_put()
585 clear_bit(dec_id, &va->active_ch_mask[dai_id]); in va_macro_tx_mixer_put()
586 va->active_ch_cnt[dai_id]--; in va_macro_tx_mixer_put()
589 snd_soc_dapm_mixer_update_power(widget->dapm, kcontrol, enable, update); in va_macro_tx_mixer_put()
607 dmic_clk_cnt = &(va->dmic_0_1_clk_cnt); in va_dmic_clk_enable()
608 dmic_clk_div = &(va->dmic_0_1_clk_div); in va_dmic_clk_enable()
614 dmic_clk_cnt = &(va->dmic_2_3_clk_cnt); in va_dmic_clk_enable()
615 dmic_clk_div = &(va->dmic_2_3_clk_div); in va_dmic_clk_enable()
621 dmic_clk_cnt = &(va->dmic_4_5_clk_cnt); in va_dmic_clk_enable()
622 dmic_clk_div = &(va->dmic_4_5_clk_div); in va_dmic_clk_enable()
628 dmic_clk_cnt = &(va->dmic_6_7_clk_cnt); in va_dmic_clk_enable()
629 dmic_clk_div = &(va->dmic_6_7_clk_div); in va_dmic_clk_enable()
634 dev_err(component->dev, "%s: Invalid DMIC Selection\n", in va_dmic_clk_enable()
636 return -EINVAL; in va_dmic_clk_enable()
640 clk_div = va->dmic_clk_div; in va_dmic_clk_enable()
672 (*dmic_clk_cnt)--; in va_dmic_clk_enable()
681 clk_div = va->dmic_clk_div; in va_dmic_clk_enable()
683 clk_div = va->dmic_clk_div; in va_dmic_clk_enable()
708 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in va_macro_enable_dmic()
709 unsigned int dmic = w->shift; in va_macro_enable_dmic()
726 struct snd_soc_component *comp = snd_soc_dapm_to_component(w->dapm); in va_macro_enable_dec()
734 decimator = w->shift; in va_macro_enable_dec()
749 va->dec_mode[decimator] << CDC_VA_ADC_MODE_SHIFT); in va_macro_enable_dec()
750 /* Enable TX PGA Mute */ in va_macro_enable_dec()
753 /* Enable TX CLK */ in va_macro_enable_dec()
799 /* Disable TX CLK */ in va_macro_enable_dec()
813 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in va_macro_dec_mode_get()
814 int path = e->shift_l; in va_macro_dec_mode_get()
816 ucontrol->value.enumerated.item[0] = va->dec_mode[path]; in va_macro_dec_mode_get()
825 int value = ucontrol->value.enumerated.item[0]; in va_macro_dec_mode_put()
826 struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; in va_macro_dec_mode_put()
827 int path = e->shift_l; in va_macro_dec_mode_put()
830 va->dec_mode[path] = value; in va_macro_dec_mode_put()
840 struct snd_soc_component *component = dai->component; in va_macro_hw_params()
843 struct device *va_dev = component->dev; in va_macro_hw_params()
870 dev_err(va_dev, "%s: Invalid TX sample rate: %d\n", in va_macro_hw_params()
872 return -EINVAL; in va_macro_hw_params()
875 for_each_set_bit(decimator, &va->active_ch_mask[dai->id], in va_macro_hw_params()
889 struct snd_soc_component *component = dai->component; in va_macro_get_channel_map()
890 struct device *va_dev = component->dev; in va_macro_get_channel_map()
893 switch (dai->id) { in va_macro_get_channel_map()
897 *tx_slot = va->active_ch_mask[dai->id]; in va_macro_get_channel_map()
898 *tx_num = va->active_ch_cnt[dai->id]; in va_macro_get_channel_map()
909 struct snd_soc_component *component = dai->component; in va_macro_digital_mute()
913 for_each_set_bit(decimator, &va->active_ch_mask[dai->id], in va_macro_digital_mute()
1120 SND_SOC_DAPM_REGULATOR_SUPPLY("vdd-micb", 0, 0),
1195 SND_SOC_DAPM_SUPPLY_S("VA_MCLK", -1, SND_SOC_NOPM, 0, 0,
1291 -84, 40, digital_gain),
1293 -84, 40, digital_gain),
1295 -84, 40, digital_gain),
1297 -84, 40, digital_gain),
1313 snd_soc_component_init_regmap(component, va->regmap); in va_macro_component_probe()
1319 .name = "VA MACRO",
1332 struct regmap *regmap = va->regmap; in fsgen_gate_enable()
1336 if (!va->has_swr_master) in fsgen_gate_enable()
1354 struct regmap *regmap = va->regmap; in fsgen_gate_disable()
1356 if (va->has_swr_master) in fsgen_gate_disable()
1368 regmap_read(va->regmap, CDC_VA_TOP_CSR_TOP_CFG0, &val); in fsgen_gate_is_enabled()
1381 struct clk *parent = va->mclk; in va_macro_register_fsgen_output()
1382 struct device *dev = va->dev; in va_macro_register_fsgen_output()
1383 struct device_node *np = dev->of_node; in va_macro_register_fsgen_output()
1391 of_property_read_string(np, "clock-output-names", &clk_name); in va_macro_register_fsgen_output()
1398 va->hw.init = &init; in va_macro_register_fsgen_output()
1399 ret = devm_clk_hw_register(va->dev, &va->hw); in va_macro_register_fsgen_output()
1403 return devm_of_clk_add_hw_provider(dev, of_clk_hw_simple_get, &va->hw); in va_macro_register_fsgen_output()
1419 va->dmic_clk_div = VA_MACRO_CLK_DIV_2; in va_macro_validate_dmic_sample_rate()
1422 va->dmic_clk_div = VA_MACRO_CLK_DIV_3; in va_macro_validate_dmic_sample_rate()
1425 va->dmic_clk_div = VA_MACRO_CLK_DIV_4; in va_macro_validate_dmic_sample_rate()
1428 va->dmic_clk_div = VA_MACRO_CLK_DIV_6; in va_macro_validate_dmic_sample_rate()
1431 va->dmic_clk_div = VA_MACRO_CLK_DIV_8; in va_macro_validate_dmic_sample_rate()
1434 va->dmic_clk_div = VA_MACRO_CLK_DIV_16; in va_macro_validate_dmic_sample_rate()
1444 dev_err(va->dev, "%s: Invalid rate %d, for mclk %d\n", in va_macro_validate_dmic_sample_rate()
1453 struct device *dev = &pdev->dev; in va_macro_probe()
1462 return -ENOMEM; in va_macro_probe()
1464 va->dev = dev; in va_macro_probe()
1466 va->macro = devm_clk_get_optional(dev, "macro"); in va_macro_probe()
1467 if (IS_ERR(va->macro)) in va_macro_probe()
1468 return PTR_ERR(va->macro); in va_macro_probe()
1470 va->dcodec = devm_clk_get_optional(dev, "dcodec"); in va_macro_probe()
1471 if (IS_ERR(va->dcodec)) in va_macro_probe()
1472 return PTR_ERR(va->dcodec); in va_macro_probe()
1474 va->mclk = devm_clk_get(dev, "mclk"); in va_macro_probe()
1475 if (IS_ERR(va->mclk)) in va_macro_probe()
1476 return PTR_ERR(va->mclk); in va_macro_probe()
1478 va->pds = lpass_macro_pds_init(dev); in va_macro_probe()
1479 if (IS_ERR(va->pds)) in va_macro_probe()
1480 return PTR_ERR(va->pds); in va_macro_probe()
1482 ret = of_property_read_u32(dev->of_node, "qcom,dmic-sample-rate", in va_macro_probe()
1485 dev_err(dev, "qcom,dmic-sample-rate dt entry missing\n"); in va_macro_probe()
1486 va->dmic_clk_div = VA_MACRO_CLK_DIV_2; in va_macro_probe()
1490 ret = -EINVAL; in va_macro_probe()
1501 va->regmap = devm_regmap_init_mmio(dev, base, &va_regmap_config); in va_macro_probe()
1502 if (IS_ERR(va->regmap)) { in va_macro_probe()
1503 ret = -EINVAL; in va_macro_probe()
1510 va->has_swr_master = data->has_swr_master; in va_macro_probe()
1513 clk_set_rate(va->mclk, 2 * VA_MACRO_MCLK_FREQ); in va_macro_probe()
1515 ret = clk_prepare_enable(va->macro); in va_macro_probe()
1519 ret = clk_prepare_enable(va->dcodec); in va_macro_probe()
1523 ret = clk_prepare_enable(va->mclk); in va_macro_probe()
1531 va->fsgen = clk_hw_get_clk(&va->hw, "fsgen"); in va_macro_probe()
1532 if (IS_ERR(va->fsgen)) { in va_macro_probe()
1533 ret = PTR_ERR(va->fsgen); in va_macro_probe()
1537 if (va->has_swr_master) { in va_macro_probe()
1539 regmap_update_bits(va->regmap, CDC_VA_TOP_CSR_SWR_MIC_CTL0, in va_macro_probe()
1542 regmap_update_bits(va->regmap, CDC_VA_TOP_CSR_SWR_MIC_CTL1, in va_macro_probe()
1545 regmap_update_bits(va->regmap, CDC_VA_TOP_CSR_SWR_MIC_CTL2, in va_macro_probe()
1566 clk_disable_unprepare(va->mclk); in va_macro_probe()
1568 clk_disable_unprepare(va->dcodec); in va_macro_probe()
1570 clk_disable_unprepare(va->macro); in va_macro_probe()
1572 lpass_macro_pds_exit(va->pds); in va_macro_probe()
1579 struct va_macro *va = dev_get_drvdata(&pdev->dev); in va_macro_remove()
1581 clk_disable_unprepare(va->mclk); in va_macro_remove()
1582 clk_disable_unprepare(va->dcodec); in va_macro_remove()
1583 clk_disable_unprepare(va->macro); in va_macro_remove()
1585 lpass_macro_pds_exit(va->pds); in va_macro_remove()
1594 regcache_cache_only(va->regmap, true); in va_macro_runtime_suspend()
1595 regcache_mark_dirty(va->regmap); in va_macro_runtime_suspend()
1597 clk_disable_unprepare(va->mclk); in va_macro_runtime_suspend()
1607 ret = clk_prepare_enable(va->mclk); in va_macro_runtime_resume()
1609 dev_err(va->dev, "unable to prepare mclk\n"); in va_macro_runtime_resume()
1613 regcache_cache_only(va->regmap, false); in va_macro_runtime_resume()
1614 regcache_sync(va->regmap); in va_macro_runtime_resume()
1625 { .compatible = "qcom,sc7280-lpass-va-macro", .data = &sm8250_va_data },
1626 { .compatible = "qcom,sm8250-lpass-va-macro", .data = &sm8250_va_data },
1627 { .compatible = "qcom,sm8450-lpass-va-macro", .data = &sm8450_va_data },
1628 { .compatible = "qcom,sc8280xp-lpass-va-macro", .data = &sm8450_va_data },
1645 MODULE_DESCRIPTION("VA macro driver");