Skip to contentSkip to conversation

pl011: assert RTS signal in case the receiver uses flow control

PATCH In review Andre Przywara 3 participants 6 messages Sep 2, 2013 – Sep 3, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pl011: assert RTS signal in case the receiver uses flow control

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
 xen/drivers/char/pl011.c         | 4 ++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +2 -2
index 3ec6e10..e340961 100644
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct serial_port *port)
     pl011_write(uart, IMSC, 0);
     pl011_write(uart, ICR, ALLI);
 
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end cares */
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
 }
 
 static void __init pl011_init_postirq(struct serial_port *port)
xen/include/asm-arm/pl011-uart.h +4 -0
index 3332c51..123f477 100644
@@ -38,6 +38,10 @@
 #define DMACR  (0x48)
 
 /* CR bits */
+#define CTSEN  (1<<15) /* automatic CTS hardware flow control */
+#define RTSEN  (1<<14) /* automatic RTS hardware flow control */
+#define RTS    (1<<11) /* RTS signal */
+#define DTR    (1<<10) /* DTR signal */
 #define RXE    (1<<9) /* Receive enable */
 #define TXE    (1<<8) /* Transmit enable */
 #define UARTEN (1<<0) /* UART enable */
Signature · 1 line
1.7.12.1
#1 lore raw
Quoted 18 lines · Andre Przywara

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
 xen/drivers/char/pl011.c         | 4 ++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +0 -0
index 3ec6e10..e340961 100644

xen/drivers/char/pl011.c static void __init pl011_init_preirq(struct serial_port *port) · line 125

Quoted 8 lines
xen/drivers/char/pl011.c +2 -2
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct serial_port *port)
     pl011_write(uart, IMSC, 0);
     pl011_write(uart, ICR, ALLI);
 
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end cares */
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
 }

Instead of overriding CR can we read CR and enable the necessary bit? It seems that Linux doesn't set RTS but keep the level from the previous register value.

BTW, this patch works on the versatile express :).

Cheers,

Signature · 1 line
Julien Grall
#2 lore raw
Quoted 22 lines · Julien Grall
Quoted 21 lines · Andre Przywara

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
  xen/drivers/char/pl011.c         | 4 ++--
  xen/include/asm-arm/pl011-uart.h | 4 ++++
  2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +0 -0
index 3ec6e10..e340961 100644
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct serial_port *port)
      pl011_write(uart, IMSC, 0);
      pl011_write(uart, ICR, ALLI);
 
Quoted 9 lines

xen/drivers/char/pl011.c static void __init pl011_init_preirq(struct serial_port *port) · line 125

Quoted 5 lines
xen/drivers/char/pl011.c +2 -2
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end cares */
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
  }

Instead of overriding CR can we read CR and enable the necessary bit? It seems that Linux doesn't set RTS but keep the level from the previous register value.

Right, that is the way to do it. In fact u-boot already cares about this: http://git.denx.de/?p=u-boot.git;a=commit;h=10501df05e2d2eef501c92483c134d5f7c9da150

Will send a new version.

Quoted 1 line

BTW, this patch works on the versatile express :).

Nice, thanks for testing.

Andre.

#3 lore raw
In reply to Andre Przywara
Quoted 33 lines · Andre Przywara

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
 xen/drivers/char/pl011.c         | 4 ++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +2 -2
index 3ec6e10..e340961 100644
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct serial_port *port)
     pl011_write(uart, IMSC, 0);
     pl011_write(uart, ICR, ALLI);
 
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end cares */
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
 }
 
 static void __init pl011_init_postirq(struct serial_port *port)
xen/include/asm-arm/pl011-uart.h +0 -0
index 3332c51..123f477 100644

xen/include/asm-arm/pl011-uart.h line 42

Quoted 5 lines
xen/include/asm-arm/pl011-uart.h +2 -0
@@ -38,6 +38,10 @@
 #define DMACR  (0x48)
 
 /* CR bits */
+#define CTSEN  (1<<15) /* automatic CTS hardware flow control */
+#define RTSEN  (1<<14) /* automatic RTS hardware flow control */

