From patchwork Tue Nov 17 23:39:11 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vikram pandita X-Patchwork-Id: 60854 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAHNdbAL024760 for ; Tue, 17 Nov 2009 23:39:37 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756214AbZKQXj3 (ORCPT ); Tue, 17 Nov 2009 18:39:29 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756213AbZKQXj3 (ORCPT ); Tue, 17 Nov 2009 18:39:29 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:58645 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756085AbZKQXj2 (ORCPT ); Tue, 17 Nov 2009 18:39:28 -0500 Received: from dlep34.itg.ti.com ([157.170.170.115]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id nAHNdRH2021649 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 17 Nov 2009 17:39:27 -0600 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep34.itg.ti.com (8.13.7/8.13.7) with ESMTP id nAHNdPeK006748; Tue, 17 Nov 2009 17:39:25 -0600 (CST) Received: from vip-tid (lta0307903-128247075087.am.dhcp.ti.com [128.247.75.87]) by legion.dal.design.ti.com (8.11.7p1+Sun/8.11.7) with ESMTP id nAHNdOZ01505; Tue, 17 Nov 2009 17:39:24 -0600 (CST) Received: from vip-tid (localhost.localdomain [127.0.0.1]) by vip-tid (Postfix) with ESMTP id BB1FA29CB76; Tue, 17 Nov 2009 17:39:13 -0600 (CST) Received: (from vikram@localhost) by vip-tid (8.14.3/8.14.3/Submit) id nAHNdD4H030898; Tue, 17 Nov 2009 17:39:13 -0600 X-Authentication-Warning: vip-tid: vikram set sender to vikram.pandita@ti.com using -f From: Vikram Pandita To: linux-omap@vger.kernel.org Cc: Vikram Pandita , Alan Cox Subject: [PATCH v2 1/1] omap: serial: fix non-empty uart fifo read abort Date: Tue, 17 Nov 2009 17:39:11 -0600 Message-Id: <1258501151-30866-1-git-send-email-vikram.pandita@ti.com> X-Mailer: git-send-email 1.6.5.1.69.g36942 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index 2e17b57..362cb82 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -71,6 +71,30 @@ struct omap_uart_state { static LIST_HEAD(uart_list); +static struct omap_uart_state omap_uart[]; +static inline unsigned int serial_read_reg(struct plat_serial8250_port *, int); + +/* + * Overrigt 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_8250(struct uart_port *up, int offset) +{ + /* Do not read empty UART fifo on omap3630/44xx */ + if ((UART_RX == offset) && + (cpu_is_omap3630() || cpu_is_omap44xx())) { + + unsigned int lsr; + + lsr = serial_read_reg(omap_uart[up->line].p, UART_LSR); + if (!(lsr & UART_LSR_DR)) + return 0; + } + return serial_read_reg(omap_uart[up->line].p, offset); +} + static struct plat_serial8250_port serial_platform_data0[] = { { .mapbase = OMAP_UART1_BASE, @@ -79,6 +103,7 @@ static struct plat_serial8250_port serial_platform_data0[] = { .iotype = UPIO_MEM, .regshift = 2, .uartclk = OMAP24XX_BASE_BAUD * 16, + .serial_in = serial_in_8250, }, { .flags = 0 } @@ -92,6 +117,7 @@ static struct plat_serial8250_port serial_platform_data1[] = { .iotype = UPIO_MEM, .regshift = 2, .uartclk = OMAP24XX_BASE_BAUD * 16, + .serial_in = serial_in_8250, }, { .flags = 0 } @@ -105,6 +131,7 @@ static struct plat_serial8250_port serial_platform_data2[] = { .iotype = UPIO_MEM, .regshift = 2, .uartclk = OMAP24XX_BASE_BAUD * 16, + .serial_in = serial_in_8250, }, { .flags = 0 } @@ -119,6 +146,7 @@ static struct plat_serial8250_port serial_platform_data3[] = { .iotype = UPIO_MEM, .regshift = 2, .uartclk = OMAP24XX_BASE_BAUD * 16, + .serial_in = serial_in_8250, }, { .flags = 0 }