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 v2 12/16] ASoC: codecs: rx-macro: add runtime pm support
Date: Thu, 24 Feb 2022 11:17:14 +0000	[thread overview]
Message-ID: <20220224111718.6264-13-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20220224111718.6264-1-srinivas.kandagatla@linaro.org>

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

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index a2f49a21678b..67bec5befc02 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -5,6 +5,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <sound/soc.h>
 #include <sound/pcm.h>
@@ -3605,6 +3606,13 @@ static int rx_macro_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_clkout;
 
+
+	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 0;
 
 err_clkout:
@@ -3641,11 +3649,65 @@ static const struct of_device_id rx_macro_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rx_macro_dt_match);
 
+static int __maybe_unused rx_macro_runtime_suspend(struct device *dev)
+{
+	struct rx_macro *rx = dev_get_drvdata(dev);
+
+	regcache_cache_only(rx->regmap, true);
+	regcache_mark_dirty(rx->regmap);
+
+	clk_disable_unprepare(rx->mclk);
+	clk_disable_unprepare(rx->npl);
+	clk_disable_unprepare(rx->fsgen);
+
+	return 0;
+}
+
+static int __maybe_unused rx_macro_runtime_resume(struct device *dev)
+{
+	struct rx_macro *rx = dev_get_drvdata(dev);
+	int ret;
+
+	ret = clk_prepare_enable(rx->mclk);
+	if (ret) {
+		dev_err(dev, "unable to prepare mclk\n");
+		return ret;
+	}
+
+	ret = clk_prepare_enable(rx->npl);
+	if (ret) {
+		dev_err(dev, "unable to prepare mclkx2\n");
+		goto err_npl;
+	}
+
+	ret = clk_prepare_enable(rx->fsgen);
+	if (ret) {
+		dev_err(dev, "unable to prepare fsgen\n");
+		goto err_fsgen;
+	}
+	regcache_cache_only(rx->regmap, false);
+	regcache_sync(rx->regmap);
+	rx->reset_swr = true;
+
+	return 0;
+err_fsgen:
+	clk_disable_unprepare(rx->npl);
+err_npl:
+	clk_disable_unprepare(rx->mclk);
+
+	return ret;
+}
+
+static const struct dev_pm_ops rx_macro_pm_ops = {
+	SET_RUNTIME_PM_OPS(rx_macro_runtime_suspend, rx_macro_runtime_resume, NULL)
+};
+
 static struct platform_driver rx_macro_driver = {
 	.driver = {
 		.name = "rx_macro",
 		.of_match_table = rx_macro_dt_match,
 		.suppress_bind_attrs = true,
+		.pm = &rx_macro_pm_ops,
 	},
 	.probe = rx_macro_probe,
 	.remove = rx_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 v2 12/16] ASoC: codecs: rx-macro: add runtime pm support
Date: Thu, 24 Feb 2022 11:17:14 +0000	[thread overview]
Message-ID: <20220224111718.6264-13-srinivas.kandagatla@linaro.org> (raw)
In-Reply-To: <20220224111718.6264-1-srinivas.kandagatla@linaro.org>

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

diff --git a/sound/soc/codecs/lpass-rx-macro.c b/sound/soc/codecs/lpass-rx-macro.c
index a2f49a21678b..67bec5befc02 100644
--- a/sound/soc/codecs/lpass-rx-macro.c
+++ b/sound/soc/codecs/lpass-rx-macro.c
@@ -5,6 +5,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/clk.h>
 #include <sound/soc.h>
 #include <sound/pcm.h>
@@ -3605,6 +3606,13 @@ static int rx_macro_probe(struct platform_device *pdev)
 	if (ret)
 		goto err_clkout;
 
+
+	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 0;
 
 err_clkout:
@@ -3641,11 +3649,65 @@ static const struct of_device_id rx_macro_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, rx_macro_dt_match);
 
