public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] 8250: Auto RS485 direction control
@ 2008-07-24 11:47 Laurent Pinchart
  2008-07-24 11:57 ` Alan Cox
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Laurent Pinchart @ 2008-07-24 11:47 UTC (permalink / raw)
  To: linux-serial; +Cc: Alan Cox, rmk

[-- Attachment #1: Type: text/plain, Size: 2696 bytes --]

This patch adds support for the automatic RS485 direction control feature
present in 16850 UARTs.

A new termios c_cflag, CARTS, is introduced to configure automatic direction
control from userspace.

This is a first proposal. I'm open to suggestions regarding the CARTS name.
I assume the CARTS flag will have to be added to all asm/termbits.h headers.
Why are the termios bits definitions platform specific ?

---
 drivers/serial/8250.c          |   14 ++++++++++++++
 include/asm-powerpc/termbits.h |    1 +
 include/linux/serial_reg.h     |    1 +
 3 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/drivers/serial/8250.c b/drivers/serial/8250.c
index 62a2e49..a1351d5 100644
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -2071,6 +2071,20 @@ serial8250_set_termios(struct uart_port *port, struct ktermios *termios,
 	if (up->port.type == PORT_16750)
 		serial_outp(up, UART_FCR, fcr);
 
+#ifdef CARTS
+	/* Auto RS485 Direction Control on 16850 UARTs */
+	if (up->port.type == PORT_16850) {
+		unsigned char fctr;
+
+		serial_outp(up, UART_LCR, 0xbf);
+		fctr = serial_inp(up, UART_FCTR) & ~UART_FCTR_RS485;
+		if (termios->c_cflag & CARTS)
+			fctr |= UART_FCTR_RS485;
+		serial_outp(up, UART_FCTR, fctr);
+		serial_outp(up, UART_LCR, 0);
+	}
+#endif
+
 	serial_outp(up, UART_LCR, cval);		/* reset DLAB */
 	up->lcr = cval;					/* Save LCR */
 	if (up->port.type != PORT_16750) {
diff --git a/include/asm-powerpc/termbits.h b/include/asm-powerpc/termbits.h
index 5e79198..7b7ee27 100644
--- a/include/asm-powerpc/termbits.h
+++ b/include/asm-powerpc/termbits.h
@@ -166,6 +166,7 @@ struct ktermios {
 #define HUPCL	00040000
 
 #define CLOCAL	00100000
+#define CARTS	  004000000000		/* auto RTS control */
 #define CMSPAR	  010000000000		/* mark or space (stick) parity */
 #define CRTSCTS	  020000000000		/* flow control */
 
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
index 3c8a6aa..3db78cc 100644
--- a/include/linux/serial_reg.h
+++ b/include/linux/serial_reg.h
@@ -188,6 +188,7 @@
 #define UART_FCTR_RTS_8DELAY	0x03
 #define UART_FCTR_IRDA		0x04  /* IrDa data encode select */
 #define UART_FCTR_TX_INT	0x08  /* Tx interrupt type select */
+#define UART_FCTR_RS485		0x08  /* Auto RS485 direction control */
 #define UART_FCTR_TRGA		0x00  /* Tx/Rx 550 trigger table select */
 #define UART_FCTR_TRGB		0x10  /* Tx/Rx 650 trigger table select */
 #define UART_FCTR_TRGC		0x20  /* Tx/Rx 654 trigger table select */
-- 
1.5.0

-- 
Laurent Pinchart
CSE Semaphore Belgium

Chaussee de Bruxelles, 732A
B-1410 Waterloo
Belgium

T +32 (2) 387 42 59
F +32 (2) 387 42 75

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2008-12-04 11:04 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-24 11:47 [PATCH/RFC] 8250: Auto RS485 direction control Laurent Pinchart
2008-07-24 11:57 ` Alan Cox
2008-07-24 12:24   ` Russell King
2008-07-24 12:27     ` Alan Cox
2008-07-24 12:52       ` Russell King
2008-07-24 13:00         ` Alan Cox
2008-07-24 13:18         ` Laurent Pinchart
2008-07-24 14:13         ` Matt Schulte
2008-07-24 14:47           ` Russell King
2008-07-24 12:10 ` Russell King
2008-08-04 14:14 ` Tosoni
2008-08-04 14:22   ` Grant Edwards
2008-08-04 14:36   ` Laurent Pinchart
2008-08-04 16:15     ` Grant Edwards
2008-08-04 16:21       ` Grant Edwards
2008-08-05  9:41       ` Laurent Pinchart
2008-08-05 12:55         ` Tosoni
2008-08-06 14:30           ` Christopher Gibson
2008-08-06 16:33             ` Tosoni
2008-08-09 10:08               ` Christopher Gibson
2008-08-07  8:50             ` Laurent Pinchart
2008-08-07 13:50               ` Grant Edwards
2008-08-10  3:49               ` Christopher Gibson
2008-08-10  3:57               ` Christopher Gibson
2008-08-29 12:22                 ` Christopher Gibson
2008-12-02 13:09                 ` [PATCH/RFC] " Christopher Gibson
2008-12-04 11:14                   ` Christopher Gibson
2008-08-04 16:47     ` [PATCH/RFC] 8250: " Tosoni
2008-08-04 17:46       ` Grant Edwards
2008-08-04 20:59         ` Matt Schulte
2008-08-05  9:23         ` Laurent Pinchart
2008-08-05  9:34         ` Tosoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox