Lines Matching full:tas2770
3 // ALSA SoC Texas Instruments TAS2770 20-W Digital Input Mono Class-D
29 #include "tas2770.h"
33 static void tas2770_reset(struct tas2770_priv *tas2770) in tas2770_reset() argument
35 if (tas2770->reset_gpio) { in tas2770_reset()
36 gpiod_set_value_cansleep(tas2770->reset_gpio, 0); in tas2770_reset()
38 gpiod_set_value_cansleep(tas2770->reset_gpio, 1); in tas2770_reset()
42 snd_soc_component_write(tas2770->component, TAS2770_SW_RST, in tas2770_reset()
47 static int tas2770_update_pwr_ctrl(struct tas2770_priv *tas2770) in tas2770_update_pwr_ctrl() argument
49 struct snd_soc_component *component = tas2770->component; in tas2770_update_pwr_ctrl()
53 if (tas2770->dac_powered) in tas2770_update_pwr_ctrl()
54 val = tas2770->unmuted ? in tas2770_update_pwr_ctrl()
70 struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); in tas2770_codec_suspend() local
73 regcache_cache_only(tas2770->regmap, true); in tas2770_codec_suspend()
74 regcache_mark_dirty(tas2770->regmap); in tas2770_codec_suspend()
76 if (tas2770->sdz_gpio) { in tas2770_codec_suspend()
77 gpiod_set_value_cansleep(tas2770->sdz_gpio, 0); in tas2770_codec_suspend()
83 regcache_cache_only(tas2770->regmap, false); in tas2770_codec_suspend()
84 regcache_sync(tas2770->regmap); in tas2770_codec_suspend()
96 struct tas2770_priv *tas2770 = snd_soc_component_get_drvdata(component); in tas2770_codec_resume() local
99 if (tas2770->sdz_gpio) { in tas2770_codec_resume()
100 gpiod_set_value_cansleep(tas2770->sdz_gpio, 1); in tas2770_codec_resume()
103 ret = tas2770_update_pwr_ctrl(tas2770); in tas2770_codec_resume()
108 regcache_cache_only(tas2770->regmap, false); in tas2770_codec_resume()
110 return regcache_sync(tas2770->regmap); in tas2770_codec_resume()
133 struct tas2770_priv *tas2770 = in tas2770_dac_event() local
139 tas2770->dac_powered = 1; in tas2770_dac_event()
140 ret = tas2770_update_pwr_ctrl(tas2770); in tas2770_dac_event()
143 tas2770->dac_powered = 0; in tas2770_dac_event()
144 ret = tas2770_update_pwr_ctrl(tas2770); in tas2770_dac_event()
147 dev_err(tas2770->dev, "Not supported evevt\n"); in tas2770_dac_event()
185 struct tas2770_priv *tas2770 = in tas2770_mute() local
188 tas2770->unmuted = !mute; in tas2770_mute()
189 return tas2770_update_pwr_ctrl(tas2770); in tas2770_mute()
192 static int tas2770_set_bitwidth(struct tas2770_priv *tas2770, int bitwidth) in tas2770_set_bitwidth() argument
195 struct snd_soc_component *component = tas2770->component; in tas2770_set_bitwidth()
202 tas2770->v_sense_slot = tas2770->i_sense_slot + 2; in tas2770_set_bitwidth()
208 tas2770->v_sense_slot = tas2770->i_sense_slot + 4; in tas2770_set_bitwidth()
214 tas2770->v_sense_slot = tas2770->i_sense_slot + 4; in tas2770_set_bitwidth()
228 tas2770->v_sense_slot); in tas2770_set_bitwidth()
236 tas2770->i_sense_slot); in tas2770_set_bitwidth()
243 static int tas2770_set_samplerate(struct tas2770_priv *tas2770, int samplerate) in tas2770_set_samplerate() argument
245 struct snd_soc_component *component = tas2770->component; in tas2770_set_samplerate()
293 struct tas2770_priv *tas2770 = in tas2770_hw_params() local
297 ret = tas2770_set_bitwidth(tas2770, params_format(params)); in tas2770_hw_params()
301 return tas2770_set_samplerate(tas2770, params_rate(params)); in tas2770_hw_params()
307 struct tas2770_priv *tas2770 = in tas2770_set_fmt() local
316 dev_err(tas2770->dev, "ASI invalid DAI clocking\n"); in tas2770_set_fmt()
334 dev_err(tas2770->dev, "ASI format Inverse is not found\n"); in tas2770_set_fmt()
362 dev_err(tas2770->dev, in tas2770_set_fmt()
467 .name = "tas2770 ASI1",
492 struct tas2770_priv *tas2770 = in tas2770_codec_probe() local
495 tas2770->component = component; in tas2770_codec_probe()
497 if (tas2770->sdz_gpio) { in tas2770_codec_probe()
498 gpiod_set_value_cansleep(tas2770->sdz_gpio, 1); in tas2770_codec_probe()
502 tas2770_reset(tas2770); in tas2770_codec_probe()
503 regmap_reinit_cache(tas2770->regmap, &tas2770_i2c_regmap); in tas2770_codec_probe()
532 static int tas2770_register_codec(struct tas2770_priv *tas2770) in tas2770_register_codec() argument
534 return devm_snd_soc_register_component(tas2770->dev, in tas2770_register_codec()
622 static int tas2770_parse_dt(struct device *dev, struct tas2770_priv *tas2770) in tas2770_parse_dt() argument
627 &tas2770->i_sense_slot); in tas2770_parse_dt()
629 dev_info(tas2770->dev, "Property %s is missing setting default slot\n", in tas2770_parse_dt()
632 tas2770->i_sense_slot = 0; in tas2770_parse_dt()
636 &tas2770->v_sense_slot); in tas2770_parse_dt()
638 dev_info(tas2770->dev, "Property %s is missing setting default slot\n", in tas2770_parse_dt()
641 tas2770->v_sense_slot = 2; in tas2770_parse_dt()
644 tas2770->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); in tas2770_parse_dt()
645 if (IS_ERR(tas2770->sdz_gpio)) { in tas2770_parse_dt()
646 if (PTR_ERR(tas2770->sdz_gpio) == -EPROBE_DEFER) in tas2770_parse_dt()
649 tas2770->sdz_gpio = NULL; in tas2770_parse_dt()
657 struct tas2770_priv *tas2770; in tas2770_i2c_probe() local
660 tas2770 = devm_kzalloc(&client->dev, sizeof(struct tas2770_priv), in tas2770_i2c_probe()
662 if (!tas2770) in tas2770_i2c_probe()
665 tas2770->dev = &client->dev; in tas2770_i2c_probe()
666 i2c_set_clientdata(client, tas2770); in tas2770_i2c_probe()
667 dev_set_drvdata(&client->dev, tas2770); in tas2770_i2c_probe()
669 tas2770->regmap = devm_regmap_init_i2c(client, &tas2770_i2c_regmap); in tas2770_i2c_probe()
670 if (IS_ERR(tas2770->regmap)) { in tas2770_i2c_probe()
671 result = PTR_ERR(tas2770->regmap); in tas2770_i2c_probe()
678 result = tas2770_parse_dt(&client->dev, tas2770); in tas2770_i2c_probe()
680 dev_err(tas2770->dev, "%s: Failed to parse devicetree\n", in tas2770_i2c_probe()
686 tas2770->reset_gpio = devm_gpiod_get_optional(tas2770->dev, "reset", in tas2770_i2c_probe()
688 if (IS_ERR(tas2770->reset_gpio)) { in tas2770_i2c_probe()
689 if (PTR_ERR(tas2770->reset_gpio) == -EPROBE_DEFER) { in tas2770_i2c_probe()
690 tas2770->reset_gpio = NULL; in tas2770_i2c_probe()
695 result = tas2770_register_codec(tas2770); in tas2770_i2c_probe()
697 dev_err(tas2770->dev, "Register codec failed.\n"); in tas2770_i2c_probe()
703 { "tas2770"},
710 { .compatible = "ti,tas2770" },
718 .name = "tas2770",
727 MODULE_DESCRIPTION("TAS2770 I2C Smart Amplifier driver");