aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/ad1938.c
diff options
context:
space:
mode:
authorBarry Song <21cnbao@gmail.com>2009-12-25 01:10:08 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-12-30 13:30:34 -0500
commit5b61735534193ab357636d5b56c098f0bbe8bac8 (patch)
treeaa10523f64f4595731732a28090dd62fcde4622b /sound/soc/codecs/ad1938.c
parent08ba864e2789a94c259b8d0aee13a5a183edd46e (diff)
ASoC: ad1938: let soc-core dapm handle PLL power
PM architecture of ad1938 is simple, we don't need a bundle of functions like ad1938_pll_powerctrl, ad1938_set_bias_level for only PLL. A dapm supply will handle on/off of PLL. Since soc-core can poweron/off PLL on-demand, we don't need to poweron/off PLL in suspend/resume entries too. 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/ad1938.c')
-rw-r--r--sound/soc/codecs/ad1938.c62
1 files changed, 3 insertions, 59 deletions
diff --git a/sound/soc/codecs/ad1938.c b/sound/soc/codecs/ad1938.c
index 735c3562d20d..47d9ac0ec9d9 100644
--- a/sound/soc/codecs/ad1938.c
+++ b/sound/soc/codecs/ad1938.c
@@ -97,6 +97,7 @@ static const struct snd_kcontrol_new ad1938_snd_controls[] = {
97static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = { 97static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = {
98 SND_SOC_DAPM_DAC("DAC", "Playback", AD1938_DAC_CTRL0, 0, 1), 98 SND_SOC_DAPM_DAC("DAC", "Playback", AD1938_DAC_CTRL0, 0, 1),
99 SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0), 99 SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0),
100 SND_SOC_DAPM_SUPPLY("PLL_PWR", AD1938_PLL_CLK_CTRL0, 0, 1, NULL, 0),
100 SND_SOC_DAPM_SUPPLY("ADC_PWR", AD1938_ADC_CTRL0, 0, 1, NULL, 0), 101 SND_SOC_DAPM_SUPPLY("ADC_PWR", AD1938_ADC_CTRL0, 0, 1, NULL, 0),
101 SND_SOC_DAPM_OUTPUT("DAC1OUT"), 102 SND_SOC_DAPM_OUTPUT("DAC1OUT"),
102 SND_SOC_DAPM_OUTPUT("DAC2OUT"), 103 SND_SOC_DAPM_OUTPUT("DAC2OUT"),
@@ -107,6 +108,8 @@ static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = {
107}; 108};
108 109
109static const struct snd_soc_dapm_route audio_paths[] = { 110static const struct snd_soc_dapm_route audio_paths[] = {
111 { "DAC", NULL, "PLL_PWR" },
112 { "ADC", NULL, "PLL_PWR" },
110 { "DAC", NULL, "ADC_PWR" }, 113 { "DAC", NULL, "ADC_PWR" },
111 { "ADC", NULL, "ADC_PWR" }, 114 { "ADC", NULL, "ADC_PWR" },
112 { "DAC1OUT", "DAC1 Switch", "DAC" }, 115 { "DAC1OUT", "DAC1 Switch", "DAC" },
@@ -134,16 +137,6 @@ static int ad1938_mute(struct snd_soc_dai *dai, int mute)
134 return 0; 137 return 0;
135} 138}
136 139
137static inline int ad1938_pll_powerctrl(struct snd_soc_codec *codec, int cmd)
138{
139 int reg = codec->read(codec, AD1938_PLL_CLK_CTRL0);
140 reg = (cmd > 0) ? reg & (~AD1938_PLL_POWERDOWN) : reg |
141 AD1938_PLL_POWERDOWN;
142 codec->write(codec, AD1938_PLL_CLK_CTRL0, reg);
143
144 return 0;
145}
146
147static int ad1938_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, 140static int ad1938_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
148 unsigned int rx_mask, int slots, int width) 141 unsigned int rx_mask, int slots, int width)
149{ 142{
@@ -306,24 +299,6 @@ static int ad1938_hw_params(struct snd_pcm_substream *substream,
306 return 0; 299 return 0;
307} 300}
308 301
309static int ad1938_set_bias_level(struct snd_soc_codec *codec,
310 enum snd_soc_bias_level level)
311{
312 switch (level) {
313 case SND_SOC_BIAS_ON:
314 ad1938_pll_powerctrl(codec, 1);
315 break;
316 case SND_SOC_BIAS_PREPARE:
317 break;
318 case SND_SOC_BIAS_STANDBY:
319 case SND_SOC_BIAS_OFF:
320 ad1938_pll_powerctrl(codec, 0);
321 break;
322 }
323 codec->bias_level = level;
324 return 0;
325}
326
327/* 302/*
328 * interface to read/write ad1938 register 303 * interface to read/write ad1938 register
329 */ 304 */
@@ -514,7 +489,6 @@ static int ad1938_register(struct ad1938_priv *ad1938)
514 codec->num_dai = 1; 489 codec->num_dai = 1;
515 codec->write = ad1938_write_reg; 490 codec->write = ad1938_write_reg;
516 codec->read = ad1938_read_reg_cache; 491 codec->read = ad1938_read_reg_cache;
517 codec->set_bias_level = ad1938_set_bias_level;
518 INIT_LIST_HEAD(&codec->dapm_widgets); 492 INIT_LIST_HEAD(&codec->dapm_widgets);
519 INIT_LIST_HEAD(&codec->dapm_paths); 493 INIT_LIST_HEAD(&codec->dapm_paths);
520 494
@@ -559,7 +533,6 @@ static int ad1938_register(struct ad1938_priv *ad1938)
559 533
560static void ad1938_unregister(struct ad1938_priv *ad1938) 534static void ad1938_unregister(struct ad1938_priv *ad1938)
561{ 535{
562 ad1938_set_bias_level(&ad1938->codec, SND_SOC_BIAS_OFF);
563 snd_soc_unregister_dai(&ad1938_dai); 536 snd_soc_unregister_dai(&ad1938_dai);
564 snd_soc_unregister_codec(&ad1938->codec); 537 snd_soc_unregister_codec(&ad1938->codec);
565 kfree(ad1938); 538 kfree(ad1938);
@@ -593,7 +566,6 @@ static int ad1938_probe(struct platform_device *pdev)
593 ARRAY_SIZE(ad1938_dapm_widgets)); 566 ARRAY_SIZE(ad1938_dapm_widgets));
594 snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths)); 567 snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
595 568
596 ad1938_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
597 569
598pcm_err: 570pcm_err:
599 return ret; 571 return ret;
@@ -610,37 +582,9 @@ static int ad1938_remove(struct platform_device *pdev)
610 return 0; 582 return 0;
611} 583}
612 584
613#ifdef CONFIG_PM
614static int ad1938_suspend(struct platform_device *pdev,
615 pm_message_t state)
616{
617 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
618 struct snd_soc_codec *codec = socdev->card->codec;
619
620 ad1938_set_bias_level(codec, SND_SOC_BIAS_OFF);
621 return 0;
622}
623
624static int ad1938_resume(struct platform_device *pdev)
625{
626 struct snd_soc_device *socdev = platform_get_drvdata(pdev);
627 struct snd_soc_codec *codec = socdev->card->codec;
628
629 if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
630 ad1938_set_bias_level(codec, SND_SOC_BIAS_ON);
631
632 return 0;
633}
634#else
635#define ad1938_suspend NULL
636#define ad1938_resume NULL
637#endif
638
639struct snd_soc_codec_device soc_codec_dev_ad1938 = { 585struct snd_soc_codec_device soc_codec_dev_ad1938 = {
640 .probe = ad1938_probe, 586 .probe = ad1938_probe,
641 .remove = ad1938_remove, 587 .remove = ad1938_remove,
642 .suspend = ad1938_suspend,
643 .resume = ad1938_resume,
644}; 588};
645EXPORT_SYMBOL_GPL(soc_codec_dev_ad1938); 589EXPORT_SYMBOL_GPL(soc_codec_dev_ad1938);
646 590