summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorBoris Baykov <dev@borisbaykov.com>2016-06-08 12:23:55 +0200
committerCédric Le Goater <clg@kaod.org>2016-06-08 12:23:55 +0200
commit146062255451c196701c8a36e4196023a7be36be (patch)
tree9162ed08f1498c79ab86d5b5dc7ee4fc389d6849 /flashrom.c
parent648cdc2841665febf3c4bb174c2ee4a0f365c9b7 (diff)
downloadflashrom-146062255451c196701c8a36e4196023a7be36be.zip
flashrom-146062255451c196701c8a36e4196023a7be36be.tar.gz
4BA: Support for new direct-4BA instructions + W25Q256.V update
Large flash chips usually support special instructions to work with 4-bytes address directly from 3-bytes addressing mode and without do switching to 4-bytes mode. There are 13h (4BA Read), 12h (4BA Program) and 21h,5Ch,DCh (4BA Erase), correspondingly. However not all these instructions are supported by all large flash chips. Some chips support 13h only, some 13h,12h,21h and DCh, but not 5Ch. This depends on the manufacturer of the chip. This patch provides code to use direct 4-bytes addressing instructions. This code should work but it tested partially only. My W25Q256FV has support for 4BA_Read (13h), but doesn't have support 4BA_Program (12h) and 4BA_Erase instructions. So, direct 4BA program and erase should be tested after. Patched files ------------- chipdrivers.h + added functions declarations for spi4ba.c flash.h + feature definitions added flashchips.c + modified definition of Winbond W25Q256BV/W25Q256FV chips flashrom.c + modified switch to 4-bytes addressing for direct-4BA instructions spi4ba.h + definitions for 4-bytes addressing JEDEC commands + functions declarations from spi4ba.c (same as in chipdrivers.h, just to see) spi4ba.c + functions for read/write/erase directly with 4-bytes address (from any mode) Signed-off-by: Boris Baykov <dev@borisbaykov.com>, Russia, Jan 2014 [clg: ported from https://www.flashrom.org/pipermail/flashrom/2015-January/013198.html ] Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/flashrom.c b/flashrom.c
index 79ddf76..6a6f5b6 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -2011,8 +2011,14 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
else if(flash->chip->feature_bits & FEATURE_4BA_EXTENDED_ADDR_REG) {
msg_cdbg("Using 4-bytes addressing with extended address register.\n");
}
- /* Go to 4-Bytes Addressing mode */
- else {
+ /* Go to 4-Bytes Addressing mode if selected
+ operation requires 4-Bytes Addressing mode
+ (no need if functions are direct-4BA) */
+ else if(((read_it || verify_it)
+ && (!(flash->chip->feature_bits & FEATURE_4BA_DIRECT_READ)))
+ || ((erase_it || write_it)
+ && ((flash->chip->feature_bits & FEATURE_4BA_ALL_DIRECT) != FEATURE_4BA_ALL_DIRECT))) {
+
if (!flash->chip->four_bytes_addr_funcs.enter_4ba) {
msg_cerr("No function for Enter 4-bytes addressing mode for this flash chip.\n"
"Please report to flashrom@flashrom.org\n");
@@ -2026,6 +2032,11 @@ int doit(struct flashctx *flash, int force, const char *filename, int read_it,
msg_cdbg("Switched to 4-bytes addressing mode.\n");
}
+ /* Do not switch to 4-Bytes Addressing mode if all instructions are direct-4BA
+ or if the flash chip is 4-Bytes Addressing Only and always in 4BA-mode */
+ else {
+ msg_cdbg2("No need to switch to 4-bytes addressing mode.\n");
+ }
}
if (read_it) {
OpenPOWER on IntegriCloud