Would this bit not be better than blindly setting RTS?

Tim.

#4 lore raw
Quoted 36 lines · Tim Deegan
Quoted 35 lines · Andre Przywara

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
  xen/drivers/char/pl011.c         | 4 ++--
  xen/include/asm-arm/pl011-uart.h | 4 ++++
  2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +2 -2
index 3ec6e10..e340961 100644
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct serial_port *port)
      pl011_write(uart, IMSC, 0);
      pl011_write(uart, ICR, ALLI);
 
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end cares */
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
  }
 
  static void __init pl011_init_postirq(struct serial_port *port)
xen/include/asm-arm/pl011-uart.h +0 -0
index 3332c51..123f477 100644
@@ -38,6 +38,10 @@
  #define DMACR  (0x48)
 
Quoted 5 lines

xen/include/asm-arm/pl011-uart.h line 42

Quoted 3 lines
xen/include/asm-arm/pl011-uart.h +2 -0
  /* CR bits */
+#define CTSEN  (1<<15) /* automatic CTS hardware flow control */
+#define RTSEN  (1<<14) /* automatic RTS hardware flow control */

Would this bit not be better than blindly setting RTS?

I don't think so. This sets and clears RTS according to the FIFO fill level. Since we don't claim to support h/w flow control, we better leave this disabled.
Just asserting RTS all of the time should have no influence on non-prepared devices[1]. So I will go with simply ORing in our requested bits and leave the flow-control bits as they have been setup before.

Regards,
Andre.

[1] http://git.denx.de/?p=u-boot.git;a=commit;h=10501df05e2d2eef501c92483c134d5f7c9da150

#5 lore raw
Quoted 46 lines · Andre Przywara
Quoted 39 lines · Tim Deegan
Quoted 38 lines · Andre Przywara

Although we do not support hardware flow control in the Xen driver for the PL011 UART, the other end may be configured to use it. In this case it waits in vain for the RTS signal to be asserted by the host and will never transmit any characters.
This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
 xen/drivers/char/pl011.c         | 4 ++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +1 -2
index 3ec6e10..e340961 100644
@@ -120,8 +120,8 @@ static void __init pl011_init_preirq(struct 
 serial_port *port)
     pl011_write(uart, IMSC, 0);
     pl011_write(uart, ICR, ALLI);
 
-    /* Enable the UART for RX and TX; no flow ctrl */
-    pl011_write(uart, CR, RXE | TXE | UARTEN);
+    /* Enable the UART for RX and TX; assert RTS in case the other end 

cares */

xen/drivers/char/pl011.c +1 -0
+    pl011_write(uart, CR, RTS | RXE | TXE | UARTEN);
 }
 
 static void __init pl011_init_postirq(struct serial_port *port)
xen/include/asm-arm/pl011-uart.h +0 -0
index 3332c51..123f477 100644
@@ -38,6 +38,10 @@
 #define DMACR  (0x48)
 
Quoted 5 lines

xen/include/asm-arm/pl011-uart.h line 42

Quoted 3 lines
xen/include/asm-arm/pl011-uart.h +2 -0
 /* CR bits */
+#define CTSEN  (1<<15) /* automatic CTS hardware flow control */
+#define RTSEN  (1<<14) /* automatic RTS hardware flow control */

Would this bit not be better than blindly setting RTS?

Quoted 5 lines

I don't think so. This sets and clears RTS according to the FIFO fill level. Since we don't claim to support h/w flow control, we better leave this disabled.
Just asserting RTS all of the time should have no influence on non-prepared devices

Sure, but frobbing RTS up and down won't have any effect on devices that ignore it either, and if the hardware will actually DTRT when the other end _wants_ flow control, why not?

But it's no big deal either way; asserting RTS is harmless and better than what we have.

Quoted 2 lines

[1]. So I will go with simply ORing in our requested
bits and leave the flow-control bits as they have been setup before.

That's fine too, at least in cases where we're alreay taking the baud settings from the existing setup (which is all the time now?).

Tim.