From patchwork Wed Jun 29 18:05:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 929972 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5TI68gF001286 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 29 Jun 2011 18:06:29 GMT Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qbz9D-00054q-Ov; Wed, 29 Jun 2011 18:05:59 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Qbz9D-00044K-B4; Wed, 29 Jun 2011 18:05:59 +0000 Received: from [2002:4e20:1eda::1] (helo=caramon.arm.linux.org.uk) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Qbz97-00043u-Vp for linux-arm-kernel@lists.infradead.org; Wed, 29 Jun 2011 18:05:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=Dp2sNUhDdqZzGzgyn0MUA+ixLYWTBq1RB2XD7nx5/jY=; b=WnzoZMzGJGGNPEVLLy0F9nuV2ZuhVhrhG5w/1LW/DdDyxnrcdxJGvA8mIAcctpIJQYcn2zdjgZy+CpOvR0rC1Axe4kX+YPInQ4xofjVS6zpl3EVsmErLERhD+2mTWyumIi64LYap8kZ6vwA8VvgLLn0wiWdd3fFV2t68ljXhWX4=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1Qbz8r-0004d2-8O; Wed, 29 Jun 2011 19:05:37 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.72) (envelope-from ) id 1Qbz8p-0004sR-PC; Wed, 29 Jun 2011 19:05:35 +0100 Date: Wed, 29 Jun 2011 19:05:35 +0100 From: Russell King - ARM Linux To: Kevin Hilman Subject: Re: [PATCH] OMAP3: run the ASM sleep code from DDR Message-ID: <20110629180535.GF23312@n2100.arm.linux.org.uk> References: <1309365623-14704-1-git-send-email-j-pihet@ti.com> <87mxh0tuk2.fsf@ti.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <87mxh0tuk2.fsf@ti.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110629_140555_381037_4BA54968 X-CRM114-Status: GOOD ( 20.71 ) X-Spam-Score: 1.2 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS Cc: linux-omap@vger.kernel.org, santosh.shilimkar@ti.com, jean.pihet@newoldbits.com, linux-arm-kernel@lists.infradead.org, Jean Pihet X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 29 Jun 2011 18:06:29 +0000 (UTC) On Wed, Jun 29, 2011 at 10:29:49AM -0700, Kevin Hilman wrote: > Russell, if you're OK with it, can you add it to your suspend branch for > the upcoming merge window? Yes - though I think we can go a little bit further - this patch is on top of my code so far, and is untested. There isn't a need for the saving of these registers to be in assembly because we can read them just as easily from C code. Comments? arch/arm/mach-omap2/pm.h | 2 +- arch/arm/mach-omap2/pm34xx.c | 19 +++++++++++++++++-- arch/arm/mach-omap2/sleep34xx.S | 12 ++---------- 3 files changed, 20 insertions(+), 13 deletions(-) Tested-by: Kevin Hilman diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h index 45bcfce..4984cca 100644 --- a/arch/arm/mach-omap2/pm.h +++ b/arch/arm/mach-omap2/pm.h @@ -92,7 +92,7 @@ extern void omap24xx_idle_loop_suspend(void); extern void omap24xx_cpu_suspend(u32 dll_ctrl, void __iomem *sdrc_dlla_ctrl, void __iomem *sdrc_power); -extern void omap34xx_cpu_suspend(u32 *addr, int save_state); +extern void omap34xx_cpu_suspend(int save_state); extern int save_secure_ram_context(u32 *addr); extern void omap3_save_scratchpad_contents(void); diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 3e9a13e..6366352 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -78,7 +78,7 @@ struct power_state { static LIST_HEAD(pwrst_list); -static void (*_omap_sram_idle)(u32 *addr, int save_state); +static void (*_omap_sram_idle)(int save_state); static int (*_omap_save_secure_sram)(u32 *addr); @@ -307,9 +307,22 @@ static irqreturn_t prcm_interrupt_handler (int irq, void *dev_id) return IRQ_HANDLED; } +static void omap34xx_save_context(u32 *save) +{ + u32 val; + + asm("mrc p15, 0, %0, c1, c0, 1" : "=r" (val)); + *save++ = 1; + *save++ = val; + + asm("mrc p15, 1, %0, c9, c0, 2" : "=r" (val)); + *save++ = 1; + *save++ = val; +} + static void omap34xx_do_sram_idle(unsigned long save_state) { - _omap_sram_idle(omap3_arm_context, save_state); + _omap_sram_idle(save_state); } void omap_sram_idle(void) @@ -412,6 +425,8 @@ void omap_sram_idle(void) * get saved. The rest is placed on the stack, and restored * from there before resuming. */ + if (save_state) + omap34xx_save_context(omap3_arm_context); if (save_state == 1 || save_state == 3) cpu_suspend(save_state, omap34xx_do_sram_idle); else diff --git a/arch/arm/mach-omap2/sleep34xx.S b/arch/arm/mach-omap2/sleep34xx.S index d18f52e..3335753 100644 --- a/arch/arm/mach-omap2/sleep34xx.S +++ b/arch/arm/mach-omap2/sleep34xx.S @@ -150,8 +150,7 @@ ENTRY(omap34xx_cpu_suspend) stmfd sp!, {r4 - r11, lr} @ save registers on stack /* - * r0 contains CPU context save/restore pointer in sdram - * r1 contains information about saving context: + * r0 contains information about saving context: * 0 - No context lost * 1 - Only L1 and logic lost * 2 - Only L2 lost (Even L1 is retained we clean it along with L2) @@ -159,18 +158,11 @@ ENTRY(omap34xx_cpu_suspend) */ /* Directly jump to WFI is the context save is not required */ - cmp r1, #0x0 + cmp r0, #0x0 beq omap3_do_wfi /* Otherwise fall through to the save context code */ save_context_wfi: - mov r8, r0 @ Store SDRAM address in r8 - mrc p15, 0, r5, c1, c0, 1 @ Read Auxiliary Control Register - mov r4, #0x1 @ Number of parameters for restore call - stmia r8!, {r4-r5} @ Push parameters for restore call - mrc p15, 1, r5, c9, c0, 2 @ Read L2 AUX ctrl register - stmia r8!, {r4-r5} @ Push parameters for restore call - /* * jump out to kernel flush routine * - reuse that code is better