Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: imx: Fix the CTS_B polarity in RS485 mode

When userspace passes the SER_RS485_RTS_ON_SEND flag it means that the
CTS_B pin should go to logic level high before the transmission begins.

CTS_B goes to logic level high when both CTSC and CTS bits are cleared.

When userspace passes the SER_RS485_RTS_AFTER_SEND flag it means that the
CTS_B pin should go to logic level low after the transmission finishes.

CTS_B goes to logic level low when CTSC bit is cleared and CTS bit is set.

So fix the CTS_B polarity logic.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Fabio Estevam and committed by
Greg Kroah-Hartman
bc2be239 1a613626

+3 -3
+3 -3
drivers/tty/serial/imx.c
··· 336 336 337 337 static void imx_port_rts_active(struct imx_port *sport, unsigned long *ucr2) 338 338 { 339 - *ucr2 &= ~UCR2_CTSC; 340 - *ucr2 |= UCR2_CTS; 339 + *ucr2 &= ~(UCR2_CTSC | UCR2_CTS); 341 340 342 341 mctrl_gpio_set(sport->gpios, sport->port.mctrl | TIOCM_RTS); 343 342 } 344 343 345 344 static void imx_port_rts_inactive(struct imx_port *sport, unsigned long *ucr2) 346 345 { 347 - *ucr2 &= ~(UCR2_CTSC | UCR2_CTS); 346 + *ucr2 &= ~UCR2_CTSC; 347 + *ucr2 |= UCR2_CTS; 348 348 349 349 mctrl_gpio_set(sport->gpios, sport->port.mctrl & ~TIOCM_RTS); 350 350 }