ASoC: Ensure WM8962 PLL registers are reset
Subsystems (3)
PATCH 1/7 ASoC: Ensure WM8962 PLL registers are reset
The WM8962 has a separate software reset for the PLL registers. Ensure that these are reset also on startup.
--- sound/soc/codecs/wm8962.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8962.c +7 -1
@@ -1963,7 +1963,13 @@ static int wm8962_readable_register(struct snd_soc_codec *codec, unsigned int restatic int wm8962_reset (struct snd_soc_codec *codec) { -return snd_soc_write (codec,WM8962_SOFTWARE_RESET ,0x6243 ); +int ret; + + ret =snd_soc_write (codec,WM8962_SOFTWARE_RESET ,0x6243 ); +if (ret !=0 ) +return ret; + +return snd_soc_write (codec,WM8962_PLL_SOFTWARE_RESET ,0 ); } static const DECLARE_TLV_DB_SCALE(inpga_tlv, -2325, 75, 0);
Signature · 1 line
1.7.7.1
PATCH 2/7 ASoC: Ensure the WM8962 oscillator and PLLs start up disabled
Since there is no current software control for these they would otherwise be left enabled, consuming power.
--- sound/soc/codecs/wm8962.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
sound/soc/codecs/wm8962.c +5 -0
@@ -4058,6 +4058,11 @@ static int wm8962_probe(struct snd_soc_codec *codec)snd_soc_update_bits (codec,WM8962_CLOCKING2 ,WM8962_CLKREG_OVD ,WM8962_CLKREG_OVD ); +/* Ensure that the oscillator and PLLs are disabled */ +snd_soc_update_bits (codec,WM8962_PLL2 , +WM8962_OSC_ENA |WM8962_PLL2_ENA |WM8962_PLL3_ENA , +0 ); +regulator_bulk_disable (ARRAY_SIZE (wm8962->supplies), wm8962->supplies);if (pdata) {
Signature · 1 line
1.7.7.1
PATCH 3/7 ASoC: Ensure we always delay for WM8962 FLL when starting from SYSCLK
In reply to Mark Brown--- sound/soc/codecs/wm8962.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-)
sound/soc/codecs/wm8962.c +8 -9
@@ -2368,15 +2368,14 @@ static int sysclk_event(struct snd_soc_dapm_widget *w,snd_soc_update_bits (codec,WM8962_FLL_CONTROL_1 ,WM8962_FLL_ENA ,WM8962_FLL_ENA ); -if (wm8962->irq) { - timeout =msecs_to_jiffies (5 ); - timeout =wait_for_completion_timeout (&wm8962->fll_lock, - timeout); - -if (timeout ==0 ) -dev_err (codec->dev, -"Timed out starting FLL\n" ); - } + + timeout =msecs_to_jiffies (5 ); + timeout =wait_for_completion_timeout (&wm8962->fll_lock, + timeout); + +if (wm8962->irq && timeout ==0 ) +dev_err (codec->dev, +"Timed out starting FLL\n" ); }break ;
Signature · 1 line
1.7.7.1
PATCH 4/7 ASoC: Start WM8962 FLL if SYSCLK is enabled
In reply to Mark BrownSince we have code to automatically manage the start and stop of the FLL based on the SYSCLK widget if SYSCLK is already enabled and the FLL is configured then we need to start it up.
--- sound/soc/codecs/wm8962.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
sound/soc/codecs/wm8962.c +4 -0
@@ -3406,6 +3406,7 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,unsigned long timeout;int ret;int fll1 =snd_soc_read (codec,WM8962_FLL_CONTROL_1 ) &WM8962_FLL_ENA ; +int sysclk =snd_soc_read (codec,WM8962_CLOCKING2 ) &WM8962_SYSCLK_ENA ;/* Any change? */ if (source == wm8962->fll_src && Fref == wm8962->fll_fref &&
@@ -3466,6 +3467,9 @@ static int wm8962_set_fll(struct snd_soc_codec *codec, int fll_id, int source,try_wait_for_completion (&wm8962->fll_lock); +if (sysclk) + fll1 |=WM8962_FLL_ENA ; +snd_soc_update_bits (codec,WM8962_FLL_CONTROL_1 ,WM8962_FLL_FRAC |WM8962_FLL_REFCLK_SRC_MASK |WM8962_FLL_ENA , fll1);
Signature · 1 line
1.7.7.1
PATCH 5/7 ASoC: Enable SYSCLK last when enabling WM8962 mic detection
In reply to Mark BrownEnsure everything is set up before we start detecting.
--- sound/soc/codecs/wm8962.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
sound/soc/codecs/wm8962.c +3 -2
@@ -3672,8 +3672,6 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)if (jack) { irq_mask =0 ; enable =WM8962_MICDET_ENA ; - -snd_soc_dapm_force_enable_pin (&codec->dapm,"SYSCLK" ); }else { irq_mask =WM8962_MICD_EINT |WM8962_MICSCD_EINT ; enable =0 ;
@@ -3688,6 +3686,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)snd_soc_jack_report (wm8962->jack,0 ,SND_JACK_MICROPHONE |SND_JACK_BTN_0 ); +if (jack) +snd_soc_dapm_force_enable_pin (&codec->dapm,"SYSCLK" ); +return 0 ; }EXPORT_SYMBOL_GPL (wm8962_mic_detect);
Signature · 1 line
1.7.7.1
PATCH 6/7 ASoC: WM8962 accessory detection requires MICBIAS
In reply to Mark BrownForce MICBIAS on as well as SYSCLK as the WM8962 accessory detection can't function without both. No point in making machine drivers manually enable it.
--- sound/soc/codecs/wm8962.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
sound/soc/codecs/wm8962.c +3 -1
@@ -3686,8 +3686,10 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)snd_soc_jack_report (wm8962->jack,0 ,SND_JACK_MICROPHONE |SND_JACK_BTN_0 ); -if (jack) +if (jack) {snd_soc_dapm_force_enable_pin (&codec->dapm,"SYSCLK" ); +snd_soc_dapm_force_enable_pin (&codec->dapm,"MICBIAS" ); + }return 0 ; }
Signature · 1 line
1.7.7.1
PATCH 7/7 ASoC: Disable MICBIAS and SYSCLK when stopping WM8962 accessory detection
In reply to Mark BrownThey aren't needed any more. If machines need them for other purposes then further changes will be required.
--- sound/soc/codecs/wm8962.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
sound/soc/codecs/wm8962.c +3 -0
@@ -3689,6 +3689,9 @@ int wm8962_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack)if (jack) {snd_soc_dapm_force_enable_pin (&codec->dapm,"SYSCLK" );snd_soc_dapm_force_enable_pin (&codec->dapm,"MICBIAS" ); + }else { +snd_soc_dapm_disable_pin (&codec->dapm,"SYSCLK" ); +snd_soc_dapm_disable_pin (&codec->dapm,"MICBIAS" ); }return 0 ;
Signature · 1 line
1.7.7.1