1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

spi: Add function to probe erase command opcode for all spi_master

Add a field, probe_opcode, to struct spi_master which points to a
function returning a bool by checking if a given command is supported by
the programmer in use. This is used for getting a whitelist of commands
supported by the programmer, as some programmers like ichspi don't
support all opcodes.

Most programmers use the default function, which just returns true.
ICHSPI and dummyflasher use their specialized function.

Change-Id: I6852ef92788221f471a859c879f8aff42558d36d
Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/65183
Reviewed-by: Thomas Heijligen <src@posteo.de>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Aarya Chaumal
2022-07-04 18:21:50 +05:30
committed by Thomas Heijligen
parent d0ae8686b1
commit edcea80d68
25 changed files with 50 additions and 1 deletions

View File

@ -121,6 +121,17 @@ static int dummy_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsig
emu_data->spi_write_256_chunksize);
}
static bool dummy_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
{
size_t i;
struct emu_data *emu_data = flash->mst->spi.data;
for (i = 0; i < emu_data->spi_blacklist_size; i++) {
if (emu_data->spi_blacklist[i] == opcode)
return false;
}
return true;
}
static int probe_variable_size(struct flashctx *flash)
{
const struct emu_data *emu_data = flash->mst->opaque.data;
@ -916,6 +927,7 @@ static const struct spi_master spi_master_dummyflasher = {
.read = default_spi_read,
.write_256 = dummy_spi_write_256,
.write_aai = default_spi_write_aai,
.probe_opcode = dummy_spi_probe_opcode,
};
static const struct par_master par_master_dummyflasher = {