summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Organov <sorganov@gmail.com>2019-07-26 14:52:40 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-09-04 06:43:46 -0400
commit197540dc8301a296e8ae7aa062f9f61f047eea05 (patch)
tree57c0730d640a96aac2e4a66acb7b5208d14fb3f4
parenta25aee902e666e8cc41e33754f13c69a979dd67f (diff)
serial: imx: set_mctrl(): correctly restore autoRTS state
imx_uart_set_mctrl() happened to set UCR2_CTSC bit whenever TIOCM_RTS was set, no matter if RTS/CTS handshake is enabled or not. Now fixed by turning handshake on only when CRTSCTS bit for the port is set. Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de> Tested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Sergey Organov <sorganov@gmail.com> Link: https://lore.kernel.org/r/1564167161-3972-3-git-send-email-sorganov@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/tty/serial/imx.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 32f36d86a960..059ba354d17e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -974,10 +974,22 @@ static void imx_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
974 if (!(port->rs485.flags & SER_RS485_ENABLED)) { 974 if (!(port->rs485.flags & SER_RS485_ENABLED)) {
975 u32 ucr2; 975 u32 ucr2;
976 976
977 /*
978 * Turn off autoRTS if RTS is lowered and restore autoRTS
979 * setting if RTS is raised.
980 */
977 ucr2 = imx_uart_readl(sport, UCR2); 981 ucr2 = imx_uart_readl(sport, UCR2);
978 ucr2 &= ~(UCR2_CTS | UCR2_CTSC); 982 ucr2 &= ~(UCR2_CTS | UCR2_CTSC);
979 if (mctrl & TIOCM_RTS) 983 if (mctrl & TIOCM_RTS) {
980 ucr2 |= UCR2_CTS | UCR2_CTSC; 984 ucr2 |= UCR2_CTS;
985 /*
986 * UCR2_IRTS is unset if and only if the port is
987 * configured for CRTSCTS, so we use inverted UCR2_IRTS
988 * to get the state to restore to.
989 */
990 if (!(ucr2 & UCR2_IRTS))
991 ucr2 |= UCR2_CTSC;
992 }
981 imx_uart_writel(sport, ucr2, UCR2); 993 imx_uart_writel(sport, ucr2, UCR2);
982 } 994 }
983 995