From 032c84381751bab0fe1da2e963af41cbe52c303d Mon Sep 17 00:00:00 2001 From: David Hendricks Date: Fri, 11 Apr 2014 19:48:55 -0700 Subject: spi_flash: Move (de-)assertion of /CS to single location This consolidates all calls to spi_claim_bus() and spi_release_bus() to a single location where spi_xfer() is called. This avoids confusing (and potentially redundant) calls that were being done throughout the generic spi_flash.c functions and chip-specific functions. I don't think the current approach could even work since many chip drivers assert /CS once and then issue multiple commands such as page program followed by reading the status register. I suspect the reason we didn't notice it on x86 is because the ICH/PCH handled each individual command correctly (spi_claim_bus() and spi_release_bus() are noops) in spite of the broken code. BUG=none BRANCH=none TEST=tested on nyan and link Signed-off-by: David Hendricks Original-Change-Id: I3257e2f6a2820834f4c9018069f90fcf2bab05f6 Original-Reviewed-on: https://chromium-review.googlesource.com/194510 Original-Reviewed-by: David Hendricks Original-Commit-Queue: David Hendricks Original-Tested-by: David Hendricks (cherry picked from commit d3394d34fb49e9e252f67371674d5b3aa220bc9e) Signed-off-by: Marc Jones Change-Id: Ieb62309b18090d8f974f91a6e448af3d65dd3d1d Reviewed-on: http://review.coreboot.org/7829 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/drivers/spi/gigadevice.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'src/drivers/spi/gigadevice.c') diff --git a/src/drivers/spi/gigadevice.c b/src/drivers/spi/gigadevice.c index d9d4e17f57..68b487efca 100644 --- a/src/drivers/spi/gigadevice.c +++ b/src/drivers/spi/gigadevice.c @@ -126,19 +126,13 @@ static int gigadevice_write(struct spi_flash *flash, u32 offset, unsigned long page_size; size_t chunk_len; size_t actual; - int ret; + int ret = 0; u8 cmd[4]; page_size = 1 << stm->params->l2_page_size; byte_addr = offset % page_size; flash->spi->rw = SPI_WRITE_FLAG; - ret = spi_claim_bus(flash->spi); - if (ret) { - printk(BIOS_WARNING, - "SF gigadevice.c: Unable to claim SPI bus\n"); - return ret; - } for (actual = 0; actual < len; actual += chunk_len) { chunk_len = min(len - actual, page_size - byte_addr); @@ -187,7 +181,6 @@ static int gigadevice_write(struct spi_flash *flash, u32 offset, ret = 0; out: - spi_release_bus(flash->spi); return ret; } -- cgit v1.2.3