[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACRpkdbCw1Agnsy-aYPs+2PhQDFjj+=VjmGQBmxuCUfwRuWkfw@mail.gmail.com>
Date: Tue, 14 Oct 2025 10:37:10 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Jonas Jelonek <jelonek.jonas@...il.com>, Peter Rosin <peda@...ntia.se>,
Geert Uytterhoeven <geert+renesas@...der.be>
Cc: Bartosz Golaszewski <brgl@...ev.pl>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, linux-gpio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v1 2/2] gpio: add gpio-split driver
Hi Jonas,
thanks for your patch!
overall I like the idea and I think we definitely need
something like this.
On Fri, Oct 10, 2025 at 12:35 AM Jonas Jelonek <jelonek.jonas@...il.com> wrote:
> Add a new driver which allows to split a physical GPIO into multiple
> virtual GPIOs by using a multiplexer.
>
> For now, this doesn't support advanced features like IRQs, just normal
> IN and OUT functionality of GPIOs.
>
> 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 to 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.
>
> Signed-off-by: Jonas Jelonek <jelonek.jonas@...il.com>
This can be made easier these days, reusing the
forwarder library. I think! Check if I'm right.
Make sure you use kernel v6.18-rc1 as a
baseline for your next patch iteration.
select GPIO_AGGREGATOR
#include <linux/gpio/forwarder.h>
Look into this driver for an example of forwarding
GPIO lines:
drivers/pinctrl/pinctrl-upboard.c
See
commit dca2f73cf19fedd7bc38fa6a0eb50fea63cd0214
Now that is a pin controller so it contains a lot of
irrelevant stuff. Focus on the forwarding part.
This part is maybe the most interesting:
fwd = devm_gpiochip_fwd_alloc(dev, pctrl->pctrl_data->ngpio);
Here ngpio will be 1 for your usecase.
if (IS_ERR(fwd))
return dev_err_probe(dev, PTR_ERR(fwd), "Failed to
allocate the gpiochip forwarder\n");
chip = gpiochip_fwd_get_gpiochip(fwd);
chip->request = upboard_gpio_request;
chip->free = upboard_gpio_free;
chip->get_direction = upboard_gpio_get_direction;
chip->direction_output = upboard_gpio_direction_output;
chip->direction_input = upboard_gpio_direction_input;
ret = gpiochip_fwd_register(fwd, pctrl);
if (ret)
return dev_err_probe(dev, ret, "Failed to register the
gpiochip forwarder\n");
As you can see you can override request/free/get_direction etc.
In this case you probably don't want to override these functions,
but instead override chip->get and chip->set so that these set
the mux (and delay a bit?) before reading/writing the line.
->get_multiple and ->set_multiple seems hard to implement
and should probably be overridden with functions returning
an error.
> +++ b/drivers/gpio/gpio-split.c
As mentioned I would call this gpio-line-mux.c
Yours,
Linus Walleij
Powered by blists - more mailing lists