ASoC: dwc: add runtime suspend/resume functionality
When DW controller is in master mode, it can disable/enable clock during the device runtime suspend/resume sequence. Signed-off-by: Maruthi Bayyavarapu <maruthi.bayyavarapu@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
8005c49d9a
commit
f48303122d
|
@ -18,6 +18,7 @@
|
||||||
#include <linux/interrupt.h>
|
#include <linux/interrupt.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/pm_runtime.h>
|
||||||
#include <sound/designware_i2s.h>
|
#include <sound/designware_i2s.h>
|
||||||
#include <sound/pcm.h>
|
#include <sound/pcm.h>
|
||||||
#include <sound/pcm_params.h>
|
#include <sound/pcm_params.h>
|
||||||
|
@ -394,6 +395,23 @@ static const struct snd_soc_component_driver dw_i2s_component = {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
|
static int dw_i2s_runtime_suspend(struct device *dev)
|
||||||
|
{
|
||||||
|
struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (dw_dev->capability & DW_I2S_MASTER)
|
||||||
|
clk_disable(dw_dev->clk);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dw_i2s_runtime_resume(struct device *dev)
|
||||||
|
{
|
||||||
|
struct dw_i2s_dev *dw_dev = dev_get_drvdata(dev);
|
||||||
|
|
||||||
|
if (dw_dev->capability & DW_I2S_MASTER)
|
||||||
|
clk_enable(dw_dev->clk);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int dw_i2s_suspend(struct snd_soc_dai *dai)
|
static int dw_i2s_suspend(struct snd_soc_dai *dai)
|
||||||
{
|
{
|
||||||
|
@ -649,7 +667,7 @@ static int dw_i2s_probe(struct platform_device *pdev)
|
||||||
goto err_clk_disable;
|
goto err_clk_disable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
pm_runtime_enable(&pdev->dev);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_clk_disable:
|
err_clk_disable:
|
||||||
|
@ -665,6 +683,7 @@ static int dw_i2s_remove(struct platform_device *pdev)
|
||||||
if (dev->capability & DW_I2S_MASTER)
|
if (dev->capability & DW_I2S_MASTER)
|
||||||
clk_disable_unprepare(dev->clk);
|
clk_disable_unprepare(dev->clk);
|
||||||
|
|
||||||
|
pm_runtime_disable(&pdev->dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -677,12 +696,17 @@ static const struct of_device_id dw_i2s_of_match[] = {
|
||||||
MODULE_DEVICE_TABLE(of, dw_i2s_of_match);
|
MODULE_DEVICE_TABLE(of, dw_i2s_of_match);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static const struct dev_pm_ops dwc_pm_ops = {
|
||||||
|
SET_RUNTIME_PM_OPS(dw_i2s_runtime_suspend, dw_i2s_runtime_resume, NULL)
|
||||||
|
};
|
||||||
|
|
||||||
static struct platform_driver dw_i2s_driver = {
|
static struct platform_driver dw_i2s_driver = {
|
||||||
.probe = dw_i2s_probe,
|
.probe = dw_i2s_probe,
|
||||||
.remove = dw_i2s_remove,
|
.remove = dw_i2s_remove,
|
||||||
.driver = {
|
.driver = {
|
||||||
.name = "designware-i2s",
|
.name = "designware-i2s",
|
||||||
.of_match_table = of_match_ptr(dw_i2s_of_match),
|
.of_match_table = of_match_ptr(dw_i2s_of_match),
|
||||||
|
.pm = &dwc_pm_ops,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue