* [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of
@ 2026-04-27 8:43 Linus Walleij
2026-04-27 9:46 ` Bartosz Golaszewski
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Linus Walleij @ 2026-04-27 8:43 UTC (permalink / raw)
To: Bartosz Golaszewski, Srinivas Kandagatla, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai
Cc: linux-gpio, linux-sound, linux-arm-msm, Linus Walleij
The WSA881x codec driver has a local workaround for old device
trees that have the "powerdown" GPIO flagged as active high,
despite it is active low.
This quirk can be replaced by a single quirk entry in
gpiolib-of.c
Drop all polarity inversion code and drop the surplus
gpiod_direction_output() call in probe() since we now set up
the line correctly when getting the GPIO.
Also drop the inclusion of the unused <linux/gpio.h>.
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Perhaps this can be applied to ASoC directly we seldom add
things to these quirks so I think it'll be fine.
I was thinking of adding Fixes: but the current code is fine,
we don't really fix anything we just make it simpler.
---
Changes in v2:
- Property name needs to be "powerdown-gpios" not just "powerdown".
- Link to v1: https://lore.kernel.org/r/20260327-asoc-wsa881x-v1-1-53dc05867e6b@kernel.org
---
drivers/gpio/gpiolib-of.c | 8 ++++++++
sound/soc/codecs/wsa881x.c | 35 ++++-------------------------------
2 files changed, 12 insertions(+), 31 deletions(-)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 2c923d17541f..90f6295ab338 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -240,6 +240,14 @@ static void of_gpio_try_fixup_polarity(const struct device_node *np,
* treats it as "active low".
*/
{ "ti,tsc2005", "reset-gpios", false },
+#endif
+#if IS_ENABLED(CONFIG_SND_SOC_WSA881X)
+ /*
+ * WSA881 powerdown is always active low, but some device trees
+ * missed this when first contributed. It also has a very strange
+ * compatible.
+ */
+ { "sdw10217201000", "powerdown-gpios", false },
#endif
};
unsigned int i;
diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c
index 2fc234adca5f..d15fda648dad 100644
--- a/sound/soc/codecs/wsa881x.c
+++ b/sound/soc/codecs/wsa881x.c
@@ -3,7 +3,6 @@
// Copyright (c) 2019, Linaro Limited
#include <linux/bitops.h>
-#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/regmap.h>
@@ -672,11 +671,6 @@ struct wsa881x_priv {
struct sdw_stream_runtime *sruntime;
struct sdw_port_config port_config[WSA881X_MAX_SWR_PORTS];
struct gpio_desc *sd_n;
- /*
- * Logical state for SD_N GPIO: high for shutdown, low for enable.
- * For backwards compatibility.
- */
- unsigned int sd_n_val;
int active_ports;
bool hw_init;
bool port_prepared[WSA881X_MAX_SWR_PORTS];
@@ -1121,31 +1115,11 @@ static int wsa881x_probe(struct sdw_slave *pdev,
if (!wsa881x)
return -ENOMEM;
- wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", 0);
+ wsa881x->sd_n = devm_gpiod_get_optional(dev, "powerdown", GPIOD_OUT_LOW);
if (IS_ERR(wsa881x->sd_n))
return dev_err_probe(dev, PTR_ERR(wsa881x->sd_n),
"Shutdown Control GPIO not found\n");
- /*
- * Backwards compatibility work-around.
- *
- * The SD_N GPIO is active low, however upstream DTS used always active
- * high. Changing the flag in driver and DTS will break backwards
- * compatibility, so add a simple value inversion to work with both old
- * and new DTS.
- *
- * This won't work properly with DTS using the flags properly in cases:
- * 1. Old DTS with proper ACTIVE_LOW, however such case was broken
- * before as the driver required the active high.
- * 2. New DTS with proper ACTIVE_HIGH (intended), which is rare case
- * (not existing upstream) but possible. This is the price of
- * backwards compatibility, therefore this hack should be removed at
- * some point.
- */
- wsa881x->sd_n_val = gpiod_is_active_low(wsa881x->sd_n);
- if (!wsa881x->sd_n_val)
- dev_warn(dev, "Using ACTIVE_HIGH for shutdown GPIO. Your DTB might be outdated or you use unsupported configuration for the GPIO.");
-
dev_set_drvdata(dev, wsa881x);
wsa881x->slave = pdev;
wsa881x->dev = dev;
@@ -1158,7 +1132,6 @@ static int wsa881x_probe(struct sdw_slave *pdev,
pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop;
pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;
pdev->prop.clk_stop_mode1 = true;
- gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val);
wsa881x->regmap = devm_regmap_init_sdw(pdev, &wsa881x_regmap_config);
if (IS_ERR(wsa881x->regmap))
@@ -1181,7 +1154,7 @@ static int wsa881x_runtime_suspend(struct device *dev)
struct regmap *regmap = dev_get_regmap(dev, NULL);
struct wsa881x_priv *wsa881x = dev_get_drvdata(dev);
- gpiod_direction_output(wsa881x->sd_n, wsa881x->sd_n_val);
+ gpiod_direction_output(wsa881x->sd_n, 1);
regcache_cache_only(regmap, true);
regcache_mark_dirty(regmap);
@@ -1196,13 +1169,13 @@ static int wsa881x_runtime_resume(struct device *dev)
struct wsa881x_priv *wsa881x = dev_get_drvdata(dev);
unsigned long time;
- gpiod_direction_output(wsa881x->sd_n, !wsa881x->sd_n_val);
+ gpiod_direction_output(wsa881x->sd_n, 0);
time = wait_for_completion_timeout(&slave->initialization_complete,
msecs_to_jiffies(WSA881X_PROBE_TIMEOUT));
if (!time) {
dev_err(dev, "Initialization not complete, timed out\n");
- gpiod_direction_output(wsa881x->sd_n, wsa881x->sd_n_val);
+ gpiod_direction_output(wsa881x->sd_n, 1);
return -ETIMEDOUT;
}
---
base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
change-id: 20260326-asoc-wsa881x-633cc7f70132
Best regards,
--
Linus Walleij <linusw@kernel.org>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of
2026-04-27 8:43 [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of Linus Walleij
@ 2026-04-27 9:46 ` Bartosz Golaszewski
2026-04-27 22:39 ` Mark Brown
2026-04-28 3:40 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2026-04-27 9:46 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-gpio, linux-sound, linux-arm-msm, Bartosz Golaszewski,
Srinivas Kandagatla, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai
On Mon, 27 Apr 2026 10:43:21 +0200, Linus Walleij <linusw@kernel.org> said:
> The WSA881x codec driver has a local workaround for old device
> trees that have the "powerdown" GPIO flagged as active high,
> despite it is active low.
>
> This quirk can be replaced by a single quirk entry in
> gpiolib-of.c
>
> Drop all polarity inversion code and drop the surplus
> gpiod_direction_output() call in probe() since we now set up
> the line correctly when getting the GPIO.
>
> Also drop the inclusion of the unused <linux/gpio.h>.
>
> Signed-off-by: Linus Walleij <linusw@kernel.org>
> ---
> Perhaps this can be applied to ASoC directly we seldom add
> things to these quirks so I think it'll be fine.
>
I'm fine with that but I'd still like this to be in an immutable branch
shared with the GPIO tree as we're very early into the cycle and we can't
tell what kind of patches we'll see.
Or we can do it the other way around and I can create an immutable branch
for Mark.
Bart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of
2026-04-27 8:43 [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of Linus Walleij
2026-04-27 9:46 ` Bartosz Golaszewski
@ 2026-04-27 22:39 ` Mark Brown
2026-04-28 3:40 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-27 22:39 UTC (permalink / raw)
To: Bartosz Golaszewski, Srinivas Kandagatla, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, Linus Walleij
Cc: linux-gpio, linux-sound, linux-arm-msm
On Mon, 27 Apr 2026 10:43:21 +0200, Linus Walleij wrote:
> ASoC: wsa881x: Move custom workaround to gpiolib-of
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/1] ASoC: wsa881x: Move custom workaround to gpiolib-of
https://git.kernel.org/broonie/sound/c/bfa336cee332
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] 4+ messages in thread
* Re: [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of
2026-04-27 8:43 [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of Linus Walleij
2026-04-27 9:46 ` Bartosz Golaszewski
2026-04-27 22:39 ` Mark Brown
@ 2026-04-28 3:40 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-04-28 3:40 UTC (permalink / raw)
To: Linus Walleij
Cc: Bartosz Golaszewski, Srinivas Kandagatla, Liam Girdwood,
Jaroslav Kysela, Takashi Iwai, linux-gpio, linux-sound,
linux-arm-msm
[-- Attachment #1: Type: text/plain, Size: 1169 bytes --]
On Mon, Apr 27, 2026 at 10:43:21AM +0200, Linus Walleij wrote:
> The WSA881x codec driver has a local workaround for old device
> trees that have the "powerdown" GPIO flagged as active high,
> despite it is active low.
The following changes since commit 254f49634ee16a731174d2ae34bc50bd5f45e731:
Linux 7.1-rc1 (2026-04-26 14:19:00 -0700)
are available in the Git repository at:
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git tags/asoc-wsa881x-gpiolib-of
for you to fetch changes up to bfa336cee3324f991e93e9e570e8b827273df97e:
ASoC: wsa881x: Move custom workaround to gpiolib-of (2026-04-28 07:39:15 +0900)
----------------------------------------------------------------
ASoC: wsa881x: Move custom workaround to gpiolib-of
Move a workaround for misdescribed GPIOs from the wsa881x to use a
generic implementation in gpiolib-of.
----------------------------------------------------------------
Linus Walleij (1):
ASoC: wsa881x: Move custom workaround to gpiolib-of
drivers/gpio/gpiolib-of.c | 8 ++++++++
sound/soc/codecs/wsa881x.c | 35 ++++-------------------------------
2 files changed, 12 insertions(+), 31 deletions(-)
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-04-28 3:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-27 8:43 [PATCH v2] ASoC: wsa881x: Move custom workaround to gpiolib-of Linus Walleij
2026-04-27 9:46 ` Bartosz Golaszewski
2026-04-27 22:39 ` Mark Brown
2026-04-28 3:40 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox