summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Green <avg@google.com>2021-01-18 18:41:25 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2021-01-24 11:13:16 +0000
commit3207844ec0b5dc16f9ae9ee45294213dbf6d060b (patch)
treec67d86b80482a99c03aecf9284459af0dba43340
parent25a5bceb930b6db3f29b1af58133ebbd8ea5f85c (diff)
downloadflashrom-3207844ec0b5dc16f9ae9ee45294213dbf6d060b.tar.gz
flashrom-3207844ec0b5dc16f9ae9ee45294213dbf6d060b.tar.bz2
flashrom-3207844ec0b5dc16f9ae9ee45294213dbf6d060b.zip
ft2232_spi.c: Generalize GPIOL pin control
Adds a new arg "gpiol" to allow the four FT2232 GPIOL pins to be set to any combination of high, low or high-impedance. The existing arg "csgpiol", is intended to function as an additional "cs" signal, allowing pins to be set high but not low. This patch preserves the csgpiol arg for backward compatibility. In the event that both arguments are specified, gpiol is used. Signed-off-by: Alan Green <avg@google.com> Change-Id: I1f2b3b968577e62e3c5b11bcdf4afe2de6eb84ab Reviewed-on: https://review.coreboot.org/c/flashrom/+/49637 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Xiang Wang <merle@hardenedlinux.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
-rw-r--r--ft2232_spi.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/ft2232_spi.c b/ft2232_spi.c
index c963a45b1..0d287dff3 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -367,7 +367,7 @@ int ft2232_spi_init(void)
}
free(arg);
- /* Allows setting multiple GPIOL states, for example: csgpiol=012 */
+ /* Allows setting multiple GPIOL pins to high, for example: csgpiol=012 */
arg = extract_programmer_param("csgpiol");
if (arg) {
unsigned int ngpios = strlen(arg);
@@ -388,6 +388,48 @@ int ft2232_spi_init(void)
}
free(arg);
+ /* Allows setting GPIOL pins high, low or input (high-z) */
+ arg = extract_programmer_param("gpiol");
+ if (arg) {
+ int ok = 0;
+ if (strlen(arg) == 4) {
+ ok = 1;
+ for (int i = 0; i < 4; i++) {
+ unsigned int pin = i + 4;
+ switch (toupper(arg[i])) {
+ case 'H':
+ cs_bits |= 1 << pin;
+ pindir |= 1 << pin;
+ break;
+ case 'L':
+ cs_bits &= ~(1 << pin);
+ pindir |= 1 << pin;
+ break;
+ case 'Z':
+ pindir &= ~(1 << pin);
+ break;
+ case 'X':
+ break;
+ default:
+ ok = 0;
+ }
+ }
+ }
+ if (!ok) {
+ msg_perr("Error: Invalid GPIOLs specified: \"%s\".\n"
+ "Valid values are 4 character strings of H, L, Z and X.\n"
+ " H - Set GPIOL output high\n"
+ " L - Set GPIOL output low\n"
+ " Z - Set GPIOL as input (high impedance)\n"
+ " X - Leave as programmer default\n"
+ "Example: gpiol=LZXH drives GPIOL 0 low, and GPIOL 3 high, sets GPIOL 1\n"
+ "to an input and leaves GPIOL 2 set according to the programmer type.\n", arg);
+ free(arg);
+ return -2;
+ }
+ }
+ free(arg);
+
msg_pdbg("Using device type %s %s ",
get_ft2232_vendorname(ft2232_vid, ft2232_type),
get_ft2232_devicename(ft2232_vid, ft2232_type));