1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

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>
This commit is contained in:
Michael Niewöhner 2021-09-21 19:43:04 +02:00 committed by Nico Huber
parent 51a9c38fcc
commit 22ee33c39b

View File

@ -419,6 +419,9 @@ static int ft2232_spi_init(void)
} }
free(arg); free(arg);
/* Remember reserved pins before pindir gets modified. */
const uint8_t rsv_bits = pindir & 0xf0;
arg = extract_programmer_param("port"); arg = extract_programmer_param("port");
if (arg) { if (arg) {
switch (toupper((unsigned char)*arg)) { switch (toupper((unsigned char)*arg)) {
@ -478,6 +481,15 @@ static int ft2232_spi_init(void)
return -2; return -2;
} }
unsigned int pin = temp + 4; 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; cs_bits |= 1 << pin;
pindir |= 1 << pin; pindir |= 1 << pin;
} }