mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 0/2] mux: gpio: Add optional enable gpio
@ 2026-11-05 10:11 Tapio Reijonen
  2026-11-05 10:11 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios Tapio Reijonen
  2026-11-05 10:11 ` [PATCH v5 2/2] mux: gpio: Add optional enable gpio Tapio Reijonen
  0 siblings, 2 replies; 5+ messages in thread
From: Tapio Reijonen @ 2026-11-05 10:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Peter Rosin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Tapio Reijonen, Conor Dooley

Analog multiplexers have an enable input that puts all channels in the
high-impedance off state independent of the address inputs - the E input
of a 74HC4051, for example. gpio-mux has no way to describe it, so it can
neither reach the idle state of disconnect that the mux-controller
binding defines, nor keep the mux disabled while the address gpios are
updated one gpio controller at a time.

Add enable-gpios for that input, and use it in the driver.

Without it the driver rejects MUX_IDLE_DISCONNECT outright.
mux-controller.yaml allows it - idle-state is an int32 with a minimum of
-2 - but mux_gpio_probe() treats every negative value other than
MUX_IDLE_AS_IS as invalid, so a device tree asking for the disconnect
idle state does not probe at all. On the board below that takes out the
i2c-mux behind the mux controller, both SFP i2c buses and both sfp
devices with it:

  gpio-mux muxes:mux-controller-slot@0: invalid idle-state 4294967294
  gpio-mux muxes:mux-controller-slot@0: probe with driver gpio-mux failed with error -22

4294967294 is MUX_IDLE_DISCONNECT, -2, printed through %u.

Tested on an i.MX6SX board where two SFP cages share one SMBus behind
DG9411 analog switches: the address input selects the cage and the
enable input gates the bus, both driven by a PCA9501 I2C gpio expander.
With enable-gpios and an idle state of disconnect, the parent bus scans
empty between transfers while each cage stays reachable through its own
child bus. A logic analyser on the enable, address and bus lines over a
full boot shows 97 enable windows and 82 address changes, with no bus
activity outside a window and no address change inside one. Dropping
enable-gpios while keeping the disconnect idle state makes the driver
refuse to probe, as intended.

Greg, there has been no reply from the mux maintainer since the v2
review in September, and v4 and its resend went unanswered. The binding
carries Conor's Acked-by. Could you take this through char-misc?

Tool use: Claude Code (Anthropic) helped draft the patches and messages
and reviewed the series; I made the design decisions, reviewed every
change and ran the hardware tests.

Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
Changes in v5:
- Request the enable gpio before the mux gpios, so that probe does not
  pass through intermediate addresses while the mux is enabled.
- Rebased onto v7.4-rc1.
- RESEND of v4: https://lore.kernel.org/r/20261004-add-external-mux-enable-gpio-v4-0-e9393660feed@vaisala.com
- Link to v4: https://lore.kernel.org/r/20260909-add-external-mux-enable-gpio-v4-0-3b12a767bb94@vaisala.com

Changes in v4:
- Pick up Conor Dooley's Acked-by on 1/2. It arrived on the v2 thread
  after v3 had been sent, as Rob Herring noted.
- No other changes.
- Link to v3: https://lore.kernel.org/r/20260904-add-external-mux-enable-gpio-v3-0-1b868e669e43@vaisala.com

Changes in v3:
- Address Peter Rosin's review of 2/2. Cosmetic, except for the last
  item below.
- Say "Some analog multiplexers", not all of them, and note that the mux
  gpios are not guaranteed to be updated atomically and that only
  controllers implementing set_multiple() can possibly update theirs in
  a single write.
- Drop the _gpio suffix from the struct member: enable_gpio -> enable.
- Reflow the comment in mux_gpio_set() and soften it to "might not be
  updated atomically".
- Flatten the idle-state handling in probe, read the property into the
  existing default when it is absent, and assign mux->idle_state once at
  the end. Use dev_err() and return -EINVAL rather than dev_err_probe(),
  as suggested. Written without the empty if branches of the suggested
  snippet, but with the same behaviour.
- Beyond the review: return the status of the gpio writes from
  mux_gpio_set() instead of zero. The other mux drivers pass the write
  status back, and mux_control_set() only invalidates the cached state
  when set() reports an error, so a failed write reported as success is
  not retried. Happy to drop this hunk if it should be a separate patch.
- Link to v2: https://lore.kernel.org/r/20260831-add-external-mux-enable-gpio-v2-0-f6027a4afe61@vaisala.com

Changes in v2:
- Describe the enable input in terms of real multiplexers (the E input of
  a 74HC4051) instead of repeating the binding text, and say what needs
  it, as requested by Krzysztof.
- Add the missing gpio-mux: prefix to the binding patch subject.
- Limit enable-gpios to one entry, and require it for an idle state of
  disconnect in both the schema and the driver: without an enable gpio
  mux_gpio_set() drove the address gpios to the bit pattern of
  MUX_IDLE_DISCONNECT instead of disconnecting.
- Deassert the enable gpio while the mux gpios are updated, not only for
  the disconnect idle state, since they are not updated atomically.
- Show enable-gpios in the binding example.
- Link to v1: https://lore.kernel.org/r/20251105-add-external-mux-enable-gpio-v1-0-e59cba6f9e47@vaisala.com

---
Tapio Reijonen (2):
      dt-bindings: mux: gpio-mux: Add enable-gpios
      mux: gpio: Add optional enable gpio

 .../devicetree/bindings/mux/gpio-mux.yaml          | 22 +++++++++++
 drivers/mux/gpio.c                                 | 43 ++++++++++++++++++----
 2 files changed, 57 insertions(+), 8 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20250925-add-external-mux-enable-gpio-c9ba5beddd49

Best regards,
-- 
Tapio Reijonen <tapio.reijonen@vaisala.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios
  2026-11-05 10:11 [PATCH v5 0/2] mux: gpio: Add optional enable gpio Tapio Reijonen
@ 2026-11-05 10:11 ` Tapio Reijonen
  2026-11-05 12:57   ` Alvin Šipraga
  2026-11-05 10:11 ` [PATCH v5 2/2] mux: gpio: Add optional enable gpio Tapio Reijonen
  1 sibling, 1 reply; 5+ messages in thread
