Skip to content
Unverified Commit f3186dd8 authored by Linus Walleij's avatar Linus Walleij Committed by Mark Brown
Browse files

spi: Optionally use GPIO descriptors for CS GPIOs

This augments the SPI core to optionally use GPIO descriptors
for chip select on a per-master-driver opt-in basis.

Drivers using this will rely on the SPI core to look up
GPIO descriptors associated with the device, such as
when using device tree or board files with GPIO descriptor
tables.

When getting descriptors from the device tree, this will in
turn activate the code in gpiolib that was
added in commit 6953c57a


("gpio: of: Handle SPI chipselect legacy bindings")
which means that these descriptors are aware of the active
low semantics that is the default for SPI CS GPIO lines
and we can assume that all of these are "active high" and
thus assign SPI_CS_HIGH to all CS lines on the DT path.

The previously used gpio_set_value() would call down into
gpiod_set_raw_value() and ignore the polarity inversion
semantics.

It seems like many drivers go to great lengths to set up the
CS GPIO line as non-asserted, respecting SPI_CS_HIGH. We pull
this out of the SPI drivers and into the core, and by simply
requesting the line as GPIOD_OUT_LOW when retrieveing it from
the device and relying on the gpiolib to handle any inversion
semantics. This way a lot of code can be simplified and
removed in each converted driver.

The end goal after dealing with each driver in turn, is to
delete the non-descriptor path (of_spi_register_master() for
example) and let the core deal with only descriptors.

The different SPI drivers have complex interactions with the
core so we cannot simply change them all over, we need to use
a stepwise, bisectable approach so that each driver can be
converted and fixed in isolation.

This patch has the intended side effect of adding support for
ACPI GPIOs as it starts relying on gpiod_get_*() to get
the GPIO handle associated with the device.

Cc: Linuxarm <linuxarm@huawei.com>
Acked-by: default avatarJonathan Cameron <jonathan.cameron@huawei.com>
Tested-by: default avatarFangjian (Turing) <f.fangjian@huawei.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 8d245475
  • mirror @mirror

    mentioned in commit 9aa024375428f893b681b6abd699996da275c9fe

    ·

    mentioned in commit 9aa024375428f893b681b6abd699996da275c9fe

    Toggle commit list
  • mirror @mirror

    mentioned in commit 822403fb7092a382f0d9cd0b36e1f97f80d44ccd

    ·

    mentioned in commit 822403fb7092a382f0d9cd0b36e1f97f80d44ccd

    Toggle commit list
  • mirror @mirror

    mentioned in commit e6685ef376d491ebdd94b54abf3c6ac3017c1b6c

    ·

    mentioned in commit e6685ef376d491ebdd94b54abf3c6ac3017c1b6c

    Toggle commit list
  • mirror @mirror

    mentioned in commit 63848d362baed9da650a62374edea30062d0a12b

    ·

    mentioned in commit 63848d362baed9da650a62374edea30062d0a12b

    Toggle commit list
  • mirror @mirror

    mentioned in commit 9801cda4340202fd6b94592f13ccd118f7c6376b

    ·

    mentioned in commit 9801cda4340202fd6b94592f13ccd118f7c6376b

    Toggle commit list
  • mirror @mirror

    mentioned in commit b3da5250

    ·

    mentioned in commit b3da5250

    Toggle commit list
  • mirror @mirror

    mentioned in commit 157761d7

    ·

    mentioned in commit 157761d7

    Toggle commit list
  • mirror @mirror

    mentioned in commit b4659f44

    ·

    mentioned in commit b4659f44

    Toggle commit list
  • mirror @mirror

    mentioned in commit d1601892489d13f57bebdea8fabd150307f6c085

    ·

    mentioned in commit d1601892489d13f57bebdea8fabd150307f6c085

    Toggle commit list
  • mirror @mirror

    mentioned in commit 2a75e3dbcc11c072fabe975f8cd2821e73c1b85e

    ·

    mentioned in commit 2a75e3dbcc11c072fabe975f8cd2821e73c1b85e

    Toggle commit list
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment