From patchwork Mon Jan 24 08:51:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Santosh Shilimkar X-Patchwork-Id: 500531 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0OJh2Un026265 for ; Mon, 24 Jan 2011 19:43:08 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751360Ab1AXIvt (ORCPT ); Mon, 24 Jan 2011 03:51:49 -0500 Received: from devils.ext.ti.com ([198.47.26.153]:58013 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751307Ab1AXIvs (ORCPT ); Mon, 24 Jan 2011 03:51:48 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by devils.ext.ti.com (8.13.7/8.13.7) with ESMTP id p0O8pSoa024991 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 24 Jan 2011 02:51:31 -0600 Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p0O8pNPI016796; Mon, 24 Jan 2011 14:21:24 +0530 (IST) Received: from linfarm476.india.ti.com (localhost [127.0.0.1]) by linfarm476.india.ti.com (8.12.11/8.12.11) with ESMTP id p0O8pNvq015337; Mon, 24 Jan 2011 14:21:23 +0530 Received: (from a0393909@localhost) by linfarm476.india.ti.com (8.12.11/8.12.11/Submit) id p0O8pN5U015335; Mon, 24 Jan 2011 14:21:23 +0530 From: Santosh Shilimkar To: linux-arm-kernel@lists.infradead.org Cc: linux-omap@vger.kernel.org, ccross@android.com, catalin.marinas@arm.com, linux@arm.linux.org.uk, linus.ml.walleij@gmail.com, Santosh Shilimkar , Russell King Subject: [PATCH 3/5] ARM: twd: Add context save restore support Date: Mon, 24 Jan 2011 14:21:17 +0530 Message-Id: <1295859080-15259-4-git-send-email-santosh.shilimkar@ti.com> X-Mailer: git-send-email 1.5.6.6 In-Reply-To: <1295859080-15259-1-git-send-email-santosh.shilimkar@ti.com> References: <1295859080-15259-1-git-send-email-santosh.shilimkar@ti.com> 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.6 (demeter1.kernel.org [140.211.167.41]); Mon, 24 Jan 2011 19:43:08 +0000 (UTC) diff --git a/arch/arm/include/asm/localtimer.h b/arch/arm/include/asm/localtimer.h index 6bc63ab..6753754 100644 --- a/arch/arm/include/asm/localtimer.h +++ b/arch/arm/include/asm/localtimer.h @@ -31,6 +31,9 @@ asmlinkage void do_local_timer(struct pt_regs *); #define local_timer_ack() twd_timer_ack() +#define local_timer_save(cpu) twd_context_save(cpu); +#define local_timer_restore(cpu) twd_context_save(cpu); + #else /* @@ -46,6 +49,16 @@ int local_timer_ack(void); */ void local_timer_setup(struct clock_event_device *); +/* + * Save local timer register context + */ +void local_timer_save(unsigned int cpu); + +/* + * Restore local timer register context + */ +void local_timer_restoree(unsigned int cpu); + #endif #endif diff --git a/arch/arm/include/asm/smp_twd.h b/arch/arm/include/asm/smp_twd.h index fed9981..7828f29 100644 --- a/arch/arm/include/asm/smp_twd.h +++ b/arch/arm/include/asm/smp_twd.h @@ -24,5 +24,7 @@ extern void __iomem *twd_base; int twd_timer_ack(void); void twd_timer_setup(struct clock_event_device *); +void twd_context_save(unsigned int cpu); +void twd_context_restore(unsigned int cpu); #endif diff --git a/arch/arm/kernel/smp_twd.c b/arch/arm/kernel/smp_twd.c index fd91566..f3098e4 100644 --- a/arch/arm/kernel/smp_twd.c +++ b/arch/arm/kernel/smp_twd.c @@ -24,6 +24,12 @@ /* set up by the platform code */ void __iomem *twd_base; +/* Timer context to be saved in low power modes */ +struct twd_registers { + unsigned long timer_ctrl; + unsigned long timer_load; +}; +static DEFINE_PER_CPU(struct twd_registers, twd_context); static unsigned long twd_timer_rate; static void twd_set_mode(enum clock_event_mode mode, @@ -145,3 +151,21 @@ void __cpuinit twd_timer_setup(struct clock_event_device *clk) clockevents_register_device(clk); } + +/* Low power context save */ +void twd_context_save(unsigned int cpu) +{ + struct twd_registers *regs = &per_cpu(twd_context, cpu); + + regs->timer_ctrl = __raw_readl(twd_base + TWD_TIMER_CONTROL); + regs->timer_load = __raw_readl(twd_base + TWD_TIMER_LOAD); +} + +/* Low power context restore */ +void twd_context_restore(unsigned int cpu) +{ + struct twd_registers *regs = &per_cpu(twd_context, cpu); + + __raw_writel(regs->timer_load, twd_base + TWD_TIMER_LOAD); + __raw_writel(regs->timer_ctrl, twd_base + TWD_TIMER_CONTROL); +}