From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sebastian Reichel <sebastian.reichel@collabora.com>, Fabio Estevam <festivem@gmail.com>, Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>, alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 4.9 04/17] ASoC: sgtl5000: Fix VAG power-on handling Date: Thu, 30 Apr 2020 09:54:20 -0400 [thread overview] Message-ID: <20200430135433.21204-4-sashal@kernel.org> (raw) In-Reply-To: <20200430135433.21204-1-sashal@kernel.org> From: Sebastian Reichel <sebastian.reichel@collabora.com> [ Upstream commit aa7812737f2877e192d57626cbe8825cc7cf6de9 ] As mentioned slightly out of patch context in the code, there is no reset routine for the chip. On boards where the chip is supplied by a fixed regulator, it might not even be resetted during (e.g. watchdog) reboot and can be in any state. If the device is probed with VAG enabled, the driver's probe routine will generate a loud pop sound when ANA_POWER is being programmed. Avoid this by properly disabling just the VAG bit and waiting the required power down time. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Fabio Estevam <festivem@gmail.com> Link: https://lore.kernel.org/r/20200414181140.145825-1-sebastian.reichel@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- sound/soc/codecs/sgtl5000.c | 34 ++++++++++++++++++++++++++++++++++ sound/soc/codecs/sgtl5000.h | 1 + 2 files changed, 35 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 39810b713d5f2..0c2a1413a8f57 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1464,6 +1464,40 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, dev_err(&client->dev, "Error %d initializing CHIP_CLK_CTRL\n", ret); + /* Mute everything to avoid pop from the following power-up */ + ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_CTRL, + SGTL5000_CHIP_ANA_CTRL_DEFAULT); + if (ret) { + dev_err(&client->dev, + "Error %d muting outputs via CHIP_ANA_CTRL\n", ret); + goto disable_clk; + } + + /* + * If VAG is powered-on (e.g. from previous boot), it would be disabled + * by the write to ANA_POWER in later steps of the probe code. This + * may create a loud pop even with all outputs muted. The proper way + * to circumvent this is disabling the bit first and waiting the proper + * cool-down time. + */ + ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, &value); + if (ret) { + dev_err(&client->dev, "Failed to read ANA_POWER: %d\n", ret); + goto disable_clk; + } + if (value & SGTL5000_VAG_POWERUP) { + ret = regmap_update_bits(sgtl5000->regmap, + SGTL5000_CHIP_ANA_POWER, + SGTL5000_VAG_POWERUP, + 0); + if (ret) { + dev_err(&client->dev, "Error %d disabling VAG\n", ret); + goto disable_clk; + } + + msleep(SGTL5000_VAG_POWERDOWN_DELAY); + } + /* Follow section 2.2.1.1 of AN3663 */ ana_pwr = SGTL5000_ANA_POWER_DEFAULT; if (sgtl5000->num_supplies <= VDDD) { diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 22f3442af9826..9ea41749d0375 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -236,6 +236,7 @@ /* * SGTL5000_CHIP_ANA_CTRL */ +#define SGTL5000_CHIP_ANA_CTRL_DEFAULT 0x0133 #define SGTL5000_LINE_OUT_MUTE 0x0100 #define SGTL5000_HP_SEL_MASK 0x0040 #define SGTL5000_HP_SEL_SHIFT 6 -- 2.20.1
WARNING: multiple messages have this Message-ID (diff)
From: Sasha Levin <sashal@kernel.org> To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sasha Levin <sashal@kernel.org>, alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org>, Fabio Estevam <festivem@gmail.com>, Sebastian Reichel <sebastian.reichel@collabora.com> Subject: [PATCH AUTOSEL 4.9 04/17] ASoC: sgtl5000: Fix VAG power-on handling Date: Thu, 30 Apr 2020 09:54:20 -0400 [thread overview] Message-ID: <20200430135433.21204-4-sashal@kernel.org> (raw) In-Reply-To: <20200430135433.21204-1-sashal@kernel.org> From: Sebastian Reichel <sebastian.reichel@collabora.com> [ Upstream commit aa7812737f2877e192d57626cbe8825cc7cf6de9 ] As mentioned slightly out of patch context in the code, there is no reset routine for the chip. On boards where the chip is supplied by a fixed regulator, it might not even be resetted during (e.g. watchdog) reboot and can be in any state. If the device is probed with VAG enabled, the driver's probe routine will generate a loud pop sound when ANA_POWER is being programmed. Avoid this by properly disabling just the VAG bit and waiting the required power down time. Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com> Reviewed-by: Fabio Estevam <festivem@gmail.com> Link: https://lore.kernel.org/r/20200414181140.145825-1-sebastian.reichel@collabora.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- sound/soc/codecs/sgtl5000.c | 34 ++++++++++++++++++++++++++++++++++ sound/soc/codecs/sgtl5000.h | 1 + 2 files changed, 35 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 39810b713d5f2..0c2a1413a8f57 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1464,6 +1464,40 @@ static int sgtl5000_i2c_probe(struct i2c_client *client, dev_err(&client->dev, "Error %d initializing CHIP_CLK_CTRL\n", ret); + /* Mute everything to avoid pop from the following power-up */ + ret = regmap_write(sgtl5000->regmap, SGTL5000_CHIP_ANA_CTRL, + SGTL5000_CHIP_ANA_CTRL_DEFAULT); + if (ret) { + dev_err(&client->dev, + "Error %d muting outputs via CHIP_ANA_CTRL\n", ret); + goto disable_clk; + } + + /* + * If VAG is powered-on (e.g. from previous boot), it would be disabled + * by the write to ANA_POWER in later steps of the probe code. This + * may create a loud pop even with all outputs muted. The proper way + * to circumvent this is disabling the bit first and waiting the proper + * cool-down time. + */ + ret = regmap_read(sgtl5000->regmap, SGTL5000_CHIP_ANA_POWER, &value); + if (ret) { + dev_err(&client->dev, "Failed to read ANA_POWER: %d\n", ret); + goto disable_clk; + } + if (value & SGTL5000_VAG_POWERUP) { + ret = regmap_update_bits(sgtl5000->regmap, + SGTL5000_CHIP_ANA_POWER, + SGTL5000_VAG_POWERUP, + 0); + if (ret) { + dev_err(&client->dev, "Error %d disabling VAG\n", ret); + goto disable_clk; + } + + msleep(SGTL5000_VAG_POWERDOWN_DELAY); + } + /* Follow section 2.2.1.1 of AN3663 */ ana_pwr = SGTL5000_ANA_POWER_DEFAULT; if (sgtl5000->num_supplies <= VDDD) { diff --git a/sound/soc/codecs/sgtl5000.h b/sound/soc/codecs/sgtl5000.h index 22f3442af9826..9ea41749d0375 100644 --- a/sound/soc/codecs/sgtl5000.h +++ b/sound/soc/codecs/sgtl5000.h @@ -236,6 +236,7 @@ /* * SGTL5000_CHIP_ANA_CTRL */ +#define SGTL5000_CHIP_ANA_CTRL_DEFAULT 0x0133 #define SGTL5000_LINE_OUT_MUTE 0x0100 #define SGTL5000_HP_SEL_MASK 0x0040 #define SGTL5000_HP_SEL_SHIFT 6 -- 2.20.1
next prev parent reply other threads:[~2020-04-30 13:58 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-30 13:54 [PATCH AUTOSEL 4.9 01/17] iio:ad7797: Use correct attribute_group Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 02/17] nfsd: memory corruption in nfsd4_lock() Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 03/17] selftests/ipc: Fix test failure seen after initial test run Sasha Levin 2020-04-30 13:54 ` Sasha Levin [this message] 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 04/17] ASoC: sgtl5000: Fix VAG power-on handling Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 05/17] wimax/i2400m: Fix potential urb refcnt leak Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 06/17] net: stmmac: Fix sub-second increment Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 07/17] team: fix hang in team_mode_get() Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 08/17] cifs: protect updating server->dstaddr with a spinlock Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 09/17] macvlan: fix null dereference in macvlan_device_event() Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 10/17] scripts/config: allow colons in option strings for sed Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 11/17] net: dsa: b53: Fix ARL register definitions Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 12/17] net: dsa: b53: Rework ARL bin logic Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 13/17] perf/core: fix parent pid/tid in task exit events Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 14/17] lib/mpi: Fix building for powerpc with clang Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 15/17] macsec: avoid to set wrong mtu Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 16/17] net: bcmgenet: suppress warnings on failed Rx SKB allocations Sasha Levin 2020-04-30 13:54 ` [PATCH AUTOSEL 4.9 17/17] net: systemport: " Sasha Levin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200430135433.21204-4-sashal@kernel.org \ --to=sashal@kernel.org \ --cc=alsa-devel@alsa-project.org \ --cc=broonie@kernel.org \ --cc=festivem@gmail.com \ --cc=linux-kernel@vger.kernel.org \ --cc=sebastian.reichel@collabora.com \ --cc=stable@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.