From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Xiaolei Wang <xiaolei.wang@windriver.com>,
Adam Ford <aford173@gmail.com>,
Charles Keepax <ckeepax@opensource.cirrus.com>,
Mark Brown <broonie@kernel.org>, Sasha Levin <sashal@kernel.org>,
lgirdwood@gmail.com, perex@perex.cz, tiwai@suse.com,
steve@sk2.org, chi.minghao@zte.com.cn,
patches@opensource.cirrus.com, alsa-devel@alsa-project.org
Subject: [PATCH AUTOSEL 6.0 09/30] ASoC: wm8962: Add an event handler for TEMP_HP and TEMP_SPK
Date: Sun, 6 Nov 2022 12:03:21 -0500 [thread overview]
Message-ID: <20221106170345.1579893-9-sashal@kernel.org> (raw)
In-Reply-To: <20221106170345.1579893-1-sashal@kernel.org>
From: Xiaolei Wang <xiaolei.wang@windriver.com>
[ Upstream commit ee1aa2ae3eaa96e70229fa61deee87ef4528ffdf ]
In wm8962 driver, the WM8962_ADDITIONAL_CONTROL_4 is used as a volatile
register, but this register mixes a bunch of volatile status bits and a
bunch of non-volatile control bits. The dapm widgets TEMP_HP and
TEMP_SPK leverages the control bits in this register. After the wm8962
probe, the regmap will bet set to cache only mode, then a read error
like below would be triggered when trying to read the initial power
state of the dapm widgets TEMP_HP and TEMP_SPK.
wm8962 0-001a: ASoC: error at soc_component_read_no_lock
on wm8962.0-001a: -16
In order to fix this issue, we add event handler to actually power
up/down these widgets. With this change, we also need to explicitly
power off these widgets in the wm8962 probe since they are enabled
by default.
Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
Tested-by: Adam Ford <aford173@gmail.com>
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20221010092014.2229246-1-xiaolei.wang@windriver.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
sound/soc/codecs/wm8962.c | 54 +++++++++++++++++++++++++++++++++++++--
1 file changed, 52 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 398c448ea854..6df06fba4377 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -1840,6 +1840,49 @@ SOC_SINGLE_TLV("SPKOUTR Mixer DACR Volume", WM8962_SPEAKER_MIXER_5,
4, 1, 0, inmix_tlv),
};
+static int tp_event(struct snd_soc_dapm_widget *w,
+ struct snd_kcontrol *kcontrol, int event)
+{
+ int ret, reg, val, mask;
+ struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
+
+ ret = pm_runtime_resume_and_get(component->dev);
+ if (ret < 0) {
+ dev_err(component->dev, "Failed to resume device: %d\n", ret);
+ return ret;
+ }
+
+ reg = WM8962_ADDITIONAL_CONTROL_4;
+
+ if (!strcmp(w->name, "TEMP_HP")) {
+ mask = WM8962_TEMP_ENA_HP_MASK;
+ val = WM8962_TEMP_ENA_HP;
+ } else if (!strcmp(w->name, "TEMP_SPK")) {
+ mask = WM8962_TEMP_ENA_SPK_MASK;
+ val = WM8962_TEMP_ENA_SPK;
+ } else {
+ pm_runtime_put(component->dev);
+ return -EINVAL;
+ }
+
+ switch (event) {
+ case SND_SOC_DAPM_POST_PMD:
+ val = 0;
+ fallthrough;
+ case SND_SOC_DAPM_POST_PMU:
+ ret = snd_soc_component_update_bits(component, reg, mask, val);
+ break;
+ default:
+ WARN(1, "Invalid event %d\n", event);
+ pm_runtime_put(component->dev);
+ return -EINVAL;
+ }
+
+ pm_runtime_put(component->dev);
+
+ return 0;
+}
+
static int cp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *kcontrol, int event)
{
@@ -2140,8 +2183,10 @@ SND_SOC_DAPM_SUPPLY("TOCLK", WM8962_ADDITIONAL_CONTROL_1, 0, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY_S("DSP2", 1, WM8962_DSP2_POWER_MANAGEMENT,
WM8962_DSP2_ENA_SHIFT, 0, dsp2_event,
SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD),
-SND_SOC_DAPM_SUPPLY("TEMP_HP", WM8962_ADDITIONAL_CONTROL_4, 2, 0, NULL, 0),
-SND_SOC_DAPM_SUPPLY("TEMP_SPK", WM8962_ADDITIONAL_CONTROL_4, 1, 0, NULL, 0),
+SND_SOC_DAPM_SUPPLY("TEMP_HP", SND_SOC_NOPM, 0, 0, tp_event,
+ SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
+SND_SOC_DAPM_SUPPLY("TEMP_SPK", SND_SOC_NOPM, 0, 0, tp_event,
+ SND_SOC_DAPM_POST_PMU|SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_MIXER("INPGAL", WM8962_LEFT_INPUT_PGA_CONTROL, 4, 0,
inpgal, ARRAY_SIZE(inpgal)),
@@ -3763,6 +3808,11 @@ static int wm8962_i2c_probe(struct i2c_client *i2c)
if (ret < 0)
goto err_pm_runtime;
+ regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
+ WM8962_TEMP_ENA_HP_MASK, 0);
+ regmap_update_bits(wm8962->regmap, WM8962_ADDITIONAL_CONTROL_4,
+ WM8962_TEMP_ENA_SPK_MASK, 0);
+
regcache_cache_only(wm8962->regmap, true);
/* The drivers should power up as needed */
--
2.35.1
next prev parent reply other threads:[~2022-11-06 17:04 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-06 17:03 [PATCH AUTOSEL 6.0 01/30] drm/msm/gpu: Fix crash during system suspend after unbind Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 02/30] spi: tegra210-quad: Fix combined sequence Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 03/30] ASoC: wm5102: Revert "ASoC: wm5102: Fix PM disable depth imbalance in wm5102_probe" Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 04/30] ASoC: wm5110: Revert "ASoC: wm5110: Fix PM disable depth imbalance in wm5110_probe" Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 05/30] ASoC: wm8997: Revert "ASoC: wm8997: Fix PM disable depth imbalance in wm8997_probe" Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 06/30] ASoC: mt6660: Keep the pm_runtime enables before component stuff in mt6660_i2c_probe Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 07/30] ASoC: rt5682s: Fix the TDM Tx settings Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 08/30] ASoC: rt1019: Fix the TDM settings Sasha Levin
2022-11-06 17:03 ` Sasha Levin [this message]
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 10/30] spi: intel: Fix the offset to get the 64K erase opcode Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 11/30] ASoC: codecs: jz4725b: add missed Line In power control bit Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 12/30] ASoC: codecs: jz4725b: fix reported volume for Master ctl Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 13/30] ASoC: codecs: jz4725b: use right control for Capture Volume Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 14/30] ASoC: codecs: jz4725b: fix capture selector naming Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 15/30] ASoC: Intel: sof_sdw: add quirk variant for LAPBC710 NUC15 Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 16/30] selftests/futex: fix build for clang Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 17/30] selftests/intel_pstate: fix build for ARCH=x86_64 Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 18/30] selftests/kexec: " Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 19/30] ASoC: Intel: sof_rt5682: Add quirk for Rex board Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 20/30] rtc: cmos: fix build on non-ACPI platforms Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 21/30] ASoC: rt1308-sdw: add the default value of some registers Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 22/30] ASoC: amd: yc: Adding Lenovo ThinkBook 14 Gen 4+ ARA and Lenovo ThinkBook 16 Gen 4+ ARA to the Quirks List Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 23/30] ASoC: amd: yc: Add Lenovo Thinkbook 14+ 2022 21D0 to quirks table Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 24/30] drm/amdgpu: Adjust MES polling timeout for sriov Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 25/30] platform/x86: thinkpad_acpi: Fix reporting a non present second fan on some models Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 26/30] platform/x86/intel: pmc/core: Add Raptor Lake support to pmc core driver Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 27/30] drm/amd/display: Remove wrong pipe control lock Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 28/30] drm/amd/display: Don't return false if no stream Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 29/30] drm/scheduler: fix fence ref counting Sasha Levin
2022-11-06 17:03 ` [PATCH AUTOSEL 6.0 30/30] ACPI: scan: Add LATT2021 to acpi_ignore_dep_ids[] 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=20221106170345.1579893-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=aford173@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=chi.minghao@zte.com.cn \
--cc=ckeepax@opensource.cirrus.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=steve@sk2.org \
--cc=tiwai@suse.com \
--cc=xiaolei.wang@windriver.com \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox