tty/serial: Add explicit PORT_TEGRA type
Subsystems (3)
PATCH v2 1/2 tty/serial: Add explicit PORT_TEGRA type
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.
--- 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 2/2 tty/serial: Fix break handling for PORT_TEGRA
In reply to a message not in the archiveWhen 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.
v2: Added FIXME comment to clear_rx_fifo
--- drivers/tty/serial/8250.c | 28 ++++++++++++++++++++++++++++ include/linux/serial_reg.h | 1 + 2 files changed, 29 insertions(+), 0 deletions(-)
drivers/tty/serial/8250.c +28 -0
@@ -1433,6 +1433,27 @@ static void serial8250_enable_ms(struct uart_port *port)serial_out (up,UART_IER , up->ier); } +/* +* Clear the Tegra rx fifo after a break +* +* FIXME: This needs to become a port specific callback once we have a +* framework for this +*/ +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 +1489,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
@@ -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
Alan Cox
Acked-byRe: [PATCH v2 2/2] tty/serial: Fix break handling for PORT_TEGRA
In reply to a message not in the archiveQuoted 5 lines · On Tue, 17 May 2011 16:12:37 -0600 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_SYSRQto work on Tegra's UARTs.v2: Added FIXME comment to
clear_rx_fifo
--
"I'm sure there were advantages to getting older but I've forgotten them"