Lines Matching +full:ignore +full:- +full:power +full:- +full:on +full:- +full:sel
1 // SPDX-License-Identifier: GPL-2.0-only
3 * tas5720.c - ALSA SoC Texas Instruments TAS5720 Mono Audio Amplifier
5 * Copyright (C)2015-2016 Texas Instruments Incorporated - https://www.ti.com
23 #include <sound/soc-dapm.h>
37 "dvdd", /* Digital power supply. Connect to 3.3-V supply. */
38 "pvdd", /* Class-D amp and analog power supply (connected). */
57 struct snd_soc_component *component = dai->component; in tas5720_hw_params()
72 dev_err(component->dev, "unsupported sample rate: %u\n", rate); in tas5720_hw_params()
73 return -EINVAL; in tas5720_hw_params()
79 dev_err(component->dev, "error setting sample rate: %d\n", ret); in tas5720_hw_params()
88 struct snd_soc_component *component = dai->component; in tas5720_set_dai_fmt()
93 dev_vdbg(component->dev, "DAI clocking invalid\n"); in tas5720_set_dai_fmt()
94 return -EINVAL; in tas5720_set_dai_fmt()
127 dev_vdbg(component->dev, "DAI Format is not found\n"); in tas5720_set_dai_fmt()
128 return -EINVAL; in tas5720_set_dai_fmt()
135 dev_err(component->dev, "error setting SAIF format: %d\n", ret); in tas5720_set_dai_fmt()
146 struct snd_soc_component *component = dai->component; in tas5720_set_dai_tdm_slot()
152 dev_err(component->dev, "tx masks must not be 0\n"); in tas5720_set_dai_tdm_slot()
153 return -EINVAL; in tas5720_set_dai_tdm_slot()
164 dev_err(component->dev, "slot selection out of bounds (%u)\n", in tas5720_set_dai_tdm_slot()
166 return -EINVAL; in tas5720_set_dai_tdm_slot()
182 switch (tas5720->devtype) { in tas5720_set_dai_tdm_slot()
198 dev_err(component->dev, "error configuring TDM mode: %d\n", ret); in tas5720_set_dai_tdm_slot()
204 struct snd_soc_component *component = dai->component; in tas5720_mute()
210 dev_err(component->dev, "error (un-)muting device: %d\n", ret); in tas5720_mute()
221 struct device *dev = tas5720->component->dev; in tas5720_fault_check_work()
225 ret = regmap_read(tas5720->regmap, TAS5720_FAULT_REG, &curr_fault); in tas5720_fault_check_work()
240 if ((curr_fault & TAS5720_OCE) && !(tas5720->last_fault & TAS5720_OCE)) in tas5720_fault_check_work()
243 if ((curr_fault & TAS5720_DCE) && !(tas5720->last_fault & TAS5720_DCE)) in tas5720_fault_check_work()
246 if ((curr_fault & TAS5720_OTE) && !(tas5720->last_fault & TAS5720_OTE)) in tas5720_fault_check_work()
250 tas5720->last_fault = curr_fault; in tas5720_fault_check_work()
256 * Periodically toggle SDZ (shutdown bit) H->L->H to clear any latching in tas5720_fault_check_work()
261 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG, in tas5720_fault_check_work()
266 ret = regmap_write_bits(tas5720->regmap, TAS5720_POWER_CTRL_REG, in tas5720_fault_check_work()
273 schedule_delayed_work(&tas5720->fault_check_work, in tas5720_fault_check_work()
283 tas5720->component = component; in tas5720_codec_probe()
285 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), in tas5720_codec_probe()
286 tas5720->supplies); in tas5720_codec_probe()
288 dev_err(component->dev, "failed to enable supplies: %d\n", ret); in tas5720_codec_probe()
297 ret = regmap_read(tas5720->regmap, TAS5720_DEVICE_ID_REG, &device_id); in tas5720_codec_probe()
299 dev_err(component->dev, "failed to read device ID register: %d\n", in tas5720_codec_probe()
304 switch (tas5720->devtype) { in tas5720_codec_probe()
312 dev_err(component->dev, "unexpected private driver data\n"); in tas5720_codec_probe()
313 return -EINVAL; in tas5720_codec_probe()
317 dev_warn(component->dev, "wrong device ID. expected: %u read: %u\n", in tas5720_codec_probe()
327 * Enter shutdown mode - our default when not playing audio - to in tas5720_codec_probe()
328 * minimize current consumption. On the TAS5720 there is no real down in tas5720_codec_probe()
337 INIT_DELAYED_WORK(&tas5720->fault_check_work, tas5720_fault_check_work); in tas5720_codec_probe()
342 dev_err(component->dev, "error configuring device registers: %d\n", ret); in tas5720_codec_probe()
345 regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), in tas5720_codec_probe()
346 tas5720->supplies); in tas5720_codec_probe()
355 cancel_delayed_work_sync(&tas5720->fault_check_work); in tas5720_codec_remove()
357 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), in tas5720_codec_remove()
358 tas5720->supplies); in tas5720_codec_remove()
360 dev_err(component->dev, "failed to disable supplies: %d\n", ret); in tas5720_codec_remove()
366 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in tas5720_dac_event()
375 dev_err(component->dev, "error waking component: %d\n", ret); in tas5720_dac_event()
380 * Observe codec shutdown-to-active time. The datasheet only in tas5720_dac_event()
381 * lists a nominal value however just use-it as-is without in tas5720_dac_event()
389 /* Turn on TAS5720 periodic fault checking/handling */ in tas5720_dac_event()
390 tas5720->last_fault = 0; in tas5720_dac_event()
391 schedule_delayed_work(&tas5720->fault_check_work, in tas5720_dac_event()
395 cancel_delayed_work_sync(&tas5720->fault_check_work); in tas5720_dac_event()
401 dev_err(component->dev, "error shutting down component: %d\n", in tas5720_dac_event()
416 regcache_cache_only(tas5720->regmap, true); in tas5720_suspend()
417 regcache_mark_dirty(tas5720->regmap); in tas5720_suspend()
419 ret = regulator_bulk_disable(ARRAY_SIZE(tas5720->supplies), in tas5720_suspend()
420 tas5720->supplies); in tas5720_suspend()
422 dev_err(component->dev, "failed to disable supplies: %d\n", ret); in tas5720_suspend()
432 ret = regulator_bulk_enable(ARRAY_SIZE(tas5720->supplies), in tas5720_resume()
433 tas5720->supplies); in tas5720_resume()
435 dev_err(component->dev, "failed to enable supplies: %d\n", ret); in tas5720_resume()
439 regcache_cache_only(tas5720->regmap, false); in tas5720_resume()
441 ret = regcache_sync(tas5720->regmap); in tas5720_resume()
443 dev_err(component->dev, "failed to sync regcache: %d\n", ret); in tas5720_resume()
495 * DAC digital volumes. From -103.5 to 24 dB in 0.5 dB or 0.25 dB steps
496 * depending on the device. Note that setting the gain below -100 dB
502 static DECLARE_TLV_DB_SCALE(tas5720_dac_tlv, -10350, 50, 0);
503 static DECLARE_TLV_DB_SCALE(tas5722_dac_tlv, -10350, 25, 0);
512 ucontrol->value.integer.value[0] = val << 1; in tas5722_volume_get()
515 ucontrol->value.integer.value[0] |= val & TAS5722_VOL_CONTROL_LSB; in tas5722_volume_get()
524 unsigned int sel = ucontrol->value.integer.value[0]; in tas5722_volume_set() local
526 snd_soc_component_write(component, TAS5720_VOLUME_CTRL_REG, sel >> 1); in tas5722_volume_set()
528 TAS5722_VOL_CONTROL_LSB, sel); in tas5722_volume_set()
617 * simply ignore any extra channel(s) asides from the one channel that is
622 .name = "tas5720-amplifier",
643 struct device *dev = &client->dev; in tas5720_probe()
652 return -ENOMEM; in tas5720_probe()
655 data->tas5720_client = client; in tas5720_probe()
656 data->devtype = id->driver_data; in tas5720_probe()
658 switch (id->driver_data) { in tas5720_probe()
667 return -EINVAL; in tas5720_probe()
669 data->regmap = devm_regmap_init_i2c(client, regmap_config); in tas5720_probe()
670 if (IS_ERR(data->regmap)) { in tas5720_probe()
671 ret = PTR_ERR(data->regmap); in tas5720_probe()
676 for (i = 0; i < ARRAY_SIZE(data->supplies); i++) in tas5720_probe()
677 data->supplies[i].supply = tas5720_supply_names[i]; in tas5720_probe()
679 ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), in tas5720_probe()
680 data->supplies); in tas5720_probe()
688 switch (id->driver_data) { in tas5720_probe()
690 ret = devm_snd_soc_register_component(&client->dev, in tas5720_probe()
696 ret = devm_snd_soc_register_component(&client->dev, in tas5720_probe()
703 return -EINVAL; in tas5720_probe()