All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tty/serial: omap: remove unwanted local echo during half-duplex TX
@ 2014-03-13 13:11 Dimitris Lampridis
  2014-03-13 13:11 ` [PATCH 1/2] tty/serial: omap: fix RX interrupt enable/disable in " Dimitris Lampridis
  2014-03-13 13:11 ` [PATCH 2/2] tty/serial: omap: empty the RX FIFO at the end of " Dimitris Lampridis
  0 siblings, 2 replies; 3+ messages in thread
From: Dimitris Lampridis @ 2014-03-13 13:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, Dimitris Lampridis

This patchset addresses the issue of unwanted local echo during half-duplex RS485 
transmissions within the OMAP serial driver.

The first patch disables all RX-related interrupts in the serial_omap_stop_rx(), 
which is called from serial_omap_start_tx() before the start of a half-duplex
transmission. It also makes sure that whatever is disabled by serial_omap_stop_rx(), 
is subsequently re-enabled in serial_omap_stop_tx() when the half-duplex transmission 
is complete.

The second patch empties the RX FIFO of the OMAP UART at the end of a half-duplex TX.
This is required when using a transceiver such as the Intersil ISL3332, which does
not provide a way to disable the receiver during a half-duplex transmission.

Both patches have been successfully tested on a Beaglebone Black with ttyO2 and ttyO4
wired to an Intersil ISL3332 dual port transceiver, while communicating with 3-wire
RS485 half-duplex (MODBUS) devices.

Dimitris Lampridis (2):
  tty/serial: omap: fix RX interrupt enable/disable in half-duplex TX
  tty/serial: omap: empty the RX FIFO at the end of half-duplex TX

 drivers/tty/serial/omap-serial.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] tty/serial: omap: fix RX interrupt enable/disable in half-duplex TX
  2014-03-13 13:11 [PATCH 0/2] tty/serial: omap: remove unwanted local echo during half-duplex TX Dimitris Lampridis
@ 2014-03-13 13:11 ` Dimitris Lampridis
  2014-03-13 13:11 ` [PATCH 2/2] tty/serial: omap: empty the RX FIFO at the end of " Dimitris Lampridis
  1 sibling, 0 replies; 3+ messages in thread
From: Dimitris Lampridis @ 2014-03-13 13:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, Dimitris Lampridis

Make sure that serial_omap_stop_rx() also disables RDI (Receiver Data Interrupt),
otherwise the interrupt handler will call serial_omap_rdi() to read the new data,
resulting in the transmission being echoed back.

When the half-duplex transmission is complete, in order to reverse the effects of
serial_omap_stop_rx(), we should re-enable:

  * the RX interrupts _without_ overwriting up->ier

  * the UART_LSR_DR bit of the up->port.read_status_mask

Signed-off-by: Dimitris Lampridis <dlampridis@logikonlabs.com>
---
 drivers/tty/serial/omap-serial.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 77f0351..65abea2 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -342,7 +342,8 @@ static void serial_omap_stop_tx(struct uart_port *port)
 
 	if ((up->rs485.flags & SER_RS485_ENABLED) &&
 	    !(up->rs485.flags & SER_RS485_RX_DURING_TX)) {
-		up->ier = UART_IER_RLSI | UART_IER_RDI;
+		up->ier |= UART_IER_RLSI | UART_IER_RDI;
+		up->port.read_status_mask |= UART_LSR_DR;
 		serial_out(up, UART_IER, up->ier);
 	}
 
@@ -355,7 +356,7 @@ static void serial_omap_stop_rx(struct uart_port *port)
 	struct uart_omap_port *up = to_uart_omap_port(port);
 
 	pm_runtime_get_sync(up->dev);
-	up->ier &= ~UART_IER_RLSI;
+	up->ier &= ~(UART_IER_RLSI | UART_IER_RDI);
 	up->port.read_status_mask &= ~UART_LSR_DR;
 	serial_out(up, UART_IER, up->ier);
 	pm_runtime_mark_last_busy(up->dev);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] tty/serial: omap: empty the RX FIFO at the end of half-duplex TX
  2014-03-13 13:11 [PATCH 0/2] tty/serial: omap: remove unwanted local echo during half-duplex TX Dimitris Lampridis
  2014-03-13 13:11 ` [PATCH 1/2] tty/serial: omap: fix RX interrupt enable/disable in " Dimitris Lampridis
@ 2014-03-13 13:11 ` Dimitris Lampridis
  1 sibling, 0 replies; 3+ messages in thread
From: Dimitris Lampridis @ 2014-03-13 13:11 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Jiri Slaby, linux-serial, Dimitris Lampridis

Provided that the SER_RS485_RX_DURING_TX flag is not set, empty the
RX FIFO to prevent reading back the transmitted data.

Signed-off-by: Dimitris Lampridis <dlampridis@logikonlabs.com>
---
 drivers/tty/serial/omap-serial.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c
index 65abea2..dd8b1a5 100644
--- a/drivers/tty/serial/omap-serial.c
+++ b/drivers/tty/serial/omap-serial.c
@@ -342,6 +342,12 @@ static void serial_omap_stop_tx(struct uart_port *port)
 
 	if ((up->rs485.flags & SER_RS485_ENABLED) &&
 	    !(up->rs485.flags & SER_RS485_RX_DURING_TX)) {
+		/*
+		 * Empty the RX FIFO, we are not interested in anything
+		 * received during the half-duplex transmission.
+		 */
+		serial_out(up, UART_FCR, up->fcr | UART_FCR_CLEAR_RCVR);
+		/* Re-enable RX interrupts */
 		up->ier |= UART_IER_RLSI | UART_IER_RDI;
 		up->port.read_status_mask |= UART_LSR_DR;
 		serial_out(up, UART_IER, up->ier);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-13 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-13 13:11 [PATCH 0/2] tty/serial: omap: remove unwanted local echo during half-duplex TX Dimitris Lampridis
2014-03-13 13:11 ` [PATCH 1/2] tty/serial: omap: fix RX interrupt enable/disable in " Dimitris Lampridis
2014-03-13 13:11 ` [PATCH 2/2] tty/serial: omap: empty the RX FIFO at the end of " Dimitris Lampridis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.