public inbox for alsa-devel@alsa-project.org
 help / color / mirror / Atom feed
* [PATCH v3 1/4] ASoC: fsl_sai: Add driver suspend and resume to support MEGA Fast
@ 2015-08-07  6:21 Zidan Wang
  2015-08-07  6:21 ` [PATCH v3 2/4] ASoC: fsl_spdif: " Zidan Wang
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Zidan Wang @ 2015-08-07  6:21 UTC (permalink / raw)
  To: nicoleotsuka
  Cc: alsa-devel, timur, Zidan Wang, Xiubo.Lee, tiwai, lgirdwood,
	broonie

For i.MX6 SoloX, there is a mode of the SoC to shutdown all power source of
modules during system suspend and resume procedure. Thus, SAI needs to save
all the values of registers before the system suspend and restore them after
the system resume.

Signed-off-by: Zidan Wang <zidan.wang@freescale.com>
---
 sound/soc/fsl/fsl_sai.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index a18fd92..5c737f1 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -637,6 +637,8 @@ static bool fsl_sai_readable_reg(struct device *dev, unsigned int reg)
 static bool fsl_sai_volatile_reg(struct device *dev, unsigned int reg)
 {
 	switch (reg) {
+	case FSL_SAI_TCSR:
+	case FSL_SAI_RCSR:
 	case FSL_SAI_TFR:
 	case FSL_SAI_RFR:
 	case FSL_SAI_TDR:
@@ -681,6 +683,7 @@ static const struct regmap_config fsl_sai_regmap_config = {
 	.readable_reg = fsl_sai_readable_reg,
 	.volatile_reg = fsl_sai_volatile_reg,
 	.writeable_reg = fsl_sai_writeable_reg,
+	.cache_type = REGCACHE_FLAT,
 };
 
 static int fsl_sai_probe(struct platform_device *pdev)
@@ -802,10 +805,40 @@ static const struct of_device_id fsl_sai_ids[] = {
 	{ /* sentinel */ }
 };
 
+#if CONFIG_PM_SLEEP
+static int fsl_sai_suspend(struct device *dev)
+{
+	struct fsl_sai *sai = dev_get_drvdata(dev);
+
+	regcache_cache_only(sai->regmap, true);
+	regcache_mark_dirty(sai->regmap);
+
+	return 0;
+}
+
+static int fsl_sai_resume(struct device *dev)
+{
+	struct fsl_sai *sai = dev_get_drvdata(dev);
+
+	regcache_cache_only(sai->regmap, false);
+	regmap_write(sai->regmap, FSL_SAI_TCSR, FSL_SAI_CSR_SR);
+	regmap_write(sai->regmap, FSL_SAI_RCSR, FSL_SAI_CSR_SR);
+	msleep(1);
+	regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
+	regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
+	return regcache_sync(sai->regmap);
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops fsl_sai_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(fsl_sai_suspend, fsl_sai_resume)
+};
+
 static struct platform_driver fsl_sai_driver = {
 	.probe = fsl_sai_probe,
 	.driver = {
 		.name = "fsl-sai",
+		.pm = &fsl_sai_pm_ops,
 		.of_match_table = fsl_sai_ids,
 	},
 };
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-10-05 16:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-07  6:21 [PATCH v3 1/4] ASoC: fsl_sai: Add driver suspend and resume to support MEGA Fast Zidan Wang
2015-08-07  6:21 ` [PATCH v3 2/4] ASoC: fsl_spdif: " Zidan Wang
2015-10-05 16:44   ` Applied "ASoC: fsl_spdif: Add driver suspend and resume to support MEGA Fast" to the asoc tree Mark Brown
2015-08-07  6:21 ` [PATCH v3 3/4] ASoC: fsl_ssi: Add driver suspend and resume to support MEGA Fast Zidan Wang
2015-10-05 16:44   ` Applied "ASoC: fsl_ssi: Add driver suspend and resume to support MEGA Fast" to the asoc tree Mark Brown
2015-08-07  6:21 ` [PATCH v3 4/4] ASoC: fsl_esai: Add driver suspend and resume to support MEGA Fast Zidan Wang
2015-10-05 16:44   ` Applied "ASoC: fsl_esai: Add driver suspend and resume to support MEGA Fast" to the asoc tree Mark Brown
2015-08-11  9:12 ` [PATCH v3 1/4] ASoC: fsl_sai: Add driver suspend and resume to support MEGA Fast Nicolin Chen
2015-08-11  9:28   ` Zidan Wang
2015-08-11 10:41   ` Fabio Estevam
2015-08-11  9:34     ` Zidan Wang
2015-08-11 10:46       ` Fabio Estevam
2015-08-11  9:50         ` Zidan Wang
2015-08-11 19:29           ` Nicolin Chen
2015-09-16  5:08 ` Nicolin Chen
2015-10-05 16:44 ` Applied "ASoC: fsl_sai: Add driver suspend and resume to support MEGA Fast" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox