* [PATCH 0/3] ad1836/ad1938: PM and typo fix/cleanup
@ 2009-12-25 6:10 Barry Song
2009-12-25 6:10 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Barry Song
0 siblings, 1 reply; 5+ messages in thread
From: Barry Song @ 2009-12-25 6:10 UTC (permalink / raw)
To: broonie; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
Hi Mark,
The following 3 patches fix/cleanup PM and typo of ad1836/ad1938 codec driver:
1. ad1836: reset and restore clock control mode in suspend/resume entry
2. ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot
3. ad1938:let soc-core dapm handle PLL power
As I will send patches special for moving to soc-cache, in patch 1, I still use
the old way to read/write codec registers.
Thanks
Barry
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry
2009-12-25 6:10 [PATCH 0/3] ad1836/ad1938: PM and typo fix/cleanup Barry Song
@ 2009-12-25 6:10 ` Barry Song
2009-12-25 6:10 ` [PATCH 2/3] ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot Barry Song
2009-12-30 18:31 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Barry Song @ 2009-12-25 6:10 UTC (permalink / raw)
To: broonie; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
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>
---
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 2c18e3d..83add2f 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,
return reg_cache[reg];
}
+#ifdef CONFIG_PM
+static int ad1836_soc_suspend(struct platform_device *pdev,
+ pm_message_t state)
+{
+ struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_codec *codec = socdev->card->codec;
+
+ /* reset clock control mode */
+ u16 adc_ctrl2 = codec->read(codec, AD1836_ADC_CTRL2);
+ adc_ctrl2 &= ~AD1836_ADC_SERFMT_MASK;
+
+ return codec->write(codec, AD1836_ADC_CTRL2, adc_ctrl2);
+}
+
+static int ad1836_soc_resume(struct platform_device *pdev)
+{
+ struct snd_soc_device *socdev = platform_get_drvdata(pdev);
+ struct snd_soc_codec *codec = socdev->card->codec;
+
+ /* restore clock control mode */
+ u16 adc_ctrl2 = codec->read(codec, AD1836_ADC_CTRL2);
+ adc_ctrl2 |= AD1836_ADC_AUX;
+
+ return codec->write(codec, AD1836_ADC_CTRL2, adc_ctrl2);
+}
+#else
+#define ad1836_soc_suspend NULL
+#define ad1836_soc_resume NULL
+#endif
+
static int __devinit ad1836_spi_probe(struct spi_device *spi)
{
struct snd_soc_codec *codec;
@@ -404,6 +434,8 @@ static int ad1836_remove(struct platform_device *pdev)
struct snd_soc_codec_device soc_codec_dev_ad1836 = {
.probe = ad1836_probe,
.remove = ad1836_remove,
+ .suspend = ad1836_soc_suspend,
+ .resume = ad1836_soc_resume,
};
EXPORT_SYMBOL_GPL(soc_codec_dev_ad1836);
--
1.5.6.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot
2009-12-25 6:10 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Barry Song
@ 2009-12-25 6:10 ` Barry Song
2009-12-25 6:10 ` [PATCH 3/3] ad1938:let soc-core dapm handle PLL power Barry Song
2009-12-30 18:31 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Barry Song @ 2009-12-25 6:10 UTC (permalink / raw)
To: broonie; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
Signed-off-by: Barry Song <21cnbao@gmail.com>
---
sound/soc/codecs/ad1938.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/ad1938.c b/sound/soc/codecs/ad1938.c
index 5d48918..735c356 100644
--- a/sound/soc/codecs/ad1938.c
+++ b/sound/soc/codecs/ad1938.c
@@ -145,7 +145,7 @@ static inline int ad1938_pll_powerctrl(struct snd_soc_codec *codec, int cmd)
}
static int ad1938_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
- unsigned int mask, int slots, int width)
+ unsigned int rx_mask, int slots, int width)
{
struct snd_soc_codec *codec = dai->codec;
int dac_reg = codec->read(codec, AD1938_DAC_CTRL1);
--
1.5.6.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ad1938:let soc-core dapm handle PLL power
2009-12-25 6:10 ` [PATCH 2/3] ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot Barry Song
@ 2009-12-25 6:10 ` Barry Song
0 siblings, 0 replies; 5+ messages in thread
From: Barry Song @ 2009-12-25 6:10 UTC (permalink / raw)
To: broonie; +Cc: uclinux-dist-devel, alsa-devel, Barry Song
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>
---
sound/soc/codecs/ad1938.c | 62 ++------------------------------------------
1 files changed, 3 insertions(+), 59 deletions(-)
diff --git a/sound/soc/codecs/ad1938.c b/sound/soc/codecs/ad1938.c
index 735c356..47d9ac0 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[] = {
static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = {
SND_SOC_DAPM_DAC("DAC", "Playback", AD1938_DAC_CTRL0, 0, 1),
SND_SOC_DAPM_ADC("ADC", "Capture", SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_SUPPLY("PLL_PWR", AD1938_PLL_CLK_CTRL0, 0, 1, NULL, 0),
SND_SOC_DAPM_SUPPLY("ADC_PWR", AD1938_ADC_CTRL0, 0, 1, NULL, 0),
SND_SOC_DAPM_OUTPUT("DAC1OUT"),
SND_SOC_DAPM_OUTPUT("DAC2OUT"),
@@ -107,6 +108,8 @@ static const struct snd_soc_dapm_widget ad1938_dapm_widgets[] = {
};
static const struct snd_soc_dapm_route audio_paths[] = {
+ { "DAC", NULL, "PLL_PWR" },
+ { "ADC", NULL, "PLL_PWR" },
{ "DAC", NULL, "ADC_PWR" },
{ "ADC", NULL, "ADC_PWR" },
{ "DAC1OUT", "DAC1 Switch", "DAC" },
@@ -134,16 +137,6 @@ static int ad1938_mute(struct snd_soc_dai *dai, int mute)
return 0;
}
-static inline int ad1938_pll_powerctrl(struct snd_soc_codec *codec, int cmd)
-{
- int reg = codec->read(codec, AD1938_PLL_CLK_CTRL0);
- reg = (cmd > 0) ? reg & (~AD1938_PLL_POWERDOWN) : reg |
- AD1938_PLL_POWERDOWN;
- codec->write(codec, AD1938_PLL_CLK_CTRL0, reg);
-
- return 0;
-}
-
static int ad1938_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask,
unsigned int rx_mask, int slots, int width)
{
@@ -306,24 +299,6 @@ static int ad1938_hw_params(struct snd_pcm_substream *substream,
return 0;
}
-static int ad1938_set_bias_level(struct snd_soc_codec *codec,
- enum snd_soc_bias_level level)
-{
- switch (level) {
- case SND_SOC_BIAS_ON:
- ad1938_pll_powerctrl(codec, 1);
- break;
- case SND_SOC_BIAS_PREPARE:
- break;
- case SND_SOC_BIAS_STANDBY:
- case SND_SOC_BIAS_OFF:
- ad1938_pll_powerctrl(codec, 0);
- break;
- }
- codec->bias_level = level;
- return 0;
-}
-
/*
* interface to read/write ad1938 register
*/
@@ -514,7 +489,6 @@ static int ad1938_register(struct ad1938_priv *ad1938)
codec->num_dai = 1;
codec->write = ad1938_write_reg;
codec->read = ad1938_read_reg_cache;
- codec->set_bias_level = ad1938_set_bias_level;
INIT_LIST_HEAD(&codec->dapm_widgets);
INIT_LIST_HEAD(&codec->dapm_paths);
@@ -559,7 +533,6 @@ static int ad1938_register(struct ad1938_priv *ad1938)
static void ad1938_unregister(struct ad1938_priv *ad1938)
{
- ad1938_set_bias_level(&ad1938->codec, SND_SOC_BIAS_OFF);
snd_soc_unregister_dai(&ad1938_dai);
snd_soc_unregister_codec(&ad1938->codec);
kfree(ad1938);
@@ -593,7 +566,6 @@ static int ad1938_probe(struct platform_device *pdev)
ARRAY_SIZE(ad1938_dapm_widgets));
snd_soc_dapm_add_routes(codec, audio_paths, ARRAY_SIZE(audio_paths));
- ad1938_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
pcm_err:
return ret;
@@ -610,37 +582,9 @@ static int ad1938_remove(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_PM
-static int ad1938_suspend(struct platform_device *pdev,
- pm_message_t state)
-{
- struct snd_soc_device *socdev = platform_get_drvdata(pdev);
- struct snd_soc_codec *codec = socdev->card->codec;
-
- ad1938_set_bias_level(codec, SND_SOC_BIAS_OFF);
- return 0;
-}
-
-static int ad1938_resume(struct platform_device *pdev)
-{
- struct snd_soc_device *socdev = platform_get_drvdata(pdev);
- struct snd_soc_codec *codec = socdev->card->codec;
-
- if (codec->suspend_bias_level == SND_SOC_BIAS_ON)
- ad1938_set_bias_level(codec, SND_SOC_BIAS_ON);
-
- return 0;
-}
-#else
-#define ad1938_suspend NULL
-#define ad1938_resume NULL
-#endif
-
struct snd_soc_codec_device soc_codec_dev_ad1938 = {
.probe = ad1938_probe,
.remove = ad1938_remove,
- .suspend = ad1938_suspend,
- .resume = ad1938_resume,
};
EXPORT_SYMBOL_GPL(soc_codec_dev_ad1938);
--
1.5.6.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry
2009-12-25 6:10 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Barry Song
2009-12-25 6:10 ` [PATCH 2/3] ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot Barry Song
@ 2009-12-30 18:31 ` Mark Brown
1 sibling, 0 replies; 5+ messages in thread
From: Mark Brown @ 2009-12-30 18:31 UTC (permalink / raw)
To: Barry Song; +Cc: uclinux-dist-devel, alsa-devel
On Fri, Dec 25, 2009 at 02:10:06PM +0800, Barry Song wrote:
> 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>
Applied all three, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-12-30 18:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-25 6:10 [PATCH 0/3] ad1836/ad1938: PM and typo fix/cleanup Barry Song
2009-12-25 6:10 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Barry Song
2009-12-25 6:10 ` [PATCH 2/3] ad1938: fix typo, rename mask to rx_mask for ad1938_set_tdm_slot Barry Song
2009-12-25 6:10 ` [PATCH 3/3] ad1938:let soc-core dapm handle PLL power Barry Song
2009-12-30 18:31 ` [PATCH 1/3] ad1836: reset and restore clock control mode in suspend/resume entry Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox