From patchwork Thu Dec 3 23:29:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vikram pandita X-Patchwork-Id: 64716 X-Patchwork-Delegate: tony@atomide.com 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 nB3NSuZo010161 for ; Thu, 3 Dec 2009 23:28:56 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751906AbZLCX2s (ORCPT ); Thu, 3 Dec 2009 18:28:48 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751575AbZLCX2s (ORCPT ); Thu, 3 Dec 2009 18:28:48 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:34173 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751304AbZLCX2r (ORCPT ); Thu, 3 Dec 2009 18:28:47 -0500 Received: from dlep36.itg.ti.com ([157.170.170.91]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id nB3NSsnS017661 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 3 Dec 2009 17:28:54 -0600 Received: from legion.dal.design.ti.com (localhost [127.0.0.1]) by dlep36.itg.ti.com (8.13.8/8.13.8) with ESMTP id nB3NSohq003843; Thu, 3 Dec 2009 17:28:50 -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 nB3NSoZ00691; Thu, 3 Dec 2009 17:28:50 -0600 (CST) Received: from vip-tid (localhost.localdomain [127.0.0.1]) by vip-tid (Postfix) with ESMTP id 2C48629C8FB; Thu, 3 Dec 2009 17:29:48 -0600 (CST) Received: (from vikram@localhost) by vip-tid (8.14.3/8.14.3/Submit) id nB3NTmOf011043; Thu, 3 Dec 2009 17:29:48 -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 , "Cousson, Benoit" Subject: [PATCH v2] omap: serial: fix non-empty uart fifo read abort Date: Thu, 3 Dec 2009 17:29:46 -0600 Message-Id: <1259882986-11009-1-git-send-email-vikram.pandita@ti.com> X-Mailer: git-send-email 1.6.6.rc0.66.ge160d 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..bd646a2 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -33,6 +33,7 @@ #include "pm.h" #include "prm-regbits-34xx.h" +#define UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV 0x52 #define UART_OMAP_WER 0x17 /* Wake-up enable register */ #define DEFAULT_TIMEOUT (5 * HZ) @@ -572,6 +573,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; @@ -650,5 +668,16 @@ void __init omap_serial_init(void) device_init_wakeup(dev, true); DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout); } + +#ifdef CONFIG_ARCH_OMAP4 + /* Never read empty UART fifo on omap4 */ + p->serial_in = serial_in_override; +#else + /* OMAP2/3 */ + /* Never read empty UART fifo on UARTs with IP rev >=0x52 */ + if ((serial_read_reg(uart->p, UART_OMAP_MVER) & 0xFF) + >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV) + uart->p->serial_in = serial_in_override; +#endif } }