Lines Matching +full:dmic +full:- +full:clk +full:- +full:threshold

1 // SPDX-License-Identifier: GPL-2.0-only
3 * cs53l30.c -- CS53l30 ALSA Soc Audio driver
11 #include <linux/clk.h>
35 struct clk *mclk;
166 static DECLARE_TLV_DB_SCALE(pga_tlv, -600, 50, 0);
167 static DECLARE_TLV_DB_SCALE(dig_tlv, -9600, 100, 1);
245 * TB - Time base
262 /* The noise gate threshold selected will depend on NG Boost */
264 "-64dB/-34dB", "-66dB/-36dB", "-70dB/-40dB", "-73dB/-43dB",
265 "-76dB/-46dB", "-82dB/-52dB", "-58dB", "-64dB",
292 SOC_SINGLE("Digital Soft-Ramp Switch", CS53L30_SFT_RAMP,
344 SOC_ENUM("ADC1 NG Threshold", adc1_ng_thres_enum),
345 SOC_ENUM("ADC2 NG Threshold", adc2_ng_thres_enum),
422 /* DMIC Paths */
529 return -EINVAL; in cs53l30_get_mclkx_coeff()
542 return -EINVAL; in cs53l30_get_mclk_coeff()
548 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_set_sysclk()
552 /* MCLKX -> MCLK */ in cs53l30_set_sysclk()
560 regmap_update_bits(priv->regmap, CS53L30_MCLKCTL, in cs53l30_set_sysclk()
564 priv->mclk_rate = mclk_rate; in cs53l30_set_sysclk()
571 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_set_dai_fmt()
581 return -EINVAL; in cs53l30_set_dai_fmt()
587 /* Set TDM_PDN to turn off TDM mode -- Reset default */ in cs53l30_set_dai_fmt()
593 * with SHIFT_LEFT = 1 combination as Figure 4-13 shows in in cs53l30_set_dai_fmt()
599 return -EINVAL; in cs53l30_set_dai_fmt()
612 regmap_update_bits(priv->regmap, CS53L30_ASPCFG_CTL, in cs53l30_set_dai_fmt()
615 regmap_update_bits(priv->regmap, CS53L30_ASP_CTL1, in cs53l30_set_dai_fmt()
625 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_pcm_hw_params()
629 /* MCLK -> srate */ in cs53l30_pcm_hw_params()
630 mclk_coeff = cs53l30_get_mclk_coeff(priv->mclk_rate, srate); in cs53l30_pcm_hw_params()
632 return -EINVAL; in cs53l30_pcm_hw_params()
634 regmap_update_bits(priv->regmap, CS53L30_INT_SR_CTL, in cs53l30_pcm_hw_params()
638 regmap_update_bits(priv->regmap, CS53L30_MCLKCTL, in cs53l30_pcm_hw_params()
642 regmap_update_bits(priv->regmap, CS53L30_ASPCFG_CTL, in cs53l30_pcm_hw_params()
661 if (dapm->bias_level == SND_SOC_BIAS_STANDBY) in cs53l30_set_bias_level()
662 regmap_update_bits(priv->regmap, CS53L30_PWRCTL, in cs53l30_set_bias_level()
666 if (dapm->bias_level == SND_SOC_BIAS_OFF) { in cs53l30_set_bias_level()
667 ret = clk_prepare_enable(priv->mclk); in cs53l30_set_bias_level()
669 dev_err(component->dev, in cs53l30_set_bias_level()
673 regmap_update_bits(priv->regmap, CS53L30_MCLKCTL, in cs53l30_set_bias_level()
675 regmap_update_bits(priv->regmap, CS53L30_PWRCTL, in cs53l30_set_bias_level()
679 regmap_update_bits(priv->regmap, CS53L30_PWRCTL, in cs53l30_set_bias_level()
685 regmap_update_bits(priv->regmap, CS53L30_INT_MASK, in cs53l30_set_bias_level()
694 regmap_read(priv->regmap, CS53L30_SFT_RAMP, &reg); in cs53l30_set_bias_level()
700 regmap_update_bits(priv->regmap, CS53L30_PWRCTL, in cs53l30_set_bias_level()
706 regmap_read(priv->regmap, CS53L30_IS, &reg); in cs53l30_set_bias_level()
710 regmap_read(priv->regmap, CS53L30_IS, &reg); in cs53l30_set_bias_level()
715 regmap_read(priv->regmap, CS53L30_IS, &reg); in cs53l30_set_bias_level()
721 regmap_update_bits(priv->regmap, CS53L30_INT_MASK, in cs53l30_set_bias_level()
723 regmap_update_bits(priv->regmap, CS53L30_MCLKCTL, in cs53l30_set_bias_level()
726 clk_disable_unprepare(priv->mclk); in cs53l30_set_bias_level()
735 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_set_tristate()
738 return regmap_update_bits(priv->regmap, CS53L30_ASP_CTL1, in cs53l30_set_tristate()
751 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_set_dai_tdm_slot()
758 dev_err(dai->dev, "rx masks must not be 0\n"); in cs53l30_set_dai_tdm_slot()
759 return -EINVAL; in cs53l30_set_dai_tdm_slot()
764 dev_err(dai->dev, "invalid slot number or slot width\n"); in cs53l30_set_dai_tdm_slot()
765 return -EINVAL; in cs53l30_set_dai_tdm_slot()
769 dev_err(dai->dev, "slot width must count in byte\n"); in cs53l30_set_dai_tdm_slot()
770 return -EINVAL; in cs53l30_set_dai_tdm_slot()
782 tx_enable |= (u64)((u64)(1 << slot_step) - 1) << (u64)loc[i]; in cs53l30_set_dai_tdm_slot()
789 dev_err(dai->dev, "rx_mask exceeds max slot number: %d\n", in cs53l30_set_dai_tdm_slot()
791 return -EINVAL; in cs53l30_set_dai_tdm_slot()
795 slot_next = loc[i - 1] + slot_step - 1; in cs53l30_set_dai_tdm_slot()
797 dev_err(dai->dev, "slot selection out of bounds: %u\n", in cs53l30_set_dai_tdm_slot()
799 return -EINVAL; in cs53l30_set_dai_tdm_slot()
803 regmap_update_bits(priv->regmap, CS53L30_ASP_TDMTX_CTL(i), in cs53l30_set_dai_tdm_slot()
805 dev_dbg(dai->dev, "loc[%d]=%x\n", i, loc[i]); in cs53l30_set_dai_tdm_slot()
809 regmap_write(priv->regmap, CS53L30_ASP_TDMTX_ENx(i), in cs53l30_set_dai_tdm_slot()
812 dev_dbg(dai->dev, "en_reg=%x, tx_enable=%llx\n", in cs53l30_set_dai_tdm_slot()
821 struct cs53l30_private *priv = snd_soc_component_get_drvdata(dai->component); in cs53l30_mute_stream()
823 gpiod_set_value_cansleep(priv->mute_gpio, mute); in cs53l30_mute_stream()
862 if (priv->use_sdout2) in cs53l30_component_probe()
903 const struct device_node *np = client->dev.of_node; in cs53l30_i2c_probe()
904 struct device *dev = &client->dev; in cs53l30_i2c_probe()
912 return -ENOMEM; in cs53l30_i2c_probe()
914 for (i = 0; i < ARRAY_SIZE(cs53l30->supplies); i++) in cs53l30_i2c_probe()
915 cs53l30->supplies[i].supply = cs53l30_supply_names[i]; in cs53l30_i2c_probe()
917 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(cs53l30->supplies), in cs53l30_i2c_probe()
918 cs53l30->supplies); in cs53l30_i2c_probe()
924 ret = regulator_bulk_enable(ARRAY_SIZE(cs53l30->supplies), in cs53l30_i2c_probe()
925 cs53l30->supplies); in cs53l30_i2c_probe()
932 cs53l30->reset_gpio = devm_gpiod_get_optional(dev, "reset", in cs53l30_i2c_probe()
934 if (IS_ERR(cs53l30->reset_gpio)) { in cs53l30_i2c_probe()
935 ret = PTR_ERR(cs53l30->reset_gpio); in cs53l30_i2c_probe()
939 gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); in cs53l30_i2c_probe()
943 cs53l30->mclk_rate = 0; in cs53l30_i2c_probe()
945 cs53l30->regmap = devm_regmap_init_i2c(client, &cs53l30_regmap); in cs53l30_i2c_probe()
946 if (IS_ERR(cs53l30->regmap)) { in cs53l30_i2c_probe()
947 ret = PTR_ERR(cs53l30->regmap); in cs53l30_i2c_probe()
953 devid = cirrus_read_device_id(cs53l30->regmap, CS53L30_DEVID_AB); in cs53l30_i2c_probe()
961 ret = -ENODEV; in cs53l30_i2c_probe()
967 ret = regmap_read(cs53l30->regmap, CS53L30_REVID, &reg); in cs53l30_i2c_probe()
974 cs53l30->mclk = devm_clk_get_optional(dev, "mclk"); in cs53l30_i2c_probe()
975 if (IS_ERR(cs53l30->mclk)) { in cs53l30_i2c_probe()
976 ret = PTR_ERR(cs53l30->mclk); in cs53l30_i2c_probe()
981 cs53l30->mute_gpio = devm_gpiod_get_optional(dev, "mute", in cs53l30_i2c_probe()
983 if (IS_ERR(cs53l30->mute_gpio)) { in cs53l30_i2c_probe()
984 ret = PTR_ERR(cs53l30->mute_gpio); in cs53l30_i2c_probe()
988 if (cs53l30->mute_gpio) { in cs53l30_i2c_probe()
990 regmap_write(cs53l30->regmap, CS53L30_MUTEP_CTL1, in cs53l30_i2c_probe()
993 if (gpiod_is_active_low(cs53l30->mute_gpio)) in cs53l30_i2c_probe()
994 regmap_update_bits(cs53l30->regmap, CS53L30_MUTEP_CTL2, in cs53l30_i2c_probe()
998 if (!of_property_read_u8(np, "cirrus,micbias-lvl", &val)) in cs53l30_i2c_probe()
999 regmap_update_bits(cs53l30->regmap, CS53L30_MICBIAS_CTL, in cs53l30_i2c_probe()
1002 if (of_property_read_bool(np, "cirrus,use-sdout2")) in cs53l30_i2c_probe()
1003 cs53l30->use_sdout2 = true; in cs53l30_i2c_probe()
1016 gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); in cs53l30_i2c_probe()
1018 regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), in cs53l30_i2c_probe()
1019 cs53l30->supplies); in cs53l30_i2c_probe()
1028 gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); in cs53l30_i2c_remove()
1030 regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), in cs53l30_i2c_remove()
1031 cs53l30->supplies); in cs53l30_i2c_remove()
1039 regcache_cache_only(cs53l30->regmap, true); in cs53l30_runtime_suspend()
1042 gpiod_set_value_cansleep(cs53l30->reset_gpio, 0); in cs53l30_runtime_suspend()
1044 regulator_bulk_disable(ARRAY_SIZE(cs53l30->supplies), in cs53l30_runtime_suspend()
1045 cs53l30->supplies); in cs53l30_runtime_suspend()
1055 ret = regulator_bulk_enable(ARRAY_SIZE(cs53l30->supplies), in cs53l30_runtime_resume()
1056 cs53l30->supplies); in cs53l30_runtime_resume()
1062 gpiod_set_value_cansleep(cs53l30->reset_gpio, 1); in cs53l30_runtime_resume()
1064 regcache_cache_only(cs53l30->regmap, false); in cs53l30_runtime_resume()
1065 ret = regcache_sync(cs53l30->regmap); in cs53l30_runtime_resume()