mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vladimir Yakovlev <vovchkir@gmail.com>
To: Rajeev Kumar <rajeevkumar.linux@gmail.com>,
	Liam Girdwood <lgirdwood@gmail.com>
Cc: Vladimir Yakovlev <vovchkir@gmail.com>,
	Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>,
	Takashi Iwai <tiwai@suse.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Brady Norander <bradynorander@gmail.com>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: dwc: rework pm functions
Date: Mon,  2 Mar 2026 14:51:59 +0300	[thread overview]
Message-ID: <20260302115159.776850-1-vovchkir@gmail.com> (raw)

When using a power domain, we must completely disconnect the module and
turn off external signals when it is not in use and turn everything back
on at the right time.

When entering system_sleep, pm_runtime_force_suspend() is called, which
turns off the device if it was running. When exiting system_sleep, the
opposite occurs: pm_runtime_force_resume() is called.

Signed-off-by: Vladimir Yakovlev <vovchkir@gmail.com>
---
 sound/soc/dwc/dwc-i2s.c | 38 +++++++++++++++++++++++++++-----------
 1 file changed, 27 insertions(+), 11 deletions(-)

diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c
index 28001e9857d9..1d99d42400c3 100644
--- a/sound/soc/dwc/dwc-i2s.c
+++ b/sound/soc/dwc/dwc-i2s.c
@@ -481,8 +481,11 @@ static int dw_i2s_runtime_suspend(struct device *dev)
 {
 	struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev);
 
+	reset_control_assert(dw_dev->reset);
+
 	if (dw_dev->capability & DW_I2S_MASTER)
-		clk_disable(dw_dev->clk);
+		clk_disable_unprepare(dw_dev->clk);
+
 	return 0;
 }
 
@@ -492,10 +495,18 @@ static int dw_i2s_runtime_resume(struct device *dev)
 	int ret;
 
 	if (dw_dev->capability & DW_I2S_MASTER) {
-		ret = clk_enable(dw_dev->clk);
+		ret = clk_prepare_enable(dw_dev->clk);
 		if (ret)
 			return ret;
 	}
+
+	ret = reset_control_deassert(dw_dev->reset);
+	if (ret) {
+		if (dw_dev->capability & DW_I2S_MASTER)
+			clk_disable_unprepare(dw_dev->clk);
+		return ret;
+	}
+
 	return 0;
 }
 
@@ -504,22 +515,16 @@ static int dw_i2s_suspend(struct snd_soc_component *component)
 {
 	struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component);
 
-	if (dev->capability & DW_I2S_MASTER)
-		clk_disable(dev->clk);
-	return 0;
+	return pm_runtime_force_suspend(dev->dev);
 }
 
 static int dw_i2s_resume(struct snd_soc_component *component)
 {
 	struct dw_i2s_dev *dev = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dai *dai;
-	int stream, ret;
+	int stream;
 
-	if (dev->capability & DW_I2S_MASTER) {
-		ret = clk_enable(dev->clk);
-		if (ret)
-			return ret;
-	}
+	pm_runtime_force_resume(dev->dev);
 
 	for_each_component_dais(component, dai) {
 		for_each_pcm_streams(stream)
@@ -1030,6 +1035,17 @@ static int dw_i2s_probe(struct platform_device *pdev)
 	}
 
 	pm_runtime_enable(&pdev->dev);
+	if (pm_runtime_enabled(&pdev->dev)) {
+		/*
+		 * runtime_pm will control clocks and resets,
+		 * but if RPM is off - turn on clocks and resets permanently
+		 */
+		if (dev->capability & DW_I2S_MASTER)
+			clk_disable_unprepare(dev->clk);
+		if (!dev->is_jh7110)
+			reset_control_assert(dev->reset);
+	}
+
 	return 0;
 
 err_assert_reset:
-- 
2.34.1


                 reply	other threads:[~2026-03-02 11:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260302115159.776850-1-vovchkir@gmail.com \
    --to=vovchkir@gmail.com \
    --cc=bradynorander@gmail.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=perex@perex.cz \
    --cc=rajeevkumar.linux@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®