* [PATCH] ASoC: cs35l41: Restore register state after system sleep
@ 2026-06-15 14:54 Nícolas F. R. A. Prado
2026-06-15 17:42 ` Mark Brown
2026-06-16 16:31 ` Stefan Binding
0 siblings, 2 replies; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2026-06-15 14:54 UTC (permalink / raw)
To: David Rhodes, Richard Fitzgerald, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, patches, linux-kernel, Nícolas F. R. A. Prado
Currently, on the Steam Deck LCD when the system goes into hibernation
and resumes back, the speakers are silent when playing with:
aplay -D plughw:acp5x,1 /usr/share/sounds/alsa/Front_Left.wav
A crude workaround was to, after resuming the system, bypassing the
regmap cache on the cs35l41 devices, before playing:
echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:00/cache_bypass
echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:01/cache_bypass
That indicated that the hardware registers had gone out of sync with
the regmap cache due to the power down in system hibernation.
Fix the issue by, before system sleep, marking the regcache as cache
only, and after system sleep, resetting the hardware and restoring the
hardware registers from the regcache.
This gets the sound working on the Steam Deck LCD after resume from S4.
While the issue was only observed on S4 on this platform, the callbacks
for suspend/resume are also set in the same way to account for platforms
that might power down the chip on S3 as well.
Note that this change does not take care of restoring the DSP state,
since the affected platform does not use the DSP and it couldn't be
tested, so it is only shut down on resume so it can be reinitialized in
a future DSP preload event.
Assisted-by: Copilot:claude-sonnet-4.6
Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
---
sound/soc/codecs/cs35l41.c | 127 ++++++++++++++++++++++++++++++++++++---------
1 file changed, 102 insertions(+), 25 deletions(-)
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index b2a076706c79..231341a7eb44 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1199,9 +1199,41 @@ static int cs35l41_get_system_name(struct cs35l41_private *cs35l41)
return ret;
}
+static int cs35l41_boot(struct cs35l41_private *cs35l41)
+{
+ u32 int_status;
+ int ret;
+
+ if (cs35l41->reset_gpio) {
+ /* satisfy minimum reset pulse width spec */
+ gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
+ usleep_range(2000, 2100);
+ gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
+ }
+
+ usleep_range(2000, 2100);
+
+ ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4,
+ int_status, int_status & CS35L41_OTP_BOOT_DONE,
+ 1000, 100000);
+ if (ret) {
+ dev_err_probe(cs35l41->dev, ret,
+ "Failed waiting for OTP_BOOT_DONE\n");
+ return ret;
+ }
+
+ regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status);
+ if (int_status & CS35L41_OTP_BOOT_ERR) {
+ dev_err(cs35l41->dev, "OTP Boot error\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
{
- u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match;
+ u32 regid, reg_revid, i, mtl_revid, chipid_match;
int irq_pol = 0;
int ret;
@@ -1242,29 +1274,10 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *
goto err;
}
}
- if (cs35l41->reset_gpio) {
- /* satisfy minimum reset pulse width spec */
- usleep_range(2000, 2100);
- gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
- }
-
- usleep_range(2000, 2100);
-
- ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4,
- int_status, int_status & CS35L41_OTP_BOOT_DONE,
- 1000, 100000);
- if (ret) {
- dev_err_probe(cs35l41->dev, ret,
- "Failed waiting for OTP_BOOT_DONE\n");
- goto err;
- }
- regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status);
- if (int_status & CS35L41_OTP_BOOT_ERR) {
- dev_err(cs35l41->dev, "OTP Boot error\n");
- ret = -EINVAL;
+ ret = cs35l41_boot(cs35l41);
+ if (ret)
goto err;
- }
ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id);
if (ret < 0) {
@@ -1450,7 +1463,20 @@ static int cs35l41_sys_suspend(struct device *dev)
{
struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
- dev_dbg(cs35l41->dev, "System suspend, disabling IRQ\n");
+ dev_dbg(cs35l41->dev, "System suspend, saving state\n");
+ disable_irq(cs35l41->irq);
+
+ regcache_cache_only(cs35l41->regmap, true);
+ regcache_mark_dirty(cs35l41->regmap);
+
+ return 0;
+}
+
+static int cs35l41_sys_poweroff(struct device *dev)
+{
+ struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
+
+ dev_dbg(cs35l41->dev, "System poweroff, disabling IRQ\n");
disable_irq(cs35l41->irq);
return 0;
@@ -1476,20 +1502,71 @@ static int cs35l41_sys_resume_noirq(struct device *dev)
return 0;
}
+static int cs35l41_sys_thaw(struct device *dev)
+{
+ struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
+
+ dev_dbg(cs35l41->dev, "System thaw, reenabling IRQ\n");
+ enable_irq(cs35l41->irq);
+
+ return 0;
+}
+
static int cs35l41_sys_resume(struct device *dev)
{
struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
+ int ret;
+
+ dev_dbg(cs35l41->dev, "System resume, restoring state\n");
+
+ regcache_cache_only(cs35l41->regmap, false);
+
+ ret = cs35l41_boot(cs35l41);
+ if (ret)
+ return ret;
+
+ cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap);
+ ret = regcache_sync(cs35l41->regmap);
+ cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap);
+ if (ret) {
+ dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret);
+ return ret;
+ }
+
+ ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap,
+ &cs35l41->hw_cfg);
+ if (ret)
+ return ret;
- dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n");
enable_irq(cs35l41->irq);
+ if (!cs35l41->dsp.cs_dsp.running)
+ return 0;
+
+ /*
+ * DSP firmware is gone after a full power cycle. Reset the DSP
+ * software state so that firmware is reloaded on next DSP preload event
+ */
+ wm_adsp_stop(&cs35l41->dsp);
+
+ if (!cs35l41->dsp.cs_dsp.booted)
+ return 0;
+
+ wm_adsp_power_down(&cs35l41->dsp);
+
return 0;
}
EXPORT_GPL_DEV_PM_OPS(cs35l41_pm_ops) = {
RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL)
- SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume)
+ .suspend = pm_sleep_ptr(cs35l41_sys_suspend),
+ .resume = pm_sleep_ptr(cs35l41_sys_resume),
+ .freeze = pm_sleep_ptr(cs35l41_sys_suspend),
+ .thaw = pm_sleep_ptr(cs35l41_sys_thaw),
+ .poweroff = pm_sleep_ptr(cs35l41_sys_poweroff),
+ .restore = pm_sleep_ptr(cs35l41_sys_resume),
+
NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend_noirq, cs35l41_sys_resume_noirq)
};
---
base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b
change-id: 20260615-cs35l41-s4-support-aac193d7ccba
Best regards,
--
Nícolas F. R. A. Prado <nfraprado@collabora.com>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: cs35l41: Restore register state after system sleep
2026-06-15 14:54 [PATCH] ASoC: cs35l41: Restore register state after system sleep Nícolas F. R. A. Prado
@ 2026-06-15 17:42 ` Mark Brown
2026-06-16 16:31 ` Stefan Binding
1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2026-06-15 17:42 UTC (permalink / raw)
To: Nícolas F. R. A. Prado
Cc: David Rhodes, Richard Fitzgerald, Liam Girdwood, Jaroslav Kysela,
Takashi Iwai, kernel, linux-sound, patches, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1383 bytes --]
On Mon, Jun 15, 2026 at 10:54:10AM -0400, Nícolas F. R. A. Prado wrote:
> Currently, on the Steam Deck LCD when the system goes into hibernation
> and resumes back, the speakers are silent when playing with:
> static int cs35l41_sys_resume(struct device *dev)
> {
> struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
> + int ret;
> +
> + dev_dbg(cs35l41->dev, "System resume, restoring state\n");
> +
> + regcache_cache_only(cs35l41->regmap, false);
> +
> + ret = cs35l41_boot(cs35l41);
> + if (ret)
> + return ret;
The error handling in this function needs some attention, we probably
ought to go back to cache only mode here for example.
> + ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap,
> + &cs35l41->hw_cfg);
> + if (ret)
> + return ret;
>
> - dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n");
> enable_irq(cs35l41->irq);
We can also leave the IRQ disabled now which might be fun if it's
shared. Not sure there's a good solution to that though, and we're in
trouble if resume fails anyway.
> - SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume)
> + .suspend = pm_sleep_ptr(cs35l41_sys_suspend),
> + .resume = pm_sleep_ptr(cs35l41_sys_resume),
> + .freeze = pm_sleep_ptr(cs35l41_sys_suspend),
> + .thaw = pm_sleep_ptr(cs35l41_sys_thaw),
This undoes far less than freeze does...
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: cs35l41: Restore register state after system sleep
2026-06-15 14:54 [PATCH] ASoC: cs35l41: Restore register state after system sleep Nícolas F. R. A. Prado
2026-06-15 17:42 ` Mark Brown
@ 2026-06-16 16:31 ` Stefan Binding
2026-06-17 17:40 ` Rhodes, David
1 sibling, 1 reply; 6+ messages in thread
From: Stefan Binding @ 2026-06-16 16:31 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, David Rhodes, Richard Fitzgerald,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, patches, linux-kernel
Hi,
I have some concerns about this patch.
This driver is used for more than just the Steam Deck, so we would need to ensure that this patch doesn't break those systems.
There are some potential complexities around cs35l41 with respect to Boost and DSP enablement that need careful thought when supporting system sleep.
The HDA equivalent driver for cs35l41 does have support for system sleep, but this driver works very differently.
I recommend reaching out to David Rhodes <david.rhodes@cirrus.com> for more information on the ASoC driver for CS35L41.
Please also cc patches@opensource.cirrus.com.
Thanks,
Stefan
On 15/06/2026 15:54, Nícolas F. R. A. Prado wrote:
> Currently, on the Steam Deck LCD when the system goes into hibernation
> and resumes back, the speakers are silent when playing with:
>
> aplay -D plughw:acp5x,1 /usr/share/sounds/alsa/Front_Left.wav
>
> A crude workaround was to, after resuming the system, bypassing the
> regmap cache on the cs35l41 devices, before playing:
>
> echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:00/cache_bypass
> echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:01/cache_bypass
>
> That indicated that the hardware registers had gone out of sync with
> the regmap cache due to the power down in system hibernation.
>
> Fix the issue by, before system sleep, marking the regcache as cache
> only, and after system sleep, resetting the hardware and restoring the
> hardware registers from the regcache.
>
> This gets the sound working on the Steam Deck LCD after resume from S4.
>
> While the issue was only observed on S4 on this platform, the callbacks
> for suspend/resume are also set in the same way to account for platforms
> that might power down the chip on S3 as well.
>
> Note that this change does not take care of restoring the DSP state,
> since the affected platform does not use the DSP and it couldn't be
> tested, so it is only shut down on resume so it can be reinitialized in
> a future DSP preload event.
>
> Assisted-by: Copilot:claude-sonnet-4.6
> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
> ---
> sound/soc/codecs/cs35l41.c | 127 ++++++++++++++++++++++++++++++++++++---------
> 1 file changed, 102 insertions(+), 25 deletions(-)
>
> diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
> index b2a076706c79..231341a7eb44 100644
> --- a/sound/soc/codecs/cs35l41.c
> +++ b/sound/soc/codecs/cs35l41.c
> @@ -1199,9 +1199,41 @@ static int cs35l41_get_system_name(struct cs35l41_private *cs35l41)
> return ret;
> }
>
> +static int cs35l41_boot(struct cs35l41_private *cs35l41)
> +{
> + u32 int_status;
> + int ret;
> +
> + if (cs35l41->reset_gpio) {
> + /* satisfy minimum reset pulse width spec */
> + gpiod_set_value_cansleep(cs35l41->reset_gpio, 0);
> + usleep_range(2000, 2100);
> + gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
> + }
> +
> + usleep_range(2000, 2100);
> +
> + ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4,
> + int_status, int_status & CS35L41_OTP_BOOT_DONE,
> + 1000, 100000);
> + if (ret) {
> + dev_err_probe(cs35l41->dev, ret,
> + "Failed waiting for OTP_BOOT_DONE\n");
> + return ret;
> + }
> +
> + regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status);
> + if (int_status & CS35L41_OTP_BOOT_ERR) {
> + dev_err(cs35l41->dev, "OTP Boot error\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *hw_cfg)
> {
> - u32 regid, reg_revid, i, mtl_revid, int_status, chipid_match;
> + u32 regid, reg_revid, i, mtl_revid, chipid_match;
> int irq_pol = 0;
> int ret;
>
> @@ -1242,29 +1274,10 @@ int cs35l41_probe(struct cs35l41_private *cs35l41, const struct cs35l41_hw_cfg *
> goto err;
> }
> }
> - if (cs35l41->reset_gpio) {
> - /* satisfy minimum reset pulse width spec */
> - usleep_range(2000, 2100);
> - gpiod_set_value_cansleep(cs35l41->reset_gpio, 1);
> - }
> -
> - usleep_range(2000, 2100);
> -
> - ret = regmap_read_poll_timeout(cs35l41->regmap, CS35L41_IRQ1_STATUS4,
> - int_status, int_status & CS35L41_OTP_BOOT_DONE,
> - 1000, 100000);
> - if (ret) {
> - dev_err_probe(cs35l41->dev, ret,
> - "Failed waiting for OTP_BOOT_DONE\n");
> - goto err;
> - }
>
> - regmap_read(cs35l41->regmap, CS35L41_IRQ1_STATUS3, &int_status);
> - if (int_status & CS35L41_OTP_BOOT_ERR) {
> - dev_err(cs35l41->dev, "OTP Boot error\n");
> - ret = -EINVAL;
> + ret = cs35l41_boot(cs35l41);
> + if (ret)
> goto err;
> - }
>
> ret = regmap_read(cs35l41->regmap, CS35L41_DEVID, ®id);
> if (ret < 0) {
> @@ -1450,7 +1463,20 @@ static int cs35l41_sys_suspend(struct device *dev)
> {
> struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
>
> - dev_dbg(cs35l41->dev, "System suspend, disabling IRQ\n");
> + dev_dbg(cs35l41->dev, "System suspend, saving state\n");
> + disable_irq(cs35l41->irq);
> +
> + regcache_cache_only(cs35l41->regmap, true);
> + regcache_mark_dirty(cs35l41->regmap);
> +
> + return 0;
> +}
> +
> +static int cs35l41_sys_poweroff(struct device *dev)
> +{
> + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
> +
> + dev_dbg(cs35l41->dev, "System poweroff, disabling IRQ\n");
> disable_irq(cs35l41->irq);
>
> return 0;
> @@ -1476,20 +1502,71 @@ static int cs35l41_sys_resume_noirq(struct device *dev)
> return 0;
> }
>
> +static int cs35l41_sys_thaw(struct device *dev)
> +{
> + struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
> +
> + dev_dbg(cs35l41->dev, "System thaw, reenabling IRQ\n");
> + enable_irq(cs35l41->irq);
> +
> + return 0;
> +}
> +
> static int cs35l41_sys_resume(struct device *dev)
> {
> struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
> + int ret;
> +
> + dev_dbg(cs35l41->dev, "System resume, restoring state\n");
> +
> + regcache_cache_only(cs35l41->regmap, false);
> +
> + ret = cs35l41_boot(cs35l41);
> + if (ret)
> + return ret;
> +
> + cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap);
> + ret = regcache_sync(cs35l41->regmap);
> + cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap);
> + if (ret) {
> + dev_err(cs35l41->dev, "Failed to restore register cache: %d\n", ret);
> + return ret;
> + }
> +
> + ret = cs35l41_init_boost(cs35l41->dev, cs35l41->regmap,
> + &cs35l41->hw_cfg);
> + if (ret)
> + return ret;
>
> - dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n");
> enable_irq(cs35l41->irq);
>
> + if (!cs35l41->dsp.cs_dsp.running)
> + return 0;
> +
> + /*
> + * DSP firmware is gone after a full power cycle. Reset the DSP
> + * software state so that firmware is reloaded on next DSP preload event
> + */
> + wm_adsp_stop(&cs35l41->dsp);
> +
> + if (!cs35l41->dsp.cs_dsp.booted)
> + return 0;
> +
> + wm_adsp_power_down(&cs35l41->dsp);
> +
> return 0;
> }
>
> EXPORT_GPL_DEV_PM_OPS(cs35l41_pm_ops) = {
> RUNTIME_PM_OPS(cs35l41_runtime_suspend, cs35l41_runtime_resume, NULL)
>
> - SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend, cs35l41_sys_resume)
> + .suspend = pm_sleep_ptr(cs35l41_sys_suspend),
> + .resume = pm_sleep_ptr(cs35l41_sys_resume),
> + .freeze = pm_sleep_ptr(cs35l41_sys_suspend),
> + .thaw = pm_sleep_ptr(cs35l41_sys_thaw),
> + .poweroff = pm_sleep_ptr(cs35l41_sys_poweroff),
> + .restore = pm_sleep_ptr(cs35l41_sys_resume),
> +
> NOIRQ_SYSTEM_SLEEP_PM_OPS(cs35l41_sys_suspend_noirq, cs35l41_sys_resume_noirq)
> };
>
>
> ---
> base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b
> change-id: 20260615-cs35l41-s4-support-aac193d7ccba
>
> Best regards,
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: cs35l41: Restore register state after system sleep
2026-06-16 16:31 ` Stefan Binding
@ 2026-06-17 17:40 ` Rhodes, David
2026-07-21 20:08 ` Nícolas F. R. A. Prado
0 siblings, 1 reply; 6+ messages in thread
From: Rhodes, David @ 2026-06-17 17:40 UTC (permalink / raw)
To: Stefan Binding, Nícolas F. R. A. Prado, David Rhodes,
Richard Fitzgerald, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
Cc: kernel, linux-sound, patches, linux-kernel
On 6/16/26 11:31 AM, Stefan Binding wrote:
> Hi,
>
> I have some concerns about this patch.
>
> This driver is used for more than just the Steam Deck, so we would need to ensure that this patch doesn't break those systems.
> There are some potential complexities around cs35l41 with respect to Boost and DSP enablement that need careful thought when supporting system sleep.
>
> The HDA equivalent driver for cs35l41 does have support for system sleep, but this driver works very differently.
>
> I recommend reaching out to David Rhodes <david.rhodes@cirrus.com> for more information on the ASoC driver for CS35L41.
> Please also cc patches@opensource.cirrus.com.
>
> Thanks,
>
> Stefan
>
> On 15/06/2026 15:54, Nícolas F. R. A. Prado wrote:
>> Currently, on the Steam Deck LCD when the system goes into hibernation
>> and resumes back, the speakers are silent when playing with:
>>
>> aplay -D plughw:acp5x,1 /usr/share/sounds/alsa/Front_Left.wav
>>
>> A crude workaround was to, after resuming the system, bypassing the
>> regmap cache on the cs35l41 devices, before playing:
>>
>> echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:00/cache_bypass
>> echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:01/cache_bypass
>>
>> That indicated that the hardware registers had gone out of sync with
>> the regmap cache due to the power down in system hibernation.
>>
>> Fix the issue by, before system sleep, marking the regcache as cache
>> only, and after system sleep, resetting the hardware and restoring the
>> hardware registers from the regcache.
>>
>> This gets the sound working on the Steam Deck LCD after resume from S4.
>>
>> While the issue was only observed on S4 on this platform, the callbacks
>> for suspend/resume are also set in the same way to account for platforms
>> that might power down the chip on S3 as well.
>>
>> Note that this change does not take care of restoring the DSP state,
>> since the affected platform does not use the DSP and it couldn't be
>> tested, so it is only shut down on resume so it can be reinitialized in
>> a future DSP preload event.
>>
>> Assisted-by: Copilot:claude-sonnet-4.6
>> Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Hi Nicholas,
I share Stefan's concerns about this patch affecting other devices. I
also wonder if there is a less crude workaround for your system's behavior.
The existing driver uses runtime_suspend/runtime_resume to enter and
exit a low power 'hibernation' mode
(wm_adsp_hibernate/cs35l41_enter_hibernate). In this mode the part will
lose some configuration so the regmap is put into cache_only for the
duration of the sleep and synced when waking up.
Are you sure the device is not just missing a runtime_resume after the
system is in S4? This whole sequence of sys operations should only be
needed if the amp is completely losing power.
Thanks,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ASoC: cs35l41: Restore register state after system sleep
2026-06-17 17:40 ` Rhodes, David
@ 2026-07-21 20:08 ` Nícolas F. R. A. Prado
2026-07-23 17:27 ` Rhodes, David
0 siblings, 1 reply; 6+ messages in thread
From: Nícolas F. R. A. Prado @ 2026-07-21 20:08 UTC (permalink / raw)
To: Rhodes, David, Stefan Binding, David Rhodes, Richard Fitzgerald,
Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: kernel, linux-sound, patches, linux-kernel
On Wed, 2026-06-17 at 12:40 -0500, Rhodes, David wrote:
> On 6/16/26 11:31 AM, Stefan Binding wrote:
> > Hi,
> >
> > I have some concerns about this patch.
> >
> > This driver is used for more than just the Steam Deck, so we would
> > need to ensure that this patch doesn't break those systems.
> > There are some potential complexities around cs35l41 with respect
> > to Boost and DSP enablement that need careful thought when
> > supporting system sleep.
> >
> > The HDA equivalent driver for cs35l41 does have support for system
> > sleep, but this driver works very differently.
> >
> > I recommend reaching out to David Rhodes <david.rhodes@cirrus.com>
> > for more information on the ASoC driver for CS35L41.
> > Please also cc patches@opensource.cirrus.com.
> >
> > Thanks,
> >
> > Stefan
> >
> > On 15/06/2026 15:54, Nícolas F. R. A. Prado wrote:
> > > Currently, on the Steam Deck LCD when the system goes into
> > > hibernation
> > > and resumes back, the speakers are silent when playing with:
> > >
> > > aplay -D plughw:acp5x,1 /usr/share/sounds/alsa/Front_Left.wav
> > >
> > > A crude workaround was to, after resuming the system, bypassing
> > > the
> > > regmap cache on the cs35l41 devices, before playing:
> > >
> > > echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:00/cache_bypass
> > > echo 1 > /sys/kernel/debug/regmap/spi-VLV1776\:01/cache_bypass
> > >
> > > That indicated that the hardware registers had gone out of sync
> > > with
> > > the regmap cache due to the power down in system hibernation.
> > >
> > > Fix the issue by, before system sleep, marking the regcache as
> > > cache
> > > only, and after system sleep, resetting the hardware and
> > > restoring the
> > > hardware registers from the regcache.
> > >
> > > This gets the sound working on the Steam Deck LCD after resume
> > > from S4.
> > >
> > > While the issue was only observed on S4 on this platform, the
> > > callbacks
> > > for suspend/resume are also set in the same way to account for
> > > platforms
> > > that might power down the chip on S3 as well.
> > >
> > > Note that this change does not take care of restoring the DSP
> > > state,
> > > since the affected platform does not use the DSP and it couldn't
> > > be
> > > tested, so it is only shut down on resume so it can be
> > > reinitialized in
> > > a future DSP preload event.
> > >
> > > Assisted-by: Copilot:claude-sonnet-4.6
> > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
>
> Hi Nicholas,
>
> I share Stefan's concerns about this patch affecting other devices. I
> also wonder if there is a less crude workaround for your system's
> behavior.
>
> The existing driver uses runtime_suspend/runtime_resume to enter and
> exit a low power 'hibernation' mode
> (wm_adsp_hibernate/cs35l41_enter_hibernate). In this mode the part
> will
> lose some configuration so the regmap is put into cache_only for the
> duration of the sleep and synced when waking up.
>
> Are you sure the device is not just missing a runtime_resume after
> the
> system is in S4? This whole sequence of sys operations should only be
> needed if the amp is completely losing power.
Hi David, Stefan,
The current PM runtime logic is to runtime-resume the device before
carrying out the system PM callbacks, and only allow runtime-suspend
after the system has resumed back. So during S4 the device is runtime-
resumed.
Also, since on my system the DSP is not used, the early return in the
runtime suspend/resume `if (!cs35l41->dsp.preloaded || !cs35l41-
>dsp.cs_dsp.running)` means that the runtime suspend/resume callbacks
are no-ops on my system.
Nonetheless, I tried simply marking the regcache dirty and syncing it
upon system resume, mimicking the runtime suspend/resume, as follows:
diff --git a/sound/soc/codecs/cs35l41.c b/sound/soc/codecs/cs35l41.c
index 5001a546a3e7..5933d61753d8 100644
--- a/sound/soc/codecs/cs35l41.c
+++ b/sound/soc/codecs/cs35l41.c
@@ -1445,6 +1445,9 @@ static int cs35l41_sys_suspend(struct device
*dev)
{
struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
+ regcache_cache_only(cs35l41->regmap, true);
+ regcache_mark_dirty(cs35l41->regmap);
+
dev_dbg(cs35l41->dev, "System suspend, disabling IRQ\n");
disable_irq(cs35l41->irq);
@@ -1474,10 +1477,23 @@ static int cs35l41_sys_resume_noirq(struct
device *dev)
static int cs35l41_sys_resume(struct device *dev)
{
struct cs35l41_private *cs35l41 = dev_get_drvdata(dev);
+ int ret;
dev_dbg(cs35l41->dev, "System resume, reenabling IRQ\n");
enable_irq(cs35l41->irq);
+ regcache_cache_only(cs35l41->regmap, false);
+
+ /* Test key needs to be unlocked to allow the OTP settings to
re-apply */
+ cs35l41_test_key_unlock(cs35l41->dev, cs35l41->regmap);
+ ret = regcache_sync(cs35l41->regmap);
+ cs35l41_test_key_lock(cs35l41->dev, cs35l41->regmap);
+ if (ret) {
+ dev_err(cs35l41->dev, "Failed to restore register
cache: %d\n", ret);
+ return ret;
+ }
+ cs35l41_init_boost(cs35l41->dev, cs35l41->regmap, &cs35l41-
>hw_cfg);
+
return 0;
}
With just this change, the first playback after resume from S4 works,
but I see in dmesg:
[ 133.019606] cs35l41 spi-VLV1776:00: Enable(0) failed: -110
[ 133.019896] cs35l41 spi-VLV1776:00: ASoC: POST_PMD: Left Main AMP
event failed: -110
[ 133.124515] cs35l41 spi-VLV1776:01: Enable(0) failed: -110
[ 133.124831] cs35l41 spi-VLV1776:01: ASoC: POST_PMD: Right Main AMP
event failed: -110
Which points to CS35L41_IRQ1_STATUS1 reads timing out. Subsequent
attempts to playback sound are completely silent and the same error is
printed.
Given that my patch that fully reinitializes the hardware works, while
this doesn't, I'm inclined to believe that the chip loses power during
S4 indeed, at which point just restoring the register state is no
longer enough. But perhaps you could shed more light into this since
you're much more familiar with this hardware than I am.
Thanks,
Nícolas
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] ASoC: cs35l41: Restore register state after system sleep
2026-07-21 20:08 ` Nícolas F. R. A. Prado
@ 2026-07-23 17:27 ` Rhodes, David
0 siblings, 0 replies; 6+ messages in thread
From: Rhodes, David @ 2026-07-23 17:27 UTC (permalink / raw)
To: Nícolas F. R. A. Prado, Stefan Binding, David Rhodes,
Richard Fitzgerald, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, pgriffais
Cc: kernel, linux-sound, patches, linux-kernel
On 7/21/26 3:08 PM, Nícolas F. R. A. Prado wrote:
> Also, since on my system the DSP is not used, the early return in the
> runtime suspend/resume `if (!cs35l41->dsp.preloaded || !cs35l41-
>> dsp.cs_dsp.running)` means that the runtime suspend/resume callbacks
> are no-ops on my system.
>
The Steam Deck LCD should be using the DSP firmware. Valve distributed
this initially but it was added to linux-firmware early last year.
See 'cirrus/cs35l41-dsp1-spk-prot-vlv1776.bin'.
> Nonetheless, I tried simply marking the regcache dirty and syncing it
> upon system resume, mimicking the runtime suspend/resume, as follows:
>
>
> Given that my patch that fully reinitializes the hardware works, while
> this doesn't, I'm inclined to believe that the chip loses power during
> S4 indeed, at which point just restoring the register state is no
> longer enough. But perhaps you could shed more light into this since
> you're much more familiar with this hardware than I am.
>
> Thanks,
> Nícolas
Thank you for looking into this. I agree with your conclusion that the
chip is fully losing power. With that in mind, your implementation makes
sense.
Given the above comments about disabling the DSP on your system, I have
to ask: Are you working on a 'standard' Steam Deck, or have you made
other changes to the power management that aren't present on a typical
device? Has this always been an issue affecting the Steam Deck LCD?
The Steam Deck is the primary use for this ASoC driver. Valve is
regularly updating the kernel in their OS releases, so I don't want to
make any changes that affect the out-of-box behavior. Of course if you
are in touch with Valve and submitting this on their behalf, no worries
and I'd love to see an Ack from someone on their side.
Thanks,
David
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-07-23 17:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-15 14:54 [PATCH] ASoC: cs35l41: Restore register state after system sleep Nícolas F. R. A. Prado
2026-06-15 17:42 ` Mark Brown
2026-06-16 16:31 ` Stefan Binding
2026-06-17 17:40 ` Rhodes, David
2026-07-21 20:08 ` Nícolas F. R. A. Prado
2026-07-23 17:27 ` Rhodes, David
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®