From ae9aea38274a92aec582a34aebd9db6ea554cc3c Mon Sep 17 00:00:00 2001 From: Brian Gomes Bascoy Date: Tue, 30 Aug 2022 17:15:00 +0200 Subject: [PATCH] Add group 0 & 1 options to ftdi_eeprom, and fix group1 eeprom offset for ft232h This is a WIP patch for ftdi_eeprom that adds support for drive, slew and schmitt settings for both ADBUS and ACBUS on the ft232h (currently only group0_drive exists). I also changed the offset used for the group1 settings in ftdi.c: The eeprom (with stock configuration) of my um232h seems to have the same memory map used in the 2232h and 4232h for these settings. The factory defaults are: group0_drive=8MA group0_slew=false group0_schmitt=false group1_drive=8MA group1_slew=false group1_schmitt=false Signed-off-by: Brian Gomes Bascoy (pera) --- ftdi_eeprom/main.c | 32 ++++++++++++++++++++++++++++++++ src/ftdi.c | 8 ++++---- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/ftdi_eeprom/main.c b/ftdi_eeprom/main.c index e3a09ba..fc427db 100644 --- a/ftdi_eeprom/main.c +++ b/ftdi_eeprom/main.c @@ -87,6 +87,27 @@ static int parse_group0_drive(cfg_t *cfg, cfg_opt_t *opt, const char *value, voi return -1; } +static int parse_group1_drive(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) +{ + static const char* options[] = + { + "4MA", "8MA", "12MA", "16MA" + }; + + int i; + for (i=0; itype == TYPE_230X) { diff --git a/src/ftdi.c b/src/ftdi.c index 0a7fb27..8100dff 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -3424,13 +3424,13 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) output[0x0c] |= SLOW_SLEW; if (eeprom->group1_drive > DRIVE_16MA) - output[0x0d] |= DRIVE_16MA; + output[0x0c] |= DRIVE_16MA<<4; else - output[0x0d] |= eeprom->group1_drive; + output[0x0c] |= eeprom->group1_drive<<4; if (eeprom->group1_schmitt) - output[0x0d] |= IS_SCHMITT; + output[0x0c] |= IS_SCHMITT<<4; if (eeprom->group1_slew) - output[0x0d] |= SLOW_SLEW; + output[0x0c] |= SLOW_SLEW<<4; set_ft232h_cbus(eeprom, output); -- 1.7.1