[PATCH 5/7] serial: 8250: handle DTR in rs485 emulation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Heiko Stuebner <heiko.stuebner@xxxxxxxxxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxxxxxxxxx>
---
 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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux