* [PATCH v4 0/2] add gpio-line-mux
@ 2025-11-05 10:36 Jonas Jelonek
2025-11-05 10:36 ` [PATCH v4 1/2] dt-bindings: gpio: add gpio-line-mux controller Jonas Jelonek
2025-11-05 10:36 ` [PATCH v4 2/2] gpio: add gpio-line-mux driver Jonas Jelonek
0 siblings, 2 replies; 12+ messages in thread
From: Jonas Jelonek @ 2025-11-05 10:36 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Rob Herring,
Krzysztof Kozlowski, Conor Dooley, Peter Rosin,
Geert Uytterhoeven
Cc: linux-gpio, devicetree, linux-kernel, Thomas Richard,
Jonas Jelonek
This proposes a new type of virtual GPIO controller and corresponding
driver to provide a 1-to-many mapping between virtual GPIOs and a single
real GPIO in combination with a multiplexer. Existing drivers apparently
do not serve the purpose for what I need.
I came across an issue with a switch device from Zyxel which has two
SFP+ cages. Most similar switches either wire up the SFP signals
(RX_LOS, MOD_ABS, TX_FAULT, TX_DISABLE) directly to the SoC (if it has
enough GPIOs) or two a GPIO expander (for which a driver usually
exists). However, Zyxel decided to do it differently in the following
way:
The signals RX_LOS, MOD_ABS and TX_FAULT share a single GPIO line to
the SoC. Which one is actually connected to that GPIO line at a time
is controlled by a separate multiplexer, a GPIO multiplexer in this
case (which uses two other GPIOs). Only the TX_DISABLE is separate.
The SFP core/driver doesn't seem to support such a usecase for now, for
each signal one needs to specify a separate GPIO like:
los-gpio = <&gpio0 0 GPIO_ACTIVE_HIGH>;
mod-def0-gpio = <&gpio0 1 GPIO_ACTIVE_LOW>;
...
But for my device, I actually need to directly specify multiplexing
behavior in the SFP node or provide a mux-controller with 'mux-controls'.
To fill this gap, I created a dt-schema and a working driver which
exactly does what is needed. It takes a phandle to a mux-controller and
the 'shared' gpio, and provides several virtual GPIOs based on the
gpio-line-mux-states property.
This virtual gpio-controller can then be referenced in the '-gpio'
properties of the SFP node (or other nodes depending on the usecase) as
usual and do not require any modification to the SFP core/driver.
---
Changelog:
v4: - dropped useless cast (as suggested by Thomas)
- dropped unneeded locking (as suggested by Peter)
- fixed wording in commit message
- included Reviewed-by of Krzysztof
Link to v3:
https://lore.kernel.org/linux-gpio/20251104210021.247476-1-jelonek.jonas@gmail.com/
v3: - fixed dt_binding_check errors in DT schema
- as requested by Rob (for DT schema):
- removed example from gpio-mux.yaml
- added '|' to preserve formatting
- 'shared-gpio' --> 'shared-gpios'
- general fixes to DT schema
- use mux_control_select_delay (as suggested by Peter) with
hopefully reasonable delay of 100us
- gpiochip ops implementation changes:
- drop '.set' implementation (as suggested by Peter)
- new '.set' implementation just returning -EOPNOTSUPP
- '.direction_output' and '.direction_input' dropped
- '.get_direction' returns fixed value for 'input'
- direction of shared gpio set to input during probe
- as suggested by Thomas
- usage of dev_err_probe
- further simplifications
Since the consensus was that this should be input-only,
'.direction_output' and '.direction_input' have been dropped
completely, as suggested in the docs of struct gpio_chip. '.set' is
kept but returns -ENOTSUPP.
The shared GPIO is set to input during probe, thus '.direction_input'
doesn't need to be implemented. '.get_direction' is kept (as
suggested in docs of struct gpio_chip) but always returns
GPIO_LINE_DIRECTION_IN.
Link to v2:
https://lore.kernel.org/linux-gpio/20251026231754.2368904-1-jelonek.jonas@gmail.com/
v2: - as requested by Linus:
- renamed from 'gpio-split' to 'gpio-line-mux'
- added better description and examples to DT bindings
- simplified driver
- added missing parts to DT bindings
- dropped RFC tag
- renamed patchset
Link to v1 (in case it isn't linked properly due to changed title):
https://lore.kernel.org/linux-gpio/20251009223501.570949-1-jelonek.jonas@gmail.com/
---
Jonas Jelonek (2):
dt-bindings: gpio: add gpio-line-mux controller
gpio: add gpio-line-mux driver
.../bindings/gpio/gpio-line-mux.yaml | 109 +++++++++++++++
MAINTAINERS | 6 +
drivers/gpio/Kconfig | 9 ++
drivers/gpio/Makefile | 1 +
drivers/gpio/gpio-line-mux.c | 129 ++++++++++++++++++
5 files changed, 254 insertions(+)
create mode 100644 Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml
create mode 100644 drivers/gpio/gpio-line-mux.c
base-commit: bac88be0d2a83daf761129828e7ae3c79cc260c2
--
2.48.1
^ permalink raw reply [flat|nested] 12+ messages in thread* [PATCH v4 1/2] dt-bindings: gpio: add gpio-line-mux controller 2025-11-05 10:36 [PATCH v4 0/2] add gpio-line-mux Jonas Jelonek @ 2025-11-05 10:36 ` Jonas Jelonek 2025-11-05 10:36 ` [PATCH v4 2/2] gpio: add gpio-line-mux driver Jonas Jelonek 1 sibling, 0 replies; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 10:36 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven Cc: linux-gpio, devicetree, linux-kernel, Thomas Richard, Jonas Jelonek, Krzysztof Kozlowski Add dt-schema for a gpio-line-mux controller which exposes virtual GPIOs for a shared GPIO controlled by a multiplexer, e.g. a gpio-mux. The gpio-line-mux controller is a gpio-controller, thus has mostly the same semantics. However, it requires a mux-control to be specified upon which it will operate. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- .../bindings/gpio/gpio-line-mux.yaml | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml diff --git a/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml b/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml new file mode 100644 index 000000000000..fb91500fa10f --- /dev/null +++ b/Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml @@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/gpio/gpio-line-mux.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: GPIO line mux + +maintainers: + - Jonas Jelonek <jelonek.jonas@gmail.com> + +description: | + A GPIO controller to provide virtual GPIOs for a 1-to-many input-only mapping + backed by a single shared GPIO and a multiplexer. A simple illustrated + example is + + +----- A + IN / + <-----o------- B + / |\ + | | +----- C + | | \ + | | +--- D + | | + M1 M0 + + MUX CONTROL + + M1 M0 IN + 0 0 A + 0 1 B + 1 0 C + 1 1 D + + This can be used in case a real GPIO is connected to multiple inputs and + controlled by a multiplexer, and another subsystem/driver does not work + directly with the multiplexer subsystem. + +properties: + compatible: + const: gpio-line-mux + + gpio-controller: true + + "#gpio-cells": + const: 2 + + gpio-line-mux-states: + description: Mux states corresponding to the virtual GPIOs. + $ref: /schemas/types.yaml#/definitions/uint32-array + + gpio-line-names: true + + mux-controls: + $ref: /schemas/types.yaml#/definitions/phandle-array + maxItems: 1 + description: + Phandle to the multiplexer to control access to the GPIOs. + + ngpios: false + + shared-gpios: + maxItems: 1 + description: + GPIO which is the '1' in 1-to-many and is shared by the virtual GPIOs + and controlled via the mux. + +required: + - compatible + - gpio-controller + - gpio-line-mux-states + - mux-controls + - shared-gpios + +additionalProperties: false + +examples: + - | + #include <dt-bindings/gpio/gpio.h> + #include <dt-bindings/mux/mux.h> + + sfp_gpio_mux: mux-controller-1 { + compatible = "gpio-mux"; + mux-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>, + <&gpio0 1 GPIO_ACTIVE_HIGH>; + #mux-control-cells = <0>; + idle-state = <MUX_IDLE_AS_IS>; + }; + + sfp1_gpio: sfp-gpio-1 { + compatible = "gpio-line-mux"; + gpio-controller; + #gpio-cells = <2>; + + mux-controls = <&sfp_gpio_mux>; + shared-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; + + gpio-line-names = "SFP1_LOS", "SFP1_MOD_ABS", "SFP1_TX_FAULT"; + gpio-line-mux-states = <0>, <1>, <3>; + }; + + sfp1: sfp-p1 { + compatible = "sff,sfp"; + + i2c-bus = <&sfp1_i2c>; + los-gpios = <&sfp1_gpio 0 GPIO_ACTIVE_HIGH>; + mod-def0-gpios = <&sfp1_gpio 1 GPIO_ACTIVE_LOW>; + tx-fault-gpios = <&sfp1_gpio 2 GPIO_ACTIVE_HIGH>; + }; -- 2.48.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 10:36 [PATCH v4 0/2] add gpio-line-mux Jonas Jelonek 2025-11-05 10:36 ` [PATCH v4 1/2] dt-bindings: gpio: add gpio-line-mux controller Jonas Jelonek @ 2025-11-05 10:36 ` Jonas Jelonek 2025-11-05 13:15 ` Bartosz Golaszewski 2025-11-05 13:26 ` Thomas Richard 1 sibling, 2 replies; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 10:36 UTC (permalink / raw) To: Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven Cc: linux-gpio, devicetree, linux-kernel, Thomas Richard, Jonas Jelonek Add a new driver which provides a 1-to-many mapping for a single real GPIO using a multiplexer. Each virtual GPIO corresponds to a multiplexer state which, if set for the multiplexer, connects the real GPIO to the corresponding virtual GPIO. This can help in various usecases. One practical case is the special hardware design of the Realtek-based XS1930-10 switch from Zyxel. It features two SFP+ ports/cages whose signals are wired directly to the switch SoC. Although Realtek SoCs are short on GPIOs, there are usually enough the fit the SFP signals without any hacks. However, Zyxel did some weird design and connected RX_LOS, MOD_ABS and TX_FAULT of one SFP cage onto a single GPIO line controlled by a multiplexer (the same for the other SFP cage). The single multiplexer controls the lines for both SFP and depending on the state, the designated 'signal GPIO lines' are connected to one of the three SFP signals. Because the SFP core/driver doesn't support multiplexer but needs single GPIOs for each of the signals, this driver fills the gap between both. It registers a gpio_chip, provides multiple virtual GPIOs and sets the backing multiplexer accordingly. Due to several practical issues, this is input-only and doesn't support IRQs. Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> --- MAINTAINERS | 6 ++ drivers/gpio/Kconfig | 9 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-line-mux.c | 129 +++++++++++++++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 drivers/gpio/gpio-line-mux.c diff --git a/MAINTAINERS b/MAINTAINERS index 3da2c26a796b..66f8706d9b4b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -10653,6 +10653,12 @@ S: Maintained F: Documentation/devicetree/bindings/leds/irled/gpio-ir-tx.yaml F: drivers/media/rc/gpio-ir-tx.c +GPIO LINE MUX +M: Jonas Jelonek <jelonek.jonas@gmail.com> +S: Maintained +F: Documentation/devicetree/bindings/gpio/gpio-line-mux.yaml +F: drivers/gpio/gpio-line-mux.c + GPIO MOCKUP DRIVER M: Bamvor Jian Zhang <bamv2005@gmail.com> L: linux-gpio@vger.kernel.org diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index ce237398fa00..5f8082ae99cc 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -1986,6 +1986,15 @@ config GPIO_LATCH Say yes here to enable a driver for GPIO multiplexers based on latches connected to other GPIOs. +config GPIO_LINE_MUX + tristate "GPIO line mux driver" + depends on OF_GPIO + select MULTIPLEXER + help + Say Y here to support the GPIO line mux, which can provide virtual + GPIOs backed by a shared real GPIO and a multiplexer in a 1-to-many + fashion. + config GPIO_MOCKUP tristate "GPIO Testing Driver (DEPRECATED)" select IRQ_SIM diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index ee260a0809d3..6caee52b0356 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -89,6 +89,7 @@ obj-$(CONFIG_GPIO_IXP4XX) += gpio-ixp4xx.o obj-$(CONFIG_GPIO_JANZ_TTL) += gpio-janz-ttl.o obj-$(CONFIG_GPIO_KEMPLD) += gpio-kempld.o obj-$(CONFIG_GPIO_LATCH) += gpio-latch.o +obj-$(CONFIG_GPIO_LINE_MUX) += gpio-line-mux.o obj-$(CONFIG_GPIO_LJCA) += gpio-ljca.o obj-$(CONFIG_GPIO_LOGICVC) += gpio-logicvc.o obj-$(CONFIG_GPIO_LOONGSON1) += gpio-loongson1.o diff --git a/drivers/gpio/gpio-line-mux.c b/drivers/gpio/gpio-line-mux.c new file mode 100644 index 000000000000..50e351d212b8 --- /dev/null +++ b/drivers/gpio/gpio-line-mux.c @@ -0,0 +1,129 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * GPIO line mux which acts as virtual gpiochip and provides a 1-to-many + * mapping between virtual GPIOs and a real GPIO + multiplexer. + * + * Copyright (c) 2025 Jonas Jelonek <jelonek.jonas@gmail.com> + */ + +#include <linux/gpio/consumer.h> +#include <linux/gpio/driver.h> +#include <linux/mod_devicetable.h> +#include <linux/mutex.h> +#include <linux/mux/consumer.h> +#include <linux/platform_device.h> + +#define MUX_SELECT_DELAY_US 100 + +struct gpio_lmux { + struct gpio_chip gc; + struct mux_control *mux; + + struct gpio_desc *shared_gpio; + /* dynamically sized, must be last */ + unsigned int gpio_mux_states[]; +}; + +static int gpio_lmux_gpio_get(struct gpio_chip *gc, unsigned int offset) +{ + struct gpio_lmux *glm = gpiochip_get_data(gc); + int ret; + + if (offset > gc->ngpio) + return -EINVAL; + + ret = mux_control_select_delay(glm->mux, glm->gpio_mux_states[offset], + MUX_SELECT_DELAY_US); + if (ret < 0) + return ret; + + ret = gpiod_get_raw_value_cansleep(glm->shared_gpio); + mux_control_deselect(glm->mux); + return ret; +} + +static int gpio_lmux_gpio_set(struct gpio_chip *gc, unsigned int offset, + int value) +{ + return -EOPNOTSUPP; +} + +static int gpio_lmux_gpio_get_direction(struct gpio_chip *gc, + unsigned int offset) +{ + return GPIO_LINE_DIRECTION_IN; +} + +static int gpio_lmux_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct gpio_lmux *glm; + unsigned int ngpio; + size_t size; + int ret; + + ngpio = device_property_count_u32(dev, "gpio-line-mux-states"); + if (!ngpio) + return -EINVAL; + + size = struct_size(glm, gpio_mux_states, ngpio); + glm = devm_kzalloc(dev, size, GFP_KERNEL); + if (!glm) + return -ENOMEM; + + glm->gc.base = -1; + glm->gc.can_sleep = true; + glm->gc.fwnode = dev_fwnode(dev); + glm->gc.label = dev_name(dev); + glm->gc.ngpio = ngpio; + glm->gc.owner = THIS_MODULE; + glm->gc.parent = dev; + + glm->gc.get = gpio_lmux_gpio_get; + glm->gc.set = gpio_lmux_gpio_set; + glm->gc.get_direction = gpio_lmux_gpio_get_direction; + + glm->mux = devm_mux_control_get(dev, NULL); + if (IS_ERR(glm->mux)) + return dev_err_probe(dev, PTR_ERR(glm->mux), + "could not get mux controller\n"); + + glm->shared_gpio = devm_gpiod_get(dev, "shared", GPIOD_ASIS); + if (IS_ERR(glm->shared_gpio)) + return dev_err_probe(dev, PTR_ERR(glm->shared_gpio), + "could not get shared-gpio\n"); + + ret = gpiod_direction_input(glm->shared_gpio); + if (ret) + return dev_err_probe(dev, ret, "could not set shared gpio as input\n"); + + ret = device_property_read_u32_array(dev, "gpio-line-mux-states", + &glm->gpio_mux_states[0], ngpio); + if (ret) + return dev_err_probe(dev, ret, "could not get mux states\n"); + + ret = devm_gpiochip_add_data(dev, &glm->gc, glm); + if (ret) + return dev_err_probe(dev, ret, "failed to add gpiochip\n"); + + return 0; +} + +static const struct of_device_id gpio_lmux_of_match[] = { + { .compatible = "gpio-line-mux" }, + { } +}; +MODULE_DEVICE_TABLE(of, gpio_lmux_of_match); + +static struct platform_driver gpio_lmux_driver = { + .driver = { + .name = "gpio-line-mux", + .of_match_table = gpio_lmux_of_match, + }, + .probe = gpio_lmux_probe, +}; +module_platform_driver(gpio_lmux_driver); + +MODULE_AUTHOR("Jonas Jelonek <jelonek.jonas@gmail.com>"); +MODULE_DESCRIPTION("GPIO line mux driver"); +MODULE_LICENSE("GPL"); -- 2.48.1 ^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 10:36 ` [PATCH v4 2/2] gpio: add gpio-line-mux driver Jonas Jelonek @ 2025-11-05 13:15 ` Bartosz Golaszewski 2025-11-05 13:23 ` Jonas Jelonek 2025-11-05 13:28 ` Jonas Jelonek 2025-11-05 13:26 ` Thomas Richard 1 sibling, 2 replies; 12+ messages in thread From: Bartosz Golaszewski @ 2025-11-05 13:15 UTC (permalink / raw) To: Jonas Jelonek Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard On Wed, Nov 5, 2025 at 11:36 AM Jonas Jelonek <jelonek.jonas@gmail.com> wrote: > > Add a new driver which provides a 1-to-many mapping for a single real > GPIO using a multiplexer. Each virtual GPIO corresponds to a multiplexer > state which, if set for the multiplexer, connects the real GPIO to the > corresponding virtual GPIO. > > This can help in various usecases. One practical case is the special > hardware design of the Realtek-based XS1930-10 switch from Zyxel. It > features two SFP+ ports/cages whose signals are wired directly to the > switch SoC. Although Realtek SoCs are short on GPIOs, there are usually > enough the fit the SFP signals without any hacks. > > However, Zyxel did some weird design and connected RX_LOS, MOD_ABS and > TX_FAULT of one SFP cage onto a single GPIO line controlled by a > multiplexer (the same for the other SFP cage). The single multiplexer > controls the lines for both SFP and depending on the state, the > designated 'signal GPIO lines' are connected to one of the three SFP > signals. > > Because the SFP core/driver doesn't support multiplexer but needs single > GPIOs for each of the signals, this driver fills the gap between both. > It registers a gpio_chip, provides multiple virtual GPIOs and sets the > backing multiplexer accordingly. > > Due to several practical issues, this is input-only and doesn't support > IRQs. > > Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> > --- [snip] > + > + glm->mux = devm_mux_control_get(dev, NULL); > + if (IS_ERR(glm->mux)) > + return dev_err_probe(dev, PTR_ERR(glm->mux), > + "could not get mux controller\n"); > + > + glm->shared_gpio = devm_gpiod_get(dev, "shared", GPIOD_ASIS); Hi Jonas! This looks good, I'm ready to queue it but I'm afraid the consumer label "shared" will logically conflict with the work I'm doing on the shared GPIO support[1] as the shared GPIOs will appear as proxy devices containing the name "shared". Do you see any problem with changing the label to "gpio-mux"? I can even change it myself when applying. Bartosz [1] https://lore.kernel.org/all/20251029-gpio-shared-v3-0-71c568acf47c@linaro.org/ ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 13:15 ` Bartosz Golaszewski @ 2025-11-05 13:23 ` Jonas Jelonek 2025-11-05 13:24 ` Bartosz Golaszewski 2025-11-05 13:28 ` Jonas Jelonek 1 sibling, 1 reply; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 13:23 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard Hi Bartosz, On 05.11.25 14:15, Bartosz Golaszewski wrote: > Hi Jonas! > > This looks good, I'm ready to queue it but I'm afraid the consumer > label "shared" will logically conflict with the work I'm doing on the > shared GPIO support[1] as the shared GPIOs will appear as proxy > devices containing the name "shared". Do you see any problem with > changing the label to "gpio-mux"? I can even change it myself when > applying. Another name is fine for me if it conflicts with your work, as long as the name is obvious enough. Not sure about "gpio-mux" though. Maybe "muxed-gpio"?. Just let me know what you think and if I should adjust it or you do. > Bartosz > > [1] https://lore.kernel.org/all/20251029-gpio-shared-v3-0-71c568acf47c@linaro.org/ Best, Jonas ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 13:23 ` Jonas Jelonek @ 2025-11-05 13:24 ` Bartosz Golaszewski 2025-11-05 14:19 ` Peter Rosin 0 siblings, 1 reply; 12+ messages in thread From: Bartosz Golaszewski @ 2025-11-05 13:24 UTC (permalink / raw) To: Jonas Jelonek Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard On Wed, Nov 5, 2025 at 2:23 PM Jonas Jelonek <jelonek.jonas@gmail.com> wrote: > > Hi Bartosz, > > On 05.11.25 14:15, Bartosz Golaszewski wrote: > > Hi Jonas! > > > > This looks good, I'm ready to queue it but I'm afraid the consumer > > label "shared" will logically conflict with the work I'm doing on the > > shared GPIO support[1] as the shared GPIOs will appear as proxy > > devices containing the name "shared". Do you see any problem with > > changing the label to "gpio-mux"? I can even change it myself when > > applying. > > Another name is fine for me if it conflicts with your work, as long as the name is obvious > enough. Not sure about "gpio-mux" though. Maybe "muxed-gpio"?. Just let me know > what you think and if I should adjust it or you do. Yes, "muxed-gpio" is good. I can change it myself when applying. Bartosz ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 13:24 ` Bartosz Golaszewski @ 2025-11-05 14:19 ` Peter Rosin 2025-11-05 14:37 ` Jonas Jelonek 2025-11-05 15:37 ` Bartosz Golaszewski 0 siblings, 2 replies; 12+ messages in thread From: Peter Rosin @ 2025-11-05 14:19 UTC (permalink / raw) To: Bartosz Golaszewski, Jonas Jelonek Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard Hi! 2025-11-05 at 14:24, Bartosz Golaszewski wrote: > On Wed, Nov 5, 2025 at 2:23 PM Jonas Jelonek <jelonek.jonas@gmail.com> wrote: >> >> Hi Bartosz, >> >> On 05.11.25 14:15, Bartosz Golaszewski wrote: >>> Hi Jonas! >>> >>> This looks good, I'm ready to queue it but I'm afraid the consumer >>> label "shared" will logically conflict with the work I'm doing on the >>> shared GPIO support[1] as the shared GPIOs will appear as proxy >>> devices containing the name "shared". Do you see any problem with >>> changing the label to "gpio-mux"? I can even change it myself when >>> applying. >> >> Another name is fine for me if it conflicts with your work, as long as the name is obvious >> enough. Not sure about "gpio-mux" though. Maybe "muxed-gpio"?. Just let me know >> what you think and if I should adjust it or you do. > > Yes, "muxed-gpio" is good. I can change it myself when applying. > > Bartosz Isn't that the name in the device tree? Is muxed-gpio-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; really satisfactory? Can you really make that change as you apply w/o a re-review of the binding? Or, are we talking about glm->shared_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); and muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; ? Cheers, Peter ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 14:19 ` Peter Rosin @ 2025-11-05 14:37 ` Jonas Jelonek 2025-11-05 15:37 ` Bartosz Golaszewski 1 sibling, 0 replies; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 14:37 UTC (permalink / raw) To: Peter Rosin, Bartosz Golaszewski Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard Hi, On 05.11.25 15:19, Peter Rosin wrote: > Hi! > > 2025-11-05 at 14:24, Bartosz Golaszewski wrote: >> Yes, "muxed-gpio" is good. I can change it myself when applying. >> >> Bartosz > Isn't that the name in the device tree? > > Is > > muxed-gpio-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; This would be quite odd and not what I had in mind when I suggested this. But I probably didn't express myself good enough. > really satisfactory? Can you really make that change as you apply > w/o a re-review of the binding? > > Or, are we talking about > > glm->shared_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); > > and > > muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; > > ? I'd be fine with this, but as you mentioned, it needs a re-review of the bindings. If it's just about the label being used upon GPIO request, I might switch to devm_fwnode_gpiod_get_index to explicitly set a different label and keep "shared" in the bindings and device tree property? > > Cheers, > Peter Best, Jonas ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 14:19 ` Peter Rosin 2025-11-05 14:37 ` Jonas Jelonek @ 2025-11-05 15:37 ` Bartosz Golaszewski 2025-11-05 15:49 ` Jonas Jelonek 1 sibling, 1 reply; 12+ messages in thread From: Bartosz Golaszewski @ 2025-11-05 15:37 UTC (permalink / raw) To: Peter Rosin Cc: Jonas Jelonek, Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard On Wed, Nov 5, 2025 at 3:19 PM Peter Rosin <peda@axentia.se> wrote: > > Hi! > > 2025-11-05 at 14:24, Bartosz Golaszewski wrote: > > On Wed, Nov 5, 2025 at 2:23 PM Jonas Jelonek <jelonek.jonas@gmail.com> wrote: > >> > >> Hi Bartosz, > >> > >> On 05.11.25 14:15, Bartosz Golaszewski wrote: > >>> Hi Jonas! > >>> > >>> This looks good, I'm ready to queue it but I'm afraid the consumer > >>> label "shared" will logically conflict with the work I'm doing on the > >>> shared GPIO support[1] as the shared GPIOs will appear as proxy > >>> devices containing the name "shared". Do you see any problem with > >>> changing the label to "gpio-mux"? I can even change it myself when > >>> applying. > >> > >> Another name is fine for me if it conflicts with your work, as long as the name is obvious > >> enough. Not sure about "gpio-mux" though. Maybe "muxed-gpio"?. Just let me know > >> what you think and if I should adjust it or you do. > > > > Yes, "muxed-gpio" is good. I can change it myself when applying. > > > > Bartosz > > Isn't that the name in the device tree? > > Is > > muxed-gpio-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; > > really satisfactory? Can you really make that change as you apply > w/o a re-review of the binding? > Ah, that's what you get for revieweing with a fever. :/ You're right of course. And yes, we'd need to modify the bindings. > Or, are we talking about > > glm->shared_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); > > and > > muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; > > ? > I would make it: glm->muxed_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); Jonas, could you please send another version with that addressed both here and in the bindings? Bartosz ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 15:37 ` Bartosz Golaszewski @ 2025-11-05 15:49 ` Jonas Jelonek 0 siblings, 0 replies; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 15:49 UTC (permalink / raw) To: Bartosz Golaszewski, Peter Rosin Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard Hi, On 05.11.25 16:37, Bartosz Golaszewski wrote: > Ah, that's what you get for revieweing with a fever. :/ > > You're right of course. > > And yes, we'd need to modify the bindings. > >> Or, are we talking about >> >> glm->shared_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); >> >> and >> >> muxed-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>; >> >> ? >> > I would make it: glm->muxed_gpio = devm_gpiod_get(dev, "muxed", GPIOD_ASIS); > > Jonas, could you please send another version with that addressed both > here and in the bindings? Yes, I'll do. > Bartosz Best, Jonas ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 13:15 ` Bartosz Golaszewski 2025-11-05 13:23 ` Jonas Jelonek @ 2025-11-05 13:28 ` Jonas Jelonek 1 sibling, 0 replies; 12+ messages in thread From: Jonas Jelonek @ 2025-11-05 13:28 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Linus Walleij, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven, linux-gpio, devicetree, linux-kernel, Thomas Richard Hi Bartosz, On 05.11.25 14:15, Bartosz Golaszewski wrote: > Hi Jonas! > > This looks good, I'm ready to queue it but I'm afraid the consumer > label "shared" will logically conflict with the work I'm doing on the > shared GPIO support[1] as the shared GPIOs will appear as proxy > devices containing the name "shared". Do you see any problem with > changing the label to "gpio-mux"? I can even change it myself when > applying. Sorry for the noise, I misunderstood your text a bit. It's just about the label. I'm fine with this and you can adjust it. Thanks! > Bartosz > > [1] https://lore.kernel.org/all/20251029-gpio-shared-v3-0-71c568acf47c@linaro.org/ Best, Jonas ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v4 2/2] gpio: add gpio-line-mux driver 2025-11-05 10:36 ` [PATCH v4 2/2] gpio: add gpio-line-mux driver Jonas Jelonek 2025-11-05 13:15 ` Bartosz Golaszewski @ 2025-11-05 13:26 ` Thomas Richard 1 sibling, 0 replies; 12+ messages in thread From: Thomas Richard @ 2025-11-05 13:26 UTC (permalink / raw) To: Jonas Jelonek, Linus Walleij, Bartosz Golaszewski, Rob Herring, Krzysztof Kozlowski, Conor Dooley, Peter Rosin, Geert Uytterhoeven Cc: linux-gpio, devicetree, linux-kernel On 11/5/25 11:36 AM, Jonas Jelonek wrote: > Add a new driver which provides a 1-to-many mapping for a single real > GPIO using a multiplexer. Each virtual GPIO corresponds to a multiplexer > state which, if set for the multiplexer, connects the real GPIO to the > corresponding virtual GPIO. > > This can help in various usecases. One practical case is the special > hardware design of the Realtek-based XS1930-10 switch from Zyxel. It > features two SFP+ ports/cages whose signals are wired directly to the > switch SoC. Although Realtek SoCs are short on GPIOs, there are usually > enough the fit the SFP signals without any hacks. > > However, Zyxel did some weird design and connected RX_LOS, MOD_ABS and > TX_FAULT of one SFP cage onto a single GPIO line controlled by a > multiplexer (the same for the other SFP cage). The single multiplexer > controls the lines for both SFP and depending on the state, the > designated 'signal GPIO lines' are connected to one of the three SFP > signals. > > Because the SFP core/driver doesn't support multiplexer but needs single > GPIOs for each of the signals, this driver fills the gap between both. > It registers a gpio_chip, provides multiple virtual GPIOs and sets the > backing multiplexer accordingly. > > Due to several practical issues, this is input-only and doesn't support > IRQs. > > Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com> > --- > MAINTAINERS | 6 ++ > drivers/gpio/Kconfig | 9 +++ > drivers/gpio/Makefile | 1 + > drivers/gpio/gpio-line-mux.c | 129 +++++++++++++++++++++++++++++++++++ > 4 files changed, 145 insertions(+) > create mode 100644 drivers/gpio/gpio-line-mux.c > Reviewed-by: Thomas Richard <thomas.richard@bootlin.com> Best Regards, Thomas ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2025-11-05 15:49 UTC | newest] Thread overview: 12+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-11-05 10:36 [PATCH v4 0/2] add gpio-line-mux Jonas Jelonek 2025-11-05 10:36 ` [PATCH v4 1/2] dt-bindings: gpio: add gpio-line-mux controller Jonas Jelonek 2025-11-05 10:36 ` [PATCH v4 2/2] gpio: add gpio-line-mux driver Jonas Jelonek 2025-11-05 13:15 ` Bartosz Golaszewski 2025-11-05 13:23 ` Jonas Jelonek 2025-11-05 13:24 ` Bartosz Golaszewski 2025-11-05 14:19 ` Peter Rosin 2025-11-05 14:37 ` Jonas Jelonek 2025-11-05 15:37 ` Bartosz Golaszewski 2025-11-05 15:49 ` Jonas Jelonek 2025-11-05 13:28 ` Jonas Jelonek 2025-11-05 13:26 ` Thomas Richard
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).