Skip to content

Commit fd29e1e

Browse files
Luke Wanggregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 068d35a commit fd29e1e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

drivers/tty/serial/fsl_lpuart.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
#define UARTCTRL_SBK 0x00010000
185185
#define UARTCTRL_MA1IE 0x00008000
186186
#define UARTCTRL_MA2IE 0x00004000
187+
#define UARTCTRL_M7 0x00000800
187188
#define UARTCTRL_IDLECFG GENMASK(10, 8)
188189
#define UARTCTRL_LOOPS 0x00000080
189190
#define UARTCTRL_DOZEEN 0x00000040
@@ -2222,8 +2223,9 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
22222223
modem = lpuart32_read(&sport->port, UARTMODIR);
22232224
sport->is_cs7 = false;
22242225
/*
2225-
* only support CS8 and CS7, and for CS7 must enable PE.
2226+
* only support CS8 and CS7
22262227
* supported mode:
2228+
* - (7,n,1) (imx only)
22272229
* - (7,e/o,1)
22282230
* - (8,n,1)
22292231
* - (8,m/s,1)
@@ -2238,7 +2240,7 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
22382240

22392241
if ((termios->c_cflag & CSIZE) == CS8 ||
22402242
(termios->c_cflag & CSIZE) == CS7)
2241-
ctrl = old_ctrl & ~UARTCTRL_M;
2243+
ctrl = old_ctrl & ~(UARTCTRL_M | UARTCTRL_M7);
22422244

22432245
if (termios->c_cflag & CMSPAR) {
22442246
if ((termios->c_cflag & CSIZE) != CS8) {
@@ -2265,9 +2267,18 @@ lpuart32_set_termios(struct uart_port *port, struct ktermios *termios,
22652267
else
22662268
bd &= ~UARTBAUD_SBNS;
22672269

2268-
/* parity must be enabled when CS7 to match 8-bits format */
2269-
if ((termios->c_cflag & CSIZE) == CS7)
2270-
termios->c_cflag |= PARENB;
2270+
/*
2271+
* imx support 7-bits format, no limitation on parity when CS7
2272+
* for layerscape, parity must be enabled when CS7 to match 8-bits format
2273+
*/
2274+
if ((termios->c_cflag & CSIZE) == CS7 && !(termios->c_cflag & PARENB)) {
2275+
if (is_imx7ulp_lpuart(sport) ||
2276+
is_imx8ulp_lpuart(sport) ||
2277+
is_imx8qxp_lpuart(sport))
2278+
ctrl |= UARTCTRL_M7;
2279+
else
2280+
termios->c_cflag |= PARENB;
2281+
}
22712282

22722283
if ((termios->c_cflag & PARENB)) {
22732284
if (termios->c_cflag & CMSPAR) {

0 commit comments

Comments
 (0)