All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] gpiolib: of: Scope the legacy SPI CS quirk to SPI
@ 2026-08-10 14:16 ` Maciej Andrzejewski ICEYE
  0 siblings, 0 replies; 7+ messages in thread
From: Maciej Andrzejewski ICEYE @ 2026-08-10 14:16 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski, linux-gpio, broonie,
	linux-spi, miquel.raynal, richard, vigneshr, linux-mtd, robh,
	krzk+dt, conor+dt, devicetree, linux-kernel, maciej.andrzejewski
  Cc: linux-gpio, Mark Brown, linux-spi, Miquel Raynal,
	Richard Weinberger, Vignesh Raghavendra, linux-mtd, Rob Herring,
	Krzysztof Kozlowski, Conor Dooley, devicetree, linux-kernel,
	Maciej Andrzejewski ICEYE

of_gpio_flags_quirks() decides whether to apply SPI chip-select polarity
semantics purely from the property name "cs-gpios". Nothing about that
name is SPI specific. nand-controller.yaml documents it for NAND
controllers too, and rawnand_dt_parse_gpio_cs() asks for those lines
with gpiod_count(dev, "cs"), which gpiolib expands to "cs-gpios". The
result is that a NAND chip node whose first reg cell happens to equal a
GPIO index gets flipped to active low, and since the NAND core requests
the descriptors GPIOD_OUT_HIGH and drivers assert with a logical 0, the
die is never selected.

We hit this on an Arasan controller with a GPIO CS1 and worked around it
downstream by putting spi-cs-high on the NAND chip node, which is
plainly the wrong property to need. These two patches narrow the quirk
instead, so that it only fires on an SPI bus.

Device tree has no bus type marker, so the series uses two tests, one
per patch, and applies the quirk if either matches:

  1. the matched child has a property namespaced with "spi-"
  2. the controller nodename has the "spi" prefix that
     spi-controller.yaml requires

Testing
-------

Both tests were scored against every board device tree in the kernel.
Each .dts under arch/*/boot/dts was expanded with the same cpp and
scripts/dtc pipeline the build uses; all 3620 expand. 503 of them hold
at least one GPIO chip select that can reach the quirk, 765 in total.
761 match both tests, 1 needs only the property scan, 3 need only the
nodename, and none match neither, so no in-tree board changes behaviour.
Patch 2 names the four exceptions individually.

The collision with NAND is in-tree but latent: 36 board trees, all
Atmel/Microchip at91, give their nand@3 controller a cs-gpios line and
escape only because the sole child of those nodes is a partitions
container with no reg for the quirk to match against.

drivers/gpio/gpiolib-of.o builds warning-free at W=1 with CONFIG_SPI=y
and with CONFIG_SPI=n.

Note on bisect
--------------

The two tests are complementary rather than layered, so patch 1 on its
own would stop applying the quirk to the three peripherals that carry no
"spi-" property (a panel, an mcp251xfd and one ecspi child, all named in
patch 2). Only the pair is behaviour-preserving. They are split because
the property scan and the nodename test are separate arguments and I
expect the second to attract more discussion. Happy to squash them into
one commit if you would rather not have that window.

Maciej Andrzejewski ICEYE (2):
  gpiolib: of: Only apply the SPI CS quirk to SPI peripherals
  gpiolib: of: Identify SPI controllers by nodename

 drivers/gpio/gpiolib-of.c | 40 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)


base-commit: db2ddb87143519e20a95aa36c60b36107b736a58
-- 
2.50.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-08-10 14:33 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-10 14:16 [PATCH 0/2] gpiolib: of: Scope the legacy SPI CS quirk to SPI Maciej Andrzejewski ICEYE
2026-08-10 14:16 ` Maciej Andrzejewski ICEYE
2026-08-10 14:16 ` [PATCH 1/2] gpiolib: of: Only apply the SPI CS quirk to SPI peripherals Maciej Andrzejewski ICEYE
2026-08-10 14:16   ` Maciej Andrzejewski ICEYE
2026-08-10 14:23   ` sashiko-bot
2026-08-10 14:16 ` [PATCH 2/2] gpiolib: of: Identify SPI controllers by nodename Maciej Andrzejewski ICEYE
2026-08-10 14:16   ` Maciej Andrzejewski ICEYE

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.