* [PATCH v2 0/2] *** wm8962 regmap related fix *** @ 2015-10-20 2:47 Jiada Wang 2015-10-20 2:47 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang 2015-10-20 2:47 ` [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers Jiada Wang 0 siblings, 2 replies; 9+ messages in thread From: Jiada Wang @ 2015-10-20 2:47 UTC (permalink / raw) To: lgirdwood, broonie, perex, tiwai Cc: patches, alsa-devel, linux-kernel, jiada_wang 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(-) -- 2.4.5 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume 2015-10-20 2:47 [PATCH v2 0/2] *** wm8962 regmap related fix *** Jiada Wang @ 2015-10-20 2:47 ` Jiada Wang 2015-10-20 7:55 ` Charles Keepax 2015-10-20 2:47 ` [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers Jiada Wang 1 sibling, 1 reply; 9+ messages in thread From: Jiada Wang @ 2015-10-20 2:47 UTC (permalink / raw) To: lgirdwood, broonie, perex, tiwai Cc: patches, alsa-devel, linux-kernel, 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(). 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. */ -- 2.4.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume 2015-10-20 2:47 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang @ 2015-10-20 7:55 ` Charles Keepax 0 siblings, 0 replies; 9+ messages in thread From: Charles Keepax @ 2015-10-20 7:55 UTC (permalink / raw) To: Jiada Wang Cc: lgirdwood, broonie, perex, tiwai, patches, alsa-devel, linux-kernel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers 2015-10-20 2:47 [PATCH v2 0/2] *** wm8962 regmap related fix *** Jiada Wang 2015-10-20 2:47 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang @ 2015-10-20 2:47 ` Jiada Wang 2015-10-20 8:59 ` Charles Keepax 2015-10-22 12:38 ` Mark Brown 1 sibling, 2 replies; 9+ messages in thread From: Jiada Wang @ 2015-10-20 2:47 UTC (permalink / raw) To: lgirdwood, broonie, perex, tiwai Cc: patches, alsa-devel, linux-kernel, 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. 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[] = { -- 2.4.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers 2015-10-20 2:47 ` [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers Jiada Wang @ 2015-10-20 8:59 ` Charles Keepax 2015-10-22 12:38 ` Mark Brown 1 sibling, 0 replies; 9+ messages in thread From: Charles Keepax @ 2015-10-20 8:59 UTC (permalink / raw) To: Jiada Wang Cc: lgirdwood, broonie, perex, tiwai, patches, alsa-devel, linux-kernel 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 ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers 2015-10-20 2:47 ` [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers Jiada Wang 2015-10-20 8:59 ` Charles Keepax @ 2015-10-22 12:38 ` Mark Brown 1 sibling, 0 replies; 9+ messages in thread From: Mark Brown @ 2015-10-22 12:38 UTC (permalink / raw) To: Jiada Wang; +Cc: lgirdwood, perex, tiwai, patches, alsa-devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 821 bytes --] 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. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 0/2] *** wm8962 regmap related fix *** @ 2015-10-06 7:06 Jiada Wang 2015-10-06 7:06 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang 0 siblings, 1 reply; 9+ messages in thread From: Jiada Wang @ 2015-10-06 7:06 UTC (permalink / raw) To: lgirdwood, broonie, perex, tiwai, patches, alsa-devel, linux-kernel Cc: jiada_wang 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. 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.4.5 ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume 2015-10-06 7:06 [PATCH 0/2] *** wm8962 regmap related fix *** Jiada Wang @ 2015-10-06 7:06 ` Jiada Wang 2015-10-06 10:59 ` Mark Brown 0 siblings, 1 reply; 9+ messages in thread From: Jiada Wang @ 2015-10-06 7:06 UTC (permalink / raw) To: lgirdwood, broonie, perex, tiwai, patches, alsa-devel, linux-kernel Cc: 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(). Signed-off-by: Jiada Wang <jiada_wang@mentor.com> --- sound/soc/codecs/wm8962.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index 293e47a..319ee38 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c @@ -3805,6 +3805,13 @@ static int wm8962_runtime_resume(struct device *dev) wm8962_reset(wm8962); + /* All registers have been reset to default value without calling + * to regmap interface, even if reset fails, some registers + * maybe in intermediate status, so we need to mark regmap + * cache_dirty flag. + */ + 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. */ -- 2.4.5 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume 2015-10-06 7:06 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang @ 2015-10-06 10:59 ` Mark Brown 2015-10-08 1:34 ` Jiada Wang 0 siblings, 1 reply; 9+ messages in thread From: Mark Brown @ 2015-10-06 10:59 UTC (permalink / raw) To: Jiada Wang; +Cc: lgirdwood, perex, tiwai, patches, alsa-devel, linux-kernel [-- Attachment #1: Type: text/plain, Size: 533 bytes --] On Tue, Oct 06, 2015 at 04:06:54PM +0900, Jiada Wang wrote: > + /* All registers have been reset to default value without calling > + * to regmap interface, even if reset fails, some registers > + * maybe in intermediate status, so we need to mark regmap > + * cache_dirty flag. > + */ > + regcache_mark_dirty(wm8962->regmap); This is a standard thing that applies to almost all devices, there should be no need for such an extensive comment (which would normally flag up that there's something weird and surprising going on). [-- Attachment #2: Digital signature --] [-- Type: application/pgp-signature, Size: 473 bytes --] ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume 2015-10-06 10:59 ` Mark Brown @ 2015-10-08 1:34 ` Jiada Wang 0 siblings, 0 replies; 9+ messages in thread From: Jiada Wang @ 2015-10-08 1:34 UTC (permalink / raw) To: Mark Brown; +Cc: lgirdwood, perex, tiwai, patches, alsa-devel, linux-kernel Hi On 10/06/2015 07:59 PM, Mark Brown wrote: > On Tue, Oct 06, 2015 at 04:06:54PM +0900, Jiada Wang wrote: > >> + /* All registers have been reset to default value without calling >> + * to regmap interface, even if reset fails, some registers >> + * maybe in intermediate status, so we need to mark regmap >> + * cache_dirty flag. >> + */ >> + regcache_mark_dirty(wm8962->regmap); > > This is a standard thing that applies to almost all devices, there > should be no need for such an extensive comment (which would normally > flag up that there's something weird and surprising going on). > Will remove the comment in next update ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-10-22 23:34 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-10-20 2:47 [PATCH v2 0/2] *** wm8962 regmap related fix *** Jiada Wang 2015-10-20 2:47 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang 2015-10-20 7:55 ` Charles Keepax 2015-10-20 2:47 ` [PATCH 2/2] ASoC: Codec: wm8962: declare ALC Coefficients as 4 separate registers Jiada Wang 2015-10-20 8:59 ` Charles Keepax 2015-10-22 12:38 ` Mark Brown -- strict thread matches above, loose matches on Subject: below -- 2015-10-06 7:06 [PATCH 0/2] *** wm8962 regmap related fix *** Jiada Wang 2015-10-06 7:06 ` [PATCH 1/2] ASoC: WM8962: mark cache_dirty flag after software reset in pm_resume Jiada Wang 2015-10-06 10:59 ` Mark Brown 2015-10-08 1:34 ` Jiada Wang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox