Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH] tty: serial: fsl_lpuart: fix the RTSWATER field mask
@ 2026-11-17  8:40 Sherry Sun (OSS)
  2026-11-17  8:43 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Sherry Sun (OSS) @ 2026-11-17  8:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-kernel, linux-serial, imx, sherry.sun

From: Sherry Sun <sherry.sun@nxp.com>

UARTMODIR_RTSWATER is currently defined as GENMASK(10, 8), which
matches older i.MX implementations where the RTSWATER field occupies
MODIR[10:8].

However, newer i.MX SoCs extend the RTSWATER field width, for example:
  i.MX8ULP       MODIR[10:8]
  i.MX93/95      MODIR[11:8]
  i.MX8QM/8DXL   MODIR[12:8]
  i.MX8QXP       MODIR[13:8]

The driver programs the RTS watermark using:
  FIELD_PREP(UARTMODIR_RTSWATER, sport->rxfifo_size >> 1)

When half the rxfifo_size exceeds the 3-bit range allowed by
GENMASK(10, 8), FIELD_PREP() truncates the value before it is written
to the register.

For example, on i.MX93/i.MX95 with a 16-byte RX FIFO, the driver
attempts to program RTSWATER to half of the FIFO depth (8). With
GENMASK(10, 8), FIELD_PREP() produces 0 instead of the expected
encoding for 8, resulting in an RTS watermark value of 0 being
programmed.

All currently supported LPUART implementations define MODIR[13:8] as
either RTSWATER bits or reserved bits. No other functionality is
assigned to these bits, and writes to unimplemented bits are ignored
by hardware. So define UARTMODIR_RTSWATER as GENMASK(13, 8), which covers
the superset of all currently supported i.MX implementations. This
restores the correct RTS watermark on SoCs with extended RTSWATER field
widths while remaining compatible with older devices.
Also clear the existing watermark field before inserting the intended
value.

Fixes: ecba98f9ddf4 ("tty: serial: fsl_lpuart: set RTS watermark for lpuart")
Signed-off-by: Sherry Sun <sherry.sun@nxp.com>
---
 drivers/tty/serial/fsl_lpuart.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c
index cd2575a3aef7..97201414ced6 100644
--- a/drivers/tty/serial/fsl_lpuart.c
+++ b/drivers/tty/serial/fsl_lpuart.c
@@ -203,7 +203,7 @@
 #define UARTDATA_MASK		0x3ff
 
 #define UARTMODIR_IREN		0x00020000
-#define UARTMODIR_RTSWATER	GENMASK(10, 8)
+#define UARTMODIR_RTSWATER	GENMASK(13, 8)
 #define UARTMODIR_TXCTSSRC	0x00000020
 #define UARTMODIR_TXCTSC	0x00000010
 #define UARTMODIR_RXRTSE	0x00000008
@@ -1695,6 +1695,7 @@ static void lpuart32_setup_watermark(struct lpuart_port *sport)
 	/* set RTS watermark */
 	if (!uart_console(&sport->port)) {
 		val = lpuart32_read(&sport->port, UARTMODIR);
+		val &= ~UARTMODIR_RTSWATER;
 		val |= FIELD_PREP(UARTMODIR_RTSWATER, sport->rxfifo_size >> 1);
 		lpuart32_write(&sport->port, val, UARTMODIR);
 	}

---
base-commit: 749a4de370409464cf8501ec5b2451df45c84eb4
change-id: 20261117-lpuart_rtswater-eacee387bb89

Best regards,
-- 
Sherry Sun <sherry.sun@nxp.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-17  8:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17  8:40 [PATCH] tty: serial: fsl_lpuart: fix the RTSWATER field mask Sherry Sun (OSS)
2026-11-17  8:43 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox