summaryrefslogtreecommitdiffstats
path: root/spi.c
diff options
context:
space:
mode:
authorBoris Baykov <dev@borisbaykov.com>2016-06-11 18:29:00 +0200
committerNico Huber <nico.h@gmx.de>2017-10-15 12:30:26 +0000
commit9912718de18e455e16d26458aca4eac37f792aa2 (patch)
treed447b47feb1d0f497c17ab6941e0b4c9afbed5cb /spi.c
parentb1f88360fc806ee69d7cf1b9404b3977bc53aace (diff)
downloadflashrom-9912718de18e455e16d26458aca4eac37f792aa2.tar.gz
flashrom-9912718de18e455e16d26458aca4eac37f792aa2.tar.bz2
flashrom-9912718de18e455e16d26458aca4eac37f792aa2.zip
4BA: Flashrom integration for the 4-bytes addressing extensions
This patch integrates code of the previous patch into Flashrom's code. All the integrations is around 3 functions spi_nbyte_read, spi_nbyte_program and spi_byte_program. After this patch then are not static and can be called by their pointers saved in flashchips array. Also I added to flashrom.c some code to switch a chip to 4-bytes addressing mode. And one error message is corrected in spi.c because it's not suitable for 32-bit addresses. Patched files ------------- flash.h + added set of 4-bytes address functions to flashchip structure definition flashrom.c + added switch to 4-bytes addressing more for chips which support it serprog.c + added 4-bytes addressing spi_nbyte_read call to serprog_spi_read spi.c + fixed flash chip size check in spi_chip_read spi25.c + added 4-bytes addressing spi_nbyte_read call to spi_read_chunked + added 4-bytes addressing spi_nbyte_program call to spi_write_chunked + added 4-bytes addressing spi_byte_program call to spi_chip_write_1 Conflicts: serprog.c Change-Id: Ib051cfc93bd4aa7580519e0e6206d025f3ca8049 Signed-off-by: Boris Baykov <dev@borisbaykov.com>, Russia, Jan 2014 [clg: ported from https://www.flashrom.org/pipermail/flashrom/2015-January/013205.html ] Signed-off-by: Cédric Le Goater <clg@kaod.org> Reviewed-on: https://review.coreboot.org/20505 Reviewed-by: Nico Huber <nico.h@gmx.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'spi.c')
-rw-r--r--spi.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/spi.c b/spi.c
index 894f73f60..0a4a6184c 100644
--- a/spi.c
+++ b/spi.c
@@ -110,7 +110,10 @@ int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start,
* means 0xffffff, the highest unsigned 24bit number.
*/
addrbase = spi_get_valid_read_addr(flash);
- if (addrbase + flash->chip->total_size * 1024 > (1 << 24)) {
+ /* Show flash chip size warning if flash chip doesn't support
+ 4-Bytes Addressing mode and last address excedes 24 bits */
+ if (!(flash->chip->feature_bits & FEATURE_4BA_SUPPORT) &&
+ addrbase + flash->chip->total_size * 1024 > (1 << 24)) {
msg_perr("Flash chip size exceeds the allowed access window. ");
msg_perr("Read will probably fail.\n");
/* Try to get the best alignment subject to constraints. */