[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180601124021.102970-9-giulio.benetti@micronovasrl.com>
Date: Fri, 1 Jun 2018 14:40:21 +0200
From: Giulio Benetti <giulio.benetti@...ronovasrl.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Jiri Slaby <jslaby@...e.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Kees Cook <keescook@...omium.org>,
Matthias Brugger <mbrugger@...e.com>,
Allen Pais <allen.lkml@...il.com>, Sean Young <sean@...s.org>,
Ed Blake <ed.blake@...drel.com>,
Stefan Potyra <Stefan.Potyra@...ktrobit.com>,
Philipp Zabel <p.zabel@...gutronix.de>,
Joshua Scott <joshua.scott@...iedtelesis.co.nz>,
Vignesh R <vigneshr@...com>,
Rolf Evers-Fischer <rolf.evers.fischer@...iv.com>,
Aaron Sierra <asierra@...-inc.com>,
Rafael Gago <rafael.gago@...il.com>,
Joel Stanley <joel@....id.au>,
Sean Wang <sean.wang@...iatek.com>,
linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
Giulio Benetti <giulio.benetti@...ronovasrl.com>
Subject: [PATCH 8/8] serial: core: Mask mctrl with TIOCM_RTS too if rs485 on and RTS_AFTER_SEND set.
If rs485 is enabled and RTS_AFTER_SEND is set on startup need to keep
TIOCM_RTS asserted to keep rs485 transceiver in RX when idle.
Check if rs485 is on and RTS_AFTER_SEND is set and mask port->mctrl with
TIOCM_RTS too and not only TIOCM_DTR.
Signed-off-by: Giulio Benetti <giulio.benetti@...ronovasrl.com>
---
drivers/tty/serial/serial_core.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 0466f9f08a91..06d9441f6d20 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2288,6 +2288,16 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
if (port->type != PORT_UNKNOWN) {
unsigned long flags;
+ int rs485_on = port->rs485_config &&
+ (port->rs485.flags & SER_RS485_ENABLED);
+ int RTS_after_send = !!(port->rs485.flags &
+ SER_RS485_RTS_AFTER_SEND);
+ int mctrl;
+
+ if (rs485_on && RTS_after_send)
+ mctrl = port->mctrl & (TIOCM_DTR | TIOCM_RTS);
+ else
+ mctrl = port->mctrl & TIOCM_DTR;
uart_report_port(drv, port);
@@ -2300,7 +2310,7 @@ uart_configure_port(struct uart_driver *drv, struct uart_state *state,
* We probably don't need a spinlock around this, but
*/
spin_lock_irqsave(&port->lock, flags);
- port->ops->set_mctrl(port, port->mctrl & TIOCM_DTR);
+ port->ops->set_mctrl(port, mctrl);
spin_unlock_irqrestore(&port->lock, flags);
/*
--
2.17.0
Powered by blists - more mailing lists