From: Tapio Reijonen @ 2026-11-05 10:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Peter Rosin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Tapio Reijonen, Conor Dooley

Analog multiplexers have an enable input besides the address inputs. On a
74HC4051 it is the E input: with E high, all eight switches are in the
high-impedance off state, independent of S0 to S2. A 74HC4067 works the
same way with four address inputs.

Two things need that input. The mux-controller binding describes an idle
state of disconnect, which a gpio-mux cannot reach today because the
address inputs always select a channel. And the address inputs are plain
gpios that may live on different gpio controllers, so they are not
updated in one go and the mux passes through the intermediate addresses
on every channel change unless it is disabled meanwhile.

Add enable-gpios to describe the enable input, and require it for an idle
state of disconnect.

Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
---
 .../devicetree/bindings/mux/gpio-mux.yaml          | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/Documentation/devicetree/bindings/mux/gpio-mux.yaml b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
index ef7e33ec85d479ce57c5fe4a780f81a08a6ab6ba..2dd94704fd7bde238af4e84af87c2ad8e955eb14 100644
--- a/Documentation/devicetree/bindings/mux/gpio-mux.yaml
+++ b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
@@ -29,6 +29,14 @@ properties:
     description:
       Regulator to power on the multiplexer.
 
+  enable-gpios:
+    maxItems: 1
+    description:
+      Enable input of the multiplexer, which disconnects all channels when
+      deasserted, independent of mux-gpios. Deasserted while the mux-gpios
+      are updated and for an idle state of disconnect, which cannot be
+      reached with the mux-gpios alone and thus requires this gpio.
+
   '#mux-control-cells':
     enum: [ 0, 1 ]
 
@@ -47,11 +55,23 @@ anyOf:
   - required:
       - "#mux-state-cells"
 
+allOf:
+  - if:
+      properties:
+        idle-state:
+          const: -2
+      required:
+        - idle-state
+    then:
+      required:
+        - enable-gpios
+
 additionalProperties: false
 
 examples:
   - |
     #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/mux/mux.h>
 
     mux: mux-controller {
         compatible = "gpio-mux";
@@ -59,6 +79,8 @@ examples:
 
         mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>,
               <&pioA 1 GPIO_ACTIVE_HIGH>;
+        enable-gpios = <&pioA 2 GPIO_ACTIVE_LOW>;
+        idle-state = <MUX_IDLE_DISCONNECT>;
     };
 
     adc-mux {

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v5 2/2] mux: gpio: Add optional enable gpio
  2026-11-05 10:11 [PATCH v5 0/2] mux: gpio: Add optional enable gpio Tapio Reijonen
  2026-11-05 10:11 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios Tapio Reijonen
@ 2026-11-05 10:11 ` Tapio Reijonen
  2026-11-05 12:57   ` Alvin Šipraga
  1 sibling, 1 reply; 5+ messages in thread
From: Tapio Reijonen @ 2026-11-05 10:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Peter Rosin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley
  Cc: devicetree, linux-kernel, Tapio Reijonen

