-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serial: add irq handler for Freescale 16550 errata.
Sending a break on the SOC UARTs found in some MPC83xx/85xx/86xx chips seems to cause a short lived IRQ storm (/proc/interrupts typically shows somewhere between 300 and 1500 events). Unfortunately this renders SysRQ over the serial console completely inoperable. The suggested workaround in the errata is to read the Rx register, wait one character period, and then read the Rx register again. We achieve this by tracking the old LSR value, and on the subsequent interrupt event after a break, we don't read LSR, instead we just read the RBR again and return immediately. The "fsl,ns16550" is used in the compatible field of the serial device to mark UARTs known to have this issue. Thanks to Scott Wood for providing the errata data which led to a much cleaner fix. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
- Loading branch information
Paul Gortmaker
authored and
Greg Kroah-Hartman
committed
Dec 10, 2011
1 parent
86b2119
commit 9deaa53
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#include <linux/serial_reg.h> | ||
#include <linux/serial_8250.h> | ||
|
||
#include "8250.h" | ||
|
||
/* | ||
* Freescale 16550 UART "driver", Copyright (C) 2011 Paul Gortmaker. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2 as | ||
* published by the Free Software Foundation. | ||
* | ||
* This isn't a full driver; it just provides an alternate IRQ | ||
* handler to deal with an errata. Everything else is just | ||
* using the bog standard 8250 support. | ||
* | ||
* We follow code flow of serial8250_default_handle_irq() but add | ||
* a check for a break and insert a dummy read on the Rx for the | ||
* immediately following IRQ event. | ||
* | ||
* We re-use the already existing "bug handling" lsr_saved_flags | ||
* field to carry the "what we just did" information from the one | ||
* IRQ event to the next one. | ||
*/ | ||
|
||
int fsl8250_handle_irq(struct uart_port *port) | ||
{ | ||
unsigned char lsr, orig_lsr; | ||
unsigned long flags; | ||
unsigned int iir; | ||
struct uart_8250_port *up = | ||
container_of(port, struct uart_8250_port, port); | ||
|
||
spin_lock_irqsave(&up->port.lock, flags); | ||
|
||
iir = port->serial_in(port, UART_IIR); | ||
if (iir & UART_IIR_NO_INT) { | ||
spin_unlock_irqrestore(&up->port.lock, flags); | ||
return 0; | ||
} | ||
|
||
/* This is the WAR; if last event was BRK, then read and return */ | ||
if (unlikely(up->lsr_saved_flags & UART_LSR_BI)) { | ||
up->lsr_saved_flags &= ~UART_LSR_BI; | ||
port->serial_in(port, UART_RX); | ||
spin_unlock_irqrestore(&up->port.lock, flags); | ||
return 1; | ||
} | ||
|
||
lsr = orig_lsr = up->port.serial_in(&up->port, UART_LSR); | ||
|
||
if (lsr & (UART_LSR_DR | UART_LSR_BI)) | ||
lsr = serial8250_rx_chars(up, lsr); | ||
|
||
serial8250_modem_status(up); | ||
|
||
if (lsr & UART_LSR_THRE) | ||
serial8250_tx_chars(up); | ||
|
||
up->lsr_saved_flags = orig_lsr; | ||
spin_unlock_irqrestore(&up->port.lock, flags); | ||
return 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters