Message ID | 1560514294-29111-6-git-send-email-sorganov@gmail.com (mailing list archive) |
---|---|
State | RFC |
Headers | show |
Series | serial: imx: fix RTS and RTS/CTS handling | expand |
Hi, On Fri, 14 Jun 2019 15:11:32 +0300 Sergey Organov wrote: > imx_set_termios() cleared RTS on every call, now fixed. > > Signed-off-by: Sergey Organov <sorganov@gmail.com> > --- > drivers/tty/serial/imx.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c > index 8ee910f..de23068 100644 > --- a/drivers/tty/serial/imx.c > +++ b/drivers/tty/serial/imx.c > @@ -1564,6 +1564,13 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, > > spin_lock_irqsave(&sport->port.lock, flags); > > + /* > + * Read current UCR2 and save it for future use, then clear all the bits > + * except those we will or may need to preserve. > + */ > + old_ucr2 = imx_uart_readl(sport, UCR2); > + ucr2 = old_ucr2 & (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN | UCR2_CTSC); > + > ucr2 = UCR2_SRST | UCR2_IRTS; s/=/|=/ Lothar Waßmann
Lothar Waßmann <LW@KARO-electronics.de> writes: > Hi, > > On Fri, 14 Jun 2019 15:11:32 +0300 Sergey Organov wrote: >> imx_set_termios() cleared RTS on every call, now fixed. >> >> Signed-off-by: Sergey Organov <sorganov@gmail.com> >> --- >> drivers/tty/serial/imx.c | 12 ++++++++---- >> 1 file changed, 8 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c >> index 8ee910f..de23068 100644 >> --- a/drivers/tty/serial/imx.c >> +++ b/drivers/tty/serial/imx.c >> @@ -1564,6 +1564,13 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, >> >> spin_lock_irqsave(&sport->port.lock, flags); >> >> + /* >> + * Read current UCR2 and save it for future use, then clear all the bits >> + * except those we will or may need to preserve. >> + */ >> + old_ucr2 = imx_uart_readl(sport, UCR2); >> + ucr2 = old_ucr2 & (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN | UCR2_CTSC); >> + >> ucr2 = UCR2_SRST | UCR2_IRTS; > s/=/|=/ Nice catch! Thanks, -- Sergey Organov
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 8ee910f..de23068 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c @@ -1564,6 +1564,13 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, spin_lock_irqsave(&sport->port.lock, flags); + /* + * Read current UCR2 and save it for future use, then clear all the bits + * except those we will or may need to preserve. + */ + old_ucr2 = imx_uart_readl(sport, UCR2); + ucr2 = old_ucr2 & (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN | UCR2_CTSC); + ucr2 = UCR2_SRST | UCR2_IRTS; if ((termios->c_cflag & CSIZE) == CS8) ucr2 |= UCR2_WS; @@ -1633,7 +1640,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, imx_uart_writel(sport, old_ucr1 & ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN), UCR1); - old_ucr2 = imx_uart_readl(sport, UCR2); imx_uart_writel(sport, old_ucr2 & ~UCR2_ATEN, UCR2); while (!(imx_uart_readl(sport, USR2) & USR2_TXDC)) @@ -1641,7 +1647,6 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, /* then, disable everything */ imx_uart_writel(sport, old_ucr2 & ~(UCR2_TXEN | UCR2_RXEN | UCR2_ATEN), UCR2); - old_ucr2 &= (UCR2_TXEN | UCR2_RXEN | UCR2_ATEN); /* custom-baudrate handling */ div = sport->port.uartclk / (baud * 16); @@ -1679,8 +1684,7 @@ imx_uart_set_termios(struct uart_port *port, struct ktermios *termios, imx_uart_writel(sport, old_ucr1, UCR1); - /* set the parity, stop bits and data size */ - imx_uart_writel(sport, ucr2 | old_ucr2, UCR2); + imx_uart_writel(sport, ucr2, UCR2); if (UART_ENABLE_MS(&sport->port, termios->c_cflag)) imx_uart_enable_ms(&sport->port);
imx_set_termios() cleared RTS on every call, now fixed. Signed-off-by: Sergey Organov <sorganov@gmail.com> --- drivers/tty/serial/imx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)