From: Chanhong Jung <happycpu@gmail.com>
To: Linus Walleij <linusw@kernel.org>,
Bartosz Golaszewski <brgl@kernel.org>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Maxime Ripard <mripard@kernel.org>
Cc: linux-gpio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/2] gpio: 74x164: seed the chain from DT at probe time
Date: Wed, 29 Apr 2026 12:51:32 +0900 [thread overview]
Message-ID: <20260429035134.1023330-1-happycpu@gmail.com> (raw)
In-Reply-To: <cover.1776872453.git.happycpu@gmail.com>
This v2 reuses the existing lines-initial-states bitmask, as suggested
by Linus Walleij, instead of inventing a new property. That sidesteps
both the v1 review concerns at once: there is no vendor-specific
property to argue about, and the bit-N-equals-line-N convention is
already documented for nxp,pcf8575.
Background (carried over from v1):
The 74HC595 / 74LVC594 family is push-pull output only. There is no
read-back path, no defined power-on state for the parallel outputs, and
__gen_74x164_write_config() always shifts the full chain on every
transaction. The driver therefore publishes whatever sits in
chip->buffer on the very first ->set() call, and today that buffer is
fresh from kzalloc(), so all outputs come up low. On boards with active-
low indicators or other signals whose initial level matters, the 0x00
publish glitches the chain before user space (or gpio-leds default-state
walking) gets a chance to run.
gpio-hog is not a substitute here: each hog is applied sequentially and
forces an intermediate full-chain write per line, and on this board
gpio-leds already claims every output, leaving no free lines to hog.
Approach in v2:
Patch 1 documents the existing lines-initial-states property under the
fairchild,74hc595 binding, with the small wording change that on this
output-only family bit=0 drives the line low and bit=1 drives it high.
Patch 2 wires the driver to read that bitmask into chip->buffer before
the first __gen_74x164_write_config(), so the chain comes up in the
configured pattern atomically on the first SPI transaction. Property
absence keeps the existing zeroing behaviour.
The bitmask covers up to 32 lines (four cascaded chips), which fits all
existing in-tree users and the typical 1-4 chip cascades. If a longer
chain ever needs seeding, the property can be extended to a uint32-array
without breaking the bit-N-equals-line-N convention.
Tested on a 4-chip 74HC595 chain (32 outputs, active-low LEDs); the
0x00 glitch on first write goes away with lines-initial-states set to
the desired idle pattern, and absence of the property leaves behaviour
unchanged.
Changes since v1
[https://lore.kernel.org/linux-gpio/cover.1776872453.git.happycpu@gmail.com/]:
- Drop the new 'registers-default' u8-array property; reuse the
existing 'lines-initial-states' uint32 bitmask instead, as
suggested by Linus Walleij. This also addresses Krzysztof
Kozlowski's concern about adding a generic, non-vendor-prefixed
property to a vendor-specific binding (the property is already
documented for nxp,pcf8575).
- Driver now reads a single u32 and maps bit N to GPIO line N,
matching the nxp,pcf8575 convention. For this output-only device
the polarity is the natural one: bit=0 drives the line low,
bit=1 drives it high.
- Binding example updated accordingly.
Chanhong Jung (2):
dt-bindings: gpio: fairchild,74hc595: add lines-initial-states
property
gpio: 74x164: support lines-initial-states for boot-time output state
.../bindings/gpio/fairchild,74hc595.yaml | 13 +++++++++++++
drivers/gpio/gpio-74x164.c | 17 ++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
--
2.34.1
next prev parent reply other threads:[~2026-04-29 3:51 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-22 16:05 [PATCH v1 0/2] gpio: 74x164: seed the chain from DT at probe time Chanhong Jung
2026-04-22 16:05 ` [PATCH v1 1/2] dt-bindings: gpio: fairchild,74hc595: add registers-default property Chanhong Jung
2026-04-23 8:59 ` Krzysztof Kozlowski
2026-04-23 10:33 ` Chanhong Jung
2026-04-28 8:40 ` Krzysztof Kozlowski
2026-04-28 9:07 ` Linus Walleij
2026-04-29 3:50 ` Chanhong Jung
2026-04-22 16:05 ` [PATCH v1 2/2] gpio: 74x164: support 'registers-default' DT property for initial state Chanhong Jung
2026-04-29 3:51 ` Chanhong Jung [this message]
2026-04-29 3:51 ` [PATCH v2 1/2] dt-bindings: gpio: fairchild,74hc595: add lines-initial-states property Chanhong Jung
2026-04-29 3:51 ` [PATCH v2 2/2] gpio: 74x164: support lines-initial-states for boot-time output state Chanhong Jung
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=20260429035134.1023330-1-happycpu@gmail.com \
--to=happycpu@gmail.com \
--cc=brgl@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mripard@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