Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Sanchayan Maity and committed by
Mark Brown
ccf7d8ee 1eaccf21

+6 -14
+6 -14
drivers/spi/spi-fsl-dspi.c
··· 196 196 struct fsl_dspi_dma *dma; 197 197 }; 198 198 199 + static u32 dspi_data_to_pushr(struct fsl_dspi *dspi, int tx_word); 200 + 199 201 static inline int is_double_byte_mode(struct fsl_dspi *dspi) 200 202 { 201 203 unsigned int val; ··· 244 242 int time_left; 245 243 int tx_word; 246 244 int i; 247 - u16 val; 248 245 249 246 tx_word = is_double_byte_mode(dspi); 250 247 251 - for (i = 0; i < dma->curr_xfer_len - 1; i++) { 252 - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; 253 - dspi->dma->tx_dma_buf[i] = 254 - SPI_PUSHR_TXDATA(val) | SPI_PUSHR_PCS(dspi->cs) | 255 - SPI_PUSHR_CTAS(0) | SPI_PUSHR_CONT; 256 - dspi->tx += tx_word + 1; 248 + for (i = 0; i < dma->curr_xfer_len; i++) { 249 + dspi->dma->tx_dma_buf[i] = dspi_data_to_pushr(dspi, tx_word); 250 + if ((dspi->cs_change) && (!dspi->len)) 251 + dspi->dma->tx_dma_buf[i] &= ~SPI_PUSHR_CONT; 257 252 } 258 - 259 - val = tx_word ? *(u16 *) dspi->tx : *(u8 *) dspi->tx; 260 - dspi->dma->tx_dma_buf[i] = SPI_PUSHR_TXDATA(val) | 261 - SPI_PUSHR_PCS(dspi->cs) | 262 - SPI_PUSHR_CTAS(0); 263 - dspi->tx += tx_word + 1; 264 253 265 254 dma->tx_desc = dmaengine_prep_slave_single(dma->chan_tx, 266 255 dma->tx_dma_phys, ··· 344 351 curr_remaining_bytes -= dma->curr_xfer_len * word; 345 352 if (curr_remaining_bytes < 0) 346 353 curr_remaining_bytes = 0; 347 - dspi->len = curr_remaining_bytes; 348 354 } 349 355 } 350 356