Some analog multiplexers have an enable input that disconnects all
channels when deasserted, independent of the address inputs; on a
74HC4051 it is the E input. Add it as an optional gpio.

The mux gpios are not guaranteed to be updated atomically.
gpiod_multi_set_value_cansleep() groups them per gpio controller, and
only controllers implementing set_multiple() can possibly update theirs
in a single write, so a mux with its address inputs spread over two
controllers passes through the intermediate addresses on every change.
Deassert the enable gpio for the duration of the update and assert it
once the address is settled.

The enable gpio is also what makes an idle state of MUX_IDLE_DISCONNECT
possible, which the mux core applies when the chip is registered and after
every deselect: it leaves the enable gpio deasserted and the address
inputs alone. Refuse that idle state without an enable gpio, because the
address inputs cannot disconnect anything on their own and mux_gpio_set()
would instead drive them to the bit pattern of MUX_IDLE_DISCONNECT.

Return the status of the gpio writes instead of zero. For a gpio on an
i2c expander the write can fail, and mux_control_set() only invalidates
the cached state when set() reports an error, so a failure reported as
success would leave the mux on the previous channel with later selects
of the same state skipping the write entirely.

Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
 drivers/mux/gpio.c | 43 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 35 insertions(+), 8 deletions(-)

diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index f9c7863e51b82fb76ed03cf17308fae74716cf6d..cb2f38c1a9e247478f97fffaf1d5ddae4315d1a7 100644
--- a/drivers/mux/gpio.c
+++ b/drivers/mux/gpio.c
@@ -18,6 +18,7 @@
 
 struct mux_gpio {
 	struct gpio_descs *gpios;
+	struct gpio_desc *enable;
 };
 
 static int mux_gpio_set(struct mux_control *mux, int state)
@@ -25,12 +26,26 @@ static int mux_gpio_set(struct mux_control *mux, int state)
 	struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip);
 	DECLARE_BITMAP(values, BITS_PER_TYPE(state));
 	u32 value = state;
+	int ret;
+
+	/*
+	 * The gpios might not be updated atomically, disable the mux
+	 * meanwhile.
+	 */
+	ret = gpiod_set_value_cansleep(mux_gpio->enable, 0);
+	if (ret)
+		return ret;
+
+	if (state == MUX_IDLE_DISCONNECT)
+		return 0;
 
 	bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
 
-	gpiod_multi_set_value_cansleep(mux_gpio->gpios, values);
+	ret = gpiod_multi_set_value_cansleep(mux_gpio->gpios, values);
+	if (ret)
+		return ret;
 
-	return 0;
+	return gpiod_set_value_cansleep(mux_gpio->enable, 1);
 }
 
 static const struct mux_control_ops mux_gpio_ops = {
@@ -63,6 +78,11 @@ static int mux_gpio_probe(struct platform_device *pdev)
 	mux_gpio = mux_chip_priv(mux_chip);
 	mux_chip->ops = &mux_gpio_ops;
 
+	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 optional enable gpio\n");
+
 	mux_gpio->gpios = devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW);
 	if (IS_ERR(mux_gpio->gpios))
 		return dev_err_probe(dev, PTR_ERR(mux_gpio->gpios),
@@ -71,15 +91,22 @@ static int mux_gpio_probe(struct platform_device *pdev)
 	mux_chip->mux->states = BIT(pins);
 
 	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) {
-			dev_err(dev, "invalid idle-state %u\n", idle_state);
-			return -EINVAL;
-		}
+	if (ret < 0)
+		idle_state = mux_chip->mux->idle_state;
 
-		mux_chip->mux->idle_state = idle_state;
+	if (idle_state == MUX_IDLE_DISCONNECT && !mux_gpio->enable) {
+		dev_err(dev, "idle-state disconnect requires enable-gpios\n");
+		return -EINVAL;
 	}
 
+	if (idle_state != MUX_IDLE_AS_IS && idle_state != MUX_IDLE_DISCONNECT &&
+	    (idle_state < 0 || idle_state >= mux_chip->mux->states)) {
+		dev_err(dev, "invalid idle-state %d\n", idle_state);
+		return -EINVAL;
+	}
+
+	mux_chip->mux->idle_state = idle_state;
+
 	ret = devm_regulator_get_enable_optional(dev, "mux");
 	if (ret && ret != -ENODEV)
 		return dev_err_probe(dev, ret, "failed to get/enable mux supply\n");

-- 
2.47.3


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios
  2026-11-05 10:11 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios Tapio Reijonen
