2023-03-15 20:42:17

by Francesco Dolcini

[permalink] [raw]
Subject: Wrong RS485 RTS polarity in 8250 OMAP UART Driver vs DT binding?

Hello all,
I have been recently working on RS485 on a TI K3 AM62 (using 8250_omap.c
driver) and there is something that I do not really understand about
the RTS polarity.

According to the DT binding (Documentation/devicetree/bindings/serial/rs485.yaml)
when `rs485-rts-active-low` is present the behavior should be "drive RTS
low when sending", however in the code it seems that this is handled the
opposite way (drivers/tty/serial/8250/8250_omap.c:861).

/*
* Retain same polarity semantics as RS485 software emulation,
* i.e. SER_RS485_RTS_ON_SEND means driving RTS low on send.
*/

We have working hardware, using another UART that expect
rs485-rts-active-low, and the exact same HW, when using OMAP uart,
requires rs485-rts-active-high (the HW is modular, so we are really just
changing the uart, keeping the same RS485 transceiver / connections).

What's going on there? Is the semantic of the 8250_omap driver just the
opposite as it should be? Am I doing something wrong in the device tree?

This is the relevant DTS part.

&main_uart1 {
linux,rs485-enabled-at-boot-time;
rs485-rts-active-high;
rs485-rx-during-tx;
status = "okay";
};

Francesco



2023-03-16 10:11:01

by Lukas Wunner

[permalink] [raw]
Subject: Re: Wrong RS485 RTS polarity in 8250 OMAP UART Driver vs DT binding?

On Wed, Mar 15, 2023 at 09:41:56PM +0100, Francesco Dolcini wrote:
> We have working hardware, using another UART that expect
> rs485-rts-active-low, and the exact same HW, when using OMAP uart,
> requires rs485-rts-active-high (the HW is modular, so we are really just
> changing the uart, keeping the same RS485 transceiver / connections).
>
> What's going on there? Is the semantic of the 8250_omap driver just the
> opposite as it should be?

Yes, sadly, for historic reasons.

See these threads:

https://lore.kernel.org/linux-serial/[email protected]/

https://lore.kernel.org/linux-serial/2de36eba3fbe11278d5002e4e501afe0ceaca039.1663863805.git.lukas@wunner.de/


> Am I doing something wrong in the device tree?

No, but regrettably you need a separate device tree depending on which SoC
you're using.

Thanks,

Lukas