Message ID | CALHCpMgQPDqV1tB6v0sA0imwfZGkoG_j84NZCehOT1pf8MTuCA@mail.gmail.com |
---|---|
State | New |
Headers | show |
Series | spi: spi-fsl-dspi: Add GPIO chip select support | expand |
On Thu, Dec 03, 2020 at 09:50:04PM +0300, Maksim Kiselev wrote: > In any case, I would like to add functionality for using GPIO as CS. > Because I have a board which actually uses this. I have absolutely nothing to object to that. But the patches should still be as clean as possible, though.
diff --git a/drivers/spi/spi-fsl-dspi.c b/drivers/spi/spi-fsl-dspi.c index 028736687488..d5fba34de740 100644 --- a/drivers/spi/spi-fsl-dspi.c +++ b/drivers/spi/spi-fsl-dspi.c @@ -913,9 +913,14 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, dspi->cur_transfer = transfer; dspi->cur_msg = message; dspi->cur_chip = spi_get_ctldata(spi); + + if (spi->cs_gpiod) + gpiod_set_value(spi->cs_gpiod, 1); + /* Prepare command word for CMD FIFO */ dspi->tx_cmd = SPI_PUSHR_CMD_CTAS(0) | - SPI_PUSHR_CMD_PCS(spi->chip_select); + SPI_PUSHR_CMD_PCS(spi->cs_gpiod ? + ctlr->unused_native_cs : spi->chip_select); if (list_is_last(&dspi->cur_transfer->transfer_list, &dspi->cur_msg->transfers)) {