Skip to content

Commit 3fcd97d

Browse files
Dilip Kotagregkh
authored andcommitted
spi: lantiq: fix: Rx overflow error in full duplex mode
[ Upstream commit 661ccf2 ] In full duplex mode, rx overflow error is observed. To overcome the error, wait until the complete data got received and proceed further. Fixes: 17f84b7 ("spi: lantiq-ssc: add support for Lantiq SSC SPI controller") Signed-off-by: Dilip Kota <eswara.kota@linux.intel.com> Link: https://lore.kernel.org/r/efb650b0faa49a00788c4e0ca8ef7196bdba851d.1594957019.git.eswara.kota@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent bcaf271 commit 3fcd97d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

drivers/spi/spi-lantiq-ssc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ struct lantiq_ssc_spi {
187187
unsigned int tx_fifo_size;
188188
unsigned int rx_fifo_size;
189189
unsigned int base_cs;
190+
unsigned int fdx_tx_level;
190191
};
191192

192193
static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg)
@@ -484,6 +485,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
484485
u32 data;
485486
unsigned int tx_free = tx_fifo_free(spi);
486487

488+
spi->fdx_tx_level = 0;
487489
while (spi->tx_todo && tx_free) {
488490
switch (spi->bits_per_word) {
489491
case 2 ... 8:
@@ -512,6 +514,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
512514

513515
lantiq_ssc_writel(spi, data, LTQ_SPI_TB);
514516
tx_free--;
517+
spi->fdx_tx_level++;
515518
}
516519
}
517520

@@ -523,6 +526,13 @@ static void rx_fifo_read_full_duplex(struct lantiq_ssc_spi *spi)
523526
u32 data;
524527
unsigned int rx_fill = rx_fifo_level(spi);
525528

529+
/*
530+
* Wait until all expected data to be shifted in.
531+
* Otherwise, rx overrun may occur.
532+
*/
533+
while (rx_fill != spi->fdx_tx_level)
534+
rx_fill = rx_fifo_level(spi);
535+
526536
while (rx_fill) {
527537
data = lantiq_ssc_readl(spi, LTQ_SPI_RB);
528538

0 commit comments

Comments
 (0)