lkml.org 
[lkml]   [2020]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 5/7] serial: 8250: handle DTR in rs485 emulation
Date
From: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>

While in a lot of cases only RTS is needed as DE signal, sometimes the
RE signals is to be controlled separately, as DTR pin.

So add necessary control functions for it.

Signed-off-by: Heiko Stuebner <heiko.stuebner@theobroma-systems.com>
---
drivers/tty/serial/8250/8250_port.c | 13 +++++++++++++
1 file changed, 13 insertions(+)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3d1d8490bc42..f8e5c096ed51 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -572,6 +572,10 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p)
mcr &= ~UART_MCR_RTS;
p->port.mctrl &= ~TIOCM_RTS;
}
+
+ mcr |= UART_MCR_DTR;
+ p->port.mctrl |= TIOCM_DTR;
+
serial8250_out_MCR(p, mcr);
}

@@ -1558,6 +1562,13 @@ static inline void start_tx_rs485(struct uart_port *port)
em485->active_timer = NULL;

mcr = serial8250_in_MCR(up);
+
+ /* in rx_during_tx mode keep DTR active, to receive data */
+ if (up->port.rs485.flags & SER_RS485_RX_DURING_TX)
+ mcr |= UART_MCR_DTR;
+ else
+ mcr &= ~UART_MCR_DTR;
+
if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) !=
!!(mcr & UART_MCR_RTS)) {
if (up->port.rs485.flags & SER_RS485_RTS_ON_SEND)
@@ -1572,6 +1583,8 @@ static inline void start_tx_rs485(struct uart_port *port)
up->port.rs485.delay_rts_before_send);
return;
}
+ } else {
+ serial8250_out_MCR(up, mcr);
}

__start_tx(port);
--
2.24.1
\
 
 \ /
  Last update: 2020-03-18 15:28    [W:0.059 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site