From: Vasili Galka Date: Sun, 9 Mar 2014 13:56:52 +0000 (+0200) Subject: drivers/spi/omap3: Bug fix of premature write transfer completion X-Git-Tag: v2014.04~25^2~11 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=ce6889a9978822172c50c92744f0ff11138e3e37;p=oweals%2Fu-boot.git drivers/spi/omap3: Bug fix of premature write transfer completion 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 --- diff --git a/drivers/spi/omap3_spi.c b/drivers/spi/omap3_spi.c index a3ad056473..651e46e4bd 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);