Skip to contentSkip to conversation

mxs: uart: allow setting RTS from software

PATCH Superseded Steffen Trumtrar 2 participants 3 messages Dec 13, 2012

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mxs: uart: allow setting RTS from software

With the patch "serial: mxs-auart: fix the wrong RTS hardware flow control" the mainline mxs-uart driver now sets RTSEN only when hardware flow control is enabled via software. It is not possible any longer to set RTS manually via software. However, the manual modification is a valid operation. Regain the possibility to set RTS via software and only set RTSEN when hardware flow control is explicitly enabled via settermios cflag CRTSCTS.

---
 drivers/tty/serial/mxs-auart.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +5 -1
index 6db23b0..21d9b12 100644
@@ -412,10 +412,12 @@ static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl)
 
 	u32 ctrl = readl(u->membase + AUART_CTRL2);
 
-	ctrl &= ~AUART_CTRL2_RTSEN;
+	ctrl &= ~(AUART_CTRL2_RTSEN | AUART_CTRL2_RTS);
 	if (mctrl & TIOCM_RTS) {
 		if (tty_port_cts_enabled(&u->state->port))
 			ctrl |= AUART_CTRL2_RTSEN;
+		else
+			ctrl |= AUART_CTRL2_RTS;
 	}
 
 	s->ctrl = mctrl;
@@ -676,8 +678,10 @@ static void mxs_auart_settermios(struct uart_port *u,
 				ctrl2 |= AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE
 				       | AUART_CTRL2_DMAONERR;
 		}
+		u->flags |= ASYNC_CTS_FLOW;
 		ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN;
 	} else {
+		u->flags &= ~ASYNC_CTS_FLOW;
 		ctrl2 &= ~(AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN);
 	}
 
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 mxs: uart: allow setting RTS from software

? 2012?12?13? 16:42, Steffen Trumtrar ??:

Quoted 31 lines

With the patch "serial: mxs-auart: fix the wrong RTS hardware flow control" the mainline mxs-uart driver now sets RTSEN only when hardware flow control is enabled via software. It is not possible any longer to set RTS manually via software. However, the manual modification is a valid operation. Regain the possibility to set RTS via software and only set RTSEN when hardware flow control is explicitly enabled via settermios cflag CRTSCTS.

---
 drivers/tty/serial/mxs-auart.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +3 -1
index 6db23b0..21d9b12 100644
@@ -412,10 +412,12 @@ static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl)
 
 	u32 ctrl = readl(u->membase + AUART_CTRL2);
 
-	ctrl &= ~AUART_CTRL2_RTSEN;
+	ctrl &= ~(AUART_CTRL2_RTSEN | AUART_CTRL2_RTS);
 	if (mctrl & TIOCM_RTS) {
 		if (tty_port_cts_enabled(&u->state->port))
 			ctrl |= AUART_CTRL2_RTSEN;
+		else
+			ctrl |= AUART_CTRL2_RTS;
 	}
 
 	s->ctrl = mctrl;

drivers/tty/serial/mxs-auart.c static void mxs_auart_settermios(struct uart_port *u, · line 684

Quoted 7 lines
drivers/tty/serial/mxs-auart.c +2 -0
@@ -676,8 +678,10 @@ static void mxs_auart_settermios(struct uart_port *u,
 				ctrl2 |= AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE
 				       | AUART_CTRL2_DMAONERR;
 		}
+		u->flags |= ASYNC_CTS_FLOW;
 		ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN;
 	} else {
+		u->flags &= ~ASYNC_CTS_FLOW;

I think these two lines is not needed. uart_change_speed() has set/unset ASYNC_CTS_FLOW for us.

thanks
Huang Shijie

Quoted 3 lines
drivers/tty/serial/mxs-auart.c +0 -0
 		ctrl2 &= ~(AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN);
 	}
 
#2 lore raw

PATCH v2 1/1 mxs: uart: allow setting RTS from software

Quoted 30 lines · Huang Shijie

? 2012?12?13? 16:42, Steffen Trumtrar ??:

Quoted 29 lines

With the patch "serial: mxs-auart: fix the wrong RTS hardware flow control" the mainline mxs-uart driver now sets RTSEN only when hardware flow control is enabled via software. It is not possible any longer to set RTS manually via software. However, the manual modification is a valid operation. Regain the possibility to set RTS via software and only set RTSEN when hardware flow control is explicitly enabled via settermios cflag CRTSCTS.

---
 drivers/tty/serial/mxs-auart.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +3 -1
index 6db23b0..21d9b12 100644
@@ -412,10 +412,12 @@ static void mxs_auart_set_mctrl(struct uart_port *u, unsigned mctrl)
 
 	u32 ctrl = readl(u->membase + AUART_CTRL2);
 
-	ctrl &= ~AUART_CTRL2_RTSEN;
+	ctrl &= ~(AUART_CTRL2_RTSEN | AUART_CTRL2_RTS);
 	if (mctrl & TIOCM_RTS) {
 		if (tty_port_cts_enabled(&u->state->port))
 			ctrl |= AUART_CTRL2_RTSEN;
+		else
+			ctrl |= AUART_CTRL2_RTS;
 	}
 
Quoted 11 lines

drivers/tty/serial/mxs-auart.c static void mxs_auart_settermios(struct uart_port *u, · line 684

Quoted 9 lines
drivers/tty/serial/mxs-auart.c +2 -0
 	s->ctrl = mctrl;
@@ -676,8 +678,10 @@ static void mxs_auart_settermios(struct uart_port *u,
 				ctrl2 |= AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE
 				       | AUART_CTRL2_DMAONERR;
 		}
+		u->flags |= ASYNC_CTS_FLOW;
 		ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN;
 	} else {
+		u->flags &= ~ASYNC_CTS_FLOW;

I think these two lines is not needed. uart_change_speed() has set/unset ASYNC_CTS_FLOW for us.

I don't know that much of the inner workings of the serial framework, but it seems like it is guaranteed, that uart_change_speed is called before the mxs_auart_settermios. And therefore you are right and the two lines can be dropped.

Regards,
Steffen

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |