[PATCH 0/3] spi: SPI bus multiplexer

From: Chris Packham
Date: Fri Apr 12 2019 - 01:02:37 EST


Hi All,

I have a hardware design where a single SPI chip select is steered by a
GPIO being asserted or de-asserted. On older kernels I was able to
(ab)use a gpio-hog and cs-gpios to deal with this.

Unfortunately recent changes have stopped my hacks from working. I've
tried adapting cs-gpios to work with my particular hardware but I came
to the realisation that the current cs-gpios support assumes a 1:1
mapping of gpio to SPI device whereas my hardware used the state of the
gpio selecting the device i.e. a 1:2 mapping.

This is my attempt to implement a driver to deal with this. One nice
property is that it is pretty much self contained. The only change to
the core SPI infrastructure is exposing a function I needed to lookup
the spi_controller instance.

Chris Packham (3):
dt-bindings: spi: Add spi-mux-gpio
spi: Make of_find_spi_controller_by_node visible
spi: Add SPI bus gpio multiplexer

.../devicetree/bindings/spi/spi-mux-gpio.txt | 46 +++++
drivers/spi/Kconfig | 7 +
drivers/spi/Makefile | 1 +
drivers/spi/spi-mux-gpio.c | 169 ++++++++++++++++++
drivers/spi/spi.c | 7 +-
include/linux/spi/spi.h | 7 +
6 files changed, 234 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/spi/spi-mux-gpio.txt
create mode 100644 drivers/spi/spi-mux-gpio.c

--
2.21.0