@ 2026-11-05 12:57   ` Alvin Šipraga
  0 siblings, 0 replies; 5+ messages in thread
From: Alvin Šipraga @ 2026-11-05 12:57 UTC (permalink / raw)
  To: Tapio Reijonen
  Cc: Greg Kroah-Hartman, Peter Rosin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, devicetree, linux-kernel,
	Conor Dooley

On Thu, Nov 05, 2026 at 10:11:04AM +0000, Tapio Reijonen wrote:
> Analog multiplexers have an enable input besides the address inputs. On a
> 74HC4051 it is the E input: with E high, all eight switches are in the
> high-impedance off state, independent of S0 to S2. A 74HC4067 works the
> same way with four address inputs.
> 
> Two things need that input. The mux-controller binding describes an idle
> state of disconnect, which a gpio-mux cannot reach today because the
> address inputs always select a channel. And the address inputs are plain
> gpios that may live on different gpio controllers, so they are not
> updated in one go and the mux passes through the intermediate addresses
> on every channel change unless it is disabled meanwhile.
> 
> Add enable-gpios to describe the enable input, and require it for an idle
> state of disconnect.
> 
> Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
> Acked-by: Conor Dooley <conor.dooley@microchip.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

> ---
>  .../devicetree/bindings/mux/gpio-mux.yaml          | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/mux/gpio-mux.yaml b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
> index ef7e33ec85d479ce57c5fe4a780f81a08a6ab6ba..2dd94704fd7bde238af4e84af87c2ad8e955eb14 100644
> --- a/Documentation/devicetree/bindings/mux/gpio-mux.yaml
> +++ b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
> @@ -29,6 +29,14 @@ properties:
>      description:
>        Regulator to power on the multiplexer.
>  
> +  enable-gpios:
> +    maxItems: 1
> +    description:
> +      Enable input of the multiplexer, which disconnects all channels when
> +      deasserted, independent of mux-gpios. Deasserted while the mux-gpios
> +      are updated and for an idle state of disconnect, which cannot be
> +      reached with the mux-gpios alone and thus requires this gpio.
> +
>    '#mux-control-cells':
>      enum: [ 0, 1 ]
>  
> @@ -47,11 +55,23 @@ anyOf:
>    - required:
>        - "#mux-state-cells"
>  
> +allOf:
> +  - if:
> +      properties:
> +        idle-state:
> +          const: -2
> +      required:
> +        - idle-state
> +    then:
> +      required:
> +        - enable-gpios
> +
>  additionalProperties: false
>  
>  examples:
>    - |
>      #include <dt-bindings/gpio/gpio.h>
> +    #include <dt-bindings/mux/mux.h>
>  
>      mux: mux-controller {
>          compatible = "gpio-mux";
> @@ -59,6 +79,8 @@ examples:
>  
>          mux-gpios = <&pioA 0 GPIO_ACTIVE_HIGH>,
>                <&pioA 1 GPIO_ACTIVE_HIGH>;
> +        enable-gpios = <&pioA 2 GPIO_ACTIVE_LOW>;
> +        idle-state = <MUX_IDLE_DISCONNECT>;
>      };
>  
>      adc-mux {
> 
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v5 2/2] mux: gpio: Add optional enable gpio
  2026-11-05 10:11 ` [PATCH v5 2/2] mux: gpio: Add optional enable gpio Tapio Reijonen
