summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorDaniel Baluta <daniel.baluta@nxp.com>2017-08-21 15:48:45 +0300
committerLeonard Crestez <leonard.crestez@nxp.com>2017-10-05 14:57:48 +0300
commit0c195d6e5d2682bbce2de7411c1764b96c709bfc (patch)
treeaf9172043dc1772a8133e3619646d58c75148ab7 /sound
parent3ae05518ae585c7740028fc73ba004e0a8f322f0 (diff)
ASoC: codecs: fsl_mqs: Add PM support
Save the values of registers at suspend and restore it at resume. We don't need to implement runtime PM support because MQS is already enabled in startup() and disabled in shutdown(). Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com> Reviewed-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/fsl_mqs.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sound/soc/codecs/fsl_mqs.c b/sound/soc/codecs/fsl_mqs.c
index 3f7dc1481574..daf75fc1bfa6 100644
--- a/sound/soc/codecs/fsl_mqs.c
+++ b/sound/soc/codecs/fsl_mqs.c
@@ -14,6 +14,7 @@
#include <linux/mfd/syscon.h>
#include <linux/mfd/syscon/imx6q-iomuxc-gpr.h>
#include <linux/of.h>
+#include <linux/pm.h>
#include <linux/slab.h>
#include <sound/soc.h>
#include <sound/pcm.h>
@@ -36,7 +37,11 @@
struct fsl_mqs {
struct platform_device *pdev;
struct regmap *gpr;
+ unsigned int reg_iomuxc_gpr2;
+
struct regmap *regmap;
+ unsigned int reg_mqs_ctrl;
+
struct clk *mclk;
struct clk *ipg;
@@ -287,6 +292,40 @@ static int fsl_mqs_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int fsl_mqs_resume(struct device *dev)
+{
+ struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
+
+ if (mqs_priv->use_gpr)
+ regmap_write(mqs_priv->gpr, IOMUXC_GPR2,
+ mqs_priv->reg_iomuxc_gpr2);
+ else
+ regmap_write(mqs_priv->regmap, REG_MQS_CTRL,
+ mqs_priv->reg_mqs_ctrl);
+
+ return 0;
+}
+
+static int fsl_mqs_suspend(struct device *dev)
+{
+ struct fsl_mqs *mqs_priv = dev_get_drvdata(dev);
+
+ if (mqs_priv->use_gpr)
+ regmap_read(mqs_priv->gpr, IOMUXC_GPR2,
+ &mqs_priv->reg_iomuxc_gpr2);
+ else
+ regmap_read(mqs_priv->regmap, REG_MQS_CTRL,
+ &mqs_priv->reg_mqs_ctrl);
+
+ return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_mqs_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(fsl_mqs_suspend, fsl_mqs_resume)
+};
+
static const struct of_device_id fsl_mqs_dt_ids[] = {
{ .compatible = "fsl,imx8qm-mqs", },
{ .compatible = "fsl,imx6sx-mqs", },
@@ -301,6 +340,7 @@ static struct platform_driver fsl_mqs_driver = {
.driver = {
.name = "fsl-mqs",
.of_match_table = fsl_mqs_dt_ids,
+ .pm = &fsl_mqs_pm_ops,
},
};