819-uart-0011-serial-fsl_lpuart-enable-two-stop-bits.patch 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. From 5f1a35c3f5c17cc6229873248a56784fcd03db1c Mon Sep 17 00:00:00 2001
  2. From: Fugang Duan <[email protected]>
  3. Date: Fri, 27 Sep 2019 15:18:41 +0800
  4. Subject: [PATCH] serial: fsl_lpuart: enable two stop bits
  5. Add two stop bits support.
  6. User can run the command to enable two stop bits
  7. for test: stty cstopb -F /dev/ttyLPx
  8. Signed-off-by: Fugang Duan <[email protected]>
  9. ---
  10. drivers/tty/serial/fsl_lpuart.c | 8 ++++++--
  11. 1 file changed, 6 insertions(+), 2 deletions(-)
  12. --- a/drivers/tty/serial/fsl_lpuart.c
  13. +++ b/drivers/tty/serial/fsl_lpuart.c
  14. @@ -2135,11 +2135,12 @@ lpuart32_set_termios(struct uart_port *p
  15. {
  16. struct lpuart_port *sport = container_of(port, struct lpuart_port, port);
  17. unsigned long flags;
  18. - unsigned long ctrl, old_ctrl, modem;
  19. + unsigned long ctrl, old_ctrl, bd, modem;
  20. unsigned int baud;
  21. unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;
  22. ctrl = old_ctrl = lpuart32_read(&sport->port, UARTCTRL);
  23. + bd = lpuart32_read(&sport->port, UARTBAUD);
  24. modem = lpuart32_read(&sport->port, UARTMODIR);
  25. /*
  26. * only support CS8 and CS7, and for CS7 must enable PE.
  27. @@ -2176,7 +2177,9 @@ lpuart32_set_termios(struct uart_port *p
  28. }
  29. if (termios->c_cflag & CSTOPB)
  30. - termios->c_cflag &= ~CSTOPB;
  31. + bd |= UARTBAUD_SBNS;
  32. + else
  33. + bd &= ~UARTBAUD_SBNS;
  34. /* parity must be enabled when CS7 to match 8-bits format */
  35. if ((termios->c_cflag & CSIZE) == CS7)
  36. @@ -2246,6 +2249,7 @@ lpuart32_set_termios(struct uart_port *p
  37. lpuart32_write(&sport->port, old_ctrl & ~(UARTCTRL_TE | UARTCTRL_RE),
  38. UARTCTRL);
  39. + lpuart32_write(&sport->port, bd, UARTBAUD);
  40. lpuart32_serial_setbrg(sport, baud);
  41. lpuart32_write(&sport->port, modem, UARTMODIR);
  42. lpuart32_write(&sport->port, ctrl, UARTCTRL);