Aristeu Rozanski | 30 Sep 20:37

[PATCH RFC 0/6] serial: make hardware flow control more flexible

This series of patches begins the changes in the serial code to allow more
flexible hardware flow control rules. Instead of having fixed models like
RTS/CTS or DSR/DTR, the new termiox structure will instead allow to specify
which pins will be used.

Currently, termiox has four flags: RTSXOFF, CTSXON, DTRXOFF and DSRXON. This
is not yet enough to fully specify Linux' CRTSCTS since it uses the DTR always
on while the serial port is available (and RTS to signal if the system is ready
or not to receive data). The plan is add RTSON and DTRON to termiox to allow
the user to specify that those pins will be always set while the serial port
is available.

These patches are not intended for inclusion, just to continue the discussion.

--

-- 
Aristeu

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

Aristeu Rozanski | 30 Sep 20:41

[PATCH RFC 2/6] serial_core: add separated CTS, RTS, DTR, DSR flow control flags

This patch is the first step to implement hardware flow control using termiox
which will allow the user to customize which pins to use for hardware flow
control.

Signed-off-by: Aristeu Rozanski <aris <at> redhat.com>

---
 include/linux/serial_core.h |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- linux-next.orig/include/linux/serial_core.h	2008-09-25 11:50:14.000000000 -0400
