From: Mehmet Fide <mehmet.fide@gmail.com>
To: Bartosz Golaszewski <brgl@kernel.org>, Linus Walleij <linusw@kernel.org>
Cc: Haibo Chen <haibo.chen@nxp.com>,
Dong Aisheng <aisheng.dong@nxp.com>,
Fabio Estevam <festevam@gmail.com>, Frank Li <Frank.Li@nxp.com>,
Jacky Bai <ping.bai@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
imx@lists.linux.dev, linux-gpio@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Mehmet Fide <mehmet.fide@screeningeagle.com>
Subject: [PATCH v6 0/4] gpio: mmio: report the line direction on chips without direction registers
Date: Tue, 15 Sep 2026 10:04:57 +0200 [thread overview]
Message-ID: <20260915080501.329424-1-mehmet.fide@gmail.com> (raw)
From: Mehmet Fide <mehmet.fide@screeningeagle.com>
Hi Bartosz, Linus,
this replaces the gpiolib guard patch [1], along the lines Bartosz
suggested there: instead of teaching gpiod_get_direction() to stay quiet
when a chip has no get_direction(), give gpio-mmio one and let the pin
controller tell it what the pad does.
The user is the Vybrid GPIO block (gpio-vf610, a generic mmio chip with
GPIO_GENERIC_PINCTRL_BACKEND and no direction registers, the direction
lives in the iomuxc pad as the OBE bit). Today a gpiod_get_direction()
there trips the WARN in gpiolib; on gpio/for-next the i2c core does it
on every boot of a Colibri VF61/VF50, asking for the SDA line's
direction before bus recovery.
Patch 1 is new in v6, after Haibo's review: the CONFIG_PINCTRL=n stubs
of pinctrl_gpio_get_config() and pinctrl_gpio_set_config() return 0
today, success for a configuration nobody read or applied. They now
return -ENOTSUPP, which is what a chip without pin ranges already gets
from gpiochip_generic_config() with pinctrl enabled.
Patch 2 is the pinctrl-imx side. Bartosz asked whether the raw register
coming back from pin_config_get() is a bug in pinctrl-imx: it is, the
callback never looked at which parameter was requested. It now answers
PIN_CONFIG_OUTPUT_ENABLE and PIN_CONFIG_INPUT_ENABLE on SoCs that say
where those bits live (Vybrid: OBE bit 1, IBE bit 0) and -ENOTSUPP for
everything else, the SCU based SoCs included; the debugfs dump, the only
raw-register user, reads the register through its own helper. The set
callback stays raw, as the fsl,pins binding requires. Converting the
driver fully to generic pinconf is a bigger job than this fix needs.
Patch 3 is what Linus asked for on v3: an optional get_config() in
struct gpio_chip and gpiochip_generic_get_config() as its pin control
backed implementation, the mirror of gpiochip_generic_config(). The
packed parameter goes in, its bare argument comes out, as with
pinctrl_gpio_get_config(). No consumer API.
Patch 4 keeps the direction in gpio-mmio's existing shadow and installs
the shadow-reading get_direction() for the "pinctrl backend, no
direction registers" combination. The pad is asked once, from request(),
in process context, through gc->get_config(), so it is safe for the
gpiochip_lock_as_irq() path that calls get_direction() under the irq
descriptor lock.
Tested on a Colibri VF61 (Iris carrier) on top of gpio/for-next, with
DEBUG_ATOMIC_SLEEP and PROVE_LOCKING enabled: no backtraces, and
/sys/kernel/debug/gpio shows the same direction for every requested line
as 6.18 does (the hogs, the SD card detect input, the USB VBUS regulator
output). On a test-only pad handed to userspace, a line driven as an
output and released reports "out" to the next as-is request, an edge
request on it is still accepted and turns it back into an input, and
both match the OBE bit in the pinconf debugfs dump. Lines the pin
controller cannot answer for keep the input default gpiolib assumed
before, so nothing that worked before is affected. The initial direction
scan in gpiochip_add_data_with_key() runs before the pin ranges exist
and still guesses; only requested lines get the real answer. The
pinconf-pins and pinconf-groups debugfs dumps are the same as on 6.18.
Patch 2, unchanged since v5, was also booted on a Verdin iMX8MP
(6.12.107) with the same debugfs comparison. The CONFIG_PINCTRL=n side
was compile tested (GPIOLIB, gpio-mmio, gpio-by-pinctrl, gpio-aspeed),
and the Vybrid configuration built with W=1.
On trees: Linus offered to take patch 2 through pinctrl, and patch 1 is
pinctrl as well. Patch 4 gives wrong answers without patch 2 (an
undecoded pad register would seed every requested line as an output), so
I would rather the two pinctrl patches land first or in the same cycle
as the two gpio patches, whichever way you two prefer to split it.
Linus's Reviewed-by on patch 3 was given on v5; the only change since is
the dropped #else branch Haibo asked for, so I kept the tag. Please say
if it should not carry over.
[1] https://lore.kernel.org/linux-gpio/20260813193715.2346477-1-mehmet.fide@gmail.com/
Changes in v6:
- new patch 1: the CONFIG_PINCTRL=n stubs return -ENOTSUPP instead of
claiming success (Haibo Chen)
- patch 3: gpiochip_generic_get_config() loses its own #else branch and
mirrors gpiochip_generic_config() exactly (Haibo Chen)
- patch 4: commit message notes that dir_unreadable is now also set for
a pinctrl-backed chip without direction registers (Haibo Chen), and
states the dependency on patch 2
- patches 2 and 4: collected Haibo Chen's Reviewed-by
- patches 2 and 3: collected Linus Walleij's Reviewed-by
- patch 4: the backtrace count in the commit message is what today's
gpio/for-next produces (one, from the i2c core), not the 21 of the
earlier base
- rebased on gpio/for-next
Changes in v5 (patch numbers as in v6):
- patch 3: the get_config() documentation said the answer comes back
packed; it is the bare argument, like pinctrl_gpio_get_config() returns
(Sashiko review). Text only, no code change.
Changes in v4:
- new patch 3: get_config() in struct gpio_chip and
gpiochip_generic_get_config() (Linus)
- patch 4: seed the shadow through gc->get_config(), no pinctrl call
and no CONFIG_PINCTRL check in gpio-mmio (Linus)
- patch 2: drop the npins check, pin_request() already rejects a pin
the controller does not have
Changes in v3:
- patch 2: return -ENOTSUPP for the SCU based SoCs instead of letting
the firmware call hand back the raw pad value (Sashiko review)
- patch 2: -EINVAL for a pin the device tree never configured, -ENOTSUPP
only for unsupported parameters and SoCs
- patch 2, 4: drop two comments that only restated the code
Changes in v2:
- patch 2: decode the requested parameter instead of returning the raw
register; debugfs group dump reads the register through its own helper
- patch 4: keep the direction in the gpio-mmio shadow, ask pinctrl once
from request() instead of from get_direction()
Mehmet Fide (4):
pinctrl: make the CONFIG_PINCTRL=n gpio config stubs return -ENOTSUPP
pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad
register
gpiolib: add get_config() and gpiochip_generic_get_config()
gpio: mmio: track the direction of chips without direction registers
Documentation/driver-api/gpio/driver.rst | 7 +++
drivers/gpio/gpio-mmio.c | 60 +++++++++++++++++++++--
drivers/gpio/gpiolib.c | 21 ++++++++
drivers/pinctrl/freescale/pinctrl-imx.c | 54 ++++++++++++++++++--
drivers/pinctrl/freescale/pinctrl-imx.h | 4 ++
drivers/pinctrl/freescale/pinctrl-vf610.c | 2 +
include/linux/gpio/driver.h | 9 ++++
include/linux/pinctrl/consumer.h | 4 +-
8 files changed, 151 insertions(+), 10 deletions(-)
base-commit: 7257c35db0fdb4fb02d857a8197a16afa84d92c0
--
2.55.0
next reply other threads:[~2026-09-15 8:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 8:04 Mehmet Fide [this message]
2026-09-15 8:04 ` [PATCH v6 1/4] pinctrl: make the CONFIG_PINCTRL=n gpio config stubs return -ENOTSUPP Mehmet Fide
2026-09-16 9:42 ` Bartosz Golaszewski
2026-09-15 8:04 ` [PATCH v6 2/4] pinctrl: imx: answer OUTPUT_ENABLE/INPUT_ENABLE queries from the pad register Mehmet Fide
2026-09-16 9:42 ` Bartosz Golaszewski
2026-09-15 8:05 ` [PATCH v6 3/4] gpiolib: add get_config() and gpiochip_generic_get_config() Mehmet Fide
2026-09-15 8:05 ` [PATCH v6 4/4] gpio: mmio: track the direction of chips without direction registers Mehmet Fide
2026-09-16 9:42 ` [PATCH v6 0/4] gpio: mmio: report the line direction on " Bartosz Golaszewski
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=20260915080501.329424-1-mehmet.fide@gmail.com \
--to=mehmet.fide@gmail.com \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=brgl@kernel.org \
--cc=festevam@gmail.com \
--cc=haibo.chen@nxp.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mehmet.fide@screeningeagle.com \
--cc=ping.bai@nxp.com \
--cc=s.hauer@pengutronix.de \
/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
all inboxes | Powered by JetHome®