summaryrefslogtreecommitdiffstats
path: root/flash.h
diff options
context:
space:
mode:
authorNikolai Artemiev <nartemiev@google.com>2021-10-20 22:30:41 +1100
committerAnastasia Klimchuk <aklm@chromium.org>2022-02-28 03:25:13 +0000
commita0319804a03f69d6e21af2ce42e8fd311e2e6a8f (patch)
tree9d16f3620ef75d5d1286e2ae7b83971395df83f7 /flash.h
parent4571361d0e2b11f43b2de5390c90705d4e8cce4a (diff)
downloadflashrom-a0319804a03f69d6e21af2ce42e8fd311e2e6a8f.tar.gz
flashrom-a0319804a03f69d6e21af2ce42e8fd311e2e6a8f.tar.bz2
flashrom-a0319804a03f69d6e21af2ce42e8fd311e2e6a8f.zip
spi25_statusreg: make register read/write functions generic
This patch adds new spi_{read,write}_register() functions that take the source/destination register as an argument. Currently they can only access SR1, support for other registers will be added in another patch. Since we're refactoring things, this commit also makes spi_read_register() return an error code, making it possible to identify error conditions that spi_read_status_register() concealed. This also removes the initial 100ms delay between writing a register and the first attempt to check the chip's status. An initial delay was added to avoid needing to read the status register multiple times, but that is unlikely to cause problems on modern flash chips. BUG=b:195381327,b:153800563 BRANCH=none TEST=flashrom -{r,w,E} TEST=flashrom --wp-{enable,disable,range,list,status} at end of patch series Change-Id: I0a3951bbf993f2d8d830143b29d3ce16cc6901d7 Signed-off-by: Nikolai Artemiev <nartemiev@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/58475 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'flash.h')
-rw-r--r--flash.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/flash.h b/flash.h
index 654cdee6d..f1a8b340e 100644
--- a/flash.h
+++ b/flash.h
@@ -166,6 +166,13 @@ struct flashrom_flashctx;
#define flashctx flashrom_flashctx /* TODO: Agree on a name and convert all occurences. */
typedef int (erasefunc_t)(struct flashctx *flash, unsigned int addr, unsigned int blocklen);
+enum flash_reg {
+ INVALID_REG = 0,
+ STATUS1,
+ STATUS2,
+ MAX_REGISTERS
+};
+
struct flashchip {
const char *vendor;
const char *name;