tty: serial: fsl_lpuart: add 7-bits format support on imx7ulp/imx8ulp/imx8qxp

imx7ulp/imx8ulp/imx8qxp lpuart IP support 7-bits format and have no
limitation on parity when CS7. Remove this limitation and add 7-bits
format support on imx7ulp/imx8ulp/imx8qxp.

Signed-off-by: Luke Wang <ziniu.wang_1@nxp.com>
Link: https://lore.kernel.org/r/20241008094418.439706-1-ziniu.wang_1@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Luke Wang 2024-10-08 17:44:18 +08:00 committed by Greg Kroah-Hartman
parent 068d35a7be
commit fd29e1e4e6

View File

@ -184,6 +184,7 @@
#define UARTCTRL_SBK 0x00010000
#define UARTCTRL_MA1IE 0x00008000
#define UARTCTRL_MA2IE 0x00004000
#define UARTCTRL_M7 0x00000800
#define UARTCTRL_IDLECFG GENMASK(10, 8)
#define UARTCTRL_LOOPS 0x00000080
#define UARTCTRL_DOZEEN 0x00000040
@ -2222,8 +2223,9 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
modem = lpuart32_read(&sport->port, UARTMODIR);
sport->is_cs7 = false;
/*
* only support CS8 and CS7, and for CS7 must enable PE.
* only support CS8 and CS7
* supported mode:
* - (7,n,1) (imx only)
* - (7,e/o,1)
* - (8,n,1)
* - (8,m/s,1)
@ -2238,7 +2240,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
if ((termios->c_cflag & CSIZE) == CS8 ||
(termios->c_cflag & CSIZE) == CS7)
ctrl = old_ctrl & ~UARTCTRL_M;
ctrl = old_ctrl & ~(UARTCTRL_M | UARTCTRL_M7);
if (termios->c_cflag & CMSPAR) {
if ((termios->c_cflag & CSIZE) != CS8) {
@ -2265,9 +2267,18 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
else
bd &= ~UARTBAUD_SBNS;
/* parity must be enabled when CS7 to match 8-bits format */
if ((termios->c_cflag & CSIZE) == CS7)
termios->c_cflag |= PARENB;
/*
* imx support 7-bits format, no limitation on parity when CS7
* for layerscape, parity must be enabled when CS7 to match 8-bits format
*/
if ((termios->c_cflag & CSIZE) == CS7 && !(termios->c_cflag & PARENB)) {
if (is_imx7ulp_lpuart(sport) ||
is_imx8ulp_lpuart(sport) ||
is_imx8qxp_lpuart(sport))
ctrl |= UARTCTRL_M7;
else
termios->c_cflag |= PARENB;
}
if ((termios->c_cflag & PARENB)) {
if (termios->c_cflag & CMSPAR) {