Nico Huber has submitted this change. ( https://review.coreboot.org/c/flashrom/+/57809 )
Change subject: ft2232_spi: prevent use of reserved pins on some programmers ......................................................................
ft2232_spi: prevent use of reserved pins on some programmers
On some programmers an output buffer needs to be enabled by pulling a gpio high/low. This gpio can not be used for `csgpiol`. Prevent this by printing an error.
Change-Id: Ied450fa5ef358153adefec3beabc63a62c9f60cd Signed-off-by: Michael Niewöhner foss@mniewoehner.de Reviewed-on: https://review.coreboot.org/c/flashrom/+/57809 Reviewed-by: Nico Huber nico.h@gmx.de Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M ft2232_spi.c 1 file changed, 12 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Nico Huber: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/ft2232_spi.c b/ft2232_spi.c index df156d6..110bdec 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -419,6 +419,9 @@ } free(arg);
+ /* Remember reserved pins before pindir gets modified. */ + const uint8_t rsv_bits = pindir & 0xf0; + arg = extract_programmer_param("port"); if (arg) { switch (toupper((unsigned char)*arg)) { @@ -478,6 +481,15 @@ return -2; } unsigned int pin = temp + 4; + + if (rsv_bits & 1 << pin) { + msg_perr("Error: Invalid GPIOL specified: "%s".\n" + "The pin is reserved on this programmer.\n", + arg); + free(arg); + return -2; + } + cs_bits |= 1 << pin; pindir |= 1 << pin; }