The Synopsys DesignWare UART has a build-in support for the
RS485 protocol from IP version 4.0 onward. This patch enables
the support of HW Full Duplex mode support for it.
To ask for full duplex mode, userspace sets SER_RS485_RX_DURING_TX
flag and HW will take care of the rest.
Co-developed-by: Raymond Tan <[email protected]>
Signed-off-by: Raymond Tan <[email protected]>
Signed-off-by: Ilpo Järvinen <[email protected]>
---
drivers/tty/serial/8250/8250_dwlib.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index a4f09a95049b..d26792999984 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -110,9 +110,14 @@ static int dw8250_rs485_config(struct uart_port *p, struct serial_rs485 *rs485)
if (rs485->flags & SER_RS485_ENABLED) {
/* Clearing unsupported flags. */
- rs485->flags &= SER_RS485_ENABLED;
-
- tcr |= DW_UART_TCR_RS485_EN | DW_UART_TCR_XFER_MODE_DE_OR_RE;
+ rs485->flags &= SER_RS485_ENABLED | SER_RS485_RX_DURING_TX;
+ tcr |= DW_UART_TCR_RS485_EN;
+
+ if (rs485->flags & SER_RS485_RX_DURING_TX) {
+ tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE;
+ } else {
+ tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE;
+ }
dw8250_writel_ext(p, DW_UART_DE_EN, 1);
dw8250_writel_ext(p, DW_UART_RE_EN, 1);
} else {
--
2.30.2
On Wed, Mar 02, 2022 at 11:56:01AM +0200, Ilpo J?rvinen wrote:
> @@ -110,9 +110,14 @@ static int dw8250_rs485_config(struct uart_port *p, struct serial_rs485 *rs485)
>
> if (rs485->flags & SER_RS485_ENABLED) {
> /* Clearing unsupported flags. */
> - rs485->flags &= SER_RS485_ENABLED;
> -
> - tcr |= DW_UART_TCR_RS485_EN | DW_UART_TCR_XFER_MODE_DE_OR_RE;
> + rs485->flags &= SER_RS485_ENABLED | SER_RS485_RX_DURING_TX;
> + tcr |= DW_UART_TCR_RS485_EN;
> +
> + if (rs485->flags & SER_RS485_RX_DURING_TX) {
> + tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE;
> + } else {
> + tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE;
> + }
This patch deletes lines introduced by the preceding patch.
I'd just squash the two together, I don't see much value in
introducing full duplex support in a separate patch.
Thanks,
Lukas
On Sun, 6 Mar 2022, Lukas Wunner wrote:
> On Wed, Mar 02, 2022 at 11:56:01AM +0200, Ilpo J?rvinen wrote:
> > @@ -110,9 +110,14 @@ static int dw8250_rs485_config(struct uart_port *p, struct serial_rs485 *rs485)
> >
> > if (rs485->flags & SER_RS485_ENABLED) {
> > /* Clearing unsupported flags. */
> > - rs485->flags &= SER_RS485_ENABLED;
> > -
> > - tcr |= DW_UART_TCR_RS485_EN | DW_UART_TCR_XFER_MODE_DE_OR_RE;
> > + rs485->flags &= SER_RS485_ENABLED | SER_RS485_RX_DURING_TX;
> > + tcr |= DW_UART_TCR_RS485_EN;
> > +
> > + if (rs485->flags & SER_RS485_RX_DURING_TX) {
> > + tcr |= DW_UART_TCR_XFER_MODE_DE_DURING_RE;
> > + } else {
> > + tcr |= DW_UART_TCR_XFER_MODE_DE_OR_RE;
> > + }
>
> This patch deletes lines introduced by the preceding patch.
> I'd just squash the two together, I don't see much value in
> introducing full duplex support in a separate patch.
Sure, I can merge them.
--
i.