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.
flashrom-stable: Added `.probe_opcode` for `dirtyjtag_spi`, `ich7`.
Change-Id: I6852ef92788221f471a859c879f8aff42558d36d
Signed-off-by: Aarya Chaumal <aarya.chaumal@gmail.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/65183
Original-Reviewed-by: Thomas Heijligen <src@posteo.de>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-by: Felix Singer <felixsinger@posteo.net>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72539
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/ichspi.c b/ichspi.c
index fc3c9a9..ee29288 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1572,6 +1572,11 @@
return ret;
}
+static bool ich_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
+{
+ return find_opcode(curopcodes, opcode) >= 0;
+}
+
#define ICH_BMWAG(x) ((x >> 24) & 0xff)
#define ICH_BMRAG(x) ((x >> 16) & 0xff)
#define ICH_BRWA(x) ((x >> 8) & 0xff)
@@ -1698,6 +1703,7 @@
.multicommand = ich_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
+ .probe_opcode = ich_spi_probe_opcode,
};
static const struct spi_master spi_master_ich9 = {
@@ -1707,6 +1713,7 @@
.multicommand = ich_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
+ .probe_opcode = ich_spi_probe_opcode,
};
static const struct opaque_master opaque_master_ich_hwseq = {
@@ -2073,6 +2080,7 @@
.multicommand = ich_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
+ .probe_opcode = ich_spi_probe_opcode,
};
int via_init_spi(uint32_t mmio_base)