drivers/pinctrl: Add pad read-back and a procfs entry - #19871
Open
Fishwaldo wants to merge 1 commit into
Open
Conversation
Fishwaldo
requested review from
Donny9,
jerpelea and
raiden00pl
as code owners
August 16, 2026 17:39
This was referenced Aug 17, 2026
Fishwaldo
force-pushed
the
upstream-pinctrl-procfs
branch
2 times, most recently
from
August 17, 2026 12:27
5f3117d to
652fef8
Compare
Fishwaldo
force-pushed
the
upstream-pinctrl-procfs
branch
from
August 18, 2026 04:33
652fef8 to
c4bf411
Compare
The pinctrl interface is write only: every operation sets a property, and nothing reports what a pin currently holds. Adds an optional get_pad method describing one pad as a structure: the settable fields, each with a validity bit because a pad need not have them all, and a text member for the controller specific fields the structure does not cover. The structure embeds its strings rather than pointing at them, so the same shape serves both callers. The first caller is /proc/pinctrl, which renders one key:value line per pad, every line the same tokens in the same order with - for a field the pad does not have, so the file is machine parseable. The framework owns the format; controllers only supply data. The second is a new PINCTRLC_GETPAD ioctl, which gives userspace the read-back that text cannot: reading a pad back after setting it. PINCTRL_PADNAME() and two lookup helpers let a controller declare its pad and function-select names in one table instead of inventing its own. Registration keeps a list, which the renderer iterates; pinctrl_dev_s gains the pad count. /proc/pinctrl is claimed when the first controller appears; procfs_register() requires that procfs is not yet mounted, which holds because controllers register during board or architecture start up. Documents the method, the validity bits and the optional naming, and records that /proc/pinctrl exists. Off by default and costs nothing when off. No in-tree configuration enables PINCTRL, so this builds only when a board turns it on. Assisted-by: Claude:claude-opus-5 Signed-off-by: Justin Hammond <justin@dynam.ac>
Fishwaldo
force-pushed
the
upstream-pinctrl-procfs
branch
from
August 18, 2026 04:44
c4bf411 to
5368fed
Compare
xiaoxiang781216
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The pinctrl interface is write only: every operation sets a property, and
nothing reports what a pin currently holds. During board bring up the useful
question is the opposite one, and the interface meant to describe pins cannot
answer it.
This adds an optional
get_padmethod that fills astruct pinctrl_padinfo_sdescribing one pad, and two callers for it:
/proc/pinctrl, under the newCONFIG_PINCTRL_PROCFS, printing onekey:valueline per pad. Every line carries the same tokens in the sameorder, with
-for a field the pad does not have, so the file can be parsed.The framework owns the format; controllers only supply data.
PINCTRLC_GETPADioctl, giving userspace the programmatic read-back thattext cannot serve, e.g. reading a pad back after setting it. The structure
embeds its strings rather than pointing at them, so one shape serves both
callers across the user/kernel boundary.
Everything here is optional. A controller that does not implement
get_padis still listed, and the ioctl returns
-ENOTSUP. A pad need not have everyfield: fill what it has and set the matching
PINCTRL_HAVE_*bit, and anythingthe structure has no member for goes in
extraas furtherkey:valuetext.Pad and function names are entirely optional too — leave them empty and pads
are reported by number alone.
PINCTRL_PADNAME()and two lookup helpers areprovided for controllers that do want names, so each one need not invent its own
table.
A minimal controller is about this much:
The documentation is updated with the method, the validity bits, the optional
naming and the procfs entry.
Impact
New feature, off by default.
CONFIG_PINCTRL_PROCFSdepends onFS_PROCFS_REGISTER; with it unset nothing here is compiled.struct pinctrl_ops_sgains one optional member andstruct pinctrl_dev_sgains
npins. There are currently no pinctrl providers in master, so noexisting driver needs updating. The first consumer will be the ESWIN EIC7700X
pad multiplexer, in a pull request following shortly; it drives 166 pads through
four different field layouts, which is what the
havebits andextraexistfor.
No change to the existing five operations, their ioctls or their behaviour.
Worth flagging to reviewers: no in-tree configuration enables
CONFIG_PINCTRLat all, so CI will not compile this code. A green run says nothing about it,
and the testing below is the only evidence.
Testing
Host: macOS 26.5.1 (arm64),
riscv-none-elf-gcc15.2.0, Sphinx 6.2.1.Build, since CI cannot:
sim:nshwithPINCTRL,FS_PROCFS,FS_PROCFS_REGISTERandPINCTRL_PROCFSforced on compilesdrivers/pinctrl/pinctrl.cclean; also built withPINCTRL_PROCFSoff to checkthe disabled path. Documentation builds with no new warnings.
Hardware: ESWIN EIC7700 EVB (EIC7700X, 4 x RV64GC), booted over TFTP with an
out-of-tree pinctrl driver implementing
get_padfor all 166 pads.Board start up:
That exercises all four of the chip's pad layouts: pad 0 a general pad, 5 an
oscillator pad with no function select and its own
frs/rdfields, 163 anRGMII pad carrying
ms, and 164 a mode-select pad that has almost nothing andrenders as
-throughout.sel:GPIO94on pad 141 is a named function select.Checked on that output:
boundary — the file is far larger than one read buffer, so this exercises the
posaccounting across manyread()callsawkpass splitting on thefields finds no line that deviates
A controller without
get_padwas checked by removing the method: thecontroller is still listed with a note, and the ioctl returns
-ENOTSUP.