Skip to contentSkip to conversation

serial/imx: support to handle break character

PATCH In review Hui Wang 3 participants 3 messages Aug 24, 2011

Subsystems (2)
lore
Share & tools
lore

Hui Wang

author
#0 lore raw

PATCH 1/1 serial/imx: support to handle break character

The imx UART hardware controller can identify BREAK character and the imx_set_termios() can accept BRKINT set by users, but current existing imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer as other serial drivers do (8250.c omap_serial.c).

Here add code to handle BREAK character and pass it to tty layer.

To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN | URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will always be set to 1.

I put the URXD_BRK to the first place to check since when BREAK error occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and URXD_FRMERR are all set to 1. This arrangement can filter out fake parity and frame errors when BREAK error occurs.

Cc Sascha Hauer <[email protected]>
Cc Alan Cox <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
---
 drivers/tty/serial/imx.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/tty/serial/imx.c +7 -3
index 7e91b3d..54ffdc6 100644
@@ -508,8 +508,10 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
 		if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
 			continue;
 
-		if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
-			if (rx & URXD_PRERR)
+		if (unlikely(rx & URXD_ERR)) {
+			if (rx & URXD_BRK)
+				sport->port.icount.brk++;
+			else if (rx & URXD_PRERR)
 				sport->port.icount.parity++;
 			else if (rx & URXD_FRMERR)
 				sport->port.icount.frame++;
@@ -524,7 +526,9 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
 
 			rx &= sport->port.read_status_mask;
 
-			if (rx & URXD_PRERR)
+			if (rx & URXD_BRK)
+				flg = TTY_BREAK;
+			else if (rx & URXD_PRERR)
 				flg = TTY_PARITY;
 			else if (rx & URXD_FRMERR)
 				flg = TTY_FRAME;
Signature · 1 line
1.7.6
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Wed, 24 Aug 2011 17:41:47 +0800 Hui Wang <[email protected]> wrote:

The imx UART hardware controller can identify BREAK character and the imx_set_termios() can accept BRKINT set by users, but current existing imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer as other serial drivers do (8250.c omap_serial.c).

Here add code to handle BREAK character and pass it to tty layer.

To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN | URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will always be set to 1.

Quoted 7 lines

I put the URXD_BRK to the first place to check since when BREAK error occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and URXD_FRMERR are all set to 1. This arrangement can filter out fake parity and frame errors when BREAK error occurs.

Cc Sascha Hauer <[email protected]>
maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Hui Wang
Quoted 16 lines · Hui Wang

The imx UART hardware controller can identify BREAK character and the imx_set_termios() can accept BRKINT set by users, but current existing imx_rxint() can't pass BREAK character and TTY_BREAK to the tty layer as other serial drivers do (8250.c omap_serial.c).

Here add code to handle BREAK character and pass it to tty layer.

To detect error occurrence, i use URXD_ERR to replace (URXD_OVRRUN | URXD_FRMERR | ...) because any kind of error occurs, URXD_ERR will always be set to 1.

I put the URXD_BRK to the first place to check since when BREAK error occurs, not only URXD_BRK is set to 1, but also URXD_PRERR and URXD_FRMERR are all set to 1. This arrangement can filter out fake parity and frame errors when BREAK error occurs.

Quoted 4 lines
Cc Sascha Hauer <[email protected]>
Cc Alan Cox <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Quoted 36 lines
---
 drivers/tty/serial/imx.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
drivers/tty/serial/imx.c +7 -3
index 7e91b3d..54ffdc6 100644
@@ -508,8 +508,10 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
 		if (uart_handle_sysrq_char(&sport->port, (unsigned char)rx))
 			continue;
 
-		if (rx & (URXD_PRERR | URXD_OVRRUN | URXD_FRMERR) ) {
-			if (rx & URXD_PRERR)
+		if (unlikely(rx & URXD_ERR)) {
+			if (rx & URXD_BRK)
+				sport->port.icount.brk++;
+			else if (rx & URXD_PRERR)
 				sport->port.icount.parity++;
 			else if (rx & URXD_FRMERR)
 				sport->port.icount.frame++;
@@ -524,7 +526,9 @@ static irqreturn_t imx_rxint(int irq, void *dev_id)
 
 			rx &= sport->port.read_status_mask;
 
-			if (rx & URXD_PRERR)
+			if (rx & URXD_BRK)
+				flg = TTY_BREAK;
+			else if (rx & URXD_PRERR)
 				flg = TTY_PARITY;
 			else if (rx & URXD_FRMERR)
 				flg = TTY_FRAME;
Signature · 1 line
1.7.6
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 |