From 2899fbcbb13725067fc4e185186358dd9d4c7706 Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Tue, 4 Jun 2024 17:24:02 -0700 Subject: [PATCH] ftdi_gpio: Turn on OUTPUT_ENABLE first Observed instability in controlling devices when OUTPUT_ENABLE wasn't enabled in the first step. I couldn't find any documented reason why this is, but the documentation does say: "FtdiOutput Pin always kept at 1". Alpaca always keeps OUTUT_ENABLE as 1, and never turns it off. The documentation seems to imply it should always be left on. This change updates the open sequence so that the OUTPUT_ENABLE bit is set first. Signed-off-by: Elliot Berman --- drivers/ftdi-gpio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/ftdi-gpio.c b/drivers/ftdi-gpio.c index 77e5384..95b9cb7 100644 --- a/drivers/ftdi-gpio.c +++ b/drivers/ftdi-gpio.c @@ -311,6 +311,9 @@ static void *ftdi_gpio_open(struct device *dev) if (ftdi_gpio->options->gpios[GPIO_POWER_KEY].present) dev->has_power_key = true; + if (ftdi_gpio->options->gpios[GPIO_OUTPUT_ENABLE].present) + ftdi_gpio_toggle_io(ftdi_gpio, GPIO_OUTPUT_ENABLE, 1); + ftdi_gpio_device_power(ftdi_gpio, 0); if (dev->usb_always_on) @@ -318,9 +321,6 @@ static void *ftdi_gpio_open(struct device *dev) else ftdi_gpio_device_usb(ftdi_gpio, 0); - if (ftdi_gpio->options->gpios[GPIO_OUTPUT_ENABLE].present) - ftdi_gpio_toggle_io(ftdi_gpio, GPIO_OUTPUT_ENABLE, 1); - usleep(500000); return ftdi_gpio;