From f002e5acff018de709bfa01a6d4c2925b79c21f4 Mon Sep 17 00:00:00 2001 From: Xing Zheng Date: Tue, 13 Jun 2023 20:38:14 +0800 Subject: [PATCH] ASoC: rockchip: sai: Add support system PM suspend/resume Change-Id: Iafce14494982a3827f0a43409cfffe53307b7193 Signed-off-by: Xing Zheng --- sound/soc/rockchip/rockchip_sai.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sound/soc/rockchip/rockchip_sai.c b/sound/soc/rockchip/rockchip_sai.c index 0fdfba0636d3..2bda4d2b5d8f 100644 --- a/sound/soc/rockchip/rockchip_sai.c +++ b/sound/soc/rockchip/rockchip_sai.c @@ -1432,8 +1432,33 @@ static int rockchip_sai_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int rockchip_sai_suspend(struct device *dev) +{ + struct rk_sai_dev *sai = dev_get_drvdata(dev); + + regcache_mark_dirty(sai->regmap); + + return 0; +} + +static int rockchip_sai_resume(struct device *dev) +{ + struct rk_sai_dev *sai = dev_get_drvdata(dev); + int ret = pm_runtime_resume_and_get(dev); + + if (ret < 0) + return ret; + ret = regcache_sync(sai->regmap); + pm_runtime_put(dev); + + return ret; +} +#endif /* CONFIG_PM_SLEEP */ + static const struct dev_pm_ops rockchip_sai_pm_ops = { SET_RUNTIME_PM_OPS(sai_runtime_suspend, sai_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(rockchip_sai_suspend, rockchip_sai_resume) }; static struct platform_driver rockchip_sai_driver = {