ASoC: codecs: add suspend and resume for ES8316
authorZhu Ning <zhuning0077@gmail.com>
Thu, 25 Aug 2022 01:49:52 +0000 (09:49 +0800)
committerMark Brown <broonie@kernel.org>
Thu, 25 Aug 2022 11:29:32 +0000 (12:29 +0100)
The registers may be lost after suspend due to powerdown.
regcache_sync solves this issue.

Signed-off-by: Zhu Ning <zhuning@everest-semi.com>
Link: https://lore.kernel.org/r/20220825014952.1038508-1-zhuning0077@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/es8316.c

index de7185f..8643014 100644 (file)
@@ -767,9 +767,31 @@ static void es8316_remove(struct snd_soc_component *component)
        clk_disable_unprepare(es8316->mclk);
 }
 
+static int es8316_resume(struct snd_soc_component *component)
+{
+       struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
+
+       regcache_cache_only(es8316->regmap, false);
+       regcache_sync(es8316->regmap);
+
+       return 0;
+}
+
+static int es8316_suspend(struct snd_soc_component *component)
+{
+       struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
+
+       regcache_cache_only(es8316->regmap, true);
+       regcache_mark_dirty(es8316->regmap);
+
+       return 0;
+}
+
 static const struct snd_soc_component_driver soc_component_dev_es8316 = {
        .probe                  = es8316_probe,
        .remove                 = es8316_remove,
+       .resume                 = es8316_resume,
+       .suspend                = es8316_suspend,
        .set_jack               = es8316_set_jack,
        .controls               = es8316_snd_controls,
        .num_controls           = ARRAY_SIZE(es8316_snd_controls),