alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sound/sgtl5000: fix codec clock source transition to avoid clockless moment
@ 2013-08-05  7:36 Oskar Schirmer
  2013-08-05 16:07 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Oskar Schirmer @ 2013-08-05  7:36 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: alsa-devel, Mark Brown, linux-kernel, Zeng Zhaoming,
	Oskar Schirmer

Powering down PLL before switching to a mode that does not use it
is a bad idea. It would cause the SGTL5000 be without internal
clock supply, especially on the I2C interface, which would make
subsequent access to it fail.

Thus, in case of not using PLL any longer, first set the mode
control, then power down PLL.

Signed-off-by: Oskar Schirmer <oskar@scara.com>
---
 sound/soc/codecs/sgtl5000.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 6c8a9e7..8ecb201 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -644,16 +644,19 @@ static int sgtl5000_set_clock(struct snd_soc_codec *codec, int frame_rate)
 		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
 			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
 			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP);
+
+		/* if using pll, clk_ctrl must be set after pll power up */
+		snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
 	} else {
+		/* otherwise, clk_ctrl must be set before pll power down */
+		snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
+
 		/* power down pll */
 		snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
 			SGTL5000_PLL_POWERUP | SGTL5000_VCOAMP_POWERUP,
 			0);
 	}
 
-	/* if using pll, clk_ctrl must be set after pll power up */
-	snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, clk_ctl);
-
 	return 0;
 }
 
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sound/sgtl5000: fix codec clock source transition to avoid clockless moment
  2013-08-05  7:36 [PATCH] sound/sgtl5000: fix codec clock source transition to avoid clockless moment Oskar Schirmer
@ 2013-08-05 16:07 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2013-08-05 16:07 UTC (permalink / raw)
  To: Oskar Schirmer; +Cc: Fabio Estevam, alsa-devel, linux-kernel, Zeng Zhaoming


[-- Attachment #1.1: Type: text/plain, Size: 374 bytes --]

On Mon, Aug 05, 2013 at 07:36:02AM +0000, Oskar Schirmer wrote:
> Powering down PLL before switching to a mode that does not use it
> is a bad idea. It would cause the SGTL5000 be without internal
> clock supply, especially on the I2C interface, which would make
> subsequent access to it fail.

Applied, thanks.  Please do use subject lines corresponding to the
subsystem.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-05 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-05  7:36 [PATCH] sound/sgtl5000: fix codec clock source transition to avoid clockless moment Oskar Schirmer
2013-08-05 16:07 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).