spi: sh-msiof: Implement cs-gpios configuration
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 13 Dec 2017 19:05:12 +0000 (20:05 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 14 Dec 2017 11:46:14 +0000 (11:46 +0000)
commitb8761434bdec32fa46a644c26a12d16a9b0f58d8
treeb8007881f64e76e6c969069844c6d554c16ce389
parent9cce882bedd2768dc251b73f2ad86a9bfcfd9fc7
spi: sh-msiof: Implement cs-gpios configuration

The current support for GPIO chip selects assumes the GPIOs have been
configured by platform code or the boot loader.  This includes pinmux
setup and GPIO direction.  Hence it does not work as expected when just
described in DT using the "cs-gpios" property.

Fix this by:
  1. using devm_gpiod_get_index() to request the GPIO, and thus
     configure pinmux, if needed,
  2. configuring the GPIO direction is the spi_master.setup() callback.

Use gpio_is_valid() instead of a check on positive numbers.

Note that when using GPIO chip selects, at least one native chip select
must be left unused, as that native chip select will be driven anyway,
and (global) native chip select polarity must be taken into account.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/spi/spi-sh-msiof.c