Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 9b34e6cc3bc2 ("ASoC: Add Freescale SGTL5000 codec support")
Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Link: https://lore.kernel.org/r/20220624101301.441314-1-francesco.dolcini@toradex.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Francesco Dolcini and committed by
Mark Brown
040e3360 980555e9

+10
+9
sound/soc/codecs/sgtl5000.c
··· 1795 1795 { 1796 1796 struct sgtl5000_priv *sgtl5000 = i2c_get_clientdata(client); 1797 1797 1798 + regmap_write(sgtl5000->regmap, SGTL5000_CHIP_DIG_POWER, SGTL5000_DIG_POWER_DEFAULT); 1799 + regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, SGTL5000_ANA_POWER_DEFAULT); 1800 + 1798 1801 clk_disable_unprepare(sgtl5000->mclk); 1799 1802 regulator_bulk_disable(sgtl5000->num_supplies, sgtl5000->supplies); 1800 1803 regulator_bulk_free(sgtl5000->num_supplies, sgtl5000->supplies); 1801 1804 1802 1805 return 0; 1806 + } 1807 + 1808 + static void sgtl5000_i2c_shutdown(struct i2c_client *client) 1809 + { 1810 + sgtl5000_i2c_remove(client); 1803 1811 } 1804 1812 1805 1813 static const struct i2c_device_id sgtl5000_id[] = { ··· 1830 1822 }, 1831 1823 .probe_new = sgtl5000_i2c_probe, 1832 1824 .remove = sgtl5000_i2c_remove, 1825 + .shutdown = sgtl5000_i2c_shutdown, 1833 1826 .id_table = sgtl5000_id, 1834 1827 }; 1835 1828
+1
sound/soc/codecs/sgtl5000.h
··· 80 80 /* 81 81 * SGTL5000_CHIP_DIG_POWER 82 82 */ 83 + #define SGTL5000_DIG_POWER_DEFAULT 0x0000 83 84 #define SGTL5000_ADC_EN 0x0040 84 85 #define SGTL5000_DAC_EN 0x0020 85 86 #define SGTL5000_DAP_POWERUP 0x0010