RE: [PATCH] atmel-serial: fix RS485 half-duplex problem

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

 



>From: Greg KH [mailto:gregkh@xxxxxxxxxxxxxxxxxxx]
>Sent: Tuesday, March 27, 2012 1:55 PM
>Care to resend this without the footer so I can accept it?

Sorry.  It turns out that the footer was added by our 3rd party email 
filtering service - I hope that it's no longer being included.

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

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

--
To unsubscribe from this list: send the line "unsubscribe linux-serial" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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