Commit f68c2a68 authored by Olivier Moysan's avatar Olivier Moysan Committed by Mark Brown

ASoC: stm32: spdifrx: add power management

Add suspend and resume sleep callbacks to STM32 SPDIFRX driver,
to support system low power modes.
Signed-off-by: default avatarOlivier Moysan <olivier.moysan@st.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent bbfaa7d3
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/pinctrl/consumer.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/reset.h> #include <linux/reset.h>
...@@ -471,6 +472,8 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) ...@@ -471,6 +472,8 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx)
memset(spdifrx->cs, 0, SPDIFRX_CS_BYTES_NB); memset(spdifrx->cs, 0, SPDIFRX_CS_BYTES_NB);
memset(spdifrx->ub, 0, SPDIFRX_UB_BYTES_NB); memset(spdifrx->ub, 0, SPDIFRX_UB_BYTES_NB);
pinctrl_pm_select_default_state(&spdifrx->pdev->dev);
ret = stm32_spdifrx_dma_ctrl_start(spdifrx); ret = stm32_spdifrx_dma_ctrl_start(spdifrx);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -502,6 +505,7 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx) ...@@ -502,6 +505,7 @@ static int stm32_spdifrx_get_ctrl_data(struct stm32_spdifrx_data *spdifrx)
end: end:
clk_disable_unprepare(spdifrx->kclk); clk_disable_unprepare(spdifrx->kclk);
pinctrl_pm_select_sleep_state(&spdifrx->pdev->dev);
return ret; return ret;
} }
...@@ -611,10 +615,15 @@ static bool stm32_spdifrx_readable_reg(struct device *dev, unsigned int reg) ...@@ -611,10 +615,15 @@ static bool stm32_spdifrx_readable_reg(struct device *dev, unsigned int reg)
static bool stm32_spdifrx_volatile_reg(struct device *dev, unsigned int reg) static bool stm32_spdifrx_volatile_reg(struct device *dev, unsigned int reg)
{ {
if (reg == STM32_SPDIFRX_DR) switch (reg) {
case STM32_SPDIFRX_DR:
case STM32_SPDIFRX_CSR:
case STM32_SPDIFRX_SR:
case STM32_SPDIFRX_DIR:
return true; return true;
default:
return false; return false;
}
} }
static bool stm32_spdifrx_writeable_reg(struct device *dev, unsigned int reg) static bool stm32_spdifrx_writeable_reg(struct device *dev, unsigned int reg)
...@@ -638,6 +647,7 @@ static const struct regmap_config stm32_h7_spdifrx_regmap_conf = { ...@@ -638,6 +647,7 @@ static const struct regmap_config stm32_h7_spdifrx_regmap_conf = {
.volatile_reg = stm32_spdifrx_volatile_reg, .volatile_reg = stm32_spdifrx_volatile_reg,
.writeable_reg = stm32_spdifrx_writeable_reg, .writeable_reg = stm32_spdifrx_writeable_reg,
.fast_io = true, .fast_io = true,
.cache_type = REGCACHE_FLAT,
}; };
static irqreturn_t stm32_spdifrx_isr(int irq, void *devid) static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)
...@@ -983,10 +993,36 @@ static int stm32_spdifrx_remove(struct platform_device *pdev) ...@@ -983,10 +993,36 @@ static int stm32_spdifrx_remove(struct platform_device *pdev)
MODULE_DEVICE_TABLE(of, stm32_spdifrx_ids); MODULE_DEVICE_TABLE(of, stm32_spdifrx_ids);
#ifdef CONFIG_PM_SLEEP
static int stm32_spdifrx_suspend(struct device *dev)
{
struct stm32_spdifrx_data *spdifrx = dev_get_drvdata(dev);
regcache_cache_only(spdifrx->regmap, true);
regcache_mark_dirty(spdifrx->regmap);
return 0;
}
static int stm32_spdifrx_resume(struct device *dev)
{
struct stm32_spdifrx_data *spdifrx = dev_get_drvdata(dev);
regcache_cache_only(spdifrx->regmap, false);
return regcache_sync(spdifrx->regmap);
}
#endif /* CONFIG_PM_SLEEP */
static const struct dev_pm_ops stm32_spdifrx_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(stm32_spdifrx_suspend, stm32_spdifrx_resume)
};
static struct platform_driver stm32_spdifrx_driver = { static struct platform_driver stm32_spdifrx_driver = {
.driver = { .driver = {
.name = "st,stm32-spdifrx", .name = "st,stm32-spdifrx",
.of_match_table = stm32_spdifrx_ids, .of_match_table = stm32_spdifrx_ids,
.pm = &stm32_spdifrx_pm_ops,
}, },
.probe = stm32_spdifrx_probe, .probe = stm32_spdifrx_probe,
.remove = stm32_spdifrx_remove, .remove = stm32_spdifrx_remove,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment