Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ftdi_gpio: add output_enable gpio type #45

Merged
merged 1 commit into from
Nov 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ftdi-gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ enum {
GPIO_FASTBOOT_KEY, // Usually volume key
GPIO_POWER_KEY, // Key to power the device
GPIO_USB_DISCONNECT, // Simulate main USB connection
GPIO_OUTPUT_ENABLE, // Enable FTDI signals to flow to the board
GPIO_COUNT
};

Expand All @@ -70,6 +71,7 @@ struct ftdi_gpio {

static int ftdi_gpio_device_power(struct ftdi_gpio *ftdi_gpio, bool on);
static void ftdi_gpio_device_usb(struct ftdi_gpio *ftdi_gpio, bool on);
static int ftdi_gpio_toggle_io(struct ftdi_gpio *ftdi_gpio, unsigned int gpio, bool on);

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

Expand Down Expand Up @@ -189,6 +193,9 @@ static void *ftdi_gpio_open(struct device *dev)
else
ftdi_gpio_device_usb(ftdi_gpio, 0);

if (ftdi_gpio->gpio_present[GPIO_OUTPUT_ENABLE])
ftdi_gpio_toggle_io(ftdi_gpio, GPIO_OUTPUT_ENABLE, 1);

usleep(500000);

return ftdi_gpio;
Expand Down