From patchwork Tue Feb 2 11:30:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 76343 X-Patchwork-Delegate: khilman@deeprootsystems.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o129fDqT013741 for ; Tue, 2 Feb 2010 09:41:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755128Ab0BBJlL (ORCPT ); Tue, 2 Feb 2010 04:41:11 -0500 Received: from smtp.nokia.com ([192.100.105.134]:55821 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755172Ab0BBJlJ (ORCPT ); Tue, 2 Feb 2010 04:41:09 -0500 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o129ciWP016351 for ; Tue, 2 Feb 2010 03:41:08 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 2 Feb 2010 11:41:02 +0200 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 2 Feb 2010 11:40:54 +0200 Received: from localhost.localdomain (sokoban.nmp.nokia.com [172.22.215.13]) by mgw-sa02.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id o129erTd021611 for ; Tue, 2 Feb 2010 11:40:53 +0200 From: Tero Kristo To: linux-omap@vger.kernel.org Subject: [PATCH] OMAP3: Serial: Improved sleep logic Date: Tue, 2 Feb 2010 13:30:24 +0200 Message-Id: <1265110224-29473-1-git-send-email-tero.kristo@nokia.com> X-Mailer: git-send-email 1.5.4.3 In-Reply-To: <> References: <> X-OriginalArrivalTime: 02 Feb 2010 09:40:54.0812 (UTC) FILETIME=[D0BC3DC0:01CAA3EB] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 02 Feb 2010 09:41:13 +0000 (UTC) diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index 777e802..e11dfe9 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -317,7 +317,8 @@ static void omap_uart_allow_sleep(struct omap_uart_state *uart) if (!uart->clocked) return; - omap_uart_smart_idle_enable(uart, 1); + if (serial_read_reg(uart->p, UART_LSR) & UART_LSR_TEMT) + omap_uart_smart_idle_enable(uart, 1); uart->can_sleep = 1; del_timer(&uart->timer); } @@ -335,7 +336,11 @@ void omap_uart_prepare_idle(int num) list_for_each_entry(uart, &uart_list, node) { if (num == uart->num && uart->can_sleep) { - omap_uart_disable_clocks(uart); + if (serial_read_reg(uart->p, UART_LSR) & + UART_LSR_TEMT) + omap_uart_disable_clocks(uart); + else + omap_uart_smart_idle_enable(uart, 0); return; } } @@ -407,8 +412,14 @@ int omap_uart_can_sleep(void) static irqreturn_t omap_uart_interrupt(int irq, void *dev_id) { struct omap_uart_state *uart = dev_id; + u8 lsr; - omap_uart_block_sleep(uart); + lsr = serial_read_reg(uart->p, UART_LSR); + /* Check for receive interrupt */ + if (lsr & UART_LSR_DR) + omap_uart_block_sleep(uart); + if (lsr & UART_LSR_TEMT && uart->can_sleep) + omap_uart_smart_idle_enable(uart, 1); return IRQ_NONE; }