All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it
@ 2011-05-17 19:27 Stephen Warren
       [not found] ` <1305660466-4704-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-05-17 19:38 ` [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it Greg KH
  0 siblings, 2 replies; 6+ messages in thread
From: Stephen Warren @ 2011-05-17 19:27 UTC (permalink / raw)
  To: gregkh-l3A5Bk7waGM
  Cc: ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, 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.

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(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] tty/serial: Add explicit PORT_TEGRA type
       [not found] ` <1305660466-4704-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-05-17 19:27   ` Stephen Warren
  2011-05-17 19:27   ` [PATCH 2/2] tty/serial: Fix break handling for PORT_TEGRA Stephen Warren
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2011-05-17 19:27 UTC (permalink / raw)
  To: gregkh-l3A5Bk7waGM
  Cc: ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren

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.

Based-on-code-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
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(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index 54482d7..a5e290d 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -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);
 
diff --git a/drivers/tty/serial/8250.h b/drivers/tty/serial/8250.h
index d13b586..6edf4a6 100644
--- a/drivers/tty/serial/8250.h
+++ b/drivers/tty/serial/8250.h
@@ -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 */
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 95d479b..a5c3114 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -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
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
index 3ecb71a..5f66e84 100644
--- a/include/linux/serial_reg.h
+++ b/include/linux/serial_reg.h
@@ -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
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] tty/serial: Fix break handling for PORT_TEGRA
       [not found] ` <1305660466-4704-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
  2011-05-17 19:27   ` [PATCH 1/2] tty/serial: Add explicit PORT_TEGRA type Stephen Warren
@ 2011-05-17 19:27   ` Stephen Warren
  1 sibling, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2011-05-17 19:27 UTC (permalink / raw)
  To: gregkh-l3A5Bk7waGM
  Cc: ldewangan-DDmLM1+adcrQT0dZR+AlfA,
	linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA, Stephen Warren

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.

Originally-by: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Cc: Laxman Dewangan <ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Stephen Warren <swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
---
 drivers/tty/serial/8250.c  |   23 +++++++++++++++++++++++
 include/linux/serial_reg.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/serial/8250.c b/drivers/tty/serial/8250.c
index a5e290d..699323f 100644
--- a/drivers/tty/serial/8250.c
+++ b/drivers/tty/serial/8250.c
@@ -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
diff --git a/include/linux/serial_reg.h b/include/linux/serial_reg.h
index 5f66e84..c75bda3 100644
--- a/include/linux/serial_reg.h
+++ b/include/linux/serial_reg.h
@@ -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 */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it
  2011-05-17 19:27 [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it Stephen Warren
       [not found] ` <1305660466-4704-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
@ 2011-05-17 19:38 ` Greg KH
       [not found]   ` <20110517193836.GA6912-l3A5Bk7waGM@public.gmane.org>
  2011-05-17 21:58   ` Alan Cox
  1 sibling, 2 replies; 6+ messages in thread
From: Greg KH @ 2011-05-17 19:38 UTC (permalink / raw)
  To: Stephen Warren; +Cc: ldewangan, linux-serial, linux-tegra

On Tue, May 17, 2011 at 01:27:44PM -0600, Stephen Warren wrote:
> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it
       [not found]   ` <20110517193836.GA6912-l3A5Bk7waGM@public.gmane.org>
@ 2011-05-17 19:44     ` Stephen Warren
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Warren @ 2011-05-17 19:44 UTC (permalink / raw)
  To: Greg KH
  Cc: Laxman Dewangan, linux-serial-u79uwXL29TY76Z2rM5mHXA,
	linux-tegra-u79uwXL29TY76Z2rM5mHXA

Greg KH wrote at Tuesday, May 17, 2011 1:39 PM:
> On Tue, May 17, 2011 at 01:27:44PM -0600, Stephen Warren wrote:
> > 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.

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.

-- 
nvpublic

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it
  2011-05-17 19:38 ` [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it Greg KH
       [not found]   ` <20110517193836.GA6912-l3A5Bk7waGM@public.gmane.org>
@ 2011-05-17 21:58   ` Alan Cox
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Cox @ 2011-05-17 21:58 UTC (permalink / raw)
  To: Greg KH; +Cc: Stephen Warren, ldewangan, linux-serial, linux-tegra

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-17 21:58 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-17 19:27 [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it Stephen Warren
     [not found] ` <1305660466-4704-1-git-send-email-swarren-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2011-05-17 19:27   ` [PATCH 1/2] tty/serial: Add explicit PORT_TEGRA type Stephen Warren
2011-05-17 19:27   ` [PATCH 2/2] tty/serial: Fix break handling for PORT_TEGRA Stephen Warren
2011-05-17 19:38 ` [PATCH 0/2] tty/serial: Add PORT_TEGRA, fix break handling for it Greg KH
     [not found]   ` <20110517193836.GA6912-l3A5Bk7waGM@public.gmane.org>
2011-05-17 19:44     ` Stephen Warren
2011-05-17 21:58   ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.