From 677b9517389dce50ab3db5daf5f909b81c2593b7 Mon Sep 17 00:00:00 2001 From: Dylan Ironside Date: Sun, 15 Nov 2026 15:27:01 +0000 Subject: [PATCH 1/2] ASoC: tas2764: Bring an SDZ group back from a deep sleep as from power-on Amps in an SDZ group keep the shared SDZ line across system sleep and only sync their register cache at resume. That holds for s2idle. A firmware-driven sleep powers the SoC's pin controller off, so the line drops while asleep and every amp comes back from a power-on reset when the pin controller restores it: TI's volatile quirk page is gone, and the page register is back at 0 while the cache may still hold another page. The cache sync at resume still succeeds, so nothing is logged then. On a J604 the first stream after a deep-sleep wake latched an over-current on one woofer amp, the failure the resume path's comment already names for an amp without its init quirks. The SDZ group then shut all six amps down, as it is meant to, and they stayed off the bus until a reboot. On a resume via firmware, treat a group like a power-on: wait the SDZ high to I2C time, reset the amp, drop the cached page so the next page switch reads the amp, sync the cache and apply the init quirks again, as the probe does. Say so when the amp does not answer on I2C, which means SDZ or the supply did not come back. s2idle keeps today's path. Tested on a J604 (M4 MacBook Pro 14"): before, the first stream after a deep wake logged "fault: over current" on a woofer amp and "SDZ group shut down"; with this change, a stream after seven deep wakes kept all six amps active with no I2C error and no over-current. Assisted-by: LLM Signed-off-by: Dylan Ironside --- sound/soc/codecs/tas2764.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c index 887de36981653..eee2631e30402 100644 --- a/sound/soc/codecs/tas2764.c +++ b/sound/soc/codecs/tas2764.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -402,6 +403,14 @@ static int tas2764_codec_suspend(struct snd_soc_component *component) static int tas2764_codec_resume(struct snd_soc_component *component) { struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); + /* + * A firmware-driven (deep) sleep powers the SoC's pin controller off, + * so the group's SDZ line drops while asleep and every amp comes back + * from a power-on reset when the pin controller restores the line + * (its resume_noirq, before this). s2idle keeps the line and the + * amps' registers and stays on the path below. + */ + bool power_on = tas2764->sdz_group && pm_resume_via_firmware(); int ret; if (!tas2764->sdz_group) { @@ -419,6 +428,25 @@ static int tas2764_codec_resume(struct snd_soc_component *component) regcache_cache_only(tas2764->regmap, false); + if (power_on) { + /* SDZ high to the first I2C access, as at probe */ + usleep_range(1000, 2000); + /* + * Start from the reset state the cache sync assumes. The page + * register is back at 0 while the cache may hold another page: + * drop it, so the next page switch is read from the amp. + */ + ret = regmap_write(tas2764->regmap, TAS2764_SW_RST, TAS2764_RST); + if (ret) { + dev_err(tas2764->dev, + "no answer on I2C after a deep sleep (%d): SDZ or supply not back\n", + ret); + goto out_irq; + } + usleep_range(1000, 2000); + regcache_drop_region(tas2764->regmap, TAS2764_PAGE, TAS2764_PAGE); + } + ret = regcache_sync(tas2764->regmap); /* * An amp whose SDZ went low came back from a power-on reset, and the @@ -428,8 +456,11 @@ static int tas2764_codec_resume(struct snd_soc_component *component) * over-current at the first stream after a resume. Apply them again, * as the probe does. */ - if (ret >= 0 && !tas2764->sdz_group && tas2764->devid == DEVID_SN012776) + if (ret >= 0 && (!tas2764->sdz_group || power_on) && + tas2764->devid == DEVID_SN012776) ret = tas2764_apply_init_quirks(tas2764); + if (ret < 0 && power_on) + dev_err(tas2764->dev, "restore after a deep sleep failed: %d\n", ret); if (ret >= 0) ret = tas2764_update_pwr_ctrl(tas2764); From a4f5e7a1ac05dbf6c88bfa7b0a90b6f104cbce9a Mon Sep 17 00:00:00 2001 From: Dylan Ironside Date: Sun, 15 Nov 2026 10:51:03 +0000 Subject: [PATCH 2/2] ASoC: tas2764: Detect a power-on reset of an SDZ group amp at resume The previous change restores an SDZ group from a power-on reset when the resume comes through firmware. A sleep can still cut the shared SDZ line or the amps' supply without the firmware reporting it, for example an s2idle resume after a deep sleep that failed half way. The amps then sit in their reset state with the cache believing otherwise, and the first stream latches an over-current on a woofer amp, which takes the whole group down. Ask the amp. PWR_CTRL resets to 0x1a with BOP_SRC clear, and the probe sets BOP_SRC on every SN012776, so a read that bypasses the cache tells a reset amp from one that kept its registers. When it was reset, or does not answer, take the power-on path. This costs one register read per amp per resume. Assisted-by: LLM Signed-off-by: Dylan Ironside --- sound/soc/codecs/tas2764.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/sound/soc/codecs/tas2764.c b/sound/soc/codecs/tas2764.c index eee2631e30402..1f6002fc10be3 100644 --- a/sound/soc/codecs/tas2764.c +++ b/sound/soc/codecs/tas2764.c @@ -400,6 +400,25 @@ static int tas2764_codec_suspend(struct snd_soc_component *component) return 0; } +/* + * Whether the amp came back from a power-on reset, read from the amp itself: + * PWR_CTRL resets to 0x1a with BOP_SRC clear, and the probe sets BOP_SRC on + * every SN012776. A failed read counts as lost too. Bypasses the cache, which + * still holds the probe's value. + */ +static bool tas2764_lost_state(struct tas2764_priv *tas2764) +{ + unsigned int val; + int ret; + + if (tas2764->devid != DEVID_SN012776) + return false; + regcache_cache_bypass(tas2764->regmap, true); + ret = regmap_read(tas2764->regmap, TAS2764_PWR_CTRL, &val); + regcache_cache_bypass(tas2764->regmap, false); + return ret || !(val & TAS2764_PWR_CTRL_BOP_SRC); +} + static int tas2764_codec_resume(struct snd_soc_component *component) { struct tas2764_priv *tas2764 = snd_soc_component_get_drvdata(component); @@ -428,6 +447,17 @@ static int tas2764_codec_resume(struct snd_soc_component *component) regcache_cache_only(tas2764->regmap, false); + /* + * Any other sleep that cut the line or the supply (an s2idle wake + * after a deep sleep that failed half way) leaves the same reset + * state without the firmware saying so; a stream started on it + * latches an over-current on a woofer amp. Check the amp itself. + */ + if (tas2764->sdz_group && !power_on && tas2764_lost_state(tas2764)) { + dev_warn(tas2764->dev, "registers lost in a sleep: restoring as from power-on\n"); + power_on = true; + } + if (power_on) { /* SDZ high to the first I2C access, as at probe */ usleep_range(1000, 2000);