[PATCH 1/2] serial: fsl_lpuart: Enable break detection in 8-bit driver

From: Jonas Juffinger via B4 Relay

Date: Sun Nov 15 2026 - 13:03:05 EST


From: Jonas Juffinger <jonas.juffinger@xxxxxxxxxxxx>

Add break detection in the code for the 8-bit LPUART.

The driver contains the code for the 8-bit and 32-bit LPUART device
but only the 32-bit part has working break detection. Add break
detection to the 8-bit LPUART driver.

Break detection in the 32-bit part was added with commit 5541a9bacfe5
("serial: fsl_lpuart: handle break and make sysrq work") and later fixed
with commit 707f816f2559 ("tty: serial: fsl_lpuart: correct the count of
break characters"). This patch is practically identical.

Signed-off-by: Jonas Juffinger <jonas.juffinger@xxxxxxxxxxxx>
---
drivers/tty/serial/fsl_lpuart.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index c8575c965203..5817c47e4db3 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -885,6 +885,7 @@ static void lpuart_rxint(struct lpuart_port *sport)
unsigned int flg, ignored = 0, overrun = 0;
struct tty_port *port = &sport->port.state->port;
u8 rx, sr;
+ bool is_break;

uart_port_lock(&sport->port);

@@ -898,14 +899,27 @@ static void lpuart_rxint(struct lpuart_port *sport)
sr = readb(sport->port.membase + UARTSR1);
rx = readb(sport->port.membase + UARTDR);

+ /*
+ * The LPUART can't distinguish between a break and a framing error,
+ * thus we assume it is a break if the received data is zero.
+ */
+ is_break = (sr & UARTSR1_FE) && !rx;
+
+ if (is_break && uart_handle_break(&sport->port))
+ continue;
+
if (uart_prepare_sysrq_char(&sport->port, rx))
continue;

if (sr & (UARTSR1_PE | UARTSR1_OR | UARTSR1_FE)) {
- if (sr & UARTSR1_PE)
+ if (sr & UARTSR1_PE) {
sport->port.icount.parity++;
- else if (sr & UARTSR1_FE)
- sport->port.icount.frame++;
+ } else if (sr & UARTSR1_FE) {
+ if (is_break)
+ sport->port.icount.brk++;
+ else
+ sport->port.icount.frame++;
+ }

if (sr & UARTSR1_OR)
overrun++;
@@ -918,15 +932,17 @@ static void lpuart_rxint(struct lpuart_port *sport)

sr &= sport->port.read_status_mask;

- if (sr & UARTSR1_PE)
+ if (sr & UARTSR1_PE) {
flg = TTY_PARITY;
- else if (sr & UARTSR1_FE)
- flg = TTY_FRAME;
+ } else if (sr & UARTSR1_FE) {
+ if (is_break)
+ flg = TTY_BREAK;
+ else
+ flg = TTY_FRAME;
+ }

if (sr & UARTSR1_OR)
flg = TTY_OVERRUN;
-
- sport->port.sysrq = 0;
}

if (tty_insert_flip_char(port, rx, flg) == 0)

--
2.43.0