diff mbox series

[20/27] ASoC: tas2764: Wait for ramp-down after shutdown

Message ID 20250215-apple-codec-changes-v1-20-723569b21b19@gmail.com (mailing list archive)
State Superseded
Commit 08a66f55f7246d477b19620a953476dfc02beefc
Headers show
Series ASoC: tas27{64,70}: improve support for Apple codec variants | expand

Commit Message

James Calligeros Feb. 15, 2025, 12:02 a.m. UTC
From: Hector Martin <marcan@marcan.st>

When we shut down the amp, we need to wait for the built-in ramp-down
before we can remove the TDM clocks. There is no documented status
regiter to poll, so the best we can do is a delay. Datasheet says 5.9ms
for ramp-down and 1.5ms between shutdown and next startup, so let's do
6ms after mute and 2ms after shutdown. That gives us a cumulative 8ms
for ramp-down and guaratees the required minimum shutdown time.

Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
---
 sound/soc/codecs/tas2764.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c
index 409c54b41dda41d33e8501fff9de421c98f2541f..bdbc210ea8306ecebf704fe33fbe41083867e1ca 100644
--- a/sound/soc/codecs/tas2764.c
+++ b/sound/soc/codecs/tas2764.c
@@ -159,6 +159,8 @@  static int tas2764_codec_suspend(struct snd_soc_component *component)
 	regcache_cache_only(tas2764->regmap, true);
 	regcache_mark_dirty(tas2764->regmap);
 
+	usleep_range(6000, 7000);
+
 	return 0;
 }
 
@@ -252,10 +254,16 @@  static int tas2764_mute(struct snd_soc_dai *dai, int mute, int direction)
 		return ret;
 
 	if (mute) {
+		/* Wait for ramp-down */
+		usleep_range(6000, 7000);
+
 		tas2764->dac_powered = false;
 		ret = tas2764_update_pwr_ctrl(tas2764);
 		if (ret)
 			return ret;
+
+		/* Wait a bit after shutdown */
+		usleep_range(2000, 3000);
 	}
 
 	return 0;