spi25: Integrate 4BA support
Back port the upstream `commit f43c654a` reworked for our tree.
BUG=chromium:478356
BRANCH=none
TEST=still builds
Change-Id: I95c12d54fcc4acfbce00e59e11d00a324cbfaf7f
Signed-off-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/flashrom/+/1667513
Reviewed-by: Stefan Reinauer <reinauer@google.com>
diff --git a/flash.h b/flash.h
index b74b428..6fa0ead 100644
--- a/flash.h
+++ b/flash.h
@@ -22,6 +22,7 @@
#include <stdint.h>
#include <stddef.h>
+#include <stdbool.h>
#include "hwaccess.h"
#ifdef _WIN32
#include <windows.h>
@@ -127,6 +128,8 @@
#define FEATURE_UNBOUND_READ (1 << 10)
#define FEATURE_NO_ERASE (1 << 11)
#define FEATURE_4BA_SUPPORT (1 << 12)
+#define FEATURE_4BA_EXT_ADDR (1 << 13) /**< Regular 3-byte operations can be used by writing the most
+ significant address byte into an extended address register. */
struct voltage_range {
uint16_t min, max;
@@ -248,6 +251,14 @@
/* Some flash devices have an additional register space. */
chipaddr virtual_registers;
struct registered_master *mst;
+
+ /* We cache the state of the extended address register (highest byte
+ * of a 4BA for 3BA instructions) and the state of the 4BA mode here.
+ * If possible, we enter 4BA mode early. If that fails, we make use
+ * of the extended address register.
+ */
+ int address_high_byte;
+ bool in_4ba_mode;
};