Skip to content

Conversation

@TheMightyMadman
Copy link
Contributor

@TheMightyMadman TheMightyMadman commented Apr 28, 2025

This patch adds RS485 mode support for UART2/3/4/5.
This allows the RTS line to be used to drive the OE pin of an RS485 transceiver (i.e. MAX3078E).
I needed this for a project & it would be useful to have in-tree.

The "ctsrts" override is automatically activated, as this is required to enable the RTS line; there are also overrides to invert the RTS signal, and to set the RTS on and off delays to change the RTS timing around data transmission.

I haven't made changes to uart0-overlay.dts or uart1-overlay.dts as the syntax is quite different, I'm guessing this is legacy.
I also haven't made changes to uartX-pi5-overlay.dts as I'm unable to test these due to them being Pi5-only.

Tested and working OK on a CM4 with a pair of MAX3078E transceivers, overrides in /boot/firmware/config.txt as follows:
dtoverlay=uart3,rs485
dtoverlay=uart4,rs485

Credit to 6by9 for pretty much all of the device tree modifications here.
The associated forum thread is available here:
https://forums.raspberrypi.com/viewtopic.php?p=2311800

Copy link
Contributor

@6by9 6by9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the one minor comment from me.

parameter, as RTS is required (default off).
rs485_invert_rts When RS485 mode is enabled, inverts the RTS
line from active-high (default) to active-low
(default off).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not quite sure what you mean by "default off" here. You've already said the default is active-high. Applies to the other instances too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :) I meant that "rs485_invert_rts" is default off, but I appreciate that could cause confusion - would it be better if I just removed the last line of rs485_invert_rts on each instance?

@TheMightyMadman
Copy link
Contributor Author

Just the one minor comment from me.

Thank you - I've amended the potentially confusing documentation in a new commit.

@pelwell pelwell merged commit 456a1f0 into raspberrypi:rpi-6.12.y Apr 28, 2025
12 of 13 checks passed
popcornmix added a commit to raspberrypi/firmware that referenced this pull request Apr 28, 2025
kernel: Add driver for the Waveshare DSI-TOUCH series panels
See: raspberrypi/linux#6566

kernel: Add support for TI ADS7828/ADS7830 I2C ADCs
See: raspberrypi/linux#6819

kernel: Add RS485 mode support for UART2, UART3, UART4, and UART5
See: raspberrypi/linux#6820
popcornmix added a commit to raspberrypi/rpi-firmware that referenced this pull request Apr 28, 2025
kernel: Add driver for the Waveshare DSI-TOUCH series panels
See: raspberrypi/linux#6566

kernel: Add support for TI ADS7828/ADS7830 I2C ADCs
See: raspberrypi/linux#6819

kernel: Add RS485 mode support for UART2, UART3, UART4, and UART5
See: raspberrypi/linux#6820
@pelwell
Copy link
Contributor

pelwell commented Dec 16, 2025

FYI Several of the parameters are incorrectly declared and have no effect. See #7177 for fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants