From ce6889a9978822172c50c92744f0ff11138e3e37 Mon Sep 17 00:00:00 2001 From: Vasili Galka Date: Sun, 9 Mar 2014 15:56:52 +0200 Subject: 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 --- drivers/spi/omap3_spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/spi') 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); -- cgit v1.1 From 7dfc4dbd2d1592ee420945afe6a82003c374b0de Mon Sep 17 00:00:00 2001 From: Axel Lin Date: Fri, 21 Feb 2014 08:55:47 +0800 Subject: spi: atmel_dataflash: Simplify AT91F_SpiEnable implementation Refactor the code a bit to make it better in readability. Remove the comments because now the intention of the code is pretty clear. Signed-off-by: Axel Lin Reviewed-by: Jagannadha Sutradharudu Teki --- drivers/spi/atmel_dataflash_spi.c | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) (limited to 'drivers/spi') diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c index 8a5eddc..a2e9c00 100644 --- a/drivers/spi/atmel_dataflash_spi.c +++ b/drivers/spi/atmel_dataflash_spi.c @@ -102,33 +102,26 @@ void AT91F_SpiEnable(int cs) { unsigned long mode; + mode = readl(ATMEL_BASE_SPI0 + AT91_SPI_MR); + mode &= ~AT91_SPI_PCS; + switch (cs) { - case 0: /* Configure SPI CS0 for Serial DataFlash AT45DBxx */ - mode = readl(ATMEL_BASE_SPI0 + AT91_SPI_MR); - mode &= 0xFFF0FFFF; - writel(mode | ((AT91_SPI_PCS0_DATAFLASH_CARD<<16) & AT91_SPI_PCS), - ATMEL_BASE_SPI0 + AT91_SPI_MR); + case 0: + mode |= AT91_SPI_PCS0_DATAFLASH_CARD << 16; break; - case 1: /* Configure SPI CS1 for Serial DataFlash AT45DBxx */ - mode = readl(ATMEL_BASE_SPI0 + AT91_SPI_MR); - mode &= 0xFFF0FFFF; - writel(mode | ((AT91_SPI_PCS1_DATAFLASH_CARD<<16) & AT91_SPI_PCS), - ATMEL_BASE_SPI0 + AT91_SPI_MR); + case 1: + mode |= AT91_SPI_PCS1_DATAFLASH_CARD << 16; break; - case 2: /* Configure SPI CS2 for Serial DataFlash AT45DBxx */ - mode = readl(ATMEL_BASE_SPI0 + AT91_SPI_MR); - mode &= 0xFFF0FFFF; - writel(mode | ((AT91_SPI_PCS2_DATAFLASH_CARD<<16) & AT91_SPI_PCS), - ATMEL_BASE_SPI0 + AT91_SPI_MR); + case 2: + mode |= AT91_SPI_PCS2_DATAFLASH_CARD << 16; break; case 3: - mode = readl(ATMEL_BASE_SPI0 + AT91_SPI_MR); - mode &= 0xFFF0FFFF; - writel(mode | ((AT91_SPI_PCS3_DATAFLASH_CARD<<16) & AT91_SPI_PCS), - ATMEL_BASE_SPI0 + AT91_SPI_MR); + mode |= AT91_SPI_PCS3_DATAFLASH_CARD << 16; break; } + writel(mode, ATMEL_BASE_SPI0 + AT91_SPI_MR); + /* SPI_Enable */ writel(AT91_SPI_SPIEN, ATMEL_BASE_SPI0 + AT91_SPI_CR); } -- cgit v1.1 From 6e16d90aca35b8f95dd6ee9aef953d702b99eecc Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 27 Feb 2014 13:26:24 -0700 Subject: sandbox: Add implementation of spi_setup_slave_fdt() This function is needed when CONFIG_OF_SPI is defined. Signed-off-by: Simon Glass --- drivers/spi/sandbox_spi.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'drivers/spi') diff --git a/drivers/spi/sandbox_spi.c b/drivers/spi/sandbox_spi.c index 7895305..12e9bda 100644 --- a/drivers/spi/sandbox_spi.c +++ b/drivers/spi/sandbox_spi.c @@ -202,3 +202,16 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout, return ret; } + +/** + * Set up a new SPI slave for an fdt node + * + * @param blob Device tree blob + * @param node SPI peripheral node to use + * @return 0 if ok, -1 on error + */ +struct spi_slave *spi_setup_slave_fdt(const void *blob, int slave_node, + int spi_node) +{ + return NULL; +} -- cgit v1.1