Skip to contentSkip to conversation

atmel-serial: fix RS485 half-duplex problem

PATCH New Siftar, Gabe 3 participants 5 messages Mar 27, 2012 – Mar 29, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 atmel-serial: fix RS485 half-duplex problem

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.

drivers/tty/serial/atmel_serial.c +4 -0
Index: 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.

maintainer
#1 lore raw

PATCH 1/1 atmel-serial: fix RS485 half-duplex problem

Quoted 13 lines · Gabe

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

Quoted 5 lines

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.

That's nice, but:

Quoted 1 line

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

This footer just contridicted your signed-off-by:

So, what should I believe?

Hint, please remove such footers, and tell anyone who insists on them that they directly prevent you from contributing to the kernel, as I can not accept patches with this on it.

Care to resend this without the footer so I can accept it?

greg k-h

#2 lore raw
Quoted 3 lines

From: Greg KH [mailto:[email protected]]
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.

drivers/tty/serial/atmel_serial.c +4 -0
Index: 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);
maintainer
#3 lore raw

PATCH 1/1 atmel-serial: fix RS485 half-duplex problem

Quoted 6 lines · Gabe
Quoted 3 lines

From: Greg KH [mailto:gregkh at linuxfoundation.org]
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.

Looks good, thanks, I'll queue this up once 3.4-rc1 is out.

thanks,

greg k-h

#4 lore raw

PATCH 1/1 tty/serial: atmel_serial: fix RS485 half-duplex problem

From: "Siftar, Gabe" <[email protected]>

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

[nicolas.ferre at atmel.com: slightly modify commit message]

---
Greg,

Here is an updated version of the patch that you received from Gabe. I have removed a superfluous tab in empty line, remove commit message non needed parts and added my "Signed-off-by" line.

Feel free to queue this version for 3.4-rc.

Thanks, best regards,
Nicolas

 drivers/tty/serial/atmel_serial.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/tty/serial/atmel_serial.c +4 -0
index 10605ec..bc3cece 100644
@@ -389,6 +389,8 @@ static void atmel_start_rx(struct uart_port *port)
 {
 	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 |
@@ -404,6 +406,8 @@ static void atmel_start_rx(struct uart_port *port)
  */
 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);
Signature · 1 line
1.7.9.4