Skip to contentSkip to conversation

*** wm8962 regmap related fix ***

PATCH In review Jiada Wang 3 participants 7 messages Oct 20, 2015 – Oct 22, 2015

Subsystems (3)
lore
Share & tools
lore

Jiada Wang

author
#0 lore raw

v2 cover *** wm8962 regmap related fix ***

This patch set aims to fix issues in wm8962 codec driver related to regmap, currently any attempt to read from ALC Coefficient register will fail when wm8962 is in suspend mode. As ALC2 register is volatile register, it can't be read when cache_only flag is set.

Another issue is, if wm8962's regulator is set to 'regulator-always-on' mode, then after wm8962 is resumed from suspend, wm8962 codec is reset, but cache_dirty flag isn't set, this cause difference between actual wm8962 HW and regmap cache.

Changeset:
--------------
v1 -> v2
* removed comment before regcache_mark_dirty

Jiada Wang (2):
ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume
ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers

 sound/soc/codecs/wm8962.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.4.5
author
#1 lore raw

PATCH v2 1/2 ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume

By doing software reset of wm8962 in pm_resume, all registers which have already been set will be reset to default value without regmap interface be involved, thus driver need to mark cache_dirty flag, to let regcache can be updated by regcache_sync().

---
 sound/soc/codecs/wm8962.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/codecs/wm8962.c +2 -0
index 293e47a..a3d7778 100644
@@ -3805,6 +3805,8 @@ static int wm8962_runtime_resume(struct device *dev)
 
 	wm8962_reset(wm8962);
 
+	regcache_mark_dirty(wm8962->regmap);
+
 	/* SYSCLK defaults to on; make sure it is off so we can safely
 	 * write to registers if the device is declocked.
 	 */
Signature · 1 line
2.4.5
Acked-by on v2 1/2
#2 lore raw

Re: [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume

Quoted 7 lines · Jiada Wang

By doing software reset of wm8962 in pm_resume, all registers which have already been set will be reset to default value without regmap interface be involved, thus driver need to mark cache_dirty flag, to let regcache can be updated by regcache_sync().

---

Thanks,
Charles

maintainer
#3 lore raw

Applied "ASoC: wm8962: mark cache_dirty flag after software reset in pm_resume" to the asoc tree

In reply to Jiada Wang

The patch

ASoC: wm8962: mark cache_dirty flag after software reset in pm_resume

has been applied to the asoc tree at

git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From 4eb0f7abcefad2d4c127aa7502d3122635eddab0 Mon Sep 17 00:00:00 2001

From: Jiada Wang <[email protected]>
Date: Tue, 20 Oct 2015 11:47:11 +0900
Subject: [PATCH] ASoC: wm8962: mark cache_dirty flag after software reset in
pm_resume

By doing software reset of wm8962 in pm_resume, all registers which have already been set will be reset to default value without regmap interface be involved, thus driver need to mark cache_dirty flag, to let regcache can be updated by regcache_sync().

---
 sound/soc/codecs/wm8962.c | 2 ++
 1 file changed, 2 insertions(+)
sound/soc/codecs/wm8962.c +2 -0
index b4eb975..45f06d5f 100644
@@ -3804,6 +3804,8 @@ static int wm8962_runtime_resume(struct device *dev)
 
 	wm8962_reset(wm8962);
 
+	regcache_mark_dirty(wm8962->regmap);
+
 	/* SYSCLK defaults to on; make sure it is off so we can safely
 	 * write to registers if the device is declocked.
 	 */
Signature · 1 line
2.6.1
author
#4 lore raw

PATCH v2 2/2 ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers

In reply to Jiada Wang

As ALC2 register is volatile, declare it as one of ALC Coefficients register together with other non-volatile registers will cause issue, in case wm8962 has enter suspend mode, and cache_only flag is set, any attempt to read from ALC2 will fail.

Instead of declaring one ALC Coefficients register which contains ALC1 ~ ALC3 and Noise Gate, this patch declares 4 separate registers, so that regmap can handle these registers differently based on their classification.

---
 sound/soc/codecs/wm8962.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8962.c +4 -1
index a3d7778..157530c 100644
@@ -1782,8 +1782,11 @@ SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30),
 
 SOC_DOUBLE("ALC Switch", WM8962_ALC1, WM8962_ALCL_ENA_SHIFT,
 		WM8962_ALCR_ENA_SHIFT, 1, 0),
