From: Linus Walleij <linus.walleij@linaro.org>
To: Jonas Jelonek <jelonek.jonas@gmail.com>,
Peter Rosin <peda@axentia.se>,
Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Bartosz Golaszewski <brgl@bgdev.pl>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 2/2] gpio: add gpio-split driver
Date: Tue, 14 Oct 2025 10:37:10 +0200 [thread overview]
Message-ID: <CACRpkdbCw1Agnsy-aYPs+2PhQDFjj+=VjmGQBmxuCUfwRuWkfw@mail.gmail.com> (raw)
In-Reply-To: <20251009223501.570949-3-jelonek.jonas@gmail.com>
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@gmail.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@gmail.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
next prev parent reply other threads:[~2025-10-14 8:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-09 22:34 [RFC PATCH v1 0/2] add support for splitting GPIOs Jonas Jelonek
2025-10-09 22:35 ` [RFC PATCH v1 1/2] dt-bindings: gpio: add gpio-split controller Jonas Jelonek
2025-10-10 1:12 ` Krzysztof Kozlowski
2025-10-10 8:27 ` Jonas Jelonek
2025-10-14 8:23 ` Linus Walleij
2025-10-16 15:36 ` Jonas Jelonek
2025-10-09 22:35 ` [RFC PATCH v1 2/2] gpio: add gpio-split driver Jonas Jelonek
2025-10-14 8:37 ` Linus Walleij [this message]
2025-10-16 15:37 ` Jonas Jelonek
2025-10-16 22:12 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACRpkdbCw1Agnsy-aYPs+2PhQDFjj+=VjmGQBmxuCUfwRuWkfw@mail.gmail.com' \
--to=linus.walleij@linaro.org \
--cc=brgl@bgdev.pl \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=geert+renesas@glider.be \
--cc=jelonek.jonas@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).