All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: broonie@kernel.org
Cc: lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
	pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	quic_srivasam@quicinc.com,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Subject: [PATCH 04/10] ASoC: codecs: tx-macro: add runtime pm support
Date: Mon, 21 Feb 2022 13:10:31 +0000	[thread overview]
Message-ID: <20220221131037.8809-5-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20220221131037.8809-1-srinivas.kandagatla@linaro.org>

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 41 +++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index 7347d79a6329..1c0f0d27ed42 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -6,6 +6,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
@@ -1844,6 +1845,13 @@ static int tx_macro_probe(struct platform_device *pdev)
 					      ARRAY_SIZE(tx_macro_dai));
 	if (ret)
 		goto err;
+
+	pm_runtime_set_autosuspend_delay(dev, 3000);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
 	return ret;
 err:
 	clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks);
@@ -1862,6 +1870,38 @@ static int tx_macro_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused tx_macro_runtime_suspend(struct device *dev)
+{
+	struct tx_macro *tx = dev_get_drvdata(dev);
+
+	regcache_cache_only(tx->regmap, true);
+	regcache_mark_dirty(tx->regmap);
+
+	clk_disable_unprepare(tx->clks[2].clk);
+	clk_disable_unprepare(tx->clks[3].clk);
+	clk_disable_unprepare(tx->clks[4].clk);
+
+	return 0;
+}
+
+static int __maybe_unused tx_macro_runtime_resume(struct device *dev)
+{
+	struct tx_macro *tx = dev_get_drvdata(dev);
+
+	clk_prepare_enable(tx->clks[2].clk);
+	clk_prepare_enable(tx->clks[3].clk);
+	clk_prepare_enable(tx->clks[4].clk);
+	regcache_cache_only(tx->regmap, false);
+	regcache_sync(tx->regmap);
+	tx->reset_swr = true;
+
+	return 0;
+}
+
+static const struct dev_pm_ops tx_macro_pm_ops = {
+	SET_RUNTIME_PM_OPS(tx_macro_runtime_suspend, tx_macro_runtime_resume, NULL)
+};
+
 static const struct of_device_id tx_macro_dt_match[] = {
 	{ .compatible = "qcom,sc7280-lpass-tx-macro" },
 	{ .compatible = "qcom,sm8250-lpass-tx-macro" },
@@ -1873,6 +1913,7 @@ static struct platform_driver tx_macro_driver = {
 		.name = "tx_macro",
 		.of_match_table = tx_macro_dt_match,
 		.suppress_bind_attrs = true,
+		.pm = &tx_macro_pm_ops,
 	},
 	.probe = tx_macro_probe,
 	.remove = tx_macro_remove,
-- 
2.21.0


WARNING: multiple messages have this Message-ID (diff)
From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: broonie@kernel.org
Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com,
	linux-kernel@vger.kernel.org,
	pierre-louis.bossart@linux.intel.com, tiwai@suse.com,
	Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	quic_srivasam@quicinc.com
Subject: [PATCH 04/10] ASoC: codecs: tx-macro: add runtime pm support
Date: Mon, 21 Feb 2022 13:10:31 +0000	[thread overview]
Message-ID: <20220221131037.8809-5-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20220221131037.8809-1-srinivas.kandagatla@linaro.org>

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 sound/soc/codecs/lpass-tx-macro.c | 41 +++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/soc/codecs/lpass-tx-macro.c b/sound/soc/codecs/lpass-tx-macro.c
index 7347d79a6329..1c0f0d27ed42 100644
--- a/sound/soc/codecs/lpass-tx-macro.c
+++ b/sound/soc/codecs/lpass-tx-macro.c
@@ -6,6 +6,7 @@
 #include <linux/clk.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <sound/soc.h>
 #include <sound/soc-dapm.h>
@@ -1844,6 +1845,13 @@ static int tx_macro_probe(struct platform_device *pdev)
 					      ARRAY_SIZE(tx_macro_dai));
 	if (ret)
 		goto err;
