ASoC: cs35l56: Always wait for firmware boot in runtime-resume
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Tue, 11 Apr 2023 15:25:26 +0000 (16:25 +0100)
committerMark Brown <broonie@kernel.org>
Wed, 12 Apr 2023 16:34:33 +0000 (17:34 +0100)
When we are resuming from a system suspend the CS35L56 has probably
been hard reset (usually a power-on reset). So we must wait for the
firmware to boot. On SoundWire we also need it to re-initialize before
we can read the registers to check the CS35L56 state.

The simplest way to handle this is for runtime-resume to always wait
for firmware boot. If the firmware is already booted the overhead is
only one register read.

The system-resume will have to runtime-resume the driver anyway before
attempting any register access. So this will automatically include the
wait for initialization on SoundWire.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20230411152528.329803-5-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/cs35l56.c

index 14cdbf5fd523c45e7306325804f2e6a67bd4c2ff..372b07fef827b8c78315ab329ca348ca01ccb235 100644 (file)
@@ -1108,10 +1108,8 @@ int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56)
        unsigned int val;
        int ret;
 
-       if (!cs35l56->can_hibernate) {
-               regcache_cache_only(cs35l56->regmap, false);
+       if (!cs35l56->can_hibernate)
                goto out_sync;
-       }
 
        if (!cs35l56->sdw_peripheral) {
                /*
@@ -1126,6 +1124,7 @@ int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56)
                             CS35L56_CONTROL_PORT_READY_US + 400);
        }
 
+out_sync:
        regcache_cache_only(cs35l56->regmap, false);
 
        ret = cs35l56_wait_for_firmware_boot(cs35l56);
@@ -1138,7 +1137,6 @@ int cs35l56_runtime_resume_common(struct cs35l56_private *cs35l56)
        if (ret)
                goto err;
 
-out_sync:
        /* BOOT_DONE will be 1 if the amp reset */
        regmap_read(cs35l56->regmap, CS35L56_IRQ1_EINT_4, &val);
        if (val & CS35L56_OTP_BOOT_DONE_MASK) {