[PATCH 10/13] HID: ft260: uart: fix active-low RTS/CTS/DTR/DSR polarity
Michael Zaidman <[email protected]>
| Newsgroups | org.kernel.vger.linux-input,org.kernel.vger.linux-gpio,org.kernel.vger.linux-i2c,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Rio Liu <[email protected]> The FT260 modem control GPIOs for RTS, CTS, DTR, and DSR are active-low. Invert the TIOCMGET sense and the TIOCMSET drive levels for those pins so userspace ioctl state matches the electrical lines. Leave DCD and RI unchanged. Signed-off-by: Rio Liu <[email protected]> Signed-off-by: Michael Zaidman <[email protected]> --- drivers/hid/hid-ft260.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/hid/hid-ft260.c b/drivers/hid/hid-ft260.c index 0a1875a1a7ec..a2f4b6e5a16b 100644 --- a/drivers/hid/hid-ft260.c +++ b/drivers/hid/hid-ft260.c @@ -1985,10 +1985,10 @@ static int ft260_uart_tiocmget(struct tty_struct *tty) gpios = ft260_gpio_get_all(port->gc, FT260_GPIO_VALUE); - return (((gpios & FT260_GPIO_B) ? TIOCM_RTS : 0) | - ((gpios & FT260_GPIO_E) ? TIOCM_CTS : 0) | - ((gpios & FT260_GPIO_F) ? TIOCM_DTR : 0) | - ((gpios & FT260_GPIO_H) ? TIOCM_DSR : 0) | + return ((!(gpios & FT260_GPIO_B) ? TIOCM_RTS : 0) | + (!(gpios & FT260_GPIO_E) ? TIOCM_CTS : 0) | + (!(gpios & FT260_GPIO_F) ? TIOCM_DTR : 0) | + (!(gpios & FT260_GPIO_H) ? TIOCM_DSR : 0) | ((gpios & FT260_GPIO_4) ? TIOCM_CAR : 0) | ((gpios & FT260_GPIO_5) ? TIOCM_RNG : 0)); } @@ -2013,13 +2013,13 @@ static int ft260_uart_tiocmset(struct tty_struct *tty, mutex_lock(&port->lock); if (set & TIOCM_RTS) - ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_RTS, 1); + ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_RTS, 0); if (set & TIOCM_DTR) - ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_DTR, 1); + ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_DTR, 0); if (clear & TIOCM_RTS) - ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_RTS, 0); + ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_RTS, 1); if (clear & TIOCM_DTR) - ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_DTR, 0); + ft260_gpio_output_cfg(&rep.gpio, FT260_GPIO_UART_DTR, 1); ft260_dbg("dirs %#02x vals %#02x ex_dirs %#02x ex_vals %#02x\n", rep.gpio.dirs, rep.gpio.vals, -- 2.43.0