+
+	pm_runtime_set_autosuspend_delay(dev, 3000);
+	pm_runtime_use_autosuspend(dev);
+	pm_runtime_mark_last_busy(dev);
+	pm_runtime_set_active(dev);
+	pm_runtime_enable(dev);
+
 	return ret;
 err:
 	clk_bulk_disable_unprepare(TX_NUM_CLKS_MAX, tx->clks);
@@ -1862,6 +1870,38 @@ static int tx_macro_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int __maybe_unused tx_macro_runtime_suspend(struct device *dev)
+{
+	struct tx_macro *tx = dev_get_drvdata(dev);
+
+	regcache_cache_only(tx->regmap, true);
+	regcache_mark_dirty(tx->regmap);
+
+	clk_disable_unprepare(tx->clks[2].clk);
+	clk_disable_unprepare(tx->clks[3].clk);
+	clk_disable_unprepare(tx->clks[4].clk);
+
+	return 0;
+}
+
+static int __maybe_unused tx_macro_runtime_resume(struct device *dev)
+{
+	struct tx_macro *tx = dev_get_drvdata(dev);
+
+	clk_prepare_enable(tx->clks[2].clk);
+	clk_prepare_enable(tx->clks[3].clk);
+	clk_prepare_enable(tx->clks[4].clk);
+	regcache_cache_only(tx->regmap, false);
+	regcache_sync(tx->regmap);
+	tx->reset_swr = true;
+
+	return 0;
+}
+
+static const struct dev_pm_ops tx_macro_pm_ops = {
+	SET_RUNTIME_PM_OPS(tx_macro_runtime_suspend, tx_macro_runtime_resume, NULL)
+};
+
 static const struct of_device_id tx_macro_dt_match[] = {
 	{ .compatible = "qcom,sc7280-lpass-tx-macro" },
 	{ .compatible = "qcom,sm8250-lpass-tx-macro" },
@@ -1873,6 +1913,7 @@ static struct platform_driver tx_macro_driver = {
 		.name = "tx_macro",
 		.of_match_table = tx_macro_dt_match,
 		.suppress_bind_attrs = true,
+		.pm = &tx_macro_pm_ops,
 	},
 	.probe = tx_macro_probe,
 	.remove = tx_macro_remove,
-- 
2.21.0


  parent reply	other threads:[~2022-02-21 13:11 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-21 13:10 [PATCH 00/10] ASoC: codec: add pm runtime support for Qualcomm codecs Srinivas Kandagatla
2022-02-21 13:10 ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 01/10] ASoC: codecs: va-macro: add runtime pm support Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 15:24   ` Mark Brown
2022-02-21 15:24     ` Mark Brown
2022-02-21 15:27     ` Srinivas Kandagatla
2022-02-21 15:27       ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 02/10] ASoC: codecs: wsa-macro: " Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 03/10] ASoC: codecs: rx-macro: " Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 13:10 ` Srinivas Kandagatla [this message]
2022-02-21 13:10   ` [PATCH 04/10] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 05/10] ASoC: codecs: wsa881x: " Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-22 19:53   ` Pierre-Louis Bossart
2022-02-22 19:53     ` Pierre-Louis Bossart
2022-02-21 13:10 ` [PATCH 06/10] ASoC: codecs: wcd938x: add simple clk stop support Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 07/10] ASoC: codecs: wcd-mbhc: add runtime pm support Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 08/10] ASoC: codecs: wsa-macro: setup soundwire clks correctly Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 09/10] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla
2022-02-21 15:38   ` Mark Brown
2022-02-21 15:38     ` Mark Brown
2022-02-21 16:11     ` Srinivas Kandagatla
2022-02-21 16:11       ` Srinivas Kandagatla
2022-02-21 16:48       ` Mark Brown
2022-02-21 16:48         ` Mark Brown
2022-02-22 12:08         ` Srinivas Kandagatla
2022-02-22 12:08           ` Srinivas Kandagatla
2022-02-21 13:10 ` [PATCH 10/10] ASoC: codecs: rx-macro: " Srinivas Kandagatla
2022-02-21 13:10   ` Srinivas Kandagatla

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220221131037.8809-5-srinivas.kandagatla@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=quic_srivasam@quicinc.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.