Lines Matching +full:hpvdd +full:- +full:supply
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2014-2017 Texas Instruments Incorporated - https://www.ti.com/
10 * The TLV320AIC31xx series of audio codecs are low-power, highly integrated
12 * and mono/stereo Class-D speaker driver.
35 #include <dt-bindings/sound/tlv320aic31xx.h>
146 "HPVDD",
179 u8 ocmv; /* output common-mode voltage */
310 static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0);
312 static const DECLARE_TLV_DB_SCALE(adc_cgain_tlv, -2000, 50, 0);
316 static const DECLARE_TLV_DB_SCALE(hp_vol_tlv, -6350, 50, 0);
317 static const DECLARE_TLV_DB_SCALE(sp_vol_tlv, -6350, 50, 0);
324 AIC31XX_RDACVOL, 0, -127, 48, 7, 0, dac_vol_tlv),
334 /* HP de-pop control: apply power not immediately but via ramp
339 SOC_ENUM("HP Output Driver Power-On time", hp_poweron_time_enum),
340 SOC_ENUM("HP Output Driver Ramp-up step", hp_rampup_step_enum),
351 0, -24, 40, 6, 0, adc_cgain_tlv),
389 int ret = regmap_read(aic31xx->regmap, reg, &bits); in aic31xx_wait_bits()
393 ret = regmap_read(aic31xx->regmap, reg, &bits); in aic31xx_wait_bits()
394 counter--; in aic31xx_wait_bits()
397 dev_err(aic31xx->dev, in aic31xx_wait_bits()
400 (count - counter) * sleep); in aic31xx_wait_bits()
401 ret = -1; in aic31xx_wait_bits()
411 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aic31xx_dapm_power_event()
417 switch (WIDGET_BIT(w->reg, w->shift)) { in aic31xx_dapm_power_event()
445 dev_err(component->dev, "Unknown widget '%s' calling %s\n", in aic31xx_dapm_power_event()
446 w->name, __func__); in aic31xx_dapm_power_event()
447 return -EINVAL; in aic31xx_dapm_power_event()
458 dev_dbg(component->dev, in aic31xx_dapm_power_event()
460 event, w->name); in aic31xx_dapm_power_event()
488 SOC_DAPM_ENUM("MIC1LP P-Terminal", mic1lp_p_enum);
491 SOC_DAPM_ENUM("MIC1RP P-Terminal", mic1rp_p_enum);
494 SOC_DAPM_ENUM("MIC1LM P-Terminal", mic1lm_p_enum);
497 SOC_DAPM_ENUM("MIC1LM M-Terminal", mic1lm_m_enum);
514 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in mic_bias_event()
522 aic31xx->micbias_vg << in mic_bias_event()
524 dev_dbg(component->dev, "%s: turned on\n", __func__); in mic_bias_event()
530 dev_dbg(component->dev, "%s: turned off\n", __func__); in mic_bias_event()
600 SND_SOC_DAPM_MUX("MIC1LP P-Terminal", SND_SOC_NOPM, 0, 0,
602 SND_SOC_DAPM_MUX("MIC1RP P-Terminal", SND_SOC_NOPM, 0, 0,
604 SND_SOC_DAPM_MUX("MIC1LM P-Terminal", SND_SOC_NOPM, 0, 0,
612 SND_SOC_DAPM_MUX("MIC1LM M-Terminal", SND_SOC_NOPM, 0, 0,
631 /* AIC3111 and AIC3110 have stereo class-D amplifier */
646 /* AIC3100 and AIC3120 have only mono class-D amplifier */
694 {"MIC1LP P-Terminal", "FFR 10 Ohm", "MIC1LP"},
695 {"MIC1LP P-Terminal", "FFR 20 Ohm", "MIC1LP"},
696 {"MIC1LP P-Terminal", "FFR 40 Ohm", "MIC1LP"},
697 {"MIC1RP P-Terminal", "FFR 10 Ohm", "MIC1RP"},
698 {"MIC1RP P-Terminal", "FFR 20 Ohm", "MIC1RP"},
699 {"MIC1RP P-Terminal", "FFR 40 Ohm", "MIC1RP"},
700 {"MIC1LM P-Terminal", "FFR 10 Ohm", "MIC1LM"},
701 {"MIC1LM P-Terminal", "FFR 20 Ohm", "MIC1LM"},
702 {"MIC1LM P-Terminal", "FFR 40 Ohm", "MIC1LM"},
704 {"MIC1LM M-Terminal", "FFR 10 Ohm", "MIC1LM"},
705 {"MIC1LM M-Terminal", "FFR 20 Ohm", "MIC1LM"},
706 {"MIC1LM M-Terminal", "FFR 40 Ohm", "MIC1LM"},
708 {"MIC_GAIN_CTL", NULL, "MIC1LP P-Terminal"},
709 {"MIC_GAIN_CTL", NULL, "MIC1RP P-Terminal"},
710 {"MIC_GAIN_CTL", NULL, "MIC1LM P-Terminal"},
711 {"MIC_GAIN_CTL", NULL, "MIC1LM M-Terminal"},
780 if (!(aic31xx->codec_type & DAC31XX_BIT)) in aic31xx_add_controls()
787 if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) in aic31xx_add_controls()
805 if (aic31xx->codec_type & DAC31XX_BIT) { in aic31xx_add_widgets()
829 if (aic31xx->codec_type & AIC31XX_STEREO_CLASS_D_BIT) { in aic31xx_add_widgets()
863 int match = -1; in aic31xx_setup_pll()
866 if (!aic31xx->sysclk || !aic31xx->p_div) { in aic31xx_setup_pll()
867 dev_err(component->dev, "Master clock not supplied\n"); in aic31xx_setup_pll()
868 return -EINVAL; in aic31xx_setup_pll()
870 mclk_p = aic31xx->sysclk / aic31xx->p_div; in aic31xx_setup_pll()
893 if (match == -1) { in aic31xx_setup_pll()
894 dev_err(component->dev, in aic31xx_setup_pll()
898 return -EINVAL; in aic31xx_setup_pll()
901 dev_warn(component->dev, "Can not produce exact bitclock"); in aic31xx_setup_pll()
914 (aic31xx->p_div << 4) | aic31xx_divs[i].pll_r); in aic31xx_setup_pll()
943 aic31xx->rate_div_line = i; in aic31xx_setup_pll()
945 dev_dbg(component->dev, in aic31xx_setup_pll()
949 aic31xx->p_div, in aic31xx_setup_pll()
966 struct snd_soc_component *component = dai->component; in aic31xx_hw_params()
970 dev_dbg(component->dev, "## %s: width %d rate %d\n", in aic31xx_hw_params()
990 dev_err(component->dev, "%s: Unsupported width %d\n", in aic31xx_hw_params()
992 return -EINVAL; in aic31xx_hw_params()
1003 if (aic31xx->sysclk_id == AIC31XX_PLL_CLKIN_BCLK) { in aic31xx_hw_params()
1004 aic31xx->sysclk = params_rate(params) * params_width(params) * in aic31xx_hw_params()
1006 aic31xx->p_div = 1; in aic31xx_hw_params()
1015 struct snd_soc_component *component = codec_dai->component; in aic31xx_dac_mute()
1038 aic31xx->master_dapm_route_applied) { in aic31xx_clock_master_routes()
1045 if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) in aic31xx_clock_master_routes()
1053 aic31xx->master_dapm_route_applied = false; in aic31xx_clock_master_routes()
1055 !aic31xx->master_dapm_route_applied) { in aic31xx_clock_master_routes()
1062 if (!ret && !(aic31xx->codec_type & DAC31XX_BIT)) in aic31xx_clock_master_routes()
1070 aic31xx->master_dapm_route_applied = true; in aic31xx_clock_master_routes()
1079 struct snd_soc_component *component = codec_dai->component; in aic31xx_set_dai_fmt()
1084 dev_dbg(component->dev, "## %s: fmt = 0x%x\n", __func__, fmt); in aic31xx_set_dai_fmt()
1099 dev_err(component->dev, "Invalid DAI clock provider\n"); in aic31xx_set_dai_fmt()
1100 return -EINVAL; in aic31xx_set_dai_fmt()
1111 dev_err(component->dev, "Invalid DAI clock signal polarity\n"); in aic31xx_set_dai_fmt()
1112 return -EINVAL; in aic31xx_set_dai_fmt()
1141 dev_err(component->dev, "Invalid DAI interface format\n"); in aic31xx_set_dai_fmt()
1142 return -EINVAL; in aic31xx_set_dai_fmt()
1162 struct snd_soc_component *component = codec_dai->component; in aic31xx_set_dai_sysclk()
1166 dev_dbg(component->dev, "## %s: clk_id = %d, freq = %d, dir = %d\n", in aic31xx_set_dai_sysclk()
1173 dev_err(aic31xx->dev, "%s: Too high mclk frequency %u\n", in aic31xx_set_dai_sysclk()
1175 return -EINVAL; in aic31xx_set_dai_sysclk()
1177 aic31xx->p_div = i; in aic31xx_set_dai_sysclk()
1180 if (aic31xx_divs[i].mclk_p == freq / aic31xx->p_div) in aic31xx_set_dai_sysclk()
1183 dev_err(aic31xx->dev, "%s: Unsupported frequency %d\n", in aic31xx_set_dai_sysclk()
1185 return -EINVAL; in aic31xx_set_dai_sysclk()
1192 aic31xx->sysclk_id = clk_id; in aic31xx_set_dai_sysclk()
1193 aic31xx->sysclk = freq; in aic31xx_set_dai_sysclk()
1203 struct aic31xx_priv *aic31xx = disable_nb->aic31xx; in aic31xx_regulator_event()
1210 if (aic31xx->gpio_reset) in aic31xx_regulator_event()
1211 gpiod_set_value(aic31xx->gpio_reset, 1); in aic31xx_regulator_event()
1213 regcache_mark_dirty(aic31xx->regmap); in aic31xx_regulator_event()
1214 dev_dbg(aic31xx->dev, "## %s: DISABLE received\n", __func__); in aic31xx_regulator_event()
1224 if (aic31xx->gpio_reset) { in aic31xx_reset()
1225 gpiod_set_value(aic31xx->gpio_reset, 1); in aic31xx_reset()
1227 gpiod_set_value(aic31xx->gpio_reset, 0); in aic31xx_reset()
1229 ret = regmap_write(aic31xx->regmap, AIC31XX_RESET, 1); in aic31xx_reset()
1242 dev_dbg(component->dev, "codec clock -> on (rate %d)\n", in aic31xx_clk_on()
1243 aic31xx_divs[aic31xx->rate_div_line].rate); in aic31xx_clk_on()
1248 if (aic31xx_divs[aic31xx->rate_div_line].nadc) in aic31xx_clk_on()
1250 if (aic31xx_divs[aic31xx->rate_div_line].madc) in aic31xx_clk_on()
1260 dev_dbg(component->dev, "codec clock -> off\n"); in aic31xx_clk_off()
1274 ret = regulator_bulk_enable(ARRAY_SIZE(aic31xx->supplies), in aic31xx_power_on()
1275 aic31xx->supplies); in aic31xx_power_on()
1279 regcache_cache_only(aic31xx->regmap, false); in aic31xx_power_on()
1281 /* Reset device registers for a consistent power-on like state */ in aic31xx_power_on()
1284 dev_err(aic31xx->dev, "Could not reset device: %d\n", ret); in aic31xx_power_on()
1286 ret = regcache_sync(aic31xx->regmap); in aic31xx_power_on()
1288 dev_err(component->dev, in aic31xx_power_on()
1290 regcache_cache_only(aic31xx->regmap, true); in aic31xx_power_on()
1291 regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), in aic31xx_power_on()
1292 aic31xx->supplies); in aic31xx_power_on()
1301 aic31xx_set_jack(component, aic31xx->jack, NULL); in aic31xx_power_on()
1310 regcache_cache_only(aic31xx->regmap, true); in aic31xx_power_off()
1311 regulator_bulk_disable(ARRAY_SIZE(aic31xx->supplies), in aic31xx_power_off()
1312 aic31xx->supplies); in aic31xx_power_off()
1318 dev_dbg(component->dev, "## %s: %d -> %d\n", __func__, in aic31xx_set_bias_level()
1354 aic31xx->jack = jack; in aic31xx_set_jack()
1357 regmap_write(aic31xx->regmap, AIC31XX_HSDETECT, in aic31xx_set_jack()
1368 dev_dbg(aic31xx->dev, "## %s\n", __func__); in aic31xx_codec_probe()
1370 aic31xx->component = component; in aic31xx_codec_probe()
1372 for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) { in aic31xx_codec_probe()
1373 aic31xx->disable_nb[i].nb.notifier_call = in aic31xx_codec_probe()
1375 aic31xx->disable_nb[i].aic31xx = aic31xx; in aic31xx_codec_probe()
1377 aic31xx->supplies[i].consumer, in aic31xx_codec_probe()
1378 &aic31xx->disable_nb[i].nb); in aic31xx_codec_probe()
1380 dev_err(component->dev, in aic31xx_codec_probe()
1387 regcache_cache_only(aic31xx->regmap, true); in aic31xx_codec_probe()
1388 regcache_mark_dirty(aic31xx->regmap); in aic31xx_codec_probe()
1398 /* set output common-mode voltage */ in aic31xx_codec_probe()
1401 aic31xx->ocmv << AIC31XX_HPD_OCMV_SHIFT); in aic31xx_codec_probe()
1432 .name = "tlv320dac31xx-hifi",
1447 .name = "tlv320aic31xx-hifi",
1493 struct device *dev = aic31xx->dev; in aic31xx_irq()
1498 ret = regmap_read(aic31xx->regmap, AIC31XX_INTRDACFLAG, &value); in aic31xx_irq()
1517 ret = regmap_read(aic31xx->regmap, AIC31XX_INTRDACFLAG2, in aic31xx_irq()
1528 ret = regmap_read(aic31xx->regmap, AIC31XX_HSDETECT, &val); in aic31xx_irq()
1546 if (aic31xx->jack) in aic31xx_irq()
1547 snd_soc_jack_report(aic31xx->jack, status, in aic31xx_irq()
1557 ret = regmap_read(aic31xx->regmap, AIC31XX_OFFLAG, &value); in aic31xx_irq()
1569 dev_warn(dev, "Left-channel DAC overflow has occurred\n"); in aic31xx_irq()
1571 dev_warn(dev, "Right-channel DAC overflow has occurred\n"); in aic31xx_irq()
1594 struct device *dev = priv->dev; in aic31xx_configure_ocmv()
1598 if (dev->fwnode && in aic31xx_configure_ocmv()
1599 fwnode_property_read_u32(dev->fwnode, "ai31xx-ocmv", &value)) { in aic31xx_configure_ocmv()
1602 priv->ocmv = value; in aic31xx_configure_ocmv()
1607 avdd = regulator_get_voltage(priv->supplies[3].consumer); in aic31xx_configure_ocmv()
1608 dvdd = regulator_get_voltage(priv->supplies[5].consumer); in aic31xx_configure_ocmv()
1612 "Too high supply voltage(s) AVDD: %d, DVDD: %d\n", in aic31xx_configure_ocmv()
1615 priv->ocmv = AIC31XX_HPD_OCMV_1_8V; in aic31xx_configure_ocmv()
1617 priv->ocmv = AIC31XX_HPD_OCMV_1_65V; in aic31xx_configure_ocmv()
1619 priv->ocmv = AIC31XX_HPD_OCMV_1_5V; in aic31xx_configure_ocmv()
1621 priv->ocmv = AIC31XX_HPD_OCMV_1_35V; in aic31xx_configure_ocmv()
1624 "Invalid supply voltage(s) AVDD: %d, DVDD: %d\n", in aic31xx_configure_ocmv()
1649 dev_dbg(&i2c->dev, "## %s: %s codec_type = %d\n", __func__, in aic31xx_i2c_probe()
1650 id->name, (int)id->driver_data); in aic31xx_i2c_probe()
1652 aic31xx = devm_kzalloc(&i2c->dev, sizeof(*aic31xx), GFP_KERNEL); in aic31xx_i2c_probe()
1654 return -ENOMEM; in aic31xx_i2c_probe()
1656 aic31xx->regmap = devm_regmap_init_i2c(i2c, &aic31xx_i2c_regmap); in aic31xx_i2c_probe()
1657 if (IS_ERR(aic31xx->regmap)) { in aic31xx_i2c_probe()
1658 ret = PTR_ERR(aic31xx->regmap); in aic31xx_i2c_probe()
1659 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in aic31xx_i2c_probe()
1663 regcache_cache_only(aic31xx->regmap, true); in aic31xx_i2c_probe()
1665 aic31xx->dev = &i2c->dev; in aic31xx_i2c_probe()
1666 aic31xx->irq = i2c->irq; in aic31xx_i2c_probe()
1668 aic31xx->codec_type = id->driver_data; in aic31xx_i2c_probe()
1670 dev_set_drvdata(aic31xx->dev, aic31xx); in aic31xx_i2c_probe()
1672 fwnode_property_read_u32(aic31xx->dev->fwnode, "ai31xx-micbias-vg", in aic31xx_i2c_probe()
1678 aic31xx->micbias_vg = micbias_value; in aic31xx_i2c_probe()
1681 dev_err(aic31xx->dev, "Bad ai31xx-micbias-vg value %d\n", in aic31xx_i2c_probe()
1683 aic31xx->micbias_vg = MICBIAS_2_0V; in aic31xx_i2c_probe()
1686 if (dev_get_platdata(aic31xx->dev)) { in aic31xx_i2c_probe()
1687 memcpy(&aic31xx->pdata, dev_get_platdata(aic31xx->dev), sizeof(aic31xx->pdata)); in aic31xx_i2c_probe()
1688 aic31xx->codec_type = aic31xx->pdata.codec_type; in aic31xx_i2c_probe()
1689 aic31xx->micbias_vg = aic31xx->pdata.micbias_vg; in aic31xx_i2c_probe()
1692 aic31xx->gpio_reset = devm_gpiod_get_optional(aic31xx->dev, "reset", in aic31xx_i2c_probe()
1694 if (IS_ERR(aic31xx->gpio_reset)) in aic31xx_i2c_probe()
1695 return dev_err_probe(aic31xx->dev, PTR_ERR(aic31xx->gpio_reset), in aic31xx_i2c_probe()
1698 for (i = 0; i < ARRAY_SIZE(aic31xx->supplies); i++) in aic31xx_i2c_probe()
1699 aic31xx->supplies[i].supply = aic31xx_supply_names[i]; in aic31xx_i2c_probe()
1701 ret = devm_regulator_bulk_get(aic31xx->dev, in aic31xx_i2c_probe()
1702 ARRAY_SIZE(aic31xx->supplies), in aic31xx_i2c_probe()
1703 aic31xx->supplies); in aic31xx_i2c_probe()
1705 return dev_err_probe(aic31xx->dev, ret, "Failed to request supplies\n"); in aic31xx_i2c_probe()
1709 if (aic31xx->irq > 0) { in aic31xx_i2c_probe()
1710 regmap_update_bits(aic31xx->regmap, AIC31XX_GPIO1, in aic31xx_i2c_probe()
1715 regmap_write(aic31xx->regmap, AIC31XX_INT1CTRL, in aic31xx_i2c_probe()
1721 ret = devm_request_threaded_irq(aic31xx->dev, aic31xx->irq, in aic31xx_i2c_probe()
1723 IRQF_ONESHOT, "aic31xx-irq", in aic31xx_i2c_probe()
1726 dev_err(aic31xx->dev, "Unable to request IRQ\n"); in aic31xx_i2c_probe()
1731 if (aic31xx->codec_type & DAC31XX_BIT) in aic31xx_i2c_probe()
1732 return devm_snd_soc_register_component(&i2c->dev, in aic31xx_i2c_probe()
1737 return devm_snd_soc_register_component(&i2c->dev, in aic31xx_i2c_probe()
1745 .name = "tlv320aic31xx-codec",