diff options
author | Nicolin Chen <Guangyu.Chen@freescale.com> | 2014-05-12 08:00:48 -0400 |
---|---|---|
committer | Nicolin Chen <Guangyu.Chen@freescale.com> | 2014-06-19 05:07:48 -0400 |
commit | fc69de0b0cc1d9a85ad7f7363da6dec02945964a (patch) | |
tree | b03c76eaaeb5c53c4d670b81113362976187bd3a /sound/soc/fsl | |
parent | 88efde0cec71d7d70948eeaf1d22ab52b8bc8f2d (diff) |
ENGR00318773-7 ASoC: fsl_esai: Add driver suspend and resume to support MEGA Fast
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, ESAI needs to save
all the values of registers before the system suspend and restore them after
the system resume.
Acked-by: Wang Shengjiu <b02247@freescale.com>
Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
Diffstat (limited to 'sound/soc/fsl')
-rw-r--r-- | sound/soc/fsl/fsl_esai.c | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index 09d904a064cc..7204171edca6 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c | |||
@@ -655,6 +655,32 @@ static bool fsl_esai_readable_reg(struct device *dev, unsigned int reg) | |||
655 | } | 655 | } |
656 | } | 656 | } |
657 | 657 | ||
658 | static bool fsl_esai_volatile_reg(struct device *dev, unsigned int reg) | ||
659 | { | ||
660 | switch (reg) { | ||
661 | case REG_ESAI_ETDR: | ||
662 | case REG_ESAI_ERDR: | ||
663 | case REG_ESAI_ESR: | ||
664 | case REG_ESAI_TFSR: | ||
665 | case REG_ESAI_RFSR: | ||
666 | case REG_ESAI_TX0: | ||
667 | case REG_ESAI_TX1: | ||
668 | case REG_ESAI_TX2: | ||
669 | case REG_ESAI_TX3: | ||
670 | case REG_ESAI_TX4: | ||
671 | case REG_ESAI_TX5: | ||
672 | case REG_ESAI_RX0: | ||
673 | case REG_ESAI_RX1: | ||
674 | case REG_ESAI_RX2: | ||
675 | case REG_ESAI_RX3: | ||
676 | case REG_ESAI_SAISR: | ||
677 | return true; | ||
678 | default: | ||
679 | return false; | ||
680 | } | ||
681 | |||
682 | } | ||
683 | |||
658 | static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) | 684 | static bool fsl_esai_writeable_reg(struct device *dev, unsigned int reg) |
659 | { | 685 | { |
660 | switch (reg) { | 686 | switch (reg) { |
@@ -693,7 +719,9 @@ static const struct regmap_config fsl_esai_regmap_config = { | |||
693 | 719 | ||
694 | .max_register = REG_ESAI_PCRC, | 720 | .max_register = REG_ESAI_PCRC, |
695 | .readable_reg = fsl_esai_readable_reg, | 721 | .readable_reg = fsl_esai_readable_reg, |
722 | .volatile_reg = fsl_esai_volatile_reg, | ||
696 | .writeable_reg = fsl_esai_writeable_reg, | 723 | .writeable_reg = fsl_esai_writeable_reg, |
724 | .cache_type = REGCACHE_RBTREE, | ||
697 | }; | 725 | }; |
698 | 726 | ||
699 | static bool fsl_esai_check_xrun(struct snd_pcm_substream *substream) | 727 | static bool fsl_esai_check_xrun(struct snd_pcm_substream *substream) |
@@ -978,11 +1006,52 @@ static const struct of_device_id fsl_esai_dt_ids[] = { | |||
978 | }; | 1006 | }; |
979 | MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); | 1007 | MODULE_DEVICE_TABLE(of, fsl_esai_dt_ids); |
980 | 1008 | ||
1009 | #if CONFIG_PM_SLEEP | ||
1010 | static int fsl_esai_suspend(struct device *dev) | ||
1011 | { | ||
1012 | struct fsl_esai *esai = dev_get_drvdata(dev); | ||
1013 | |||
1014 | regcache_cache_only(esai->regmap, true); | ||
1015 | regcache_mark_dirty(esai->regmap); | ||
1016 | |||
1017 | return 0; | ||
1018 | } | ||
1019 | |||
1020 | static int fsl_esai_resume(struct device *dev) | ||
1021 | { | ||
1022 | struct fsl_esai *esai = dev_get_drvdata(dev); | ||
1023 | int ret; | ||
1024 | |||
1025 | regcache_cache_only(esai->regmap, false); | ||
1026 | |||
1027 | /* FIFO reset for safety */ | ||
1028 | regmap_update_bits(esai->regmap, REG_ESAI_TFCR, | ||
1029 | ESAI_xFCR_xFR, ESAI_xFCR_xFR); | ||
1030 | regmap_update_bits(esai->regmap, REG_ESAI_RFCR, | ||
1031 | ESAI_xFCR_xFR, ESAI_xFCR_xFR); | ||
1032 | |||
1033 | ret = regcache_sync(esai->regmap); | ||
1034 | if (ret) | ||
1035 | return ret; | ||
1036 | |||
1037 | /* FIFO reset done */ | ||
1038 | regmap_update_bits(esai->regmap, REG_ESAI_TFCR, ESAI_xFCR_xFR, 0); | ||
1039 | regmap_update_bits(esai->regmap, REG_ESAI_RFCR, ESAI_xFCR_xFR, 0); | ||
1040 | |||
1041 | return 0; | ||
1042 | } | ||
1043 | #endif /* CONFIG_PM_SLEEP */ | ||
1044 | |||
1045 | static const struct dev_pm_ops fsl_esai_pm_ops = { | ||
1046 | SET_SYSTEM_SLEEP_PM_OPS(fsl_esai_suspend, fsl_esai_resume) | ||
1047 | }; | ||
1048 | |||
981 | static struct platform_driver fsl_esai_driver = { | 1049 | static struct platform_driver fsl_esai_driver = { |
982 | .probe = fsl_esai_probe, | 1050 | .probe = fsl_esai_probe, |
983 | .driver = { | 1051 | .driver = { |
984 | .name = "fsl-esai-dai", | 1052 | .name = "fsl-esai-dai", |
985 | .owner = THIS_MODULE, | 1053 | .owner = THIS_MODULE, |
1054 | .pm = &fsl_esai_pm_ops, | ||
986 | .of_match_table = fsl_esai_dt_ids, | 1055 | .of_match_table = fsl_esai_dt_ids, |
987 | }, | 1056 | }, |
988 | }; | 1057 | }; |