Alan Green has uploaded this change for review.
ft2232_spi.c: Generalized 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
---
M ft2232_spi.c
1 file changed, 38 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/37/49637/1
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 6cf7a3c..60327ee 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -370,7 +370,7 @@
}
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);
@@ -391,6 +391,43 @@
}
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':
+ 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 and X.\n"
+ " H - Set GPIOL high\n"
+ " L - Set GPIOL low\n"
+ " X - Leave GPIOL at high impedance\n"
+ "Example: gpiol=HXLX drives GPIOL 0 to high, GPIOL 2 to "
+ "high, and leaves GPIOLs\n1 and 3 undriven.\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));
To view, visit change 49637. To unsubscribe, or for help writing mail filters, visit settings.