-SND_SOC_BYTES_MASK("ALC Coefficients", WM8962_ALC1, 4,
+SND_SOC_BYTES_MASK("ALC1", WM8962_ALC1, 1,
 		WM8962_ALCL_ENA_MASK | WM8962_ALCR_ENA_MASK),
+SND_SOC_BYTES("ALC2", WM8962_ALC2, 1),
+SND_SOC_BYTES("ALC3", WM8962_ALC3, 1),
+SND_SOC_BYTES("Noise Gate", WM8962_NOISE_GATE, 1),
 };
 
 static const struct snd_kcontrol_new wm8962_spk_mono_controls[] = {
Signature · 1 line
2.4.5
#5 lore raw

Re: [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers

Quoted 20 lines · Jiada Wang

As ALC2 register is volatile, declare it as one of ALC Coefficients register together with other non-volatile registers will cause issue, in case wm8962 has enter suspend mode, and cache_only flag is set, any attempt to read from ALC2 will fail.

Instead of declaring one ALC Coefficients register which contains ALC1 ~ ALC3 and Noise Gate, this patch declares 4 separate registers, so that regmap can handle these registers differently based on their classification.

---
 sound/soc/codecs/wm8962.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/wm8962.c +0 -0
index a3d7778..157530c 100644

sound/soc/codecs/wm8962.c SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30), · line 1789

Quoted 9 lines
sound/soc/codecs/wm8962.c +4 -1
@@ -1782,8 +1782,11 @@ SND_SOC_BYTES("HD Bass Coefficients", WM8962_HDBASS_AI_1, 30),
 
 SOC_DOUBLE("ALC Switch", WM8962_ALC1, WM8962_ALCL_ENA_SHIFT,
 		WM8962_ALCR_ENA_SHIFT, 1, 0),
-SND_SOC_BYTES_MASK("ALC Coefficients", WM8962_ALC1, 4,
+SND_SOC_BYTES_MASK("ALC1", WM8962_ALC1, 1,
 		WM8962_ALCL_ENA_MASK | WM8962_ALCR_ENA_MASK),
+SND_SOC_BYTES("ALC2", WM8962_ALC2, 1),
+SND_SOC_BYTES("ALC3", WM8962_ALC3, 1),
+SND_SOC_BYTES("Noise Gate", WM8962_NOISE_GATE, 1),

This doesn't really seem ideal to be changing the interface at this point in the drivers life.

Looking through the datasheet/driver there are 5 status bits in the ALC2 register but we don't use them anywhere in the driver and they don't look like they are likely to be useful to the end user. I wonder if an easier solution might just be to have the register be non-volatile?

Thanks,
Charles

maintainer
#6 lore raw

Re: [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers

In reply to Jiada Wang
Quoted 9 lines · Jiada Wang

As ALC2 register is volatile, declare it as one of ALC Coefficients register together with other non-volatile registers will cause issue, in case wm8962 has enter suspend mode, and cache_only flag is set, any attempt to read from ALC2 will fail.

Instead of declaring one ALC Coefficients register which contains ALC1 ~ ALC3 and Noise Gate, this patch declares 4 separate registers, so that regmap can handle these registers differently based on their classification.

In addition to the issue with the ABI change that Charles raised this also doesn't entirely fix the issue in that we still have a control that is going to give an error in suspend mode. Charles' suggestion seems like it's more likely to be helpful to users.