linux-serial.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] atmel-serial: fix RS485 half-duplex problem
@ 2012-03-27 17:43 Siftar, Gabe
  2012-03-27 17:54 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Siftar, Gabe @ 2012-03-27 17:43 UTC (permalink / raw)
  To: linux-arm-kernel@lists.infradead.org,
	linux-serial@vger.kernel.org
  Cc: Greg Kroah-Hartman, Andrew Victor, Nicolas Ferre,
	Jean-Christophe PLAGNIOL-VILLARD, Claudio Scordino, Bernhard Roth

On our custom board, we are using RS485 in half-duplex mode on an AT91SAM9G45. 
SER_RS485_RX_DURING_TX is not set as we do not want to receive the data we 
transmit (our transceiver will receive transmitted data).  Although the current 
driver attempts to disable and enable the receiver at the appropriate points, 
incoming data is still loaded into the receive register causing our code to 
receive the very last byte that was sent once the receiver is enabled.
 
I ran this by Atmel support and they wrote:  "The issue comes from the fact 
that you disable the PDC/DMA Reception and not the USART Reception channel.  In 
your case, the[n] you will still receive data into the USART_RHR register, and 
maybe you [h]ave the overun flag set.  So please disable the USART reception 
channel."
  
The following patch should force the driver to enable/disable the receiver via 
RXEN/RXDIS fields of the USART control register.  It fixed the issue I was 
having - perhaps others will find it useful as well.

Signed-off-by: Gabe Siftar <gabe.siftar@getingeusa.com>

Index: linux-3.3/drivers/tty/serial/atmel_serial.c
===================================================================
--- linux-3.3.orig/drivers/tty/serial/atmel_serial.c
+++ linux-3.3/drivers/tty/serial/atmel_serial.c
@@ -395,6 +395,8 @@
 {
 	UART_PUT_CR(port, ATMEL_US_RSTSTA);  /* reset status and receiver */
 
+	UART_PUT_CR(port, ATMEL_US_RXEN);
+
 	if (atmel_use_dma_rx(port)) {
 		/* enable PDC controller */
 		UART_PUT_IER(port, ATMEL_US_ENDRX | ATMEL_US_TIMEOUT |
@@ -410,6 +412,8 @@
  */
 static void atmel_stop_rx(struct uart_port *port)
 {
+	UART_PUT_CR(port, ATMEL_US_RXDIS);
+	
 	if (atmel_use_dma_rx(port)) {
 		/* disable PDC receive */
 		UART_PUT_PTCR(port, ATMEL_PDC_RXTDIS);

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

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

end of thread, other threads:[~2012-03-29 13:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-27 17:43 [PATCH] atmel-serial: fix RS485 half-duplex problem Siftar, Gabe
2012-03-27 17:54 ` Greg KH
2012-03-27 20:20   ` Siftar, Gabe
2012-03-27 20:26     ` Greg KH
2012-03-29 13:40       ` [PATCH] tty/serial: atmel_serial: " Nicolas Ferre

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).