ASoC: WM8962: Set CLKREG_OVD if GP5_FN is not its reset value
Subsystems (3)
PATCH 1/1 ASoC: WM8962: Set CLKREG_OVD if GP5_FN is not its reset value
According to WM8962 datasheet, the GP5_FN bit of R516 (GPIO 5) depends on the CLKREG_OVD bit of R8 (Clocking2):
"Note that GPIO5 functions are only supported when CLKREG_OVD=1. When CLKREG_OVD=0, the contents of Register R516 must not be changed from the default value."
So set CLKREG_OVD bit before regcache_sync() updates the GP5_FN bit to a non-reset value.
--- sound/soc/codecs/wm8962.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-)
sound/soc/codecs/wm8962.c +19 -0
@@ -3739,6 +3739,23 @@ static int wm8962_i2c_remove(struct i2c_client *client) }#ifdef CONFIG_PM_RUNTIME +static void wm8962_check_gp5_fn (struct snd_soc_codec *codec) +{ +int changed; + +/* +* If GP5_FN is not going to be the reset value 0x0, +* need to set CLKREG_OVD bit of Register CLOCKING2 +* before regcache_sync() updates GP5_FN bit to a +* non-reset value. The reset value should be 0x0. +*/ + changed =snd_soc_test_bits (codec,WM8962_GPIO_5 , +WM8962_GP5_FN_MASK ,0x0 ); +if (changed) +snd_soc_update_bits (codec,WM8962_CLOCKING2 , +WM8962_CLKREG_OVD_MASK ,WM8962_CLKREG_OVD ); +} +static int wm8962_runtime_resume (struct device *dev) {struct wm8962_priv *wm8962 =dev_get_drvdata (dev);
@@ -3756,6 +3773,8 @@ static int wm8962_runtime_resume(struct device *dev)wm8962_reset (wm8962); +wm8962_check_gp5_fn (wm8962->codec); +regcache_sync (wm8962->regmap);return 0 ;
Signature · 1 line
1.7.1
Mark Brown
maintainerOn Fri, Jun 07, 2013 at 08:14:18PM +0800, Nicolin Chen wrote:
Please use subject lines appropriate for the thing you're changing.
Quoted 9 lines
According to WM8962 datasheet, the
GP5_FNbit of R516 (GPIO 5) depends on theCLKREG_OVDbit of R8 (Clocking2):"Note that GPIO5 functions are only supported when CLKREG_OVD=1. When CLKREG_OVD=0, the contents of Register R516 must not be changed from the default value."
So set
CLKREG_OVDbit beforeregcache_sync()updates theGP5_FNbit to a non-reset value.
You're missing a whole batch of handling of device reset here - look at how we handle things on power on.
Quoted 1 line · Mark Brown
Please use subject lines appropriate for the thing you're changing.
I'm sorry. I'll pay attention to it next time.
Quoted 2 lines
You're missing a whole batch of handling of device reset here - look at how we handle things on power on.
Are you talking about the initial code in wm8962_probe()?
But after wm8962_runtime_resume(), register Clocking2 will be reset to its default value without OVD-setting and won't be recovered after regcache_sync() due to volatile_reg.
If I'm wrong about it, pls tell me. I'll be happy if this codec driver hasn't this issue.
Thank you.
Mark Brown
maintainerQuoted 9 lines · On Fri, Jun 07, 2013 at 03:33:31PM +0000, Chen Guangyu-B42378 wrote:
Quoted 2 lines · Mark Brown
You're missing a whole batch of handling of device reset here - look at how we handle things on power on.
Are you talking about the initial code in
wm8962_probe()?
But afterwm8962_runtime_resume(), register Clocking2 will be reset to its default value without OVD-setting and won't be recovered afterregcache_sync()due tovolatile_reg.
The point is that there's more work needed to recover the device state here, you're only doing one of the several things that need to be done after the device has been restored.
Quoted 3 lines · Mark Brown
The point is that there's more work needed to recover the device state here, you're only doing one of the several things that need to be done after the device has been restored.
That's because I'm too scared to put too many code into my single patch :(
Sir, I'm so glad you can fix this issue with such a quick response. I'll test that patch tomorrow moring (midnight here) and give you a feedback.
Thank you so much.
Mark Brown
maintainerQuoted 7 lines · On Fri, Jun 07, 2013 at 04:29:49PM +0000, Chen Guangyu-B42378 wrote:
Quoted 3 lines · Mark Brown
The point is that there's more work needed to recover the device state here, you're only doing one of the several things that need to be done after the device has been restored.
That's because I'm too scared to put too many code into my single patch :(
Ah, OK. In this case you're being too conservative - there's a whole batch of initialistion which is missing, the simplest thing is to pull the lot over since if one bit is missing the others almost certainly are too.
Quoted 2 lines
Sir, I'm so glad you can fix this issue with such a quick response. I'll test that patch tomorrow moring (midnight here) and give you a feedback.
Note that I haven't tested that patch at all (well, I compiled it but who knows if it runs or not).