Skip to contentSkip to conversation

mxs: uart: allow setting RTS from software

PATCH New Steffen Trumtrar 3 participants 4 messages Dec 12, 2012 – Dec 14, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 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 |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +7 -1
index 6db23b0..9b62c4b 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;
@@ -678,6 +680,10 @@ static void mxs_auart_settermios(struct uart_port *u,
 		}
 		ctrl2 |= AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN;
 	} else {
+		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 1/1 mxs: uart: allow setting RTS from software

? 2012?12?13? 00:31, Steffen Trumtrar ??:

Quoted 5 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

Is there any user case to set the RTS via software? I am confused at this.

Quoted 26 lines

flow control is explicitly enabled via settermios cflag CRTSCTS.

---
 drivers/tty/serial/mxs-auart.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +3 -1
index 6db23b0..9b62c4b 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 686

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

bug.

Your code adds TWO "else" here.

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 1/1 mxs: uart: allow setting RTS from software

Hi,

Quoted 8 lines · Huang Shijie

? 2012?12?13? 00:31, Steffen Trumtrar ??:

Quoted 5 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

Is there any user case to set the RTS via software? I am confused at this.

there are cases where the RTS is used in a non-standard way. And the always-on hardware flowcontrol breaks these (e.g. Echelon FT5000).
And as stated in the commit message, it is a valid operation to use software flow control.

Quoted 35 lines
Quoted 26 lines

flow control is explicitly enabled via settermios cflag CRTSCTS.

---
 drivers/tty/serial/mxs-auart.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/tty/serial/mxs-auart.c +3 -1
index 6db23b0..9b62c4b 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 686

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

bug.

Quoted 2 lines

Your code adds TWO "else" here.

Oops, wrong merge resolution. Will fix that.

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 |
#3 lore raw

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

In reply to Steffen Trumtrar
Quoted 8 lines · Steffen Trumtrar

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.

[...]

This is not the correct way to submit a patch to stable. See Documentation/stable_kernel_rules.txt

Ben.

Signature · 3 lines
Ben Hutchings
We get into the habit of living before acquiring the habit of thinking.
                                                              - Albert Camus