+static int __maybe_unused rx_macro_runtime_suspend(struct device *dev)
+{
+	struct rx_macro *rx = dev_get_drvdata(dev);
+
+	regcache_cache_only(rx->regmap, true);
+	regcache_mark_dirty(rx->regmap);
+
+	clk_disable_unprepare(rx->mclk);
+	clk_disable_unprepare(rx->npl);
+	clk_disable_unprepare(rx->fsgen);
+
+	return 0;
+}
+
+static int __maybe_unused rx_macro_runtime_resume(struct device *dev)
+{
+	struct rx_macro *rx = dev_get_drvdata(dev);
+	int ret;
+
+	ret = clk_prepare_enable(rx->mclk);
+	if (ret) {
+		dev_err(dev, "unable to prepare mclk\n");
+		return ret;
+	}
+
+	ret = clk_prepare_enable(rx->npl);
+	if (ret) {
+		dev_err(dev, "unable to prepare mclkx2\n");
+		goto err_npl;
+	}
+
+	ret = clk_prepare_enable(rx->fsgen);
+	if (ret) {
+		dev_err(dev, "unable to prepare fsgen\n");
+		goto err_fsgen;
+	}
+	regcache_cache_only(rx->regmap, false);
+	regcache_sync(rx->regmap);
+	rx->reset_swr = true;
+
+	return 0;
+err_fsgen:
+	clk_disable_unprepare(rx->npl);
+err_npl:
+	clk_disable_unprepare(rx->mclk);
+
+	return ret;
+}
+
+static const struct dev_pm_ops rx_macro_pm_ops = {
+	SET_RUNTIME_PM_OPS(rx_macro_runtime_suspend, rx_macro_runtime_resume, NULL)
+};
+
 static struct platform_driver rx_macro_driver = {
 	.driver = {
 		.name = "rx_macro",
 		.of_match_table = rx_macro_dt_match,
 		.suppress_bind_attrs = true,
+		.pm = &rx_macro_pm_ops,
 	},
 	.probe = rx_macro_probe,
 	.remove = rx_macro_remove,
-- 
2.21.0


  parent reply	other threads:[~2022-02-24 11:18 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24 11:17 [PATCH v2 00/16] ASoC: codecs: add pm runtime support for Qualcomm codecs Srinivas Kandagatla
2022-02-24 11:17 ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 01/16] ASoC: codecs: va-macro: move to individual clks from bulk Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 02/16] ASoC: codecs: rx-macro: move clk provider to managed variants Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 03/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 04/16] ASoC: codecs: rx-macro: move to individual clks from bulk Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 05/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 06/16] ASoC: codecs: wsa-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 07/16] ASoC: codecs: wsa-macro: setup soundwire clks correctly Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 08/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 09/16] ASoC: codecs: rx-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 10/16] ASoC: codecs: va-macro: add runtime pm support Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 11/16] ASoC: codecs: wsa-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` Srinivas Kandagatla [this message]
2022-02-24 11:17   ` [PATCH v2 12/16] ASoC: codecs: rx-macro: " Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 13/16] ASoC: codecs: tx-macro: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 14/16] ASoC: codecs: wsa881x: " Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 15:29   ` Pierre-Louis Bossart
2022-02-24 15:29     ` Pierre-Louis Bossart
2022-02-24 16:13     ` Srinivas Kandagatla
2022-02-24 16:13       ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 15/16] ASoC: codecs: wcd938x: add simple clk stop support Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-24 11:17 ` [PATCH v2 16/16] ASoC: codecs: wcd-mbhc: add runtime pm support Srinivas Kandagatla
2022-02-24 11:17   ` Srinivas Kandagatla
2022-02-25 17:35 ` (subset) [PATCH v2 00/16] ASoC: codecs: add pm runtime support for Qualcomm codecs Mark Brown
2022-02-25 17:35   ` Mark Brown

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=20220224111718.6264-13-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.