Skip to contentSkip to conversation

tty/serial: Add PORT_TEGRA, fix break handling for it

PATCH Superseded Stephen Warren 3 participants 6 messages May 17, 2011 2 messages not in the archive

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover tty/serial: Add PORT_TEGRA, fix break handling for it

8250.c needs a specific PORT_TEGRA type for two reasons:
* RTOIE bit needs to be set, but UUE is reserved, so split RTOIE handling out of PORT_XSCALE.
* A WAR is needed for break reception.

I'd like to get the first of these two patches merged into the tegra arch for-next branch, so that I can modify the board files to explicitly request the new port type rather than relying on auto-detection. As such, could you please create a branch for that/these changes, then merge it into tty-2.6.git, so that the same branch can be merged into Tegra's for-next branch. Thanks.

Stephen Warren (2):
tty/serial: Add explicit PORT_TEGRA type
tty/serial: Fix break handling for PORT_TEGRA

 drivers/tty/serial/8250.c   |   37 +++++++++++++++++++++++++++++++++++--
 drivers/tty/serial/8250.h   |    1 +
 include/linux/serial_core.h |    3 ++-
 include/linux/serial_reg.h  |    2 ++
 4 files changed, 40 insertions(+), 3 deletions(-)
#2 lore raw

PATCH 1/2 tty/serial: Add explicit PORT_TEGRA type

In reply to a message not in the archive

Tegra's UART is currently auto-detected as PORT_XSCALE due to register bit UART_IER.UUE being writable. However, the Tegra documentation states that this register bit is reserved. Hence, we should not program it.

Instead, the documentation specifies that the UART is 16550 compatible. However, Tegra does need register bit UART_IER.RTOIE set, which is not enabled by any 16550 port type. This was not noticed before, since PORT_XSCALE enables CAP_UUE, which conflates both UUE and RTOIE bit programming.

This change defines PORT_TEGRA that doesn't set UART_CAP_UUE, but does set UART_CAP_RTOIE, which is a new capability indicating that the RTOIE bit needs to be enabled.

---
I'd like to get the first of these two patches merged into the tegra arch for-next branch, so that I can modify the board files to explicitly request the new port type rather than relying on auto-detection. As such, could you please create a branch for that/these changes, then merge it into tty-2.6.git, so that the same branch can be merged into Tegra's for-next branch. Thanks.

 drivers/tty/serial/8250.c   |   14 ++++++++++++--
 drivers/tty/serial/8250.h   |    1 +
 include/linux/serial_core.h |    3 ++-
 include/linux/serial_reg.h  |    1 +
 4 files changed, 16 insertions(+), 3 deletions(-)
drivers/tty/serial/8250.c +12 -2
index 54482d7..a5e290d 100644
@@ -271,7 +271,7 @@ static const struct serial8250_config uart_config[] = {
 		.fifo_size	= 32,
 		.tx_loadsz	= 32,
 		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
-		.flags		= UART_CAP_FIFO | UART_CAP_UUE,
+		.flags		= UART_CAP_FIFO | UART_CAP_UUE | UART_CAP_RTOIE,
 	},
 	[PORT_RM9000] = {
 		.name		= "RM9000",
@@ -301,6 +301,14 @@ static const struct serial8250_config uart_config[] = {
 		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10,
 		.flags		= UART_CAP_FIFO | UART_CAP_AFE,
 	},
+	[PORT_TEGRA] = {
+		.name		= "Tegra",
+		.fifo_size	= 32,
+		.tx_loadsz	= 8,
+		.fcr		= UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01 |
+				  UART_FCR_T_TRIG_01,
+		.flags		= UART_CAP_FIFO | UART_CAP_RTOIE,
+	},
 };
 
 #if defined(CONFIG_MIPS_ALCHEMY)
@@ -2403,7 +2411,9 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
 			UART_ENABLE_MS(&up->port, termios->c_cflag))
 		up->ier |= UART_IER_MSI;
 	if (up->capabilities & UART_CAP_UUE)
-		up->ier |= UART_IER_UUE | UART_IER_RTOIE;
+		up->ier |= UART_IER_UUE;
+	if (up->capabilities & UART_CAP_RTOIE)
+		up->ier |= UART_IER_RTOIE;
 
 	serial_out(up, UART_IER, up->ier);
 
drivers/tty/serial/8250.h +1 -0
index d13b586..6edf4a6 100644
@@ -42,6 +42,7 @@ struct serial8250_config {
 #define UART_CAP_SLEEP	(1 << 10)	/* UART has IER sleep */
 #define UART_CAP_AFE	(1 << 11)	/* MCR-based hw flow control */
 #define UART_CAP_UUE	(1 << 12)	/* UART needs IER bit 6 set (Xscale) */
+#define UART_CAP_RTOIE	(1 << 13)	/* UART needs IER bit 4 set (Xscale, Tegra) */
 
 #define UART_BUG_QUOT	(1 << 0)	/* UART has buggy quot LSB */
 #define UART_BUG_TXEN	(1 << 1)	/* UART has buggy TX IIR status */
include/linux/serial_core.h +2 -1
index 95d479b..a5c3114 100644
@@ -45,7 +45,8 @@
 #define PORT_OCTEON	17	/* Cavium OCTEON internal UART */
 #define PORT_AR7	18	/* Texas Instruments AR7 internal UART */
 #define PORT_U6_16550A	19	/* ST-Ericsson U6xxx internal UART */
-#define PORT_MAX_8250	19	/* max port ID */
+#define PORT_TEGRA	20	/* NVIDIA Tegra internal UART */
+#define PORT_MAX_8250	20	/* max port ID */
 
 /*
  * ARM specific type numbers.  These are not currently guaranteed
include/linux/serial_reg.h +1 -0
index 3ecb71a..5f66e84 100644
@@ -57,6 +57,7 @@
  * ST16C654:	 8  16  56  60		 8  16  32  56	PORT_16654
  * TI16C750:	 1  16  32  56		xx  xx  xx  xx	PORT_16750
  * TI16C752:	 8  16  56  60		 8  16  32  56
+ * Tegra:	 1   4   8  14		16   8   4   1	PORT_TEGRA
  */
 #define UART_FCR_R_TRIG_00	0x00
 #define UART_FCR_R_TRIG_01	0x40
Signature · 1 line
1.7.0.4
#3 lore raw

PATCH 2/2 tty/serial: Fix break handling for PORT_TEGRA

In reply to a message not in the archive

When a break is received, Tegra's UART apparently fills the FIFO with 0 bytes. These must be drained so that they aren't interpreted as actual data received. This allows e.g. MAGIC_SYSRQ to work on Tegra's UARTs.

---
 drivers/tty/serial/8250.c  |   23 +++++++++++++++++++++++
 include/linux/serial_reg.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)
