[PATCH v2 0/3] serial: core: add transceiver interface select GPIO
From: Tapio Reijonen
Date: Thu Nov 05 2026 - 02:13:58 EST
Multiprotocol transceivers such as the LTC2873 provide an RS485
interface and an alternative interface, typically RS232, on the same
bus pins and choose between them with an interface select input. Add
an optional rs485-select-gpios property next to the existing
rs485-term-gpios and rs485-rx-during-tx-gpios, and let the serial core
drive it from the RS485 configuration state, so that every UART driver
using uart_get_rs485_mode() supports such transceivers without driver
changes.
Patch 1 is new in v2 and fixes a pre-existing problem the review
found: the RS485 GPIO descriptors stored in struct uart_port were
never cleared, so a port that outlives its device, as the 8250 ports
do, kept descriptors of lines devres had already released. The select
GPIO would have made that worse, since it is driven whenever RS485 is
reconfigured, not only while RS485 is enabled.
Tested on an i.MX6SX UART and on a MAX14830 channel, each wired to an
LTC2873, by observing the bus line while switching RS485 on and off
with TIOCSRS485, across probe, unbind and rebind of both drivers.
Tool use: Claude Code (Anthropic) was used throughout. It drafted the
code and the commit messages, reviewed the series against the serial
core and the 8250 port lifetime, and prepared the v2 changes from the
review findings. I decided the design, in particular that the select
line keeps its strapped level until the port is configured, reviewed
every change against the code, and ran the hardware tests. The code
and the messages are mine to defend.
Signed-off-by: Tapio Reijonen <tapio.reijonen@xxxxxxxxxxx>
---
Changes in v2:
- New patch 1: forget the RS485 GPIO descriptors when a port is
removed, on entry to uart_get_rs485_mode() and on its error paths,
so a port never carries descriptors of a device it no longer belongs
to.
- Request the select GPIO without changing its state and make it an
output at the level it already has, or inactive when that level
cannot be read back, as on output-only GPIO controllers, so the
transceiver keeps the interface it was strapped for until
uart_rs485_config() has placed RTS at its RS485 idle level; forget
the descriptor if the request fails.
- Commit message of the select patch explains the ordering of the GPIO
against the driver callback and why the select line, unlike the
termination and RX-during-TX lines, must not be driven at request
time.
- Rebased onto v7.4-rc1; Rob's Reviewed-by added to the binding, which
is unchanged.
- Link to v1: https://lore.kernel.org/r/20261021-serial-rs485-mode-gpio-v1-0-80d7b0903d93@xxxxxxxxxxx
---
Tapio Reijonen (3):
serial: core: Forget the RS485 GPIO descriptors when a port is removed
dt-bindings: serial: rs485: Add transceiver interface select GPIO
serial: core: Drive the transceiver interface select GPIO
.../devicetree/bindings/serial/rs485.yaml | 8 +++
drivers/tty/serial/serial_core.c | 73 ++++++++++++++++++++--
include/linux/serial_core.h | 1 +
3 files changed, 77 insertions(+), 5 deletions(-)
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261019-serial-rs485-mode-gpio-e76bb72b6f21
Best regards,
--
Tapio Reijonen <tapio.reijonen@xxxxxxxxxxx>