Commit 661ccf2b authored by Dilip Kota's avatar Dilip Kota Committed by Mark Brown

spi: lantiq: fix: Rx overflow error in full duplex mode

In full duplex mode, rx overflow error is observed. To overcome the error,
wait until the complete data got received and proceed further.

Fixes: 17f84b79 ("spi: lantiq-ssc: add support for Lantiq SSC SPI controller")
Signed-off-by: default avatarDilip Kota <eswara.kota@linux.intel.com>
Link: https://lore.kernel.org/r/efb650b0faa49a00788c4e0ca8ef7196bdba851d.1594957019.git.eswara.kota@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent f185bcc7
...@@ -183,6 +183,7 @@ struct lantiq_ssc_spi { ...@@ -183,6 +183,7 @@ struct lantiq_ssc_spi {
unsigned int tx_fifo_size; unsigned int tx_fifo_size;
unsigned int rx_fifo_size; unsigned int rx_fifo_size;
unsigned int base_cs; unsigned int base_cs;
unsigned int fdx_tx_level;
}; };
static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg) static u32 lantiq_ssc_readl(const struct lantiq_ssc_spi *spi, u32 reg)
...@@ -480,6 +481,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi) ...@@ -480,6 +481,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
u32 data; u32 data;
unsigned int tx_free = tx_fifo_free(spi); unsigned int tx_free = tx_fifo_free(spi);
spi->fdx_tx_level = 0;
while (spi->tx_todo && tx_free) { while (spi->tx_todo && tx_free) {
switch (spi->bits_per_word) { switch (spi->bits_per_word) {
case 2 ... 8: case 2 ... 8:
...@@ -508,6 +510,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi) ...@@ -508,6 +510,7 @@ static void tx_fifo_write(struct lantiq_ssc_spi *spi)
lantiq_ssc_writel(spi, data, LTQ_SPI_TB); lantiq_ssc_writel(spi, data, LTQ_SPI_TB);
tx_free--; tx_free--;
spi->fdx_tx_level++;
} }
} }
...@@ -519,6 +522,13 @@ static void rx_fifo_read_full_duplex(struct lantiq_ssc_spi *spi) ...@@ -519,6 +522,13 @@ static void rx_fifo_read_full_duplex(struct lantiq_ssc_spi *spi)
u32 data; u32 data;
unsigned int rx_fill = rx_fifo_level(spi); unsigned int rx_fill = rx_fifo_level(spi);
/*
* Wait until all expected data to be shifted in.
* Otherwise, rx overrun may occur.
*/
while (rx_fill != spi->fdx_tx_level)
rx_fill = rx_fifo_level(spi);
while (rx_fill) { while (rx_fill) {
data = lantiq_ssc_readl(spi, LTQ_SPI_RB); data = lantiq_ssc_readl(spi, LTQ_SPI_RB);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment