* [PATCH v2] serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios
@ 2026-12-02 11:10 Nicolas Thibert
0 siblings, 0 replies; only message in thread
From: Nicolas Thibert @ 2026-12-02 11:10 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, Heiko Schocher, stable
Since commit 0c11b88883db ("tty: 8250_of: Use software emulated RS485
direction control"), 8250_of uses the software RS485 emulation (em485).
At the end of a transmission, em485 releases the direction line only
once the transmitter is empty (TEMT). A 16550 has no interrupt on TEMT,
so when the last THRE interrupt comes before the shift register is
empty, __stop_tx() returns and nothing releases the direction line
later: it stays asserted and the board cannot receive the answer from
the other RS485 node.
8250_dw solves the same problem by setting UART_CAP_NOTEMT, which makes
__stop_tx() release the line one frame time later instead. Do the same
in 8250_of for ports whose direction line is a GPIO (rts-gpios).
UART_CAP_NOTEMT is only used by the em485 stop path, so ports without
RS485 are not affected.
Tested on a QCA9531 board (ns16550a UART) with a CA-IS2092A RS485
transceiver whose DE/RE pins are driven by a GPIO (rts-gpios,
linux,rs485-enabled-at-boot-time). Without this patch the GPIO stays
high after the first transmission and no answer is received. With it,
the GPIO goes low after each transmission and the answers are
received.
The problem was analysed and this patch written with the help of an AI
coding assistant (Claude, Anthropic); the tests were run on hardware.
Fixes: 0c11b88883db ("tty: 8250_of: Use software emulated RS485 direction control")
Cc: stable@vger.kernel.org
Signed-off-by: Nicolas Thibert <nithibert@gmail.com>
---
v2:
- Rewrite the commit message.
- Drop the code comment.
- Put Signed-off-by last.
Answers to the review of v1:
- What changes on existing systems: UART_CAP_NOTEMT is only checked in
the em485 stop path, so only RS485 ports whose direction line is a
GPIO are affected. If the transmitter is already empty at the last
THRE interrupt, nothing changes. Otherwise the direction line is now
released one frame time later, instead of staying asserted.
- How it was tested: see the last paragraph of the commit message.
- v1 was sent twice by mistake, first with a mail client, then with
git send-email.
drivers/tty/serial/8250/8250_of.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index b41ca604083f..b58535f73cb8 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -292,6 +292,9 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
&port8250.overrun_backoff_time_ms) != 0)
port8250.overrun_backoff_time_ms = 0;
+ if (of_property_present(ofdev->dev.of_node, "rts-gpios"))
+ port8250.capabilities |= UART_CAP_NOTEMT;
+
info->uport = serial8250_register_8250_port(&port8250);
if (IS_ERR(info->uport)) {
ret = PTR_ERR(info->uport);
--
2.34.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-02 11:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 11:10 [PATCH v2] serial: 8250_of: set UART_CAP_NOTEMT for ports with rts-gpios Nicolas Thibert
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.