amd_spi100: Check IllegalAccess before executing command
The SPI controller immediately sets the IllegalAccess flag if we
configured an opcode (and optional address) that is not allowed
in the current configuration.
Change-Id: Icfa5a2823a302857aef0331ce44221747cf5fdd9
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73678
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/amd_spi100.c b/amd_spi100.c
index a6ad8c3..fab16e3 100644
--- a/amd_spi100.c
+++ b/amd_spi100.c
@@ -108,6 +108,15 @@
if (writecnt > 1)
spi100_writen(spi100, 0x80, &writearr[1], writecnt - 1);
+ /* Check if the command/address is allowed */
+ const uint32_t spi_cntrl0 = spi100_read32(spi100, 0x00);
+ if (spi_cntrl0 & (1 << 21)) {
+ msg_perr("ERROR: Illegal access for opcode 0x%02x!", writearr[0]);
+ return SPI_INVALID_OPCODE;
+ } else {
+ msg_pspew("%s: executing opcode 0x%02x.\n", __func__, writearr[0]);
+ }
+
/* Trigger command */
spi100_write8(spi100, 0x47, BIT(7));