diff options
author | Barry Song <21cnbao@gmail.com> | 2010-01-25 03:42:25 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-01-25 09:52:22 -0500 |
commit | 84549d239ab9bb2e3a85c6efcf0e6478a38b4260 (patch) | |
tree | a4ee60ceecb1a7a473b4c8f654cbfaf69be643bc /sound | |
parent | 895d4509d069f0706427ca75fcf0929ed136d0d7 (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>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/codecs/ad1836.c | 32 | ||||
-rw-r--r-- | sound/soc/codecs/ad1836.h | 1 |
2 files changed, 33 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 | ||
diff --git a/sound/soc/codecs/ad1836.h b/sound/soc/codecs/ad1836.h index 7660ee6973c0..e9d90d3951c5 100644 --- a/sound/soc/codecs/ad1836.h +++ b/sound/soc/codecs/ad1836.h | |||
@@ -54,6 +54,7 @@ | |||
54 | #define AD1836_ADC_SERFMT_MASK (7 << 6) | 54 | #define AD1836_ADC_SERFMT_MASK (7 << 6) |
55 | #define AD1836_ADC_SERFMT_PCK256 (0x4 << 6) | 55 | #define AD1836_ADC_SERFMT_PCK256 (0x4 << 6) |
56 | #define AD1836_ADC_SERFMT_PCK128 (0x5 << 6) | 56 | #define AD1836_ADC_SERFMT_PCK128 (0x5 << 6) |
57 | #define AD1836_ADC_AUX (0x6 << 6) | ||
57 | 58 | ||
58 | #define AD1836_ADC_CTRL3 14 | 59 | #define AD1836_ADC_CTRL3 14 |
59 | 60 | ||