Lines Matching full:tas2764
3 // Driver for the Texas Instruments TAS2764 CODEC
26 #include "tas2764.h"
65 struct tas2764_priv *tas2764 = data; in tas2764_irq() local
71 latched[i] = snd_soc_component_read(tas2764->component, in tas2764_irq()
76 dev_crit_ratelimited(tas2764->dev, "%s\n", in tas2764_irq()
83 dev_err_ratelimited(tas2764->dev, "other context to the fault: %02x,%02x,%02x,%02x,%02x", in tas2764_irq()
85 snd_soc_component_update_bits(tas2764->component, in tas2764_irq()
94 static void tas2764_reset(struct tas2764_priv *tas2764) in tas2764_reset() argument
96 if (tas2764->reset_gpio) { in tas2764_reset()
97 gpiod_set_value_cansleep(tas2764->reset_gpio, 0); in tas2764_reset()
99 gpiod_set_value_cansleep(tas2764->reset_gpio, 1); in tas2764_reset()
103 snd_soc_component_write(tas2764->component, TAS2764_SW_RST, in tas2764_reset()
108 static int tas2764_update_pwr_ctrl(struct tas2764_priv *tas2764) in tas2764_update_pwr_ctrl() argument
110 struct snd_soc_component *component = tas2764->component; in tas2764_update_pwr_ctrl()
114 if (tas2764->dac_powered) in tas2764_update_pwr_ctrl()
115 val = tas2764->unmuted ? in tas2764_update_pwr_ctrl()
131 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_codec_suspend() local
141 if (tas2764->sdz_gpio) in tas2764_codec_suspend()
142 gpiod_set_value_cansleep(tas2764->sdz_gpio, 0); in tas2764_codec_suspend()
144 regcache_cache_only(tas2764->regmap, true); in tas2764_codec_suspend()
145 regcache_mark_dirty(tas2764->regmap); in tas2764_codec_suspend()
152 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_codec_resume() local
155 if (tas2764->sdz_gpio) { in tas2764_codec_resume()
156 gpiod_set_value_cansleep(tas2764->sdz_gpio, 1); in tas2764_codec_resume()
160 ret = tas2764_update_pwr_ctrl(tas2764); in tas2764_codec_resume()
165 regcache_cache_only(tas2764->regmap, false); in tas2764_codec_resume()
167 return regcache_sync(tas2764->regmap); in tas2764_codec_resume()
189 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_dac_event() local
194 tas2764->dac_powered = true; in tas2764_dac_event()
195 ret = tas2764_update_pwr_ctrl(tas2764); in tas2764_dac_event()
198 tas2764->dac_powered = false; in tas2764_dac_event()
199 ret = tas2764_update_pwr_ctrl(tas2764); in tas2764_dac_event()
202 dev_err(tas2764->dev, "Unsupported event\n"); in tas2764_dac_event()
244 struct tas2764_priv *tas2764 = in tas2764_mute() local
247 tas2764->unmuted = !mute; in tas2764_mute()
248 return tas2764_update_pwr_ctrl(tas2764); in tas2764_mute()
251 static int tas2764_set_bitwidth(struct tas2764_priv *tas2764, int bitwidth) in tas2764_set_bitwidth() argument
253 struct snd_soc_component *component = tas2764->component; in tas2764_set_bitwidth()
285 val = snd_soc_component_read(tas2764->component, TAS2764_PWR_CTRL); in tas2764_set_bitwidth()
294 ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5, in tas2764_set_bitwidth()
305 ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6, in tas2764_set_bitwidth()
314 static int tas2764_set_samplerate(struct tas2764_priv *tas2764, int samplerate) in tas2764_set_samplerate() argument
316 struct snd_soc_component *component = tas2764->component; in tas2764_set_samplerate()
356 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_hw_params() local
359 ret = tas2764_set_bitwidth(tas2764, params_format(params)); in tas2764_hw_params()
363 return tas2764_set_samplerate(tas2764, params_rate(params)); in tas2764_hw_params()
369 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_set_fmt() local
406 dev_err(tas2764->dev, in tas2764_set_fmt()
432 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_set_dai_tdm_slot() local
481 tas2764->v_sense_slot); in tas2764_set_dai_tdm_slot()
487 tas2764->i_sense_slot); in tas2764_set_dai_tdm_slot()
510 .name = "tas2764 ASI1",
533 struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); in tas2764_codec_probe() local
536 tas2764->component = component; in tas2764_codec_probe()
538 if (tas2764->sdz_gpio) { in tas2764_codec_probe()
539 gpiod_set_value_cansleep(tas2764->sdz_gpio, 1); in tas2764_codec_probe()
543 tas2764_reset(tas2764); in tas2764_codec_probe()
545 if (tas2764->irq) { in tas2764_codec_probe()
546 ret = snd_soc_component_write(tas2764->component, TAS2764_INT_MASK0, 0xff); in tas2764_codec_probe()
550 ret = snd_soc_component_write(tas2764->component, TAS2764_INT_MASK1, 0xff); in tas2764_codec_probe()
554 ret = snd_soc_component_write(tas2764->component, TAS2764_INT_MASK2, 0xff); in tas2764_codec_probe()
558 ret = snd_soc_component_write(tas2764->component, TAS2764_INT_MASK3, 0xff); in tas2764_codec_probe()
562 ret = snd_soc_component_write(tas2764->component, TAS2764_INT_MASK4, 0xff); in tas2764_codec_probe()
566 ret = devm_request_threaded_irq(tas2764->dev, tas2764->irq, NULL, tas2764_irq, in tas2764_codec_probe()
568 "tas2764", tas2764); in tas2764_codec_probe()
570 dev_warn(tas2764->dev, "failed to request IRQ: %d\n", ret); in tas2764_codec_probe()
573 ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG5, in tas2764_codec_probe()
578 ret = snd_soc_component_update_bits(tas2764->component, TAS2764_TDM_CFG6, in tas2764_codec_probe()
668 static int tas2764_parse_dt(struct device *dev, struct tas2764_priv *tas2764) in tas2764_parse_dt() argument
672 tas2764->reset_gpio = devm_gpiod_get_optional(tas2764->dev, "reset", in tas2764_parse_dt()
674 if (IS_ERR(tas2764->reset_gpio)) { in tas2764_parse_dt()
675 if (PTR_ERR(tas2764->reset_gpio) == -EPROBE_DEFER) { in tas2764_parse_dt()
676 tas2764->reset_gpio = NULL; in tas2764_parse_dt()
681 tas2764->sdz_gpio = devm_gpiod_get_optional(dev, "shutdown", GPIOD_OUT_HIGH); in tas2764_parse_dt()
682 if (IS_ERR(tas2764->sdz_gpio)) { in tas2764_parse_dt()
683 if (PTR_ERR(tas2764->sdz_gpio) == -EPROBE_DEFER) in tas2764_parse_dt()
686 tas2764->sdz_gpio = NULL; in tas2764_parse_dt()
690 &tas2764->i_sense_slot); in tas2764_parse_dt()
692 tas2764->i_sense_slot = 0; in tas2764_parse_dt()
695 &tas2764->v_sense_slot); in tas2764_parse_dt()
697 tas2764->v_sense_slot = 2; in tas2764_parse_dt()
704 struct tas2764_priv *tas2764; in tas2764_i2c_probe() local
707 tas2764 = devm_kzalloc(&client->dev, sizeof(struct tas2764_priv), in tas2764_i2c_probe()
709 if (!tas2764) in tas2764_i2c_probe()
712 tas2764->dev = &client->dev; in tas2764_i2c_probe()
713 tas2764->irq = client->irq; in tas2764_i2c_probe()
714 i2c_set_clientdata(client, tas2764); in tas2764_i2c_probe()
715 dev_set_drvdata(&client->dev, tas2764); in tas2764_i2c_probe()
717 tas2764->regmap = devm_regmap_init_i2c(client, &tas2764_i2c_regmap); in tas2764_i2c_probe()
718 if (IS_ERR(tas2764->regmap)) { in tas2764_i2c_probe()
719 result = PTR_ERR(tas2764->regmap); in tas2764_i2c_probe()
726 result = tas2764_parse_dt(&client->dev, tas2764); in tas2764_i2c_probe()
728 dev_err(tas2764->dev, "%s: Failed to parse devicetree\n", in tas2764_i2c_probe()
734 return devm_snd_soc_register_component(tas2764->dev, in tas2764_i2c_probe()
741 { "tas2764", 0},
748 { .compatible = "ti,tas2764" },
756 .name = "tas2764",
765 MODULE_DESCRIPTION("TAS2764 I2C Smart Amplifier driver");