Sergii Dmytruk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/59073 )
Change subject: [RFC] dummyflasher: SR2 for W25Q128FV ......................................................................
[RFC] dummyflasher: SR2 for W25Q128FV
W25Q128FV has SR3 too, by the way.
Change-Id: I79f9b4a0b604663d3288ad70dcbe3ea4075dede5 Signed-off-by: Sergii Dmytruk sergii.dmytruk@3mdeb.com --- M dummyflasher.c 1 file changed, 20 insertions(+), 6 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/73/59073/1
diff --git a/dummyflasher.c b/dummyflasher.c index 7ef4a25..bb47c3c 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -161,9 +161,23 @@ }
/* Status registers are base 1. */ -static uint8_t get_status_ro_bits(int status_reg) +static uint8_t get_status_ro_bits(const struct emu_data *data, int status_reg) { - return (status_reg == 1 ? SPI_SR_WEL | SPI_SR_WIP : 0); + uint8_t ro_bits = (status_reg == 1 ? SPI_SR_WEL | SPI_SR_WIP : 0); + + if (data->emu_chip == EMULATE_WINBOND_W25Q128FV) { + if (status_reg == 2) { + /* SUS1 (bit_7) and (R) (bit_2). */ + ro_bits = 0x84; + /* Once any of the lock bits (LB[1..3]) are set, they + * can't be unset. */ + ro_bits |= data->emu_status2 & (1 << 3); + ro_bits |= data->emu_status2 & (1 << 4); + ro_bits |= data->emu_status2 & (1 << 5); + } + } + + return ro_bits; }
static int emulate_spi_chip_response(unsigned int writecnt, @@ -331,11 +345,11 @@ }
/* FIXME: add some reasonable simulation of the busy flag */ - ro_bits = get_status_ro_bits(1); + ro_bits = get_status_ro_bits(data, 1); data->emu_status &= ro_bits; data->emu_status |= (writearr[1] & ~ro_bits); if (writecnt == 3) { - ro_bits = get_status_ro_bits(2); + ro_bits = get_status_ro_bits(data, 2); data->emu_status2 &= ro_bits; data->emu_status2 |= (writearr[2] & ~ro_bits); } @@ -353,7 +367,7 @@ break; }
- ro_bits = get_status_ro_bits(2); + ro_bits = get_status_ro_bits(data, 2); data->emu_status2 &= ro_bits; data->emu_status2 |= (writearr[1] & ~ro_bits); break; @@ -904,7 +918,7 @@ data->emu_chip_size = 16 * 1024 * 1024; data->emu_max_byteprogram_size = 256; data->emu_max_aai_size = 0; - data->emu_status_len = 1; + data->emu_status_len = 2; data->emu_jedec_se_size = 4 * 1024; data->emu_jedec_be_52_size = 32 * 1024; data->emu_jedec_be_d8_size = 64 * 1024;