Skip to contentSkip to conversation

sound/sgtl5000: fix codec clock source transition to avoid clockless moment

PATCH Applied Oskar Schirmer 2 participants 2 messages Aug 5, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sound/sgtl5000: fix codec clock source transition to avoid clockless moment

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.

---
 sound/soc/codecs/sgtl5000.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
sound/soc/codecs/sgtl5000.c +6 -3
index 6c8a9e7..8ecb201 100644
@@ -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;
 }
 
Signature · 1 line
1.7.9.5
maintainer Applied
#1 lore raw
Quoted 4 lines · 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.

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