Commit 040e3360 authored by Francesco Dolcini's avatar Francesco Dolcini Committed by Mark Brown

ASoC: sgtl5000: Fix noise on shutdown/remove

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: 9b34e6cc ("ASoC: Add Freescale SGTL5000 codec support")
Signed-off-by: default avatarFrancesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: default avatarFabio Estevam <festevam@denx.de>
Link: https://lore.kernel.org/r/20220624101301.441314-1-francesco.dolcini@toradex.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 980555e9
...@@ -1795,6 +1795,9 @@ static int sgtl5000_i2c_remove(struct i2c_client *client) ...@@ -1795,6 +1795,9 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
{ {
struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(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); clk_disable_unprepare(sgtl5000->mclk);
regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies);
regulator_bulk_free(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) ...@@ -1802,6 +1805,11 @@ static int sgtl5000_i2c_remove(struct i2c_client *client)
return 0; return 0;
} }
static void sgtl5000_i2c_shutdown(struct i2c_client *client)
{
sgtl5000_i2c_remove(client);
}
static const struct i2c_device_id sgtl5000_id[] = { static const struct i2c_device_id sgtl5000_id[] = {
{"sgtl5000", 0}, {"sgtl5000", 0},
{}, {},
...@@ -1822,6 +1830,7 @@ static struct i2c_driver sgtl5000_i2c_driver = { ...@@ -1822,6 +1830,7 @@ static struct i2c_driver sgtl5000_i2c_driver = {
}, },
.probe_new = sgtl5000_i2c_probe, .probe_new = sgtl5000_i2c_probe,
.remove = sgtl5000_i2c_remove, .remove = sgtl5000_i2c_remove,
.shutdown = sgtl5000_i2c_shutdown,
.id_table = sgtl5000_id, .id_table = sgtl5000_id,
}; };
......
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
/* /*
* SGTL5000_CHIP_DIG_POWER * SGTL5000_CHIP_DIG_POWER
*/ */
#define SGTL5000_DIG_POWER_DEFAULT 0x0000
#define SGTL5000_ADC_EN 0x0040 #define SGTL5000_ADC_EN 0x0040
#define SGTL5000_DAC_EN 0x0020 #define SGTL5000_DAC_EN 0x0020
#define SGTL5000_DAP_POWERUP 0x0010 #define SGTL5000_DAP_POWERUP 0x0010
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment