summaryrefslogtreecommitdiffstats
path: root/chipdrivers.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 /chipdrivers.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 'chipdrivers.h')
-rw-r--r--chipdrivers.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/chipdrivers.h b/chipdrivers.h
index e1d6aa9e7..ea8d480d5 100644
--- a/chipdrivers.h
+++ b/chipdrivers.h
@@ -62,8 +62,10 @@ int spi_set_extended_address(struct flashctx *, uint8_t addr_high);
/* spi25_statusreg.c */
+/* FIXME: replace spi_read_status_register() calls with spi_read_register() */
uint8_t spi_read_status_register(const struct flashctx *flash);
-int spi_write_status_register(const struct flashctx *flash, int status);
+int spi_read_register(const struct flashctx *flash, enum flash_reg reg, uint8_t *value);
+int spi_write_register(const struct flashctx *flash, enum flash_reg reg, uint8_t value);
void spi_prettyprint_status_register_bit(uint8_t status, int bit);
int spi_prettyprint_status_register_plain(struct flashctx *flash);
int spi_prettyprint_status_register_default_welwip(struct flashctx *flash);