Lines Matching +full:pvdd +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
3 * ALSA SoC Texas Instruments TAS6424 Quad-Channel Audio Amplifier
5 * Copyright (C) 2016-2017 Texas Instruments Incorporated - https://www.ti.com/
24 #include <sound/soc-dapm.h>
33 "dvdd", /* Digital power supply. Connect to 3.3-V supply. */
34 "vbat", /* Supply used for higher voltage analog circuits. */
35 "pvdd", /* Class-D amp output FETs supply. */
53 * DAC digital volumes. From -103.5 to 24 dB in 0.5 dB steps. Note that
54 * setting the gain below -100 dB (register value <0x7) is effectively a MUTE
57 static DECLARE_TLV_DB_SCALE(dac_tlv, -10350, 50, 0);
75 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas6424_dac_event()
78 dev_dbg(component->dev, "%s() event=0x%0x\n", __func__, event); in tas6424_dac_event()
81 /* Observe codec shutdown-to-active time */ in tas6424_dac_event()
85 tas6424->last_fault1 = 0; in tas6424_dac_event()
86 tas6424->last_fault2 = 0; in tas6424_dac_event()
87 tas6424->last_warn = 0; in tas6424_dac_event()
88 schedule_delayed_work(&tas6424->fault_check_work, in tas6424_dac_event()
92 cancel_delayed_work_sync(&tas6424->fault_check_work); in tas6424_dac_event()
114 struct snd_soc_component *component = dai->component; in tas6424_hw_params()
119 dev_dbg(component->dev, "%s() rate=%u width=%u\n", __func__, rate, width); in tas6424_hw_params()
132 dev_err(component->dev, "unsupported sample rate: %u\n", rate); in tas6424_hw_params()
133 return -EINVAL; in tas6424_hw_params()
143 dev_err(component->dev, "unsupported sample width: %u\n", width); in tas6424_hw_params()
144 return -EINVAL; in tas6424_hw_params()
157 struct snd_soc_component *component = dai->component; in tas6424_set_dai_fmt()
160 dev_dbg(component->dev, "%s() fmt=0x%0x\n", __func__, fmt); in tas6424_set_dai_fmt()
167 dev_err(component->dev, "Invalid DAI clocking\n"); in tas6424_set_dai_fmt()
168 return -EINVAL; in tas6424_set_dai_fmt()
176 dev_err(component->dev, "Invalid DAI clock signal polarity\n"); in tas6424_set_dai_fmt()
177 return -EINVAL; in tas6424_set_dai_fmt()
200 dev_err(component->dev, "Invalid DAI interface format\n"); in tas6424_set_dai_fmt()
201 return -EINVAL; in tas6424_set_dai_fmt()
214 struct snd_soc_component *component = dai->component; in tas6424_set_dai_tdm_slot()
218 dev_dbg(component->dev, "%s() tx_mask=%d rx_mask=%d\n", __func__, in tas6424_set_dai_tdm_slot()
232 if (last_slot - first_slot != 4) { in tas6424_set_dai_tdm_slot()
233 dev_err(component->dev, "tdm mask must cover 4 contiguous slots\n"); in tas6424_set_dai_tdm_slot()
234 return -EINVAL; in tas6424_set_dai_tdm_slot()
245 dev_err(component->dev, "tdm mask must start at slot 0 or 4\n"); in tas6424_set_dai_tdm_slot()
246 return -EINVAL; in tas6424_set_dai_tdm_slot()
257 struct snd_soc_component *component = dai->component; in tas6424_mute()
261 dev_dbg(component->dev, "%s() mute=%d\n", __func__, mute); in tas6424_mute()
263 if (tas6424->mute_gpio) { in tas6424_mute()
264 gpiod_set_value_cansleep(tas6424->mute_gpio, mute); in tas6424_mute()
285 regcache_cache_only(tas6424->regmap, true); in tas6424_power_off()
286 regcache_mark_dirty(tas6424->regmap); in tas6424_power_off()
288 ret = regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), in tas6424_power_off()
289 tas6424->supplies); in tas6424_power_off()
291 dev_err(component->dev, "failed to disable supplies: %d\n", ret); in tas6424_power_off()
306 if (!regmap_read(tas6424->regmap, TAS6424_DC_DIAG_CTRL1, &reg_val)) in tas6424_power_on()
309 ret = regulator_bulk_enable(ARRAY_SIZE(tas6424->supplies), in tas6424_power_on()
310 tas6424->supplies); in tas6424_power_on()
312 dev_err(component->dev, "failed to enable supplies: %d\n", ret); in tas6424_power_on()
316 regcache_cache_only(tas6424->regmap, false); in tas6424_power_on()
318 ret = regcache_sync(tas6424->regmap); in tas6424_power_on()
320 dev_err(component->dev, "failed to sync regcache: %d\n", ret); in tas6424_power_on()
324 if (tas6424->mute_gpio) { in tas6424_power_on()
325 gpiod_set_value_cansleep(tas6424->mute_gpio, 0); in tas6424_power_on()
329 * access is not necessary to un-mute the channels in tas6424_power_on()
350 dev_dbg(component->dev, "%s() level=%d\n", __func__, level); in tas6424_set_bias_level()
390 .name = "tas6424-amplifier",
406 struct device *dev = tas6424->dev; in tas6424_fault_check_work()
410 ret = regmap_read(tas6424->regmap, TAS6424_CHANNEL_FAULT, &reg); in tas6424_fault_check_work()
417 tas6424->last_cfault = reg; in tas6424_fault_check_work()
427 if ((reg & TAS6424_FAULT_OC_CH1) && !(tas6424->last_cfault & TAS6424_FAULT_OC_CH1)) in tas6424_fault_check_work()
430 if ((reg & TAS6424_FAULT_OC_CH2) && !(tas6424->last_cfault & TAS6424_FAULT_OC_CH2)) in tas6424_fault_check_work()
433 if ((reg & TAS6424_FAULT_OC_CH3) && !(tas6424->last_cfault & TAS6424_FAULT_OC_CH3)) in tas6424_fault_check_work()
436 if ((reg & TAS6424_FAULT_OC_CH4) && !(tas6424->last_cfault & TAS6424_FAULT_OC_CH4)) in tas6424_fault_check_work()
439 if ((reg & TAS6424_FAULT_DC_CH1) && !(tas6424->last_cfault & TAS6424_FAULT_DC_CH1)) in tas6424_fault_check_work()
442 if ((reg & TAS6424_FAULT_DC_CH2) && !(tas6424->last_cfault & TAS6424_FAULT_DC_CH2)) in tas6424_fault_check_work()
445 if ((reg & TAS6424_FAULT_DC_CH3) && !(tas6424->last_cfault & TAS6424_FAULT_DC_CH3)) in tas6424_fault_check_work()
448 if ((reg & TAS6424_FAULT_DC_CH4) && !(tas6424->last_cfault & TAS6424_FAULT_DC_CH4)) in tas6424_fault_check_work()
452 tas6424->last_cfault = reg; in tas6424_fault_check_work()
455 ret = regmap_read(tas6424->regmap, TAS6424_GLOB_FAULT1, &reg); in tas6424_fault_check_work()
465 * stopped to avoid any false-positives. However there are no in tas6424_fault_check_work()
474 tas6424->last_fault1 = reg; in tas6424_fault_check_work()
478 if ((reg & TAS6424_FAULT_PVDD_OV) && !(tas6424->last_fault1 & TAS6424_FAULT_PVDD_OV)) in tas6424_fault_check_work()
479 dev_crit(dev, "experienced a PVDD overvoltage fault\n"); in tas6424_fault_check_work()
481 if ((reg & TAS6424_FAULT_VBAT_OV) && !(tas6424->last_fault1 & TAS6424_FAULT_VBAT_OV)) in tas6424_fault_check_work()
484 if ((reg & TAS6424_FAULT_PVDD_UV) && !(tas6424->last_fault1 & TAS6424_FAULT_PVDD_UV)) in tas6424_fault_check_work()
485 dev_crit(dev, "experienced a PVDD undervoltage fault\n"); in tas6424_fault_check_work()
487 if ((reg & TAS6424_FAULT_VBAT_UV) && !(tas6424->last_fault1 & TAS6424_FAULT_VBAT_UV)) in tas6424_fault_check_work()
491 tas6424->last_fault1 = reg; in tas6424_fault_check_work()
494 ret = regmap_read(tas6424->regmap, TAS6424_GLOB_FAULT2, &reg); in tas6424_fault_check_work()
507 tas6424->last_fault2 = reg; in tas6424_fault_check_work()
511 if ((reg & TAS6424_FAULT_OTSD) && !(tas6424->last_fault2 & TAS6424_FAULT_OTSD)) in tas6424_fault_check_work()
514 if ((reg & TAS6424_FAULT_OTSD_CH1) && !(tas6424->last_fault2 & TAS6424_FAULT_OTSD_CH1)) in tas6424_fault_check_work()
517 if ((reg & TAS6424_FAULT_OTSD_CH2) && !(tas6424->last_fault2 & TAS6424_FAULT_OTSD_CH2)) in tas6424_fault_check_work()
520 if ((reg & TAS6424_FAULT_OTSD_CH3) && !(tas6424->last_fault2 & TAS6424_FAULT_OTSD_CH3)) in tas6424_fault_check_work()
523 if ((reg & TAS6424_FAULT_OTSD_CH4) && !(tas6424->last_fault2 & TAS6424_FAULT_OTSD_CH4)) in tas6424_fault_check_work()
527 tas6424->last_fault2 = reg; in tas6424_fault_check_work()
530 ret = regmap_read(tas6424->regmap, TAS6424_WARN, &reg); in tas6424_fault_check_work()
545 tas6424->last_warn = reg; in tas6424_fault_check_work()
549 if ((reg & TAS6424_WARN_VDD_UV) && !(tas6424->last_warn & TAS6424_WARN_VDD_UV)) in tas6424_fault_check_work()
552 if ((reg & TAS6424_WARN_VDD_POR) && !(tas6424->last_warn & TAS6424_WARN_VDD_POR)) in tas6424_fault_check_work()
555 if ((reg & TAS6424_WARN_VDD_OTW) && !(tas6424->last_warn & TAS6424_WARN_VDD_OTW)) in tas6424_fault_check_work()
558 if ((reg & TAS6424_WARN_VDD_OTW_CH1) && !(tas6424->last_warn & TAS6424_WARN_VDD_OTW_CH1)) in tas6424_fault_check_work()
561 if ((reg & TAS6424_WARN_VDD_OTW_CH2) && !(tas6424->last_warn & TAS6424_WARN_VDD_OTW_CH2)) in tas6424_fault_check_work()
564 if ((reg & TAS6424_WARN_VDD_OTW_CH3) && !(tas6424->last_warn & TAS6424_WARN_VDD_OTW_CH3)) in tas6424_fault_check_work()
567 if ((reg & TAS6424_WARN_VDD_OTW_CH4) && !(tas6424->last_warn & TAS6424_WARN_VDD_OTW_CH4)) in tas6424_fault_check_work()
571 tas6424->last_warn = reg; in tas6424_fault_check_work()
574 ret = regmap_write_bits(tas6424->regmap, TAS6424_MISC_CTRL3, in tas6424_fault_check_work()
579 ret = regmap_write_bits(tas6424->regmap, TAS6424_MISC_CTRL3, in tas6424_fault_check_work()
586 schedule_delayed_work(&tas6424->fault_check_work, in tas6424_fault_check_work()
686 struct device *dev = &client->dev; in tas6424_i2c_probe()
693 return -ENOMEM; in tas6424_i2c_probe()
696 tas6424->dev = dev; in tas6424_i2c_probe()
698 tas6424->regmap = devm_regmap_init_i2c(client, &tas6424_regmap_config); in tas6424_i2c_probe()
699 if (IS_ERR(tas6424->regmap)) { in tas6424_i2c_probe()
700 ret = PTR_ERR(tas6424->regmap); in tas6424_i2c_probe()
707 * out of the stand-by mode. in tas6424_i2c_probe()
711 tas6424->standby_gpio = devm_gpiod_get_optional(dev, "standby", in tas6424_i2c_probe()
713 if (IS_ERR(tas6424->standby_gpio)) { in tas6424_i2c_probe()
714 if (PTR_ERR(tas6424->standby_gpio) == -EPROBE_DEFER) in tas6424_i2c_probe()
715 return -EPROBE_DEFER; in tas6424_i2c_probe()
717 PTR_ERR(tas6424->standby_gpio)); in tas6424_i2c_probe()
718 tas6424->standby_gpio = NULL; in tas6424_i2c_probe()
727 tas6424->mute_gpio = devm_gpiod_get_optional(dev, "mute", in tas6424_i2c_probe()
729 if (IS_ERR(tas6424->mute_gpio)) { in tas6424_i2c_probe()
730 if (PTR_ERR(tas6424->mute_gpio) == -EPROBE_DEFER) in tas6424_i2c_probe()
731 return -EPROBE_DEFER; in tas6424_i2c_probe()
733 PTR_ERR(tas6424->mute_gpio)); in tas6424_i2c_probe()
734 tas6424->mute_gpio = NULL; in tas6424_i2c_probe()
737 for (i = 0; i < ARRAY_SIZE(tas6424->supplies); i++) in tas6424_i2c_probe()
738 tas6424->supplies[i].supply = tas6424_supply_names[i]; in tas6424_i2c_probe()
739 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(tas6424->supplies), in tas6424_i2c_probe()
740 tas6424->supplies); in tas6424_i2c_probe()
746 ret = regulator_bulk_enable(ARRAY_SIZE(tas6424->supplies), in tas6424_i2c_probe()
747 tas6424->supplies); in tas6424_i2c_probe()
753 /* Reset device to establish well-defined startup state */ in tas6424_i2c_probe()
754 ret = regmap_update_bits(tas6424->regmap, TAS6424_MODE_CTRL, in tas6424_i2c_probe()
761 INIT_DELAYED_WORK(&tas6424->fault_check_work, tas6424_fault_check_work); in tas6424_i2c_probe()
773 regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), tas6424->supplies); in tas6424_i2c_probe()
779 struct device *dev = &client->dev; in tas6424_i2c_remove()
783 cancel_delayed_work_sync(&tas6424->fault_check_work); in tas6424_i2c_remove()
785 /* put the codec in stand-by */ in tas6424_i2c_remove()
786 if (tas6424->standby_gpio) in tas6424_i2c_remove()
787 gpiod_set_value_cansleep(tas6424->standby_gpio, 1); in tas6424_i2c_remove()
789 ret = regulator_bulk_disable(ARRAY_SIZE(tas6424->supplies), in tas6424_i2c_remove()
790 tas6424->supplies); in tas6424_i2c_remove()