diff options
author | Lorenzo Bianconi <lorenzo.bianconi@redhat.com> | 2018-07-28 10:19:14 +0200 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-08-01 15:50:28 +0200 |
commit | 4b859db2c60692560afbfef1b030d0ddef57b7ee (patch) | |
tree | 70a19c5a126a3eacdfda8f8112a13950cdca0a05 /drivers/spi/spi-bitbang.c | |
parent | spi: add flags parameter to txrx_word function pointers (diff) | |
download | linux-4b859db2c60692560afbfef1b030d0ddef57b7ee.tar.xz linux-4b859db2c60692560afbfef1b030d0ddef57b7ee.zip |
spi: spi-gpio: add SPI_3WIRE support
Add SPI_3WIRE support to spi-gpio controller introducing
set_line_direction function pointer in spi_bitbang data structure.
Spi-gpio controller has been tested using hts221 temp/rh iio sensor
running in 3wire mode and lsm6dsm running in 4wire mode
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-bitbang.c')
-rw-r--r-- | drivers/spi/spi-bitbang.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c index 76f1b534bdd7..f29176000b8d 100644 --- a/drivers/spi/spi-bitbang.c +++ b/drivers/spi/spi-bitbang.c @@ -243,7 +243,23 @@ static int spi_bitbang_bufs(struct spi_device *spi, struct spi_transfer *t) { struct spi_bitbang_cs *cs = spi->controller_state; unsigned nsecs = cs->nsecs; + struct spi_bitbang *bitbang; + + bitbang = spi_master_get_devdata(spi->master); + if (bitbang->set_line_direction) { + int err; + err = bitbang->set_line_direction(spi, !!(t->tx_buf)); + if (err < 0) + return err; + } + + if (spi->mode & SPI_3WIRE) { + unsigned flags; + + flags = t->tx_buf ? SPI_MASTER_NO_RX : SPI_MASTER_NO_TX; + return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, flags); + } return cs->txrx_bufs(spi, cs->txrx_word, nsecs, t, 0); } |