Skip to content

Commit

Permalink
ASoC: codecs: va-macro: add runtime pm support
Browse files Browse the repository at this point in the history
Add pm runtime support to VA Macro.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20220224111718.6264-11-srinivas.kandagatla@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Srinivas Kandagatla authored and Mark Brown committed Feb 25, 2022
1 parent eaba113 commit 72ad25e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions sound/soc/codecs/lpass-va-macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <linux/of_clk.h>
#include <linux/of_platform.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <sound/soc.h>
Expand Down Expand Up @@ -1469,6 +1470,12 @@ static int va_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:
Expand All @@ -1492,6 +1499,39 @@ static int va_macro_remove(struct platform_device *pdev)
return 0;
}

static int __maybe_unused va_macro_runtime_suspend(struct device *dev)
{
struct va_macro *va = dev_get_drvdata(dev);

regcache_cache_only(va->regmap, true);
regcache_mark_dirty(va->regmap);

clk_disable_unprepare(va->mclk);

return 0;
}

static int __maybe_unused va_macro_runtime_resume(struct device *dev)
{
struct va_macro *va = dev_get_drvdata(dev);
int ret;

ret = clk_prepare_enable(va->mclk);
if (ret) {
dev_err(va->dev, "unable to prepare mclk\n");
return ret;
}

regcache_cache_only(va->regmap, false);
regcache_sync(va->regmap);
return 0;
}


static const struct dev_pm_ops va_macro_pm_ops = {
SET_RUNTIME_PM_OPS(va_macro_runtime_suspend, va_macro_runtime_resume, NULL)
};

static const struct of_device_id va_macro_dt_match[] = {
{ .compatible = "qcom,sc7280-lpass-va-macro" },
{ .compatible = "qcom,sm8250-lpass-va-macro" },
Expand All @@ -1504,6 +1544,7 @@ static struct platform_driver va_macro_driver = {
.name = "va_macro",
.of_match_table = va_macro_dt_match,
.suppress_bind_attrs = true,
.pm = &va_macro_pm_ops,
},
.probe = va_macro_probe,
.remove = va_macro_remove,
Expand Down

0 comments on commit 72ad25e

Please sign in to comment.