From 27f835653173e2363aaeb97e94227abeb5b0d90a Mon Sep 17 00:00:00 2001 From: hailfinger Date: Fri, 21 May 2010 23:09:42 +0000 Subject: Every SPI programmer driver had its own completely different chip write implementation, and all of them were insufficiently commented. Create spi_write_chunked as a copy of spi_read_chunked and convert all SPI programmers to use it. No functional changes except: - Bus Pirate uses 12 Byte writes instead of 8 Byte writes - SB600 uses 5 Byte writes instead of 1 Byte writes Signed-off-by: Carl-Daniel Hailfinger Acked-by: Michael Karcher Acked-by: David Hendricks git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1005 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- buspirate_spi.c | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'buspirate_spi.c') diff --git a/buspirate_spi.c b/buspirate_spi.c index dc491e2..524b608 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -1,7 +1,7 @@ /* * This file is part of the flashrom project. * - * Copyright (C) 2009 Carl-Daniel Hailfinger + * Copyright (C) 2009, 2010 Carl-Daniel Hailfinger * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -319,7 +319,6 @@ int buspirate_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf) { int total_size = 1024 * flash->total_size; - int i; spi_disable_blockprotect(); /* Erase first. */ @@ -330,25 +329,5 @@ int buspirate_spi_write_256(struct flashchip *flash, uint8_t *buf) } msg_pinfo("done.\n"); - /* FIXME: We could do 12 byte writes, but then we'd have to make sure - * not to cross a 256 byte page boundary. This problem only applies to - * writes, reads can cross page boundaries just fine. - */ - for (i = 0; i < total_size; i += 8) { - int l, r; - if (i + 8 <= total_size) - l = 8; - else - l = total_size - i; - - if ((r = spi_nbyte_program(i, &buf[i], l))) { - msg_perr("%s: write fail %d\n", __func__, r); - return 1; - } - - while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP) - /* loop */; - } - - return 0; + return spi_write_chunked(flash, buf, 0, total_size, 12); } -- cgit v1.2.1