All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove
@ 2022-06-24 10:13 Francesco Dolcini
  2022-06-24 10:29 ` Fabio Estevam
  2022-06-24 14:35 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Francesco Dolcini @ 2022-06-24 10:13 UTC (permalink / raw)
  To: Fabio Estevam, Mark Brown
  Cc: alsa-devel, Takashi Iwai, Liam Girdwood, Zeng Zhaoming,
	Francesco Dolcini

Put the SGTL5000 in a silent/safe state on shutdown/remove, this is
required since the SGTL5000 produces a constant noise on its output
after it is configured and its clock is removed. Without this change
this is happening every time the module is unbound/removed or from
reboot till the clock is enabled again.

The issue was experienced on both a Toradex Colibri/Apalis iMX6, but can
be easily reproduced everywhere just playing something on the codec and
after that removing/unbinding the driver.

Fixes: 9b34e6cc3bc2 ("ASoC: Add Freescale SGTL5000 codec support")
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
---
 sound/soc/codecs/sgtl5000.c | 9 +++++++++
 sound/soc/codecs/sgtl5000.h | 1 +
 2 files changed, 10 insertions(+)

diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c
index 2aa48aef6a97..3363d1696ad7 100644
--- a/sound/soc/codecs/sgtl5000.c
+++ b/sound/soc/codecs/sgtl5000.c
@@ -1795,6 +1795,9 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
 {
 	struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client);
 
+	regmap_write(sgtl5000->regmap, SGTL5000_CHIP_DIG_POWER, SGTL5000_DIG_POWER_DEFAULT);
+	regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, SGTL5000_ANA_POWER_DEFAULT);
+
 	clk_disable_unprepare(sgtl5000->mclk);
 	regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies);
 	regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies);
@@ -1802,6 +1805,11 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
 	return 0;
 }
 
+static void sgtl5000_i2c_shutdown(struct i2c_client *client)
+{
+	sgtl5000_i2c_remove(client);
+}
+
 static const struct i2c_device_id sgtl5000_id[] = {
 	{"sgtl5000", 0},
 	{},
@@ -1822,6 +1830,7 @@ static struct i2c_driver sgtl5000_i2c_driver = {
 	},
 	.probe_new = sgtl5000_i2c_probe,
 	.remove = sgtl5000_i2c_remove,
+	.shutdown = sgtl5000_i2c_shutdown,
 	.id_table = sgtl5000_id,
 };
 
diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h
index 56ec5863f250..3a808c762299 100644
--- a/sound/soc/codecs/sgtl5000.h
+++ b/sound/soc/codecs/sgtl5000.h
@@ -80,6 +80,7 @@
 /*
  * SGTL5000_CHIP_DIG_POWER
  */
+#define SGTL5000_DIG_POWER_DEFAULT		0x0000
 #define SGTL5000_ADC_EN				0x0040
 #define SGTL5000_DAC_EN				0x0020
 #define SGTL5000_DAP_POWERUP			0x0010
-- 
2.25.1


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

* Re: [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove
  2022-06-24 10:13 [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove Francesco Dolcini
@ 2022-06-24 10:29 ` Fabio Estevam
  2022-06-24 14:35 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Fabio Estevam @ 2022-06-24 10:29 UTC (permalink / raw)
  To: Francesco Dolcini
  Cc: Linux-ALSA, Takashi Iwai, Liam Girdwood, Mark Brown, Zeng Zhaoming

Hi Francesco,

On Fri, Jun 24, 2022 at 7:13 AM Francesco Dolcini
<francesco.dolcini@toradex.com> wrote:
>
> Put the SGTL5000 in a silent/safe state on shutdown/remove, this is
> required since the SGTL5000 produces a constant noise on its output
> after it is configured and its clock is removed. Without this change
> this is happening every time the module is unbound/removed or from
> reboot till the clock is enabled again.
>
> The issue was experienced on both a Toradex Colibri/Apalis iMX6, but can
> be easily reproduced everywhere just playing something on the codec and
> after that removing/unbinding the driver.
>
> Fixes: 9b34e6cc3bc2 ("ASoC: Add Freescale SGTL5000 codec support")
> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>

Thanks for the fix:

Reviewed-by: Fabio Estevam <festevam@denx.de>

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

* Re: [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove
  2022-06-24 10:13 [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove Francesco Dolcini
  2022-06-24 10:29 ` Fabio Estevam
@ 2022-06-24 14:35 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-06-24 14:35 UTC (permalink / raw)
  To: francesco.dolcini, festevam; +Cc: zhaoming.zeng, alsa-devel, tiwai, lgirdwood

On Fri, 24 Jun 2022 12:13:01 +0200, Francesco Dolcini wrote:
> Put the SGTL5000 in a silent/safe state on shutdown/remove, this is
> required since the SGTL5000 produces a constant noise on its output
> after it is configured and its clock is removed. Without this change
> this is happening every time the module is unbound/removed or from
> reboot till the clock is enabled again.
> 
> The issue was experienced on both a Toradex Colibri/Apalis iMX6, but can
> be easily reproduced everywhere just playing something on the codec and
> after that removing/unbinding the driver.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: sgtl5000: Fix noise on shutdown/remove
      commit: 8070e590dd66b1af68b031da2edf5791fbda7b62

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

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

end of thread, other threads:[~2022-06-24 14:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 10:13 [PATCH v1] ASoC: sgtl5000: Fix noise on shutdown/remove Francesco Dolcini
2022-06-24 10:29 ` Fabio Estevam
2022-06-24 14:35 ` Mark Brown

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.