diff mbox

[U-Boot] drivers/spi/omap3: Bug fix of premature write transfer completion

Message ID 1394373412-4360-1-git-send-email-vvv444@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Vasili Galka March 9, 2014, 1:56 p.m. UTC
The logic determining SPI "write" transfer completion was faulty. At
certain conditions (e.g. slow SPI clock freq) the transfers were
interrupted before completion. Both EOT and TXS flags of channel
status registeer shall be checked to ensure that all data was
transferred. Tested on AM3359 chip.

Signed-off-by: Vasili Galka <vasili@visionmap.com>
---
 drivers/spi/omap3_spi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Tom Rini March 12, 2014, 8:04 p.m. UTC | #1
On Sun, Mar 09, 2014 at 03:56:52PM +0200, Vasili Galka wrote:

> The logic determining SPI "write" transfer completion was faulty. At
> certain conditions (e.g. slow SPI clock freq) the transfers were
> interrupted before completion. Both EOT and TXS flags of channel
> status registeer shall be checked to ensure that all data was
> transferred. Tested on AM3359 chip.
> 
> Signed-off-by: Vasili Galka <vasili@visionmap.com>

Applied to u-boot-ti/master, thanks!
diff mbox

Patch

diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c
index a3ad056..651e46e 100644
--- a/drivers/spi/omap3_spi.c
+++ b/drivers/spi/omap3_spi.c
@@ -260,8 +260,9 @@  int omap3_spi_write(struct spi_slave *slave, unsigned int len, const void *txp,
 	}
 
 	/* wait to finish of transfer */
-	while (!(readl(&ds->regs->channel[ds->slave.cs].chstat) &
-			 OMAP3_MCSPI_CHSTAT_EOT));
+	while ((readl(&ds->regs->channel[ds->slave.cs].chstat) &
+			 (OMAP3_MCSPI_CHSTAT_EOT | OMAP3_MCSPI_CHSTAT_TXS)) !=
+			 (OMAP3_MCSPI_CHSTAT_EOT | OMAP3_MCSPI_CHSTAT_TXS));
 
 	/* Disable the channel otherwise the next immediate RX will get affected */
 	omap3_spi_set_enable(ds,OMAP3_MCSPI_CHCTRL_DIS);