Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Herve Codina" <herve.codina@bootlin.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org
Subject: Re: [PATCH v3 12/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for bypass gpio
Date: Thu, 14 May 2026 04:54:42 +0000	[thread overview]
Message-ID: <20260514045443.32896C2BCB7@smtp.kernel.org> (raw)
In-Reply-To: <20260513081702.317117-13-herve.codina@bootlin.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The bypass GPIO can drive a physical logic HIGH into an unpowered amplifier chip, creating a severe risk of back-powering and permanent hardware damage.
--

commit 802f9d8e2a1a80c9fdc791af2e538c251cfdc8e9
Author: Herve Codina <herve.codina@bootlin.com>

ASoC: simple-amplifier: gpio-audio-amp: Add support for bypass gpio

This commit adds support for controlling an amplifier bypass feature using
a GPIO. It duplicates the initialization pattern used for the mute GPIO.

> diff --git a/sound/soc/codecs/simple-amplifier.c b/sound/soc/codecs/simple-amplifier.c
> index c8991e340def5..b9c09a04832a8 100644
> --- a/sound/soc/codecs/simple-amplifier.c
> +++ b/sound/soc/codecs/simple-amplifier.c
[ ... ]
> @@ -352,8 +360,15 @@ static int simple_amp_probe(struct platform_device *pdev)
>  			return ret;
>  	}
>  
> +	if (simple_amp->data->supports & SIMPLE_AUDIO_SUPPORT_BYPASS) {
> +		ret = simple_amp_parse_single_gpio(dev, &simple_amp->bypass, "bypass");

Looking at simple_amp_parse_single_gpio(), it requests the GPIO
synchronously with GPIOD_OUT_LOW:

sound/soc/codecs/simple-amplifier.c:simple_amp_parse_single_gpio() {
    ...
    single->gpio = devm_gpiod_get_optional(dev, gpio_property, GPIOD_OUT_LOW);
    ...
}

Since this is called during probe, before the DAPM powers up the device,
can this cause hardware damage if the device tree defines the GPIO as
active low?

If the GPIO is defined as active low, gpiolib will immediately drive the pin
to a physical high voltage. Because the amplifier's power supplies and enable
pin are managed by DAPM and disabled at probe time, driving a physical high
signal into an unpowered CMOS device might forward-bias the internal ESD
protection diodes.

This could back-power the chip from the SoC's GPIO pad and cause latch-up.
Would it be safer to strictly sequence the GPIO state changes with the
device's power state? For example, by deferring the GPIO output configuration
until DAPM powers up the device, or implementing the controls as DAPM widgets.

Note that this identical behavior appears to exist for the mute GPIO as
well, which this bypass GPIO implementation is modeled after.

> +		if (ret)
> +			return ret;
> +	}
> +
>  	/* Set controls name */
>  	simple_amp->mute.control_name = "Switch";
> +	simple_amp->bypass.control_name = "Bypass Switch";

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260513081702.317117-1-herve.codina@bootlin.com?part=12

  reply	other threads:[~2026-05-14  4:54 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13  8:16 [PATCH v3 00/17] ASoC: Add support for GPIOs driven amplifiers Herve Codina
2026-05-13  8:16 ` [PATCH v3 01/17] of: Introduce of_property_read_s32_index() Herve Codina
2026-05-13  8:16 ` [PATCH v3 02/17] ASoC: dt-bindings: Add support for the GPIOs driven amplifier Herve Codina
2026-05-13  8:16 ` [PATCH v3 03/17] ASoC: simple-amplifier: Remove DRV_NAME defined value Herve Codina
2026-05-13  8:16 ` [PATCH v3 04/17] ASoC: simple-amplifier: Add missing headers Herve Codina
2026-05-13  8:16 ` [PATCH v3 05/17] ASoC: simple-amplifier: Remove CONFIG_OF flag and of_match_ptr() Herve Codina
2026-05-13  8:16 ` [PATCH v3 06/17] ASoC: simple-amplifier: Rename drv_event() function Herve Codina
2026-05-13  8:16 ` [PATCH v3 07/17] ASoC: simple-amplifier: Use 'simple_amp' variable name instead of 'priv' Herve Codina
2026-05-13  8:16 ` [PATCH v3 08/17] ASoC: simple-amplifier: Remove DAPM widgets and routes from the ASoC component driver Herve Codina
2026-05-14  3:32   ` sashiko-bot
2026-05-13  8:16 ` [PATCH v3 09/17] ASoC: simple-amplifier: Introduce support for gpio-audio-amp Herve Codina
2026-05-14  3:51   ` sashiko-bot
2026-05-13  8:16 ` [PATCH v3 10/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for extra power supplies Herve Codina
2026-05-13  8:16 ` [PATCH v3 11/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for mute gpio Herve Codina
2026-05-13  8:16 ` [PATCH v3 12/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for bypass gpio Herve Codina
2026-05-14  4:54   ` sashiko-bot [this message]
2026-05-13  8:16 ` [PATCH v3 13/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for basic gain Herve Codina
2026-05-13  8:16 ` [PATCH v3 14/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-ranges Herve Codina
2026-05-14  6:10   ` sashiko-bot
2026-05-13  8:16 ` [PATCH v3 15/17] ASoC: simple-amplifier: gpio-audio-amp: Add support for gain-labels Herve Codina
2026-05-13  8:17 ` [PATCH v3 16/17] ASoC: simple-amplifier: Update author and copyright Herve Codina
2026-05-14  6:49   ` sashiko-bot
2026-05-13  8:17 ` [PATCH v3 17/17] MAINTAINERS: Add the ASoC gpio audio amplifier entry Herve Codina

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=20260514045443.32896C2BCB7@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=herve.codina@bootlin.com \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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