Lines Matching +full:regulator +full:- +full:decay

1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Author: Javier Martin <javier.martin@vista-silicon.com>
21 #include <linux/regulator/consumer.h>
29 #include <sound/soc-dapm.h>
43 struct regulator *supply_ldo;
44 struct regulator *supply_iov;
45 struct regulator *supply_dv;
46 struct regulator *supply_av;
58 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aic32x4_reset_adc()
80 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in mic_bias_event()
111 ucontrol->value.integer.value[0] = (val & 0x01); in aic32x4_get_mfp1_gpio()
128 return -EINVAL; in aic32x4_set_mfp2_gpio()
131 if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP2_GPIO_OUT_HIGH)) in aic32x4_set_mfp2_gpio()
134 if (ucontrol->value.integer.value[0]) in aic32x4_set_mfp2_gpio()
135 val |= ucontrol->value.integer.value[0]; in aic32x4_set_mfp2_gpio()
152 ucontrol->value.integer.value[0] = (val & 0x01); in aic32x4_get_mfp3_gpio()
169 return -EINVAL; in aic32x4_set_mfp4_gpio()
172 if (ucontrol->value.integer.value[0] == (val & AIC32X4_MFP5_GPIO_OUT_HIGH)) in aic32x4_set_mfp4_gpio()
175 if (ucontrol->value.integer.value[0]) in aic32x4_set_mfp4_gpio()
176 val |= ucontrol->value.integer.value[0]; in aic32x4_set_mfp4_gpio()
192 ucontrol->value.integer.value[0] = ((val & 0x2) >> 1); in aic32x4_get_mfp5_gpio()
209 return -EINVAL; in aic32x4_set_mfp5_gpio()
212 if (ucontrol->value.integer.value[0] == (val & 0x1)) in aic32x4_set_mfp5_gpio()
215 if (ucontrol->value.integer.value[0]) in aic32x4_set_mfp5_gpio()
216 val |= ucontrol->value.integer.value[0]; in aic32x4_set_mfp5_gpio()
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,
294 AIC32X4_RADCVOL, 0, -0x18, 0x28, 6, 0, tlv_adc_vol),
298 SOC_SINGLE("Auto-mute Switch", AIC32X4_DACMUTE, 4, 7, 0),
314 SOC_DOUBLE_R("AGC Decay Time", AIC32X4_LAGC5, AIC32X4_RAGC5,
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),
599 struct snd_soc_component *component = codec_dai->component; in aic32x4_set_dai_sysclk()
603 pll = devm_clk_get(component->dev, "pll"); in aic32x4_set_dai_sysclk()
614 struct snd_soc_component *component = codec_dai->component; in aic32x4_set_dai_fmt()
628 return -EINVAL; in aic32x4_set_dai_fmt()
655 return -EINVAL; in aic32x4_set_dai_fmt()
658 aic32x4->fmt = fmt; in aic32x4_set_dai_fmt()
690 if (aic32x4->type == AIC32X4_TYPE_TAS2505) { in aic32x4_set_processing_blocks()
692 return -EINVAL; in aic32x4_set_processing_blocks()
697 return -EINVAL; in aic32x4_set_processing_blocks()
728 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks); in aic32x4_setup_clocks()
737 if (aic32x4->type == AIC32X4_TYPE_TAS2505) in aic32x4_setup_clocks()
746 if (aic32x4->type == AIC32X4_TYPE_TAS2505) in aic32x4_setup_clocks()
755 if (aic32x4->type == AIC32X4_TYPE_TAS2505) in aic32x4_setup_clocks()
760 dev_err(component->dev, "Sampling rate not supported\n"); in aic32x4_setup_clocks()
761 return -EINVAL; in aic32x4_setup_clocks()
764 /* PCM over I2S is always 2-channel */ in aic32x4_setup_clocks()
765 if ((aic32x4->fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S) in aic32x4_setup_clocks()
775 for (nadc = max_nadc; nadc > 0; --nadc) { in aic32x4_setup_clocks()
778 dosr -= dosr_increment) { in aic32x4_setup_clocks()
783 for (ndac = max_ndac; ndac > 0; --ndac) { in aic32x4_setup_clocks()
820 dev_err(component->dev, in aic32x4_setup_clocks()
822 return -EINVAL; in aic32x4_setup_clocks()
829 struct snd_soc_component *component = dai->component; in aic32x4_hw_params()
862 if (aic32x4->swapdacs) in aic32x4_hw_params()
875 struct snd_soc_component *component = dai->component; in aic32x4_mute()
894 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks); in aic32x4_set_bias_level()
902 dev_err(component->dev, "Failed to enable clocks\n"); in aic32x4_set_bias_level()
935 .name = "tlv320aic32x4-hifi",
958 if (aic32x4->setup->gpio_func[0] != AIC32X4_MFPX_DEFAULT_VALUE) { in aic32x4_setup_gpios()
960 aic32x4->setup->gpio_func[0]); in aic32x4_setup_gpios()
966 if (aic32x4->setup->gpio_func[1] != AIC32X4_MFPX_DEFAULT_VALUE) { in aic32x4_setup_gpios()
968 aic32x4->setup->gpio_func[1]); in aic32x4_setup_gpios()
974 if (aic32x4->setup->gpio_func[2] != AIC32X4_MFPX_DEFAULT_VALUE) { in aic32x4_setup_gpios()
976 aic32x4->setup->gpio_func[2]); in aic32x4_setup_gpios()
982 if (aic32x4->setup->gpio_func[3] != AIC32X4_MFPX_DEFAULT_VALUE) { in aic32x4_setup_gpios()
984 aic32x4->setup->gpio_func[3]); in aic32x4_setup_gpios()
990 if (aic32x4->setup->gpio_func[4] != AIC32X4_MFPX_DEFAULT_VALUE) { in aic32x4_setup_gpios()
992 aic32x4->setup->gpio_func[4]); in aic32x4_setup_gpios()
1011 ret = devm_clk_bulk_get(component->dev, ARRAY_SIZE(clocks), clocks); in aic32x4_component_probe()
1015 if (aic32x4->setup) in aic32x4_component_probe()
1022 if (aic32x4->power_cfg & AIC32X4_PWR_MICBIAS_2075_LDOIN) { in aic32x4_component_probe()
1026 if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) in aic32x4_component_probe()
1029 tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? in aic32x4_component_probe()
1034 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) in aic32x4_component_probe()
1036 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) in aic32x4_component_probe()
1041 if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K) in aic32x4_component_probe()
1047 if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K) in aic32x4_component_probe()
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); in aic32x4_tas2505_component_probe()
1172 if (aic32x4->setup) in aic32x4_tas2505_component_probe()
1179 if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) in aic32x4_tas2505_component_probe()
1182 tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? in aic32x4_tas2505_component_probe()
1187 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) in aic32x4_tas2505_component_probe()
1189 if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) in aic32x4_tas2505_component_probe()
1226 aic32x4_setup = devm_kzalloc(aic32x4->dev, sizeof(*aic32x4_setup), in aic32x4_parse_dt()
1229 return -ENOMEM; in aic32x4_parse_dt()
1231 ret = of_property_match_string(np, "clock-names", "mclk"); in aic32x4_parse_dt()
1233 return -EINVAL; in aic32x4_parse_dt()
1234 aic32x4->mclk_name = of_clk_get_parent_name(np, ret); in aic32x4_parse_dt()
1236 aic32x4->swapdacs = false; in aic32x4_parse_dt()
1237 aic32x4->micpga_routing = 0; in aic32x4_parse_dt()
1239 aic32x4->rstn_gpio = devm_gpiod_get_optional(aic32x4->dev, "reset", GPIOD_OUT_HIGH); in aic32x4_parse_dt()
1240 if (IS_ERR(aic32x4->rstn_gpio)) { in aic32x4_parse_dt()
1241 return dev_err_probe(aic32x4->dev, PTR_ERR(aic32x4->rstn_gpio), in aic32x4_parse_dt()
1244 gpiod_set_consumer_name(aic32x4->rstn_gpio, "tlv320aic32x4_rstn"); in aic32x4_parse_dt()
1247 if (of_property_read_u32_array(np, "aic32x4-gpio-func", in aic32x4_parse_dt()
1248 aic32x4_setup->gpio_func, 5) >= 0) in aic32x4_parse_dt()
1249 aic32x4->setup = aic32x4_setup; in aic32x4_parse_dt()
1255 regulator_disable(aic32x4->supply_iov); in aic32x4_disable_regulators()
1257 if (!IS_ERR(aic32x4->supply_ldo)) in aic32x4_disable_regulators()
1258 regulator_disable(aic32x4->supply_ldo); in aic32x4_disable_regulators()
1260 if (!IS_ERR(aic32x4->supply_dv)) in aic32x4_disable_regulators()
1261 regulator_disable(aic32x4->supply_dv); in aic32x4_disable_regulators()
1263 if (!IS_ERR(aic32x4->supply_av)) in aic32x4_disable_regulators()
1264 regulator_disable(aic32x4->supply_av); in aic32x4_disable_regulators()
1272 aic32x4->supply_ldo = devm_regulator_get_optional(dev, "ldoin"); in aic32x4_setup_regulators()
1273 aic32x4->supply_iov = devm_regulator_get(dev, "iov"); in aic32x4_setup_regulators()
1274 aic32x4->supply_dv = devm_regulator_get_optional(dev, "dv"); in aic32x4_setup_regulators()
1275 aic32x4->supply_av = devm_regulator_get_optional(dev, "av"); in aic32x4_setup_regulators()
1277 /* Check if the regulator requirements are fulfilled */ in aic32x4_setup_regulators()
1279 if (IS_ERR(aic32x4->supply_iov)) { in aic32x4_setup_regulators()
1281 return PTR_ERR(aic32x4->supply_iov); in aic32x4_setup_regulators()
1284 if (IS_ERR(aic32x4->supply_ldo)) { in aic32x4_setup_regulators()
1285 if (PTR_ERR(aic32x4->supply_ldo) == -EPROBE_DEFER) in aic32x4_setup_regulators()
1286 return -EPROBE_DEFER; in aic32x4_setup_regulators()
1288 if (IS_ERR(aic32x4->supply_dv)) { in aic32x4_setup_regulators()
1290 return PTR_ERR(aic32x4->supply_dv); in aic32x4_setup_regulators()
1292 if (IS_ERR(aic32x4->supply_av)) { in aic32x4_setup_regulators()
1294 return PTR_ERR(aic32x4->supply_av); in aic32x4_setup_regulators()
1297 if (PTR_ERR(aic32x4->supply_dv) == -EPROBE_DEFER) in aic32x4_setup_regulators()
1298 return -EPROBE_DEFER; in aic32x4_setup_regulators()
1299 if (PTR_ERR(aic32x4->supply_av) == -EPROBE_DEFER) in aic32x4_setup_regulators()
1300 return -EPROBE_DEFER; in aic32x4_setup_regulators()
1303 ret = regulator_enable(aic32x4->supply_iov); in aic32x4_setup_regulators()
1305 dev_err(dev, "Failed to enable regulator iov\n"); in aic32x4_setup_regulators()
1309 if (!IS_ERR(aic32x4->supply_ldo)) { in aic32x4_setup_regulators()
1310 ret = regulator_enable(aic32x4->supply_ldo); in aic32x4_setup_regulators()
1312 dev_err(dev, "Failed to enable regulator ldo\n"); in aic32x4_setup_regulators()
1317 if (!IS_ERR(aic32x4->supply_dv)) { in aic32x4_setup_regulators()
1318 ret = regulator_enable(aic32x4->supply_dv); in aic32x4_setup_regulators()
1320 dev_err(dev, "Failed to enable regulator dv\n"); in aic32x4_setup_regulators()
1325 if (!IS_ERR(aic32x4->supply_av)) { in aic32x4_setup_regulators()
1326 ret = regulator_enable(aic32x4->supply_av); in aic32x4_setup_regulators()
1328 dev_err(dev, "Failed to enable regulator av\n"); in aic32x4_setup_regulators()
1333 if (!IS_ERR(aic32x4->supply_ldo) && IS_ERR(aic32x4->supply_av)) in aic32x4_setup_regulators()
1334 aic32x4->power_cfg |= AIC32X4_PWR_AIC32X4_LDO_ENABLE; in aic32x4_setup_regulators()
1339 if (!IS_ERR(aic32x4->supply_dv)) in aic32x4_setup_regulators()
1340 regulator_disable(aic32x4->supply_dv); in aic32x4_setup_regulators()
1343 if (!IS_ERR(aic32x4->supply_ldo)) in aic32x4_setup_regulators()
1344 regulator_disable(aic32x4->supply_ldo); in aic32x4_setup_regulators()
1347 regulator_disable(aic32x4->supply_iov); in aic32x4_setup_regulators()
1355 struct device_node *np = dev->of_node; in aic32x4_probe()
1364 return -ENOMEM; in aic32x4_probe()
1366 aic32x4->dev = dev; in aic32x4_probe()
1367 aic32x4->type = type; in aic32x4_probe()
1378 aic32x4->power_cfg = 0; in aic32x4_probe()
1379 aic32x4->swapdacs = false; in aic32x4_probe()
1380 aic32x4->micpga_routing = 0; in aic32x4_probe()
1381 aic32x4->rstn_gpio = NULL; in aic32x4_probe()
1382 aic32x4->mclk_name = "mclk"; in aic32x4_probe()
1391 if (aic32x4->rstn_gpio) { in aic32x4_probe()
1394 gpiod_set_value_cansleep(aic32x4->rstn_gpio, 0); in aic32x4_probe()
1402 ret = aic32x4_register_clocks(dev, aic32x4->mclk_name); in aic32x4_probe()
1406 switch (aic32x4->type) { in aic32x4_probe()
1439 MODULE_AUTHOR("Javier Martin <javier.martin@vista-silicon.com>");