* [PATCH v5 0/2] mux: gpio-mux: add enable GPIO support @ 2026-01-23 14:57 Antoniu Miclaus 2026-01-23 14:57 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support Antoniu Miclaus 2026-01-23 14:57 ` [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO Antoniu Miclaus 0 siblings, 2 replies; 5+ messages in thread From: Antoniu Miclaus @ 2026-01-23 14:57 UTC (permalink / raw) To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Srinivas Kandagatla, Antoniu Miclaus, Johan Hovold, Bartosz Golaszewski, David Lechner, devicetree, linux-kernel This series adds optional enable GPIO support to the gpio-mux driver. The enable GPIO allows the multiplexer to be disabled before changing address lines and re-enabled after, preventing glitches that could briefly activate unintended channels during transitions. This feature is useful for devices like the Analog Devices ADG2404 (4:1 mux) that require enable control for glitch-free operation. The binding documentation now includes ADG2404 as a supported device with a dedicated example. Changes in v5: - dt-bindings: Expand enable-gpios description to explain high-impedance (high-Z) behavior and analog signal considerations - dt-bindings: Remove separate ADG2404 example, add enable-gpios to existing example instead - driver: Enhance code comment to explain high-Z state and downstream capacitance for analog multiplexers Antoniu Miclaus (2): dt-bindings: mux: gpio-mux: add enable-gpios support mux: gpio-mux: add support for enable GPIO .../devicetree/bindings/mux/gpio-mux.yaml | 16 +++++++++ drivers/mux/gpio.c | 35 ++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) -- 2.43.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support 2026-01-23 14:57 [PATCH v5 0/2] mux: gpio-mux: add enable GPIO support Antoniu Miclaus @ 2026-01-23 14:57 ` Antoniu Miclaus 2026-01-23 17:10 ` Conor Dooley 2026-01-23 14:57 ` [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO Antoniu Miclaus 1 sibling, 1 reply; 5+ messages in thread From: Antoniu Miclaus @ 2026-01-23 14:57 UTC (permalink / raw) To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Antoniu Miclaus, Srinivas Kandagatla, Bartosz Golaszewski, Johan Hovold, David Lechner, devicetree, linux-kernel Add support for an optional enable GPIO that allows the multiplexer to be disabled before changing address lines and re-enabled after, preventing glitches during channel transitions. This is useful for devices like the Analog Devices ADG2404 (4:1 mux) that benefit from enable control to ensure clean channel switching. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> --- Changes in v5: - Expand enable-gpios description to explain high-impedance (high-Z) behavior when mux is disabled - Describe analog multiplexer use case where downstream capacitance maintains signal level during brief disconnection - Remove separate ADG2404 example, add enable-gpios to existing example --- .../devicetree/bindings/mux/gpio-mux.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Documentation/devicetree/bindings/mux/gpio-mux.yaml b/Documentation/devicetree/bindings/mux/gpio-mux.yaml index ef7e33ec85d4..798e0a73d77b 100644 --- a/Documentation/devicetree/bindings/mux/gpio-mux.yaml +++ b/Documentation/devicetree/bindings/mux/gpio-mux.yaml @@ -17,6 +17,9 @@ description: |+ multiplexer GPIO pins, where the first pin is the least significant bit. An active pin is a binary 1, an inactive pin is a binary 0. + This binding supports GPIO-controlled multiplexers such as the Analog + Devices ADG2404 (4:1 mux with enable control). + properties: compatible: const: gpio-mux @@ -25,6 +28,18 @@ properties: description: List of gpios used to control the multiplexer, least significant bit first. + enable-gpios: + description: | + Optional GPIO to enable the multiplexer. When present, the mux is + disabled before changing address lines and re-enabled after. This + prevents glitches where an unintended channel could be briefly activated + during address line transitions. When disabled, all outputs enter a + high-impedance (high-Z) state rather than holding their previous value. + This is suitable for analog multiplexers where downstream capacitance + maintains the signal level during the brief disconnection. + Required for MUX_IDLE_DISCONNECT idle-state. + maxItems: 1 + mux-supply: description: Regulator to power on the multiplexer. @@ -59,6 +74,7 @@ examples: mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>, <&pioA 1 GPIO_ACTIVE_HIGH>; + enable-gpios = <&pioA 2 GPIO_ACTIVE_HIGH>; }; adc-mux { -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support 2026-01-23 14:57 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support Antoniu Miclaus @ 2026-01-23 17:10 ` Conor Dooley 0 siblings, 0 replies; 5+ messages in thread From: Conor Dooley @ 2026-01-23 17:10 UTC (permalink / raw) To: Antoniu Miclaus Cc: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Srinivas Kandagatla, Bartosz Golaszewski, Johan Hovold, David Lechner, devicetree, linux-kernel [-- Attachment #1: Type: text/plain, Size: 75 bytes --] Acked-by: Conor Dooley <conor.dooley@microchip.com> pw-bot: not-applicable [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 228 bytes --] ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO 2026-01-23 14:57 [PATCH v5 0/2] mux: gpio-mux: add enable GPIO support Antoniu Miclaus 2026-01-23 14:57 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support Antoniu Miclaus @ 2026-01-23 14:57 ` Antoniu Miclaus 2026-01-27 9:27 ` Bartosz Golaszewski 1 sibling, 1 reply; 5+ messages in thread From: Antoniu Miclaus @ 2026-01-23 14:57 UTC (permalink / raw) To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Antoniu Miclaus, Srinivas Kandagatla, Bartosz Golaszewski, Johan Hovold, Linus Walleij, David Lechner, devicetree, linux-kernel Add support for an optional enable GPIO to the gpio-mux driver. This allows the mux to be disabled before changing address lines and re-enabled after, preventing glitches that could briefly activate unintended channels during transitions. The enable GPIO is optional and the driver maintains backward compatibility with existing gpio-mux users. Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> --- Changes in v5: - Enhance code comment to explain high-impedance (high-Z) state when mux is disabled - Add context about downstream capacitance maintaining signal level for analog multiplexers --- drivers/mux/gpio.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c index 4cc3202c58f3..b95d2c7a53ca 100644 --- a/drivers/mux/gpio.c +++ b/drivers/mux/gpio.c @@ -19,6 +19,7 @@ struct mux_gpio { struct gpio_descs *gpios; + struct gpio_desc *enable; }; static int mux_gpio_set(struct mux_control *mux, int state) @@ -27,10 +28,31 @@ static int mux_gpio_set(struct mux_control *mux, int state) DECLARE_BITMAP(values, BITS_PER_TYPE(state)); u32 value = state; + if (state == MUX_IDLE_DISCONNECT) { + if (mux_gpio->enable) + gpiod_set_value_cansleep(mux_gpio->enable, 0); + return 0; + } + + if (mux_gpio->enable) { + /* + * Disable the mux before changing address lines to prevent + * glitches where an unintended channel could be briefly + * activated during the transition. When disabled, all mux + * outputs enter high-impedance (high-Z) state. For analog + * signals, downstream capacitance typically maintains the + * signal level during this brief disconnection. + */ + gpiod_set_value_cansleep(mux_gpio->enable, 0); + } + bitmap_from_arr32(values, &value, BITS_PER_TYPE(value)); gpiod_multi_set_value_cansleep(mux_gpio->gpios, values); + if (mux_gpio->enable) + gpiod_set_value_cansleep(mux_gpio->enable, 1); + return 0; } @@ -71,9 +93,20 @@ static int mux_gpio_probe(struct platform_device *pdev) WARN_ON(pins != mux_gpio->gpios->ndescs); mux_chip->mux->states = BIT(pins); + mux_gpio->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); + if (IS_ERR(mux_gpio->enable)) + return dev_err_probe(dev, PTR_ERR(mux_gpio->enable), + "failed to get enable gpio\n"); + ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state); if (ret >= 0 && idle_state != MUX_IDLE_AS_IS) { - if (idle_state < 0 || idle_state >= mux_chip->mux->states) { + if (idle_state == MUX_IDLE_DISCONNECT) { + if (!mux_gpio->enable) { + dev_err(dev, + "invalid idle-state (MUX_IDLE_DISCONNECT requires enable-gpios)\n"); + return -EINVAL; + } + } else if (idle_state < 0 || idle_state >= mux_chip->mux->states) { dev_err(dev, "invalid idle-state %u\n", idle_state); return -EINVAL; } -- 2.43.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO 2026-01-23 14:57 ` [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO Antoniu Miclaus @ 2026-01-27 9:27 ` Bartosz Golaszewski 0 siblings, 0 replies; 5+ messages in thread From: Bartosz Golaszewski @ 2026-01-27 9:27 UTC (permalink / raw) To: Antoniu Miclaus Cc: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Srinivas Kandagatla, Johan Hovold, Linus Walleij, David Lechner, devicetree, linux-kernel On Fri, Jan 23, 2026 at 3:58 PM Antoniu Miclaus <antoniu.miclaus@analog.com> wrote: > > Add support for an optional enable GPIO to the gpio-mux driver. This > allows the mux to be disabled before changing address lines and > re-enabled after, preventing glitches that could briefly activate > unintended channels during transitions. > > The enable GPIO is optional and the driver maintains backward > compatibility with existing gpio-mux users. > > Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> > --- > Changes in v5: > - Enhance code comment to explain high-impedance (high-Z) state when > mux is disabled > - Add context about downstream capacitance maintaining signal level > for analog multiplexers > --- > drivers/mux/gpio.c | 35 ++++++++++++++++++++++++++++++++++- > 1 file changed, 34 insertions(+), 1 deletion(-) > > diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c > index 4cc3202c58f3..b95d2c7a53ca 100644 > --- a/drivers/mux/gpio.c > +++ b/drivers/mux/gpio.c > @@ -19,6 +19,7 @@ > > struct mux_gpio { > struct gpio_descs *gpios; > + struct gpio_desc *enable; > }; > > static int mux_gpio_set(struct mux_control *mux, int state) > @@ -27,10 +28,31 @@ static int mux_gpio_set(struct mux_control *mux, int state) > DECLARE_BITMAP(values, BITS_PER_TYPE(state)); > u32 value = state; > > + if (state == MUX_IDLE_DISCONNECT) { > + if (mux_gpio->enable) > + gpiod_set_value_cansleep(mux_gpio->enable, 0); > + return 0; This is optional so no need to check for NULL. Also: GPIO value setters now return errors so it can be: return gpiod_set_value_cansleep(); > + } > + > + if (mux_gpio->enable) { > + /* > + * Disable the mux before changing address lines to prevent > + * glitches where an unintended channel could be briefly > + * activated during the transition. When disabled, all mux > + * outputs enter high-impedance (high-Z) state. For analog > + * signals, downstream capacitance typically maintains the > + * signal level during this brief disconnection. > + */ > + gpiod_set_value_cansleep(mux_gpio->enable, 0); > + } Same here. > + > bitmap_from_arr32(values, &value, BITS_PER_TYPE(value)); > > gpiod_multi_set_value_cansleep(mux_gpio->gpios, values); This is not part of this change but would be useful to check this return value as well. > > + if (mux_gpio->enable) > + gpiod_set_value_cansleep(mux_gpio->enable, 1); > + > return 0; > } > > @@ -71,9 +93,20 @@ static int mux_gpio_probe(struct platform_device *pdev) > WARN_ON(pins != mux_gpio->gpios->ndescs); > mux_chip->mux->states = BIT(pins); > > + mux_gpio->enable = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW); > + if (IS_ERR(mux_gpio->enable)) > + return dev_err_probe(dev, PTR_ERR(mux_gpio->enable), > + "failed to get enable gpio\n"); > + > ret = device_property_read_u32(dev, "idle-state", (u32 *)&idle_state); > if (ret >= 0 && idle_state != MUX_IDLE_AS_IS) { > - if (idle_state < 0 || idle_state >= mux_chip->mux->states) { > + if (idle_state == MUX_IDLE_DISCONNECT) { > + if (!mux_gpio->enable) { > + dev_err(dev, > + "invalid idle-state (MUX_IDLE_DISCONNECT requires enable-gpios)\n"); > + return -EINVAL; > + } Can we check it before and then decide whether we really need the GPIO or not? > + } else if (idle_state < 0 || idle_state >= mux_chip->mux->states) { > dev_err(dev, "invalid idle-state %u\n", idle_state); > return -EINVAL; > } > -- > 2.43.0 > Bart ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-01-27 9:27 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-01-23 14:57 [PATCH v5 0/2] mux: gpio-mux: add enable GPIO support Antoniu Miclaus 2026-01-23 14:57 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: add enable-gpios support Antoniu Miclaus 2026-01-23 17:10 ` Conor Dooley 2026-01-23 14:57 ` [PATCH v5 2/2] mux: gpio-mux: add support for enable GPIO Antoniu Miclaus 2026-01-27 9:27 ` Bartosz Golaszewski
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox