linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfram Sang <w.sang@pengutronix.de>
To: linux-serial@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Greg KH <gregkh@suse.de>,
	Alan Cox <alan@linux.intel.com>,
	Claudio Scordino <claudio@evidence.eu.com>,
	Wolfram Sang <w.sang@pengutronix.de>,
	Juergen Beisert <jbe@pengutronix.de>
Subject: [PATCH RESEND 4/8] serial: 8250: add RX_DURING_TX capability to RS485 mode
Date: Fri,  9 Dec 2011 18:07:16 +0100	[thread overview]
Message-ID: <1323450440-414-5-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1323450440-414-1-git-send-email-w.sang@pengutronix.de>

To prevent echo in some configurations, make sure we do not read back
when we are sending if RS485 is configured this way. We need to shuffle
stop_rx() around, implement start_rx() and call it in apropriate places.

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
 drivers/tty/serial/8250.c |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index b5d3248..6a2f47f 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -1304,6 +1304,26 @@ static void autoconfig_irq(struct uart_8250_port *up)
 	up->port.irq = (irq > 0) ? irq : 0;
 }
 
+static void serial8250_stop_rx(struct uart_port *port)
+{
+	struct uart_8250_port *up =
+		container_of(port, struct uart_8250_port, port);
+
+	up->ier &= ~UART_IER_RLSI;
+	up->port.read_status_mask &= ~UART_LSR_DR;
+	serial_out(up, UART_IER, up->ier);
+}
+
+static void serial8250_start_rx(struct uart_port *port)
+{
+	struct uart_8250_port *up =
+		container_of(port, struct uart_8250_port, port);
+
+	up->ier |= UART_IER_RLSI;
+	up->port.read_status_mask |= UART_LSR_DR;
+	serial_out(up, UART_IER, up->ier);
+}
+
 static inline void __stop_tx(struct uart_8250_port *p)
 {
 	if (p->ier & UART_IER_THRI) {
@@ -1326,6 +1346,9 @@ static void serial8250_stop_tx(struct uart_port *port)
 		up->acr |= UART_ACR_TXDIS;
 		serial_icr_write(up, UART_ACR, up->acr);
 	}
+
+	if (!(up->rs485_flags & SER_RS485_RX_DURING_TX))
+		serial8250_start_rx(port);
 }
 
 static void transmit_chars(struct uart_8250_port *up);
@@ -1357,16 +1380,9 @@ static void serial8250_start_tx(struct uart_port *port)
 		up->acr &= ~UART_ACR_TXDIS;
 		serial_icr_write(up, UART_ACR, up->acr);
 	}
-}
 
-static void serial8250_stop_rx(struct uart_port *port)
-{
-	struct uart_8250_port *up =
-		container_of(port, struct uart_8250_port, port);
-
-	up->ier &= ~UART_IER_RLSI;
-	up->port.read_status_mask &= ~UART_LSR_DR;
-	serial_out(up, UART_IER, up->ier);
+	if (!(up->rs485_flags & SER_RS485_RX_DURING_TX))
+		serial8250_stop_rx(port);
 }
 
 static void serial8250_enable_ms(struct uart_port *port)
-- 
1.7.7.3


  parent reply	other threads:[~2011-12-09 17:07 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-09 17:07 [PATCH RESEND 0/8] serial: 8250: support hw-based RS485 direction control Wolfram Sang
2011-12-09 17:07 ` [PATCH RESEND 1/8] serial: 8250: replace hardcoded 0xbf with #define Wolfram Sang
2011-12-09 18:58   ` Alan Cox
2011-12-09 17:07 ` [PATCH RESEND 2/8] serial: 8250: Add ioctl to enable auto rs485 mode with some Exar UARTs Wolfram Sang
2011-12-09 19:00   ` Alan Cox
2011-12-09 17:07 ` [PATCH RESEND 3/8] serial: 8250: save rs485_flags per instance Wolfram Sang
2011-12-09 19:10   ` Alan Cox
2011-12-09 17:07 ` Wolfram Sang [this message]
2011-12-09 17:07 ` [PATCH RESEND 5/8] serial: 8250: reject delaying RTS with RS485 Wolfram Sang
2011-12-09 17:07 ` [PATCH RESEND 6/8] serial: 8250: update rs485 flags with polarity settings Wolfram Sang
2011-12-09 19:13   ` Alan Cox
2011-12-09 17:07 ` [PATCH RESEND 7/8] serial: 8250: add Exar 16V2750 support Wolfram Sang
2011-12-09 17:07 ` [PATCH RESEND 8/8] serial: 8250: fix comment about accessing EMSR Wolfram Sang
2011-12-12 14:42 ` [PATCH RESEND 0/8] serial: 8250: support hw-based RS485 direction control Claudio Scordino

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1323450440-414-5-git-send-email-w.sang@pengutronix.de \
    --to=w.sang@pengutronix.de \
    --cc=alan@linux.intel.com \
    --cc=claudio@evidence.eu.com \
    --cc=gregkh@suse.de \
    --cc=jbe@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).