aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichal Suchanek <hramrach@gmail.com>2016-06-13 13:46:49 -0400
committerMark Brown <broonie@kernel.org>2016-06-14 05:05:08 -0400
commit6d9fe44bd73d567d04d3a68a2d2fa521ab9532f2 (patch)
tree862f44d73573de039a5b35a2fce7f0a154530a43
parent1a695a905c18548062509178b98bc91e67510864 (diff)
spi: sun4i: fix FIFO limit
When testing SPI without DMA I noticed that filling the FIFO on the spi controller causes timeout. Always leave room for one byte in the FIFO. Signed-off-by: Michal Suchanek <hramrach@gmail.com> Acked-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
-rw-r--r--drivers/spi/spi-sun4i.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/spi/spi-sun4i.c b/drivers/spi/spi-sun4i.c
index 1ddd9e2309b6..e7e4aecb3295 100644
--- a/drivers/spi/spi-sun4i.c
+++ b/drivers/spi/spi-sun4i.c
@@ -179,7 +179,10 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
179 179
180 /* We don't support transfer larger than the FIFO */ 180 /* We don't support transfer larger than the FIFO */
181 if (tfr->len > SUN4I_FIFO_DEPTH) 181 if (tfr->len > SUN4I_FIFO_DEPTH)
182 return -EINVAL; 182 return -EMSGSIZE;
183
184 if (tfr->tx_buf && tfr->len >= SUN4I_FIFO_DEPTH)
185 return -EMSGSIZE;
183 186
184 reinit_completion(&sspi->done); 187 reinit_completion(&sspi->done);
185 sspi->tx_buf = tfr->tx_buf; 188 sspi->tx_buf = tfr->tx_buf;
@@ -269,8 +272,12 @@ static int sun4i_spi_transfer_one(struct spi_master *master,
269 sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len)); 272 sun4i_spi_write(sspi, SUN4I_BURST_CNT_REG, SUN4I_BURST_CNT(tfr->len));
270 sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len)); 273 sun4i_spi_write(sspi, SUN4I_XMIT_CNT_REG, SUN4I_XMIT_CNT(tx_len));
271 274
272 /* Fill the TX FIFO */ 275 /*
273 sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH); 276 * Fill the TX FIFO
277 * Filling the FIFO fully causes timeout for some reason
278 * at least on spi2 on A10s
279 */
280 sun4i_spi_fill_fifo(sspi, SUN4I_FIFO_DEPTH - 1);
274 281
275 /* Enable the interrupts */ 282 /* Enable the interrupts */
276 sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC); 283 sun4i_spi_write(sspi, SUN4I_INT_CTL_REG, SUN4I_INT_CTL_TC);