drivers/tty/serial/8250.c +23 -0
index a5e290d..699323f 100644
@@ -1433,6 +1433,22 @@ static void serial8250_enable_ms(struct uart_port *port)
 	serial_out(up, UART_IER, up->ier);
 }
 
+/* Clear the rx fifo */
+static void clear_rx_fifo(struct uart_8250_port *up)
+{
+	unsigned int status, tmout = 10000;
+	do {
+		status = serial_in(up, UART_LSR);
+		if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS))
+			status = serial_in(up, UART_RX);
+		else
+			break;
+		if (--tmout == 0)
+			break;
+		udelay(1);
+	} while (1);
+}
+
 static void
 receive_chars(struct uart_8250_port *up, unsigned int *status)
 {
@@ -1468,6 +1484,13 @@ receive_chars(struct uart_8250_port *up, unsigned int *status)
 				lsr &= ~(UART_LSR_FE | UART_LSR_PE);
 				up->port.icount.brk++;
 				/*
+				 * If tegra port then clear the rx fifo to
+				 * accept another break/character.
+				 */
+				if (up->port.type == PORT_TEGRA)
+					clear_rx_fifo(up);
+
+				/*
 				 * We do the SysRQ and SAK checking
 				 * here because otherwise the break
 				 * may get masked by ignore_status_mask
include/linux/serial_reg.h +1 -0
index 5f66e84..c75bda3 100644
@@ -119,6 +119,7 @@
 #define UART_MCR_DTR		0x01 /* DTR complement */
 
 #define UART_LSR	5	/* In:  Line Status Register */
+#define UART_LSR_FIFOE		0x80 /* Fifo error */
 #define UART_LSR_TEMT		0x40 /* Transmitter empty */
 #define UART_LSR_THRE		0x20 /* Transmit-hold-register empty */
 #define UART_LSR_BI		0x10 /* Break interrupt indicator */
Signature · 1 line
1.7.0.4
#4 lore raw
In reply to Stephen Warren
Quoted 11 lines · Stephen Warren

8250.c needs a specific PORT_TEGRA type for two reasons:
* RTOIE bit needs to be set, but UUE is reserved, so split RTOIE handling out of PORT_XSCALE.
* A WAR is needed for break reception.

I'd like to get the first of these two patches merged into the tegra arch for-next branch, so that I can modify the board files to explicitly request the new port type rather than relying on auto-detection. As such, could you please create a branch for that/these changes, then merge it into tty-2.6.git, so that the same branch can be merged into Tegra's for-next branch. Thanks.

No, I really don't want to create a separate branch for just 2 patches, a whole 43 lines modified, that's pretty useless.

If Alan acks these, I'll be glad to take them through the serial tree as normal, or you can take them through the tegra tree.

Either way, they need Alan's review first.

thanks,

greg k-h

#6 lore raw
In reply to a message not in the archive

Greg KH wrote at Tuesday, May 17, 2011 1:39 PM:

Quoted 13 lines · Stephen Warren
Quoted 11 lines

8250.c needs a specific PORT_TEGRA type for two reasons:
* RTOIE bit needs to be set, but UUE is reserved, so split RTOIE handling out of PORT_XSCALE.
* A WAR is needed for break reception.

I'd like to get the first of these two patches merged into the tegra arch for-next branch, so that I can modify the board files to explicitly request the new port type rather than relying on auto-detection. As such, could you please create a branch for that/these changes, then merge it into tty-2.6.git, so that the same branch can be merged into Tegra's for-next branch. Thanks.

Quoted 5 lines

No, I really don't want to create a separate branch for just 2 patches, a whole 43 lines modified, that's pretty useless.

If Alan acks these, I'll be glad to take them through the serial tree as normal, or you can take them through the tegra tree.

Hmm. OK; I thought this was standard practice, based on my experiences with other subsystems.

I guess I'll opt for you just taking these through your tree then.

Thanks.

Signature · 1 line
nvpublic
#7 lore raw
In reply to Greg KH
Quoted 4 lines

If Alan acks these, I'll be glad to take them through the serial tree as normal, or you can take them through the tegra tree.

Either way, they need Alan's review first.

First one I am fine with. Second is more chip specific goop where we don't want it. However right at the moment there isn't a magic cure to that and the port->ops hackery I've been doing isn't done and it's not reasonable to hold this up waiting for a project with indeterminate completion date.

Ack #1

Can you add a

/*
* FIXME: This needs to become a port specific callback once we have a
* framework for this
*/

to #2 so it doesn't get forgotten in a future cleanup.

Alan