* [PATCH] ASoC: dwc: rework pm functions
@ 2026-03-02 11:51 Vladimir Yakovlev
0 siblings, 0 replies; only message in thread
From: Vladimir Yakovlev @ 2026-03-02 11:51 UTC (permalink / raw)
To: Rajeev Kumar, Liam Girdwood
Cc: Vladimir Yakovlev, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Philipp Zabel, Brady Norander, Charles Keepax, linux-sound,
linux-kernel
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-03-02 11:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-02 11:51 [PATCH] ASoC: dwc: rework pm functions Vladimir Yakovlev
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®