@ 2026-11-05 12:57   ` Alvin Šipraga
  0 siblings, 0 replies; 5+ messages in thread
From: Alvin Šipraga @ 2026-11-05 12:57 UTC (permalink / raw)
  To: Tapio Reijonen
  Cc: Greg Kroah-Hartman, Peter Rosin, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, devicetree, linux-kernel

On Thu, Nov 05, 2026 at 10:11:05AM +0000, Tapio Reijonen wrote:
> Some analog multiplexers have an enable input that disconnects all
> channels when deasserted, independent of the address inputs; on a
> 74HC4051 it is the E input. Add it as an optional gpio.
> 
> The mux gpios are not guaranteed to be updated atomically.
> gpiod_multi_set_value_cansleep() groups them per gpio controller, and
> only controllers implementing set_multiple() can possibly update theirs
> in a single write, so a mux with its address inputs spread over two
> controllers passes through the intermediate addresses on every change.
> Deassert the enable gpio for the duration of the update and assert it
> once the address is settled.
> 
> The enable gpio is also what makes an idle state of MUX_IDLE_DISCONNECT
> possible, which the mux core applies when the chip is registered and after
> every deselect: it leaves the enable gpio deasserted and the address
> inputs alone. Refuse that idle state without an enable gpio, because the
> address inputs cannot disconnect anything on their own and mux_gpio_set()
> would instead drive them to the bit pattern of MUX_IDLE_DISCONNECT.
> 
> Return the status of the gpio writes instead of zero. For a gpio on an
> i2c expander the write can fail, and mux_control_set() only invalidates
> the cached state when set() reports an error, so a failure reported as
> success would leave the mux on the previous channel with later selects
> of the same state skipping the write entirely.
> 
> Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>

Reviewed-by: Alvin Šipraga <alvin.sipraga@analog.com>

> ---
>  drivers/mux/gpio.c | 43 +++++++++++++++++++++++++++++++++++--------
>  1 file changed, 35 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
> index f9c7863e51b82fb76ed03cf17308fae74716cf6d..cb2f38c1a9e247478f97fffaf1d5ddae4315d1a7 100644
> --- a/drivers/mux/gpio.c
> +++ b/drivers/mux/gpio.c
> @@ -18,6 +18,7 @@
>  
>  struct mux_gpio {
>  	struct gpio_descs *gpios;
> +	struct gpio_desc *enable;
>  };
>  
>  static int mux_gpio_set(struct mux_control *mux, int state)
> @@ -25,12 +26,26 @@ static int mux_gpio_set(struct mux_control *mux, int state)
>  	struct mux_gpio *mux_gpio = mux_chip_priv(mux->chip);
>  	DECLARE_BITMAP(values, BITS_PER_TYPE(state));
>  	u32 value = state;
> +	int ret;
> +
> +	/*
> +	 * The gpios might not be updated atomically, disable the mux
> +	 * meanwhile.
> +	 */
> +	ret = gpiod_set_value_cansleep(mux_gpio->enable, 0);
> +	if (ret)
> +		return ret;
> +
> +	if (state == MUX_IDLE_DISCONNECT)
> +		return 0;
>  
>  	bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
>  
> -	gpiod_multi_set_value_cansleep(mux_gpio->gpios, values);
> +	ret = gpiod_multi_set_value_cansleep(mux_gpio->gpios, values);
> +	if (ret)
> +		return ret;
>  
> -	return 0;
> +	return gpiod_set_value_cansleep(mux_gpio->enable, 1);
>  }
>  
>  static const struct mux_control_ops mux_gpio_ops = {
> @@ -63,6 +78,11 @@ static int mux_gpio_probe(struct platform_device *pdev)
>  	mux_gpio = mux_chip_priv(mux_chip);
>  	mux_chip->ops = &mux_gpio_ops;
>  
> +	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 optional enable gpio\n");
> +
>  	mux_gpio->gpios = devm_gpiod_get_array(dev, "mux", GPIOD_OUT_LOW);
>  	if (IS_ERR(mux_gpio->gpios))
>  		return dev_err_probe(dev, PTR_ERR(mux_gpio->gpios),
> @@ -71,15 +91,22 @@ static int mux_gpio_probe(struct platform_device *pdev)
>  	mux_chip->mux->states = BIT(pins);
>  
>  	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) {
> -			dev_err(dev, "invalid idle-state %u\n", idle_state);
> -			return -EINVAL;
> -		}
> +	if (ret < 0)
> +		idle_state = mux_chip->mux->idle_state;
>  
> -		mux_chip->mux->idle_state = idle_state;
> +	if (idle_state == MUX_IDLE_DISCONNECT && !mux_gpio->enable) {
> +		dev_err(dev, "idle-state disconnect requires enable-gpios\n");
> +		return -EINVAL;
>  	}
>  
> +	if (idle_state != MUX_IDLE_AS_IS && idle_state != MUX_IDLE_DISCONNECT &&
> +	    (idle_state < 0 || idle_state >= mux_chip->mux->states)) {
> +		dev_err(dev, "invalid idle-state %d\n", idle_state);
> +		return -EINVAL;
> +	}
> +
> +	mux_chip->mux->idle_state = idle_state;
> +
>  	ret = devm_regulator_get_enable_optional(dev, "mux");
>  	if (ret && ret != -ENODEV)
>  		return dev_err_probe(dev, ret, "failed to get/enable mux supply\n");
> 
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-05 12:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-05 10:11 [PATCH v5 0/2] mux: gpio: Add optional enable gpio Tapio Reijonen
2026-11-05 10:11 ` [PATCH v5 1/2] dt-bindings: mux: gpio-mux: Add enable-gpios Tapio Reijonen
2026-11-05 12:57   ` Alvin Šipraga
2026-11-05 10:11 ` [PATCH v5 2/2] mux: gpio: Add optional enable gpio Tapio Reijonen
2026-11-05 12:57   ` Alvin Šipraga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®