From f1ddcab82d5966ef320e027be7670a106c990cdf Mon Sep 17 00:00:00 2001 From: Vic Yang Date: Thu, 26 Jun 2014 17:33:03 -0700 Subject: [PATCH] mec1322: Disable auto read after a SPI transaction The auto mode keeps the read buffer full and thus interfere with the next transaction. We need to disable it when we are done with the current transaction. BUG=chrome-os-partner:29805 TEST=Read from SPI flash multiple times BRANCH=None Change-Id: I624299aae29fecde03e41228a694550f1deafd2a Signed-off-by: Vic Yang Reviewed-on: https://chromium-review.googlesource.com/205799 Reviewed-by: Randall Spangler --- chip/mec1322/spi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/chip/mec1322/spi.c b/chip/mec1322/spi.c index 713b88744a..86d44e639d 100644 --- a/chip/mec1322/spi.c +++ b/chip/mec1322/spi.c @@ -83,9 +83,18 @@ int spi_transaction_async(const uint8_t *txdata, int txlen, int spi_transaction_flush(void) { int ret = dma_wait(SPI_DMA_CHANNEL); + uint8_t dummy __attribute__((unused)) = 0; + + /* Disable auto read */ + MEC1322_SPI_CR(CONFIG_SPI_PORT) &= ~(1 << 5); gpio_set_level(CONFIG_SPI_CS_GPIO, 1); + dma_disable(SPI_DMA_CHANNEL); + dma_clear_isr(SPI_DMA_CHANNEL); + if (MEC1322_SPI_SR(CONFIG_SPI_PORT) & 0x2) + dummy = MEC1322_SPI_RD(CONFIG_SPI_PORT); + return ret; }