All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
To: <shawn.guo@freescale.com>, <kernel@pengutronix.de>,
	<robh+dt@kernel.org>, <pawel.moll@arm.com>,
	<mark.rutland@arm.com>, <ijc+devicetree@hellion.org.uk>,
	<galak@codeaurora.org>, <linux@arm.linux.org.uk>,
	<perex@perex.cz>, <tiwai@suse.de>
Cc: <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<=devicetree@vger.kernel.org>, <alsa-devel@alsa-project.org>,
	Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
Subject: [PATCH v2 4/4] ASoC: tlv320aic3x: fix PLL D configuration
Date: Fri, 12 Sep 2014 19:04:32 +0300	[thread overview]
Message-ID: <1410537872-17274-5-git-send-email-d.lavnikevich@sam-solutions.com> (raw)
In-Reply-To: <1410537872-17274-1-git-send-email-d.lavnikevich@sam-solutions.com>

Current caching implementation during regcache_sync() call bypasses
all register writes of values that are already known as default
(regmap reg_defaults). Same time in TLV320AIC3x codecs register 5
(AIC3X_PLL_PROGC_REG) write should be immediately followed by register
6 write (AIC3X_PLL_PROGD_REG) even if it was not changed. Otherwise
both registers will not be written.

This brings to issue that appears particulary in case of 44.1kHz
playback with 19.2MHz master clock. In this case AIC3X_PLL_PROGC_REG
is 0x6e while AIC3X_PLL_PROGD_REG is 0x0 (same as register
default). Thus AIC3X_PLL_PROGC_REG also remains not written and we get
wrong playback speed.

