Skip to content

Commit ccf7d8e

Browse files
SanchayanMaitybroonie
authored andcommitted
spi: spi-fsl-dspi: Fix continuous selection format
Current DMA implementation was not handling the continuous selection format viz. SPI chip select would be deasserted even between sequential serial transfers. Use existing dspi_data_to_pushr function to restructure the transmit code path and set or reset the CONT bit on same lines as code path in EOQ mode does. This correctly implements continuous selection format while also correcting and cleaning up the transmit code path. Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 1eaccf2 commit ccf7d8e

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

‎drivers/spi/spi-fsl-dspi.c‎

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,8 @@ struct fsl_dspi {
196196
struct fsl_dspi_dma *dma;
197197
};
198198

199+
static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word);
200+
199201
static inline int is_double_byte_mode(struct fsl_dspi *dspi)
200202
{
201203
unsigned int val;
@@ -242,24 +244,15 @@ static int dspi_next_xfer_dma_submit(struct fsl_dspi *dspi)
242244
int time_left;
243245
int tx_word;
244246
int i;
245-
u16 val;
246247

247248
tx_word = is_double_byte_mode(dspi);
248249

249-
for (i = 0; i < dma->curr_xfer_len - 1; i++) {
250-
val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
251-
dspi->dma->tx_dma_buf[i] =
252-
SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) |
253-
SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT;
254-
dspi->tx += tx_word + 1;
250+
for (i = 0; i < dma->curr_xfer_len; i++) {
251+
dspi->dma->tx_dma_buf[i] = dspi_data_to_pushr(dspi, tx_word);
252+
if ((dspi->cs_change) && (!dspi->len))
253+
dspi->dma->tx_dma_buf[i] &= ~SPI_PUSHR_CONT;
255254
}
256255

257-
val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx;
258-
dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) |
259-
SPI_PUSHR_PCS(dspi->cs) |
260-
SPI_PUSHR_CTAS(0);
261-
dspi->tx += tx_word + 1;
262-
263256
dma->tx_desc = dmaengine_prep_slave_single(dma->chan_tx,
264257
dma->tx_dma_phys,
265258
dma->curr_xfer_len *
@@ -351,7 +344,6 @@ static int dspi_dma_xfer(struct fsl_dspi *dspi)
351344
curr_remaining_bytes -= dma->curr_xfer_len * word;
352345
if (curr_remaining_bytes < 0)
353346
curr_remaining_bytes = 0;
354-
dspi->len = curr_remaining_bytes;
355347
}
356348
}
357349

0 commit comments

Comments
 (0)