summaryrefslogtreecommitdiffstats
path: root/bitbang_spi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-05-21 23:09:42 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2010-05-21 23:09:42 +0000
commit9f82928c470b196e1a9680c6628549ef2022ef64 (patch)
tree73c903182e7400386453acfbd7c738b3361849ff /bitbang_spi.c
parent9ec5edff2b22caf0d1e29df85b01f20f2fe419cd (diff)
downloadflashrom-9f82928c470b196e1a9680c6628549ef2022ef64.zip
flashrom-9f82928c470b196e1a9680c6628549ef2022ef64.tar.gz
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 Corresponding to flashrom svn r1005. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de> Acked-by: David Hendricks <dhendrix@google.com>
Diffstat (limited to 'bitbang_spi.c')
-rw-r--r--bitbang_spi.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/bitbang_spi.c b/bitbang_spi.c
index 8d6a9a1..f60a7e1 100644
--- a/bitbang_spi.c
+++ b/bitbang_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
@@ -142,24 +142,7 @@ int bitbang_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
int bitbang_spi_write_256(struct flashchip *flash, uint8_t *buf)
{
int total_size = 1024 * flash->total_size;
- int i;
msg_pdbg("total_size is %d\n", total_size);
- for (i = 0; i < total_size; i += 256) {
- int l, r;
- if (i + 256 <= total_size)
- l = 256;
- 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, 256);
}
OpenPOWER on IntegriCloud