[alsa-devel] [PATCH v2 0/2] *** 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(-)
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().
Signed-off-by: Jiada Wang jiada_wang@mentor.com --- sound/soc/codecs/wm8962.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 293e47a..a3d7778 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -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. */
On Tue, Oct 20, 2015 at 11:47:11AM +0900, Jiada Wang wrote:
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().
Signed-off-by: Jiada Wang jiada_wang@mentor.com
Acked-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com
Thanks, Charles
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
From 4eb0f7abcefad2d4c127aa7502d3122635eddab0 Mon Sep 17 00:00:00 2001
From: Jiada Wang jiada_wang@mentor.com 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().
Signed-off-by: Jiada Wang jiada_wang@mentor.com Acked-by: Charles Keepax ckeepax@opensource.wolfsonmicro.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/wm8962.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index b4eb975..45f06d5f 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -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. */
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.
Signed-off-by: Jiada Wang jiada_wang@mentor.com --- sound/soc/codecs/wm8962.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index a3d7778..157530c 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -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[] = {
On Tue, Oct 20, 2015 at 11:47:12AM +0900, Jiada Wang wrote:
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.
Signed-off-by: Jiada Wang jiada_wang@mentor.com
sound/soc/codecs/wm8962.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index a3d7778..157530c 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -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
On Tue, Oct 20, 2015 at 11:47:12AM +0900, Jiada Wang wrote:
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.
participants (3)
-
Charles Keepax
-
Jiada Wang
-
Mark Brown