diff options
author | Michael Niewöhner <foss@mniewoehner.de> | 2021-09-21 19:43:04 +0200 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2021-10-01 11:38:08 +0000 |
commit | 22ee33c39baef60e0f0b858cc0178fa8c0f98bfc (patch) | |
tree | 81dbce7ae935ddbe17aabe9ee5d4d60434aa65cd /ft2232_spi.c | |
parent | 51a9c38fcc13e6e55647da9b6e74f91fbec534d1 (diff) | |
download | flashrom-22ee33c39baef60e0f0b858cc0178fa8c0f98bfc.tar.gz flashrom-22ee33c39baef60e0f0b858cc0178fa8c0f98bfc.tar.bz2 flashrom-22ee33c39baef60e0f0b858cc0178fa8c0f98bfc.zip |
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>
Diffstat (limited to 'ft2232_spi.c')
-rw-r--r-- | ft2232_spi.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/ft2232_spi.c b/ft2232_spi.c index df156d6fa..110bdece2 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -419,6 +419,9 @@ static int ft2232_spi_init(void) } 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 @@ static int ft2232_spi_init(void) 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; } |