Lines Matching +full:mic +full:- +full:min +full:- +full:freq
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Author: Javier Martin <javier.martin@vista-silicon.com>
29 #include <sound/soc-dapm.h>
58 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
80 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
84 /* Change Mic Bias Registor */
89 printk(KERN_DEBUG "%s: Mic Bias will be turned ON\n", __func__);
94 printk(KERN_DEBUG "%s: Mic Bias will be turned OFF\n",
111 ucontrol->value.integer.value[0] = (val & 0x01);
128 return -EINVAL;
131 if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP2_GPIO_OUT_HIGH))
134 if (ucontrol->value.integer.value[0])
135 val |= ucontrol->value.integer.value[0];
152 ucontrol->value.integer.value[0] = (val & 0x01);
169 return -EINVAL;
172 if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP5_GPIO_OUT_HIGH))
175 if (ucontrol->value.integer.value[0])
176 val |= ucontrol->value.integer.value[0];
192 ucontrol->value.integer.value[0] = ((val & 0x2) >> 1);
209 return -EINVAL;
212 if (ucontrol->value.integer.value[0] == (val & 0x1))
215 if (ucontrol->value.integer.value[0])
216 val |= ucontrol->value.integer.value[0];
246 /* 0dB min, 0.5dB steps */
248 /* -63.5dB min, 0.5dB steps */
249 static DECLARE_TLV_DB_SCALE(tlv_pcm, -6350, 50, 0);
250 /* -6dB min, 1dB steps */
251 static DECLARE_TLV_DB_SCALE(tlv_driver_gain, -600, 100, 0);
252 /* -12dB min, 0.5dB steps */
253 static DECLARE_TLV_DB_SCALE(tlv_adc_vol, -1200, 50, 0);
254 /* -6dB min, 1dB steps */
255 static DECLARE_TLV_DB_SCALE(tlv_tas_driver_gain, -5850, 50, 0);
273 AIC32X4_RDACVOL, 0, -0x7f, 0x30, 7, 0, tlv_pcm),
277 AIC32X4_HPRGAIN, 0, -0x6, 0x1d, 5, 0,
280 AIC32X4_LORGAIN, 0, -0x6, 0x1d, 5, 0,
287 SOC_DOUBLE_R("Mic PGA Switch", AIC32X4_LMICPGAVOL,
294 AIC32X4_RADCVOL, 0, -0x18, 0x28, 6, 0, tlv_adc_vol),
298 SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0),
367 SOC_DAPM_ENUM("CM_L L- Switch", cml_lpga_n_enum),
370 SOC_DAPM_ENUM("IN2_R L- Switch", in2r_lpga_n_enum),
373 SOC_DAPM_ENUM("IN3_R L- Switch", in3r_lpga_n_enum),
398 SOC_DAPM_ENUM("CM_R R- Switch", cmr_rpga_n_enum),
401 SOC_DAPM_ENUM("IN1_L R- Switch", in1l_rpga_n_enum),
404 SOC_DAPM_ENUM("IN3_L R- Switch", in3l_rpga_n_enum),
461 SND_SOC_DAPM_SUPPLY("Mic Bias", AIC32X4_MICBIAS, 6, 0, mic_bias_event,
597 int clk_id, unsigned int freq, int dir)
599 struct snd_soc_component *component = codec_dai->component;
603 pll = devm_clk_get(component->dev, "pll");
609 return clk_set_rate(mclk, freq);
614 struct snd_soc_component *component = codec_dai->component;
628 return -EINVAL;
655 return -EINVAL;
658 aic32x4->fmt = fmt;
690 if (aic32x4->type == AIC32X4_TYPE_TAS2505) {
692 return -EINVAL;
697 return -EINVAL;
728 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks);
737 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
746 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
755 if (aic32x4->type == AIC32X4_TYPE_TAS2505)
760 dev_err(component->dev, "Sampling rate not supported\n");
761 return -EINVAL;
764 /* PCM over I2S is always 2-channel */
765 if ((aic32x4->fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S)
775 for (nadc = max_nadc; nadc > 0; --nadc) {
778 dosr -= dosr_increment) {
783 for (ndac = max_ndac; ndac > 0; --ndac) {
820 dev_err(component->dev,
822 return -EINVAL;
829 struct snd_soc_component *component = dai->component;
862 if (aic32x4->swapdacs)
875 struct snd_soc_component *component = dai->component;
894 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks);
902 dev_err(component->dev, "Failed to enable clocks\n");
935 .name = "tlv320aic32x4-hifi",
958 if (aic32x4->setup->gpio_func[0] != AIC32X4_MFPX_DEFAULT_VALUE) {
960 aic32x4->setup->gpio_func[0]);
966 if (aic32x4->setup->gpio_func[1] != AIC32X4_MFPX_DEFAULT_VALUE) {
968 aic32x4->setup->gpio_func[1]);
974 if (aic32x4->setup->gpio_func[2] != AIC32X4_MFPX_DEFAULT_VALUE) {
976 aic32x4->setup->gpio_func[2]);
982 if (aic32x4->setup->gpio_func[3] != AIC32X4_MFPX_DEFAULT_VALUE) {
984 aic32x4->setup->gpio_func[3]);
990 if (aic32x4->setup->gpio_func[4] != AIC32X4_MFPX_DEFAULT_VALUE) {
992 aic32x4->setup->gpio_func[4]);
1011 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks);
1015 if (aic32x4->setup)
1022 if (aic32x4->power_cfg & AIC32X4_PWR_MICBIAS_2075_LDOIN) {
1026 if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE)
1029 tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ?
1034 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36)
1036 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED)
1040 /* Mic PGA routing */
1041 if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K)
1047 if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K)
1100 AIC32X4_LDACVOL, -0x7f, 0x30, tlv_pcm),
1112 SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0),
1144 .name = "tas2505-hifi",
1168 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks);
1172 if (aic32x4->setup)
1179 if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE)
1182 tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ?
1187 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36)
1189 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED)
1226 aic32x4_setup = devm_kzalloc(aic32x4->dev, sizeof(*aic32x4_setup),
1229 return -ENOMEM;
1231 ret = of_property_match_string(np, "clock-names", "mclk");
1233 return -EINVAL;
1234 aic32x4->mclk_name = of_clk_get_parent_name(np, ret);
1236 aic32x4->swapdacs = false;
1237 aic32x4->micpga_routing = 0;
1239 aic32x4->rstn_gpio = devm_gpiod_get_optional(aic32x4->dev, "reset", GPIOD_OUT_HIGH);
1240 if (IS_ERR(aic32x4->rstn_gpio)) {
1241 return dev_err_probe(aic32x4->dev, PTR_ERR(aic32x4->rstn_gpio),
1244 gpiod_set_consumer_name(aic32x4->rstn_gpio, "tlv320aic32x4_rstn");
1247 if (of_property_read_u32_array(np, "aic32x4-gpio-func",
1248 aic32x4_setup->gpio_func, 5) >= 0)
1249 aic32x4->setup = aic32x4_setup;
1255 regulator_disable(aic32x4->supply_iov);
1257 if (!IS_ERR(aic32x4->supply_ldo))
1258 regulator_disable(aic32x4->supply_ldo);
1260 if (!IS_ERR(aic32x4->supply_dv))
1261 regulator_disable(aic32x4->supply_dv);
1263 if (!IS_ERR(aic32x4->supply_av))
1264 regulator_disable(aic32x4->supply_av);
1272 aic32x4->supply_ldo = devm_regulator_get_optional(dev, "ldoin");
1273 aic32x4->supply_iov = devm_regulator_get(dev, "iov");
1274 aic32x4->supply_dv = devm_regulator_get_optional(dev, "dv");
1275 aic32x4->supply_av = devm_regulator_get_optional(dev, "av");
1279 if (IS_ERR(aic32x4->supply_iov)) {
1280 return dev_err_probe(dev, PTR_ERR(aic32x4->supply_iov),
1284 if (IS_ERR(aic32x4->supply_ldo)) {
1285 if (PTR_ERR(aic32x4->supply_ldo) == -EPROBE_DEFER)
1286 return -EPROBE_DEFER;
1288 if (IS_ERR(aic32x4->supply_dv)) {
1289 return dev_err_probe(dev, PTR_ERR(aic32x4->supply_dv),
1292 if (IS_ERR(aic32x4->supply_av)) {
1293 return dev_err_probe(dev, PTR_ERR(aic32x4->supply_av),
1297 if (PTR_ERR(aic32x4->supply_dv) == -EPROBE_DEFER)
1298 return -EPROBE_DEFER;
1299 if (PTR_ERR(aic32x4->supply_av) == -EPROBE_DEFER)
1300 return -EPROBE_DEFER;
1303 ret = regulator_enable(aic32x4->supply_iov);
1309 if (!IS_ERR(aic32x4->supply_ldo)) {
1310 ret = regulator_enable(aic32x4->supply_ldo);
1317 if (!IS_ERR(aic32x4->supply_dv)) {
1318 ret = regulator_enable(aic32x4->supply_dv);
1325 if (!IS_ERR(aic32x4->supply_av)) {
1326 ret = regulator_enable(aic32x4->supply_av);
1333 if (!IS_ERR(aic32x4->supply_ldo) && IS_ERR(aic32x4->supply_av))
1334 aic32x4->power_cfg |= AIC32X4_PWR_AIC32X4_LDO_ENABLE;
1339 if (!IS_ERR(aic32x4->supply_dv))
1340 regulator_disable(aic32x4->supply_dv);
1343 if (!IS_ERR(aic32x4->supply_ldo))
1344 regulator_disable(aic32x4->supply_ldo);
1347 regulator_disable(aic32x4->supply_iov);
1355 struct device_node *np = dev->of_node;
1364 return -ENOMEM;
1366 aic32x4->dev = dev;
1367 aic32x4->type = type;
1378 aic32x4->power_cfg = 0;
1379 aic32x4->swapdacs = false;
1380 aic32x4->micpga_routing = 0;
1381 aic32x4->rstn_gpio = NULL;
1382 aic32x4->mclk_name = "mclk";
1389 if (aic32x4->rstn_gpio) {
1392 gpiod_set_value_cansleep(aic32x4->rstn_gpio, 0);
1400 ret = aic32x4_register_clocks(dev, aic32x4->mclk_name);
1404 switch (aic32x4->type) {
1437 MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");