linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonas Jelonek <jelonek.jonas@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Jonas Jelonek <jelonek.jonas@gmail.com>
Subject: [RFC PATCH v1 0/2] add support for splitting GPIOs
Date: Thu,  9 Oct 2025 22:34:59 +0000	[thread overview]
Message-ID: <20251009223501.570949-1-jelonek.jonas@gmail.com> (raw)

Hereby I propose a new type of virtual GPIO controller and corresponding
driver for splitting GPIOs using a multiplexer for different usecases.
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-control'.

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
children nodes defined for the gpio-split controller, each with a
mux-state which is used on access.

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.

--
Jonas Jelonek (2):
  dt-bindings: gpio: add gpio-split controller
  gpio: add gpio-split driver

 .../devicetree/bindings/gpio/gpio-split.yaml  |  77 +++++++
 MAINTAINERS                                   |   6 +
 drivers/gpio/Kconfig                          |   8 +
 drivers/gpio/Makefile                         |   1 +
 drivers/gpio/gpio-split.c                     | 210 ++++++++++++++++++
 5 files changed, 302 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-split.yaml
 create mode 100644 drivers/gpio/gpio-split.c


base-commit: bc061143637532c08d9fc657eec93fdc2588068e
-- 
2.48.1


             reply	other threads:[~2025-10-09 22:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 22:34 Jonas Jelonek [this message]
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
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=20251009223501.570949-1-jelonek.jonas@gmail.com \
    --to=jelonek.jonas@gmail.com \
    --cc=brgl@bgdev.pl \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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).