Skip to content

Commit b9f7f93

Browse files
authored
Merge pull request #45 from superna9999/ftdi-gpio-output-enable
ftdi_gpio: add output_enable gpio type
2 parents 5e3bdca + 981a8ba commit b9f7f93

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

ftdi-gpio.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ enum {
5050
GPIO_FASTBOOT_KEY, // Usually volume key
5151
GPIO_POWER_KEY, // Key to power the device
5252
GPIO_USB_DISCONNECT, // Simulate main USB connection
53+
GPIO_OUTPUT_ENABLE, // Enable FTDI signals to flow to the board
5354
GPIO_COUNT
5455
};
5556

@@ -70,6 +71,7 @@ struct ftdi_gpio {
7071

7172
static int ftdi_gpio_device_power(struct ftdi_gpio *ftdi_gpio, bool on);
7273
static void ftdi_gpio_device_usb(struct ftdi_gpio *ftdi_gpio, bool on);
74+
static int ftdi_gpio_toggle_io(struct ftdi_gpio *ftdi_gpio, unsigned int gpio, bool on);
7375

7476
/*
7577
* fdio_gpio parameter: <libftdi description>;[<interface>[;<gpios>...]]
@@ -139,6 +141,8 @@ static void ftdi_gpio_parse_config(struct ftdi_gpio *ftdi_gpio, char *control_de
139141
gpio_type = GPIO_POWER_KEY;
140142
else if (strncmp("USB_DISCONNECT", name, off - name - 1) == 0)
141143
gpio_type = GPIO_USB_DISCONNECT;
144+
else if (strncmp("OUTPUT_ENABLE", name, off - name - 1) == 0)
145+
gpio_type = GPIO_OUTPUT_ENABLE;
142146
else
143147
errx(1, "GPIOs type invalid: '%s'", name);
144148

@@ -189,6 +193,9 @@ static void *ftdi_gpio_open(struct device *dev)
189193
else
190194
ftdi_gpio_device_usb(ftdi_gpio, 0);
191195

196+
if (ftdi_gpio->gpio_present[GPIO_OUTPUT_ENABLE])
197+
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_OUTPUT_ENABLE, 1);
198+
192199
usleep(500000);
193200

194201
return ftdi_gpio;

0 commit comments

Comments
 (0)