From: Sugar Zhang Date: Tue, 5 Jul 2016 02:45:11 +0000 (+0800) Subject: FROMLIST: ASoC: rockchip: implement system suspend/resume for i2s X-Git-Tag: firefly_0821_release~2219 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=62b5ed622d843f8870c6a0779a9088e9b905cdfd;p=firefly-linux-kernel-4.4.55.git FROMLIST: ASoC: rockchip: implement system suspend/resume for i2s restore hw registers after power loss during a suspend/resume cycle. Change-Id: I109c4acaef8fef12f84e4c1b6d3488891a94ebb2 Signed-off-by: Sugar Zhang (am from https://patchwork.kernel.org/patch/9213485/) --- diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 652e8c5ea166..2408872b037f 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -663,9 +663,35 @@ static int rockchip_i2s_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_PM_SLEEP +static int rockchip_i2s_suspend(struct device *dev) +{ + struct rk_i2s_dev *i2s = dev_get_drvdata(dev); + + regcache_mark_dirty(i2s->regmap); + + return 0; +} + +static int rockchip_i2s_resume(struct device *dev) +{ + struct rk_i2s_dev *i2s = dev_get_drvdata(dev); + int ret; + + ret = pm_runtime_get_sync(dev); + if (ret < 0) + return ret; + ret = regcache_sync(i2s->regmap); + pm_runtime_put(dev); + + return ret; +} +#endif + static const struct dev_pm_ops rockchip_i2s_pm_ops = { SET_RUNTIME_PM_OPS(i2s_runtime_suspend, i2s_runtime_resume, NULL) + SET_SYSTEM_SLEEP_PM_OPS(rockchip_i2s_suspend, rockchip_i2s_resume) }; static struct platform_driver rockchip_i2s_driver = {