In this patch snd_soc_read() is used to get cached pll values and
snd_soc_write() (unlike regcache_sync() this function doesn't bypasses
hardware default values) to write them to registers.

Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
---
 sound/soc/codecs/tlv320aic3x.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 64f179ee9834..5e8626ae612b 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1121,6 +1121,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
 static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 {
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+	unsigned int pll_c, pll_d;
 	int ret;
 
 	if (power) {
@@ -1138,6 +1139,18 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 		/* Sync reg_cache with the hardware */
 		regcache_cache_only(aic3x->regmap, false);
 		regcache_sync(aic3x->regmap);
+
+		/* Rewrite paired PLL D registers in case cached sync skipped
+		 * writing one of them and thus caused other one also not
+		 * being written
+		 */
+		pll_c = snd_soc_read(codec, AIC3X_PLL_PROGC_REG);
+		pll_d = snd_soc_read(codec, AIC3X_PLL_PROGD_REG);
+		if (pll_c == aic3x_reg[AIC3X_PLL_PROGC_REG].def ||
+			pll_d == aic3x_reg[AIC3X_PLL_PROGD_REG].def) {
+			snd_soc_write(codec, AIC3X_PLL_PROGC_REG, pll_c);
+			snd_soc_write(codec, AIC3X_PLL_PROGD_REG, pll_d);
+		}
 	} else {
 		/*
 		 * Do soft reset to this codec instance in order to clear
-- 
2.1.0


WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
To: shawn.guo@freescale.com, kernel@pengutronix.de,
	robh+dt@kernel.org, pawel.moll@arm.com, mark.rutland@arm.com,
	ijc+devicetree@hellion.org.uk, galak@codeaurora.org,
	linux@arm.linux.org.uk, perex@perex.cz, tiwai@suse.de
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	=devicetree@vger.kernel.org, alsa-devel@alsa-project.org,
	Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
Subject: [PATCH v2 4/4] ASoC: tlv320aic3x: fix PLL D configuration
Date: Fri, 12 Sep 2014 19:04:32 +0300	[thread overview]
Message-ID: <1410537872-17274-5-git-send-email-d.lavnikevich@sam-solutions.com> (raw)
In-Reply-To: <1410537872-17274-1-git-send-email-d.lavnikevich@sam-solutions.com>

Current caching implementation during regcache_sync() call bypasses
all register writes of values that are already known as default
(regmap reg_defaults). Same time in TLV320AIC3x codecs register 5
(AIC3X_PLL_PROGC_REG) write should be immediately followed by register
6 write (AIC3X_PLL_PROGD_REG) even if it was not changed. Otherwise
both registers will not be written.

This brings to issue that appears particulary in case of 44.1kHz
playback with 19.2MHz master clock. In this case AIC3X_PLL_PROGC_REG
is 0x6e while AIC3X_PLL_PROGD_REG is 0x0 (same as register
default). Thus AIC3X_PLL_PROGC_REG also remains not written and we get
wrong playback speed.

In this patch snd_soc_read() is used to get cached pll values and
snd_soc_write() (unlike regcache_sync() this function doesn't bypasses
hardware default values) to write them to registers.

Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
---
 sound/soc/codecs/tlv320aic3x.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 64f179ee9834..5e8626ae612b 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1121,6 +1121,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
 static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 {
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+	unsigned int pll_c, pll_d;
 	int ret;
 
 	if (power) {
@@ -1138,6 +1139,18 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 		/* Sync reg_cache with the hardware */
 		regcache_cache_only(aic3x->regmap, false);
 		regcache_sync(aic3x->regmap);
+
+		/* Rewrite paired PLL D registers in case cached sync skipped
+		 * writing one of them and thus caused other one also not
+		 * being written
+		 */
+		pll_c = snd_soc_read(codec, AIC3X_PLL_PROGC_REG);
+		pll_d = snd_soc_read(codec, AIC3X_PLL_PROGD_REG);
+		if (pll_c == aic3x_reg[AIC3X_PLL_PROGC_REG].def ||
+			pll_d == aic3x_reg[AIC3X_PLL_PROGD_REG].def) {
+			snd_soc_write(codec, AIC3X_PLL_PROGC_REG, pll_c);
+			snd_soc_write(codec, AIC3X_PLL_PROGD_REG, pll_d);
+		}
 	} else {
 		/*
 		 * Do soft reset to this codec instance in order to clear
-- 
2.1.0

WARNING: multiple messages have this Message-ID (diff)
From: d.lavnikevich@sam-solutions.com (Dmitry Lavnikevich)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 4/4] ASoC: tlv320aic3x: fix PLL D configuration
Date: Fri, 12 Sep 2014 19:04:32 +0300	[thread overview]
Message-ID: <1410537872-17274-5-git-send-email-d.lavnikevich@sam-solutions.com> (raw)
In-Reply-To: <1410537872-17274-1-git-send-email-d.lavnikevich@sam-solutions.com>

Current caching implementation during regcache_sync() call bypasses
all register writes of values that are already known as default
(regmap reg_defaults). Same time in TLV320AIC3x codecs register 5
(AIC3X_PLL_PROGC_REG) write should be immediately followed by register
6 write (AIC3X_PLL_PROGD_REG) even if it was not changed. Otherwise
both registers will not be written.

This brings to issue that appears particulary in case of 44.1kHz
playback with 19.2MHz master clock. In this case AIC3X_PLL_PROGC_REG
is 0x6e while AIC3X_PLL_PROGD_REG is 0x0 (same as register
default). Thus AIC3X_PLL_PROGC_REG also remains not written and we get
wrong playback speed.

In this patch snd_soc_read() is used to get cached pll values and
snd_soc_write() (unlike regcache_sync() this function doesn't bypasses
hardware default values) to write them to registers.

Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com>
---
 sound/soc/codecs/tlv320aic3x.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c
index 64f179ee9834..5e8626ae612b 100644
--- a/sound/soc/codecs/tlv320aic3x.c
+++ b/sound/soc/codecs/tlv320aic3x.c
@@ -1121,6 +1121,7 @@ static int aic3x_regulator_event(struct notifier_block *nb,
 static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 {
 	struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);
+	unsigned int pll_c, pll_d;
 	int ret;
 
 	if (power) {
@@ -1138,6 +1139,18 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power)
 		/* Sync reg_cache with the hardware */
 		regcache_cache_only(aic3x->regmap, false);
 		regcache_sync(aic3x->regmap);
+
+		/* Rewrite paired PLL D registers in case cached sync skipped
+		 * writing one of them and thus caused other one also not
+		 * being written
+		 */
+		pll_c = snd_soc_read(codec, AIC3X_PLL_PROGC_REG);
+		pll_d = snd_soc_read(codec, AIC3X_PLL_PROGD_REG);
+		if (pll_c == aic3x_reg[AIC3X_PLL_PROGC_REG].def ||
+			pll_d == aic3x_reg[AIC3X_PLL_PROGD_REG].def) {
+			snd_soc_write(codec, AIC3X_PLL_PROGC_REG, pll_c);
+			snd_soc_write(codec, AIC3X_PLL_PROGD_REG, pll_d);
+		}
 	} else {
 		/*
 		 * Do soft reset to this codec instance in order to clear
-- 
2.1.0

  parent reply	other threads:[~2014-09-12 16:04 UTC|newest]

Thread overview: 139+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-10 13:46 [PATCH 0/5] Add Phytec pbab01 audio support Dmitry Lavnikevich
2014-09-10 13:46 ` Dmitry Lavnikevich
2014-09-10 13:46 ` Dmitry Lavnikevich
2014-09-10 13:46 ` [PATCH 1/5] ARM: dts: pbab01: move i2c pins and frequency configuration into pfla02 Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-11  8:47   ` Philipp Zabel
2014-09-11  8:47     ` Philipp Zabel
2014-09-11  8:47     ` Philipp Zabel
2014-09-12 15:55     ` Dmitry Lavnikevich
2014-09-12 15:55       ` Dmitry Lavnikevich
2014-09-12 15:55       ` Dmitry Lavnikevich
2014-09-10 13:46 ` [PATCH 2/5] ASoC: fsl: add imx-tlv320aic3x machine driver Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 14:19   ` Lothar Waßmann
2014-09-10 14:19     ` Lothar Waßmann
2014-09-10 14:19     ` Lothar Waßmann
2014-09-10 14:27   ` [alsa-devel] " Markus Pargmann
2014-09-10 14:27     ` Markus Pargmann
2014-09-10 14:27     ` Markus Pargmann
2014-09-10 18:14     ` [alsa-devel] " Nicolin Chen
2014-09-10 18:14       ` Nicolin Chen
2014-09-11  6:40       ` Markus Pargmann
2014-09-11  6:40         ` Markus Pargmann
2014-09-11  6:40         ` Markus Pargmann
2014-09-11 12:41         ` Dmitry Lavnikevich
2014-09-11 12:41           ` Dmitry Lavnikevich
2014-09-11 12:41           ` Dmitry Lavnikevich
2014-09-10 18:07   ` Nicolin Chen
2014-09-10 18:07     ` Nicolin Chen
2014-09-10 18:07     ` Nicolin Chen
2014-09-10 13:46 ` [PATCH 3/5] ARM: imx_v6_v7_defconfig: enable imx-tlv320aic3x by default Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46 ` [PATCH 4/5] ARM: dts: pbab01: enable I2S audio on phyFLEX-i.MX6 boards Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46 ` [PATCH 5/5] ASoC: tlv320aic3x: fix PLL D configuration Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-10 13:46   ` Dmitry Lavnikevich
2014-09-12 16:04 ` [PATCH v2 0/5] Add Phytec pbab01 audio support Dmitry Lavnikevich
2014-09-12 16:04   ` Dmitry Lavnikevich
2014-09-12 16:04   ` Dmitry Lavnikevich
2014-09-12 16:04   ` Dmitry Lavnikevich
2014-09-12 16:04   ` [PATCH v2 1/4] ARM: dts: pbab01: move i2c pins and frequency configuration into pfla02 Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04   ` [PATCH v2 2/4] ARM: dts: pbab01: enable I2S audio on phyFLEX-i.MX6 boards Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:14     ` Alexander Shiyan
2014-09-12 16:14       ` Alexander Shiyan
2014-09-12 16:14       ` Alexander Shiyan
2014-09-12 16:14       ` Alexander Shiyan
2014-09-15 12:04       ` Dmitry Lavnikevich
2014-09-15 12:04         ` Dmitry Lavnikevich
2014-09-15 12:04         ` Dmitry Lavnikevich
2014-09-12 16:26     ` Alexander Shiyan
2014-09-12 16:26       ` Alexander Shiyan
2014-09-12 16:26       ` Alexander Shiyan
2014-09-12 16:40       ` [alsa-devel] " Fabio Estevam
2014-09-12 16:40         ` Fabio Estevam
2014-09-12 16:40         ` Fabio Estevam
2014-09-15 12:07         ` Dmitry Lavnikevich
2014-09-15 12:07           ` Dmitry Lavnikevich
2014-09-15 12:07           ` Dmitry Lavnikevich
2014-09-16  1:46           ` Shawn Guo
2014-09-16  1:46             ` Shawn Guo
2014-09-16  1:46             ` Shawn Guo
2014-09-12 16:04   ` [PATCH v2 3/4] ARM: imx_v6_v7_defconfig: enable tlv320aic3x and simple-audio-card by default Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-12 16:04   ` Dmitry Lavnikevich [this message]
2014-09-12 16:04     ` [PATCH v2 4/4] ASoC: tlv320aic3x: fix PLL D configuration Dmitry Lavnikevich
2014-09-12 16:04     ` Dmitry Lavnikevich
2014-09-16  8:08   ` [PATCH v3 0/4] Add Phytec pbab01 audio support Dmitry Lavnikevich
2014-09-16  8:08     ` Dmitry Lavnikevich
2014-09-16  8:08     ` Dmitry Lavnikevich
2014-09-16  8:08     ` [PATCH v3 1/4] ARM: dts: pbab01: move i2c pins and frequency configuration into pfla02 Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08     ` [PATCH v3 2/4] ARM: dts: pbab01: enable I2S audio on phyFLEX-i.MX6 boards Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-10-01 12:11       ` Fabio Estevam
2014-10-01 12:11         ` Fabio Estevam
2014-10-01 12:11         ` Fabio Estevam
2014-10-01 13:40         ` Dmitry Lavnikevich
2014-10-01 13:40           ` Dmitry Lavnikevich
2014-10-01 13:40           ` Dmitry Lavnikevich
2014-10-01 13:45           ` Fabio Estevam
2014-10-01 13:45             ` Fabio Estevam
2014-10-01 13:45             ` Fabio Estevam
2014-10-01 13:52             ` Dmitry Lavnikevich
2014-10-01 13:52               ` Dmitry Lavnikevich
2014-10-01 13:52               ` Dmitry Lavnikevich
2014-09-16  8:08     ` [PATCH v3 3/4] ARM: imx_v6_v7_defconfig: enable tlv320aic3x audio codec by default Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:08       ` Dmitry Lavnikevich
2014-09-16  8:09     ` [PATCH v3 4/4] ASoC: tlv320aic3x: fix PLL D configuration Dmitry Lavnikevich
2014-09-16  8:09       ` Dmitry Lavnikevich
2014-09-16  8:09       ` Dmitry Lavnikevich
2014-09-16  8:09       ` Dmitry Lavnikevich
2014-10-03 13:18     ` [PATCH v4 0/4] Add Phytec pbab01 audio support Dmitry Lavnikevich
2014-10-03 13:18       ` Dmitry Lavnikevich
2014-10-03 13:18       ` Dmitry Lavnikevich
2014-10-03 13:18       ` [PATCH v4 1/4] ARM: dts: pbab01: move i2c pins and frequency configuration into pfla02 Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18       ` [PATCH v4 2/4] ARM: dts: pbab01: enable I2S audio on phyFLEX-i.MX6 boards Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18       ` [PATCH v4 3/4] ARM: imx_v6_v7_defconfig: enable tlv320aic3x audio codec by default Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18       ` [PATCH v4 4/4] ASoC: tlv320aic3x: fix PLL D configuration Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 13:18         ` Dmitry Lavnikevich
2014-10-03 15:08         ` Mark Brown
2014-10-03 15:08           ` Mark Brown
2014-10-03 15:08           ` Mark Brown
2014-10-03 15:22           ` Dmitry Lavnikevich
2014-10-22  9:08       ` [PATCH v4 0/3 RESEND] Add Phytec pbab01 audio support Dmitry Lavnikevich
2014-10-22  9:08         ` Dmitry Lavnikevich
2014-10-22  9:08         ` Dmitry Lavnikevich
2014-10-22  9:08         ` [PATCH v4 RESEND 1/3] ARM: dts: pbab01: move i2c pins and frequency configuration into pfla02 Dmitry Lavnikevich
2014-10-22  9:08           ` Dmitry Lavnikevich
2014-10-22  9:08           ` Dmitry Lavnikevich
2014-10-22  9:11         ` [PATCH v4 RESEND 3/3] ARM: imx_v6_v7_defconfig: enable tlv320aic3x audio codec by default Dmitry Lavnikevich
2014-10-22  9:11           ` Dmitry Lavnikevich
2014-10-22  9:11           ` Dmitry Lavnikevich
2014-10-22  9:12         ` [PATCH v4 RESEND 2/3] ARM: dts: pbab01: enable I2S audio on phyFLEX-i.MX6 boards Dmitry Lavnikevich
2014-10-22  9:12           ` Dmitry Lavnikevich
2014-10-22  9:12           ` Dmitry Lavnikevich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1410537872-17274-5-git-send-email-d.lavnikevich@sam-solutions.com \
    --to=d.lavnikevich@sam-solutions.com \
    --cc==devicetree@vger.kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=shawn.guo@freescale.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.