From d90e2b3e2c37aa63e0dbb4e7359e8043704d815b Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Tue, 24 May 2022 15:07:34 +0200 Subject: flashchips,spi25: Replace `.wrea_override` with FEATURE_4BA_EAR_1716 There are two competing sets of instructions to access the extended address register of 4BA SPI chips. Some chips even support both sets. So far, we assumed the 0xc5/0xc8 instructions by default and allowed to override the write instructions with the `.wrea_override` field. This has some disadvantages: * The additional field is easily overlooked. So when adding a new flash chip, one might assume only 0xc5/0xc8 are supported. * We cannot describe flash chips completely that allow both instructions (and some programmers may be picky about which instructions can be used). Therefore, replace the `.wrea_override` field with a feature flag. Signed-off-by: Nico Huber Change-Id: I6d82f24898acd0789203516a7456fd785907bc10 Ticket: https://ticket.coreboot.org/issues/357 Reviewed-on: https://review.coreboot.org/c/flashrom/+/64636 Tested-by: build bot (Jenkins) Reviewed-by: Thomas Heijligen --- spi25.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'spi25.c') diff --git a/spi25.c b/spi25.c index 74db1005..d52dc3ae 100644 --- a/spi25.c +++ b/spi25.c @@ -351,7 +351,16 @@ static int spi_simple_write_cmd(struct flashctx *const flash, const uint8_t op, static int spi_write_extended_address_register(struct flashctx *const flash, const uint8_t regdata) { - const uint8_t op = flash->chip->wrea_override ? : JEDEC_WRITE_EXT_ADDR_REG; + uint8_t op; + if (flash->chip->feature_bits & FEATURE_4BA_EAR_C5C8) { + op = JEDEC_WRITE_EXT_ADDR_REG; + } else if (flash->chip->feature_bits & FEATURE_4BA_EAR_1716) { + op = ALT_WRITE_EXT_ADDR_REG_17; + } else { + msg_cerr("Flash misses feature flag for extended-address register.\n"); + return -1; + } + struct spi_command cmds[] = { { .readarr = 0, @@ -394,7 +403,7 @@ static int spi_prepare_address(struct flashctx *const flash, uint8_t cmd_buf[], cmd_buf[4] = (addr >> 0) & 0xff; return 4; } else { - if (flash->chip->feature_bits & FEATURE_4BA_EAR_C5C8) { + if (flash->chip->feature_bits & FEATURE_4BA_EAR_ANY) { if (spi_set_extended_address(flash, addr >> 24)) return -1; } else if (addr >> 24) { -- cgit v1.2.1