aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ad1836.c
diff options
context:
space:
mode:
authorBarry Song <21cnbao@gmail.com>2010-01-25 03:42:25 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-01-25 09:52:22 -0500
commit84549d239ab9bb2e3a85c6efcf0e6478a38b4260 (patch)
treea4ee60ceecb1a7a473b4c8f654cbfaf69be643bc /sound/soc/codecs/ad1836.c
parent895d4509d069f0706427ca75fcf0929ed136d0d7 (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/soc/codecs/ad1836.c')
-rw-r--r--sound/soc/codecs/ad1836.c32
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
227static 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
240static 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
226static int __devinit ad1836_spi_probe(struct spi_device *spi) 256static 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)
404struct snd_soc_codec_device soc_codec_dev_ad1836 = { 434struct 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};
408EXPORT_SYMBOL_GPL(soc_codec_dev_ad1836); 440EXPORT_SYMBOL_GPL(soc_codec_dev_ad1836);
409 441