Skip to contentSkip to conversation

pl011: preserve RTS and DTR signal on UART init

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

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pl011: preserve RTS and DTR signal on UART init

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.
So we leave RTS and DTR as they had been setup before. This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

---
 xen/drivers/char/pl011.c         | 7 +++++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +5 -2
index 3ec6e10..3386e2b 100644
@@ -85,6 +85,7 @@ static void __init pl011_init_preirq(struct serial_port *port)
 {
     struct pl011 *uart = port->uart;
     unsigned int divisor;
+    unsigned int cr;
 
     /* No interrupts, please. */
     pl011_write(uart, IMSC, 0);
@@ -120,8 +121,10 @@ 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; keep RTS and DTR */
+    cr = pl011_read(uart, CR);
+    cr &= RTS | DTR;
+    pl011_write(uart, CR, cr | 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 9 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.
So we leave RTS and DTR as they had been setup before. This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

Acked + applied, thanks.

I wonder if we should turn of RXE/TXE/UARTEN early on before we do our own setup? Just to get things in a known quiet state. Although if this was going to be a problem it would have bit us all the way through boot...

Quoted 45 lines
---
 xen/drivers/char/pl011.c         | 7 +++++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +5 -2
index 3ec6e10..3386e2b 100644
@@ -85,6 +85,7 @@ static void __init pl011_init_preirq(struct serial_port *port)
 {
     struct pl011 *uart = port->uart;
     unsigned int divisor;
+    unsigned int cr;
 
     /* No interrupts, please. */
     pl011_write(uart, IMSC, 0);
@@ -120,8 +121,10 @@ 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; keep RTS and DTR */
+    cr = pl011_read(uart, CR);
+    cr &= RTS | DTR;
+    pl011_write(uart, CR, cr | 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 */
#2 lore raw
Quoted 9 lines · Ian Campbell
Quoted 8 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.
So we leave RTS and DTR as they had been setup before. This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

Quoted 3 lines
Quoted 1 line

Acked + applied, thanks.

Sent this a bit prematurely, having some issues with a recently upgraded build box. Should be pushed soon though.

Quoted 58 lines

I wonder if we should turn of RXE/TXE/UARTEN early on before we do our own setup? Just to get things in a known quiet state. Although if this was going to be a problem it would have bit us all the way through boot...

Quoted 35 lines
---
 xen/drivers/char/pl011.c         | 7 +++++--
 xen/include/asm-arm/pl011-uart.h | 4 ++++
 2 files changed, 9 insertions(+), 2 deletions(-)
xen/drivers/char/pl011.c +5 -2
index 3ec6e10..3386e2b 100644
@@ -85,6 +85,7 @@ static void __init pl011_init_preirq(struct serial_port *port)
 {
     struct pl011 *uart = port->uart;
     unsigned int divisor;
+    unsigned int cr;
 
     /* No interrupts, please. */
     pl011_write(uart, IMSC, 0);
@@ -120,8 +121,10 @@ 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; keep RTS and DTR */
+    cr = pl011_read(uart, CR);
+    cr &= RTS | DTR;
+    pl011_write(uart, CR, cr | 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 47

Quoted 10 lines
xen/include/asm-arm/pl011-uart.h +4 -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 */
+#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 */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Ian Campbell
Quoted 8 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.
So we leave RTS and DTR as they had been setup before. This fixes the UART input on Calxeda Midway, which uses hardware flow control for the serial-over-LAN functionality.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

Acked + applied, thanks.

Sent this a bit prematurely, having some issues with a recently upgraded build box. Should be pushed soon though.

Done!