Skip to content

Commit 5774056

Browse files
committed
spi: spi-gpio: Add support for MOSI idle state configuration
Implement MOSI idle low and MOSI idle high to better support peripherals that request specific MOSI behavior. Acked-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
1 parent fb3e2f1 commit 5774056

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/spi/spi-gpio.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,14 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)
237237
}
238238
}
239239

240+
static void spi_gpio_set_mosi_idle(struct spi_device *spi)
241+
{
242+
struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi);
243+
244+
gpiod_set_value_cansleep(spi_gpio->mosi,
245+
!!(spi->mode & SPI_MOSI_IDLE_HIGH));
246+
}
247+
240248
static int spi_gpio_setup(struct spi_device *spi)
241249
{
242250
struct gpio_desc *cs;
@@ -402,7 +410,8 @@ static int spi_gpio_probe(struct platform_device *pdev)
402410

403411
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
404412
master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL |
405-
SPI_CS_HIGH | SPI_LSB_FIRST;
413+
SPI_CS_HIGH | SPI_LSB_FIRST | SPI_MOSI_IDLE_LOW |
414+
SPI_MOSI_IDLE_HIGH;
406415
if (!spi_gpio->mosi) {
407416
/* HW configuration without MOSI pin
408417
*
@@ -427,6 +436,7 @@ static int spi_gpio_probe(struct platform_device *pdev)
427436
master->flags |= SPI_MASTER_GPIO_SS;
428437
bb->chipselect = spi_gpio_chipselect;
429438
bb->set_line_direction = spi_gpio_set_direction;
439+
bb->set_mosi_idle = spi_gpio_set_mosi_idle;
430440

431441
if (master->flags & SPI_MASTER_NO_TX) {
432442
bb->txrx_word[SPI_MODE_0] = spi_gpio_spec_txrx_word_mode0;

0 commit comments

Comments
 (0)