diff options
author | Barry Song <21cnbao@gmail.com> | 2009-12-25 01:10:06 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-12-30 13:30:11 -0500 |
commit | afe1c2cd71eb4e0fade720b5709722e7124f29c0 (patch) | |
tree | f28c00d2ec2734cf243b4ceddb827b2557a49416 | |
parent | 18240b67c8ca5efbbb2e8bb11942cc3db033fb16 (diff) |
ASoC: ad1836: reset and restore clock control mode in suspend/resume entry
Tests show frequent suspend/resume(frequent poweroff/on ad1836 internal
components) maybe make ad1836 clock mode wrong sometimes after wakeup.
This patch reset/restore ad1836 clock mode while executing PM, then
ad1836 can always resume to right clock status.
Signed-off-by: Barry Song <21cnbao@gmail.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | sound/soc/codecs/ad1836.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sound/soc/codecs/ad1836.c b/sound/soc/codecs/ad1836.c index 2c18e3d1b71e..83add2f3afba 100644 --- a/sound/soc/codecs/ad1836.c +++ b/sound/soc/codecs/ad1836.c | |||
@@ -223,6 +223,36 @@ static unsigned int ad1836_read_reg_cache(struct snd_soc_codec *codec, | |||
223 | return reg_cache[reg]; | 223 | return reg_cache[reg]; |
224 | } | 224 | } |
225 | 225 | ||
226 | #ifdef CONFIG_PM | ||
227 | static int ad1836_soc_suspend(struct platform_device *pdev, | ||
228 | pm_message_t state) | ||
229 | { | ||
230 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
231 | struct snd_soc_codec *codec = socdev->card->codec; | ||
232 | |||
233 | /* reset clock control mode */ | ||
234 | u16 adc_ctrl2 = codec->read(codec, AD1836_ADC_CTRL2); | ||
235 | adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK; | ||
236 | |||
237 | return codec->write(codec, AD1836_ADC_CTRL2, adc_ctrl2); | ||
238 | } | ||
239 | |||
240 | static int ad1836_soc_resume(struct platform_device *pdev) | ||
241 | { | ||
242 | struct snd_soc_device *socdev = platform_get_drvdata(pdev); | ||
243 | struct snd_soc_codec *codec = socdev->card->codec; | ||
244 | |||
245 | /* restore clock control mode */ | ||
246 | u16 adc_ctrl2 = codec->read(codec, AD1836_ADC_CTRL2); | ||
247 | adc_ctrl2 |= AD1836_ADC_AUX; | ||
248 | |||
249 | return codec->write(codec, AD1836_ADC_CTRL2, adc_ctrl2); | ||
250 | } | ||
251 | #else | ||
252 | #define ad1836_soc_suspend NULL | ||
253 | #define ad1836_soc_resume NULL | ||
254 | #endif | ||
255 | |||
226 | static int __devinit ad1836_spi_probe(struct spi_device *spi) | 256 | static int __devinit ad1836_spi_probe(struct spi_device *spi) |
227 | { | 257 | { |
228 | struct snd_soc_codec *codec; | 258 | struct snd_soc_codec *codec; |
@@ -404,6 +434,8 @@ static int ad1836_remove(struct platform_device *pdev) | |||
404 | struct snd_soc_codec_device soc_codec_dev_ad1836 = { | 434 | struct snd_soc_codec_device soc_codec_dev_ad1836 = { |
405 | .probe = ad1836_probe, | 435 | .probe = ad1836_probe, |
406 | .remove = ad1836_remove, | 436 | .remove = ad1836_remove, |
437 | .suspend = ad1836_soc_suspend, | ||
438 | .resume = ad1836_soc_resume, | ||
407 | }; | 439 | }; |
408 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad1836); | 440 | EXPORT_SYMBOL_GPL(soc_codec_dev_ad1836); |
409 | 441 | ||