2022-09-07 14:24:27 +03:00
|
|
|
From 617e76cb4dd7bcdff475d6c4ca25f047cdc0e509 Mon Sep 17 00:00:00 2001
|
2022-09-07 12:55:51 +03:00
|
|
|
From: Vasily Vinogradov <v.vinogradov@aq.ru>
|
|
|
|
Date: Sat, 9 Jul 2022 13:51:27 +0300
|
2022-09-07 14:24:27 +03:00
|
|
|
Subject: [PATCH 400/424] ASoC: es8316: Add power management
|
2022-09-07 12:55:51 +03:00
|
|
|
|
|
|
|
---
|
|
|
|
sound/soc/codecs/es8316.c | 39 +++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 39 insertions(+)
|
|
|
|
|
|
|
|
diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c
|
2022-09-07 14:24:27 +03:00
|
|
|
index 5fb02635c..dfc967277 100644
|
2022-09-07 12:55:51 +03:00
|
|
|
--- a/sound/soc/codecs/es8316.c
|
|
|
|
+++ b/sound/soc/codecs/es8316.c
|
|
|
|
@@ -728,6 +728,8 @@ static int es8316_probe(struct snd_soc_component *component)
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ snd_soc_component_init_regmap(component, es8316->regmap);
|
|
|
|
+
|
|
|
|
/* Reset codec and enable current state machine */
|
|
|
|
snd_soc_component_write(component, ES8316_RESET, 0x3f);
|
|
|
|
usleep_range(5000, 5500);
|
|
|
|
@@ -754,9 +756,43 @@ static void es8316_remove(struct snd_soc_component *component)
|
|
|
|
{
|
|
|
|
struct es8316_priv *es8316 = snd_soc_component_get_drvdata(component);
|
|
|
|
|
|
|
|
+ snd_soc_component_exit_regmap(component);
|
|
|
|
+
|
|
|
|
clk_disable_unprepare(es8316->mclk);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_PM_SLEEP
|
|
|
|
+static int es8316_suspend(struct device *dev)
|
|
|
|
+{
|
|
|
|
+ struct es8316_priv *es8316 = dev_get_drvdata(dev);
|
|
|
|
+
|
|
|
|
+ dev_dbg(dev, "%s: Enter\n", __func__);
|
|
|
|
+
|
|
|
|
+ regcache_cache_only(es8316->regmap, true);
|
|
|
|
+ regcache_mark_dirty(es8316->regmap);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static int es8316_resume(struct device *dev)
|
|
|
|
+{
|
|
|
|
+ struct es8316_priv *es8316 = dev_get_drvdata(dev);
|
|
|
|
+
|
|
|
|
+ dev_dbg(dev, "%s: Enter\n", __func__);
|
|
|
|
+
|
|
|
|
+ regcache_cache_only(es8316->regmap, false);
|
|
|
|
+ regcache_sync(es8316->regmap);
|
|
|
|
+
|
|
|
|
+ es8316_irq(es8316->irq, es8316);
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+static const struct dev_pm_ops es8316_pm = {
|
|
|
|
+ SET_SYSTEM_SLEEP_PM_OPS(es8316_suspend, es8316_resume)
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static const struct snd_soc_component_driver soc_component_dev_es8316 = {
|
|
|
|
.probe = es8316_probe,
|
|
|
|
.remove = es8316_remove,
|
|
|
|
@@ -787,6 +823,8 @@ static const struct regmap_config es8316_regmap = {
|
|
|
|
.max_register = 0x53,
|
|
|
|
.volatile_table = &es8316_volatile_table,
|
|
|
|
.cache_type = REGCACHE_RBTREE,
|
|
|
|
+ .use_single_read = true,
|
|
|
|
+ .use_single_write = true,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int es8316_i2c_probe(struct i2c_client *i2c_client,
|
2022-09-07 14:24:27 +03:00
|
|
|
@@ -850,6 +888,7 @@ static struct i2c_driver es8316_i2c_driver = {
|
2022-09-07 12:55:51 +03:00
|
|
|
.name = "es8316",
|
|
|
|
.acpi_match_table = ACPI_PTR(es8316_acpi_match),
|
|
|
|
.of_match_table = of_match_ptr(es8316_of_match),
|
|
|
|
+ .pm = &es8316_pm,
|
|
|
|
},
|
|
|
|
.probe = es8316_i2c_probe,
|
|
|
|
.id_table = es8316_i2c_id,
|
|
|
|
--
|
|
|
|
2.35.2
|
|
|
|
|