diff mbox

[v3,2/2] omap: serial: fix non-empty uart fifo read abort

Message ID 1258732956-18799-3-git-send-email-vikram.pandita@ti.com (mailing list archive)
State Superseded, archived
Headers show

Commit Message

vikram pandita Nov. 20, 2009, 4:02 p.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c
index 2e17b57..600e4d2 100644
--- a/arch/arm/mach-omap2/serial.c
+++ b/arch/arm/mach-omap2/serial.c
@@ -572,6 +572,23 @@  static struct omap_uart_state omap_uart[] = {
 #endif
 };
 
+/*
+ * Override the default 8250 read handler: mem_serial_in()
+ * Empty RX fifo read causes an abort on omap3630 and omap4
+ * This function makes sure that an empty rx fifo is not read on these silicons
+ * (OMAP1/2/3 are not affected)
+ */
+static unsigned int serial_in_override(struct uart_port *up, int offset)
+{
+	if (UART_RX == offset) {
+		unsigned int lsr;
+		lsr = serial_read_reg(omap_uart[up->line].p, UART_LSR);
+		if (!(lsr & UART_LSR_DR))
+			return -EPERM;
+	}
+	return serial_read_reg(omap_uart[up->line].p, offset);
+}
+
 void __init omap_serial_early_init(void)
 {
 	int i;
@@ -627,6 +644,10 @@  void __init omap_serial_early_init(void)
 		if (cpu_is_omap44xx())
 			p->irq += 32;
 
+		/* Do not read empty UART fifo on omap3630/omap4 */
+		if (omap3_has_uart_no_empty_fifo_read())
+			p->serial_in = serial_in_override;
+
 		omap_uart_enable_clocks(uart);
 	}
 }