+++ linux-next/include/linux/serial_core.h	2008-09-25 11:53:57.000000000 -0400
@@ -288,7 +288,11 @@ struct uart_port {
 #define UPF_LOW_LATENCY		((__force upf_t) (1 << 13))
 #define UPF_BUGGY_UART		((__force upf_t) (1 << 14))
 #define UPF_MAGIC_MULTIPLIER	((__force upf_t) (1 << 16))
-#define UPF_CONS_FLOW		((__force upf_t) (1 << 23))
+#define UPF_FLOW_DTRXOFF	((__force upf_t) (1 << 20))
+#define UPF_FLOW_RTSXOFF	((__force upf_t) (1 << 21))
+#define UPF_FLOW_DSRXON		((__force upf_t) (1 << 22))
+#define UPF_FLOW_CTSXON		((__force upf_t) (1 << 23))
+#define UPF_CONS_FLOW		(UPF_FLOW_RTSXOFF | UPF_FLOW_CTSXON)
 #define UPF_SHARE_IRQ		((__force upf_t) (1 << 24))
 #define UPF_BOOT_AUTOCONF	((__force upf_t) (1 << 28))
 #define UPF_FIXED_PORT		((__force upf_t) (1 << 29))

--

-- 
Aristeu

--
(Continue reading)

Aristeu Rozanski | 30 Sep 20:41

[PATCH RFC 4/6] serial: introduce uart_handle_dsr_change()

This patch introduces uart_handle_dsr_change() and change drivers to use it.
Currently the drivers will simply count the DSR changes but won't report
this to the serial_core. This is needed for using DSR for flow control.

Signed-off-by: Aristeu Rozanski <aris <at> redhat.com>

---
 drivers/serial/8250.c          |    2 -
 drivers/serial/amba-pl010.c    |    2 -
 drivers/serial/amba-pl011.c    |    2 -
 drivers/serial/atmel_serial.c  |    2 -
 drivers/serial/dz.c            |    2 -
 drivers/serial/icom.c          |    7 ++---
 drivers/serial/imx.c           |    2 -
 drivers/serial/ip22zilog.c     |    4 +-
 drivers/serial/pmac_zilog.c    |    4 +-
 drivers/serial/pnx8xxx_uart.c  |    2 -
 drivers/serial/pxa.c           |    2 -
 drivers/serial/sa1100.c        |    2 -
 drivers/serial/sb1250-duart.c  |    2 -
 drivers/serial/serial_ks8695.c |    2 -
 drivers/serial/sunsab.c        |    2 -
 drivers/serial/sunsu.c         |    2 -
 drivers/serial/sunzilog.c      |    4 +-
 drivers/serial/vr41xx_siu.c    |    2 -
 drivers/serial/zs.c            |    5 ++-
 include/linux/serial_core.h    |   55 ++++++++++++++++++++++++++++-------------
 20 files changed, 65 insertions(+), 42 deletions(-)

--- linux-next.orig/include/linux/serial_core.h	2008-09-24 13:09:48.000000000 -0400
(Continue reading)

Aristeu Rozanski | 30 Sep 20:41

[PATCH RFC 1/6] serial_core: add termiox support

This patch adds support for termiox on serial_core and implements allocation
and freeing of termiox structure in tty_struct if the driver has support for
termiox

Signed-off-by: Aristeu Rozanski <aris <at> redhat.com>

---
 drivers/char/tty_io.c        |   82 ++++++++++++++++++++++++++++++++++++++-----
 drivers/serial/serial_core.c |   13 ++++++
 include/linux/serial_core.h  |    2 +
 include/linux/tty_driver.h   |    1 
 4 files changed, 90 insertions(+), 8 deletions(-)

--- linux-next.orig/drivers/serial/serial_core.c	2008-09-25 11:50:12.000000000 -0400
+++ linux-next/drivers/serial/serial_core.c	2008-09-25 11:50:49.000000000 -0400
@@ -2292,6 +2292,16 @@ static void uart_poll_put_char(struct tt
 }
 #endif

+#ifdef TCSETX
+static int uart_set_termiox(struct tty_struct *tty, struct termiox *new)
+{
+	tty->termiox->x_cflag = new->x_cflag &
+				(RTSXOFF | CTSXON | DTRXOFF | DSRXON);
+
+	return 0;
+}
+#endif
+
 static const struct tty_operations uart_ops = {
(Continue reading)

Aristeu Rozanski | 30 Sep 20:41

[PATCH RFC 3/6] serial_core: use port flags to determine hardware flow control

This patch makes serial_core to use hardware flow port flags instead of using
the fixed RTS/CTS.

Signed-off-by: Aristeu Rozanski <aris <at> ruivo.org>

---
 drivers/serial/serial_core.c |  154 ++++++++++++++++++++++++++++++++++++-------
 include/linux/serial_core.h  |    2 
 2 files changed, 133 insertions(+), 23 deletions(-)

--- linux-next.orig/drivers/serial/serial_core.c	2008-09-25 11:50:49.000000000 -0400
+++ linux-next/drivers/serial/serial_core.c	2008-09-25 11:56:00.000000000 -0400
@@ -133,6 +133,49 @@ uart_update_mctrl(struct uart_port *port
 #define uart_set_mctrl(port, set)	uart_update_mctrl(port, set, 0)
 #define uart_clear_mctrl(port, clear)	uart_update_mctrl(port, 0, clear)

+static void uart_flow_input_start(struct uart_port *port)
+{
+	unsigned int bit;
+
+	if (port->flags & UPF_FLOW_RTSXOFF)
+		bit = TIOCM_RTS;
+	else if (port->flags & UPF_FLOW_DTRXOFF)
+		bit = TIOCM_DTR;
+	else
+		return;
+
+	uart_set_mctrl(port, bit);
+}
+
(Continue reading)

Aristeu Rozanski | 30 Sep 20:42

[PATCH RFC 5/6] serial_core: dont assert DTR pin when its being used for flow control

By default, serial_core will assert DTR for compatibility. In the case DTR is
being used for flow control this should not happen.

Signed-off-by: Aristeu Rozanski <aris <at> redhat.com>

---
 drivers/serial/serial_core.c |   25 ++++++++++++++++++-------
 include/linux/serial_core.h  |   10 +++++++---
 2 files changed, 25 insertions(+), 10 deletions(-)

--- linux-next.orig/drivers/serial/serial_core.c	2008-09-25 11:56:00.000000000 -0400
+++ linux-next/drivers/serial/serial_core.c	2008-09-25 12:02:43.000000000 -0400
@@ -227,7 +227,9 @@ static int uart_startup(struct uart_stat
 			 * port is open and ready to respond.
 			 */
 			if (info->port.tty->termios->c_cflag & CBAUD) {
-				uart_set_mctrl(port, TIOCM_DTR);
+				if (!(info->port.tty->termiox->x_cflag &
+								 DTRXOFF))
+					uart_set_mctrl(port, TIOCM_DTR);
 				uart_flow_input_start(port);
 			}
 		}
@@ -1249,7 +1251,12 @@ static void uart_set_termios(struct tty_

 	/* Handle transition away from B0 status */
 	if (!(old_termios->c_cflag & CBAUD) && (cflag & CBAUD)) {
-		uart_set_mctrl(state->port, TIOCM_DTR);
+		/*
+		 * by default, we keep DTR on all the time, except
(Continue reading)

Aristeu Rozanski | 30 Sep 20:42

[PATCH RFC 6/6] serial: convert drivers to use uart_flow_output_allowed()

This patch modifies serial drivers to use uart_flow_output_allowed() making
the flow control decision to serial_core.

Signed-off-by: Aristeu Rozanski <aris <at> redhat.com>

---
 drivers/serial/8250.c        |   18 +++++++-----------
 drivers/serial/pxa.c         |   12 ++++++------
 drivers/serial/samsung.c     |    6 +++---
 drivers/serial/serial_txx9.c |   12 ++++++------
 drivers/serial/sunsu.c       |   12 ++++++------
 drivers/serial/vr41xx_siu.c  |   15 ++++++---------
 6 files changed, 34 insertions(+), 41 deletions(-)

--- linux-next.orig/drivers/serial/8250.c	2008-09-24 13:30:30.000000000 -0400
+++ linux-next/drivers/serial/8250.c	2008-09-24 13:30:54.000000000 -0400
@@ -1779,17 +1779,13 @@ static void wait_for_xmitr(struct uart_8
 	} while ((status & bits) != bits);

 	/* Wait up to 1s for flow control if necessary */
-	if (up->port.flags & UPF_CONS_FLOW) {
-		unsigned int tmout;
-		for (tmout = 1000000; tmout; tmout--) {
-			unsigned int msr = serial_in(up, UART_MSR);
-			up->msr_saved_flags |= msr & MSR_SAVE_FLAGS;
-			if (msr & UART_MSR_CTS)
-				break;
-			udelay(1);
-			touch_nmi_watchdog();
-		}
(Continue reading)


Gmane