* [PATCH 0/2] mux: gpio: Add external mux enable gpio
@ 2025-11-05 14:49 Tapio Reijonen
2025-11-05 14:49 ` [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO Tapio Reijonen
2025-11-05 14:49 ` [PATCH 2/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
0 siblings, 2 replies; 6+ messages in thread
From: Tapio Reijonen @ 2025-11-05 14:49 UTC (permalink / raw)
To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Tapio Reijonen
The output state of a mux might be misinterpreted
during transition from one state to another.
Using a dedicated optional gpio pin, the validity
of the mux state can be communicated to connected devices.
This series adds support for defining the optional
gpio pin for this purpose, along with documentation.
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
Tapio Reijonen (2):
dt-bindings: mux: Add description for enable GPIO
mux: gpio: Add external mux enable gpio
.../devicetree/bindings/mux/gpio-mux.yaml | 5 ++++
drivers/mux/gpio.c | 30 +++++++++++++++++-----
2 files changed, 29 insertions(+), 6 deletions(-)
---
base-commit: e53642b87a4f4b03a8d7e5f8507fc3cd0c595ea6
change-id: 20250925-add-external-mux-enable-gpio-c9ba5beddd49
Best regards,
--
Tapio Reijonen <tapio.reijonen@vaisala.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO
2025-11-05 14:49 [PATCH 0/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
@ 2025-11-05 14:49 ` Tapio Reijonen
2025-11-06 9:08 ` Krzysztof Kozlowski
2025-11-05 14:49 ` [PATCH 2/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
1 sibling, 1 reply; 6+ messages in thread
From: Tapio Reijonen @ 2025-11-05 14:49 UTC (permalink / raw)
To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Tapio Reijonen
Add description for enabling GPIO-controlled multiplexer
GPIO pins, according to the state of the mux idle state.
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
Documentation/devicetree/bindings/mux/gpio-mux.yaml | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/Documentation/devicetree/bindings/mux/gpio-mux.yaml b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
index ef7e33ec85d479ce57c5fe4a780f81a08a6ab6ba..5fb26f4b65d5a24747e515f6ce358eecc36f182f 100644
--- a/Documentation/devicetree/bindings/mux/gpio-mux.yaml
+++ b/Documentation/devicetree/bindings/mux/gpio-mux.yaml
@@ -29,6 +29,11 @@ properties:
description:
Regulator to power on the multiplexer.
+ enable-gpios:
+ description:
+ External gpio output that signals mux-gpios are in a valid state.
+ Logic low when state of the mux is idle, high otherwise.
+
'#mux-control-cells':
enum: [ 0, 1 ]
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] mux: gpio: Add external mux enable gpio
2025-11-05 14:49 [PATCH 0/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
2025-11-05 14:49 ` [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO Tapio Reijonen
@ 2025-11-05 14:49 ` Tapio Reijonen
1 sibling, 0 replies; 6+ messages in thread
From: Tapio Reijonen @ 2025-11-05 14:49 UTC (permalink / raw)
To: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley
Cc: devicetree, linux-kernel, Tapio Reijonen
Add optional gpio to control gpio-controlled multiplexer
gpio pins, according to the state of the mux.
When the gpio mux controller transitions state,
it first configures all required gpio mux pins,
and then sets optional enable gpio pin to logic high.
When gpio mux controller sets "MUX_IDLE_DISCONNECT",
the optional enable gpio pin is set low.
Signed-off-by: Tapio Reijonen <tapio.reijonen@vaisala.com>
---
drivers/mux/gpio.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/mux/gpio.c b/drivers/mux/gpio.c
index 4cc3202c58f364e80ad9f632763f568d184d4173..ee2bca1214d67feb3031fe60556b68b59293f0e3 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_gpio;
};
static int mux_gpio_set(struct mux_control *mux, int state)
@@ -27,10 +28,18 @@ static int mux_gpio_set(struct mux_control *mux, int state)
DECLARE_BITMAP(values, BITS_PER_TYPE(state));
u32 value = state;
+ if (mux_gpio->enable_gpio && state == MUX_IDLE_DISCONNECT) {
+ gpiod_set_value_cansleep(mux_gpio->enable_gpio, 0);
+ return 0;
+ }
+
bitmap_from_arr32(values, &value, BITS_PER_TYPE(value));
gpiod_multi_set_value_cansleep(mux_gpio->gpios, values);
+ if (mux_gpio->enable_gpio)
+ gpiod_set_value_cansleep(mux_gpio->enable_gpio, 1);
+
return 0;
}
@@ -71,14 +80,23 @@ 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_gpio = devm_gpiod_get_optional(dev, "enable", GPIOD_OUT_LOW);
+ if (IS_ERR(mux_gpio->enable_gpio))
+ return dev_err_probe(dev, PTR_ERR(mux_gpio->enable_gpio),
+ "failed to get optional 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) {
- dev_err(dev, "invalid idle-state %u\n", idle_state);
- return -EINVAL;
+ if (ret >= 0) {
+ if (idle_state == MUX_IDLE_DISCONNECT)
+ mux_chip->mux->idle_state = MUX_IDLE_DISCONNECT;
+ else if (idle_state != MUX_IDLE_AS_IS) {
+ if (idle_state < 0 || idle_state >= mux_chip->mux->states) {
+ return dev_err_probe(dev, -EINVAL,
+ "invalid idle-state %d\n",
+ idle_state);
+ }
+ mux_chip->mux->idle_state = idle_state;
}
-
- mux_chip->mux->idle_state = idle_state;
}
ret = devm_regulator_get_enable_optional(dev, "mux");
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO
2025-11-05 14:49 ` [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO Tapio Reijonen
@ 2025-11-06 9:08 ` Krzysztof Kozlowski
2025-11-06 11:55 ` Tapio Reijonen
0 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 9:08 UTC (permalink / raw)
To: Tapio Reijonen
Cc: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
devicetree, linux-kernel
On Wed, Nov 05, 2025 at 02:49:12PM +0000, Tapio Reijonen wrote:
> Add description for enabling GPIO-controlled multiplexer
> GPIO pins, according to the state of the mux idle state.
You basically repeated binding. Please explain here which GPIO this is,
e.g. give concrete device example.
subject prefix - missing gpio-mux:. You are not adding enable GPIO to
entire/all mux bindings.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO
2025-11-06 9:08 ` Krzysztof Kozlowski
@ 2025-11-06 11:55 ` Tapio Reijonen
2025-11-06 12:18 ` Krzysztof Kozlowski
0 siblings, 1 reply; 6+ messages in thread
From: Tapio Reijonen @ 2025-11-06 11:55 UTC (permalink / raw)
To: Krzysztof Kozlowski
Cc: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
devicetree, linux-kernel
Hi,
On 11/6/25 11:08, Krzysztof Kozlowski wrote:
> On Wed, Nov 05, 2025 at 02:49:12PM +0000, Tapio Reijonen wrote:
>> Add description for enabling GPIO-controlled multiplexer
>> GPIO pins, according to the state of the mux idle state.
>
> You basically repeated binding. Please explain here which GPIO this is,
> e.g. give concrete device example.
>
Here is the example:
mux: mux-controller {
compatible = "gpio-mux";
#mux-control-cells = <0>;
mux-gpios =
<&gpio4 22 GPIO_ACTIVE_HIGH>,
<&gpio2 18 GPIO_ACTIVE_HIGH>,
<&gpio2 13 GPIO_ACTIVE_HIGH>,
<&gpio2 17 GPIO_ACTIVE_HIGH>;
idle-state = <MUX_IDLE_DISCONNECT>;
/* BUS_EN */
enable-gpios = <&gpio4 27 GPIO_ACTIVE_LOW>;
};
> subject prefix - missing gpio-mux:. You are not adding enable GPIO to
> entire/all mux bindings.
> Going to change subject "dt-bindings: gpio-mux: Add description for
enable GPIO"> Best regards,
> Krzysztof
>
--
Many thanks,
Tapio Reijonen
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO
2025-11-06 11:55 ` Tapio Reijonen
@ 2025-11-06 12:18 ` Krzysztof Kozlowski
0 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-11-06 12:18 UTC (permalink / raw)
To: Tapio Reijonen
Cc: Peter Rosin, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
devicetree, linux-kernel
On 06/11/2025 12:55, Tapio Reijonen wrote:
> Hi,
>
> On 11/6/25 11:08, Krzysztof Kozlowski wrote:
>> On Wed, Nov 05, 2025 at 02:49:12PM +0000, Tapio Reijonen wrote:
>>> Add description for enabling GPIO-controlled multiplexer
>>> GPIO pins, according to the state of the mux idle state.
>>
>> You basically repeated binding. Please explain here which GPIO this is,
>> e.g. give concrete device example.
>>
> Here is the example:
> mux: mux-controller {
> compatible = "gpio-mux";
> #mux-control-cells = <0>;
>
> mux-gpios =
> <&gpio4 22 GPIO_ACTIVE_HIGH>,
> <&gpio2 18 GPIO_ACTIVE_HIGH>,
> <&gpio2 13 GPIO_ACTIVE_HIGH>,
> <&gpio2 17 GPIO_ACTIVE_HIGH>;
> idle-state = <MUX_IDLE_DISCONNECT>;
> /* BUS_EN */
> enable-gpios = <&gpio4 27 GPIO_ACTIVE_LOW>;
I meant real device, so I can look at datasheet and understand how/why
you do it. This also is supposed to be in the commit msg.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-06 12:18 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-05 14:49 [PATCH 0/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
2025-11-05 14:49 ` [PATCH 1/2] dt-bindings: mux: Add description for enable GPIO Tapio Reijonen
2025-11-06 9:08 ` Krzysztof Kozlowski
2025-11-06 11:55 ` Tapio Reijonen
2025-11-06 12:18 ` Krzysztof Kozlowski
2025-11-05 14:49 ` [PATCH 2/2] mux: gpio: Add external mux enable gpio Tapio Reijonen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).