From patchwork Thu Feb 10 16:02:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sanjeev Premi X-Patchwork-Id: 546791 X-Patchwork-Delegate: paul@pwsan.com 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 p1AG2RSR018967 for ; Thu, 10 Feb 2011 16:02:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756370Ab1BJQC0 (ORCPT ); Thu, 10 Feb 2011 11:02:26 -0500 Received: from bear.ext.ti.com ([192.94.94.41]:33351 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756354Ab1BJQC0 (ORCPT ); Thu, 10 Feb 2011 11:02:26 -0500 Received: from dbdp31.itg.ti.com ([172.24.170.98]) by bear.ext.ti.com (8.13.7/8.13.7) with ESMTP id p1AG2K4Y008318 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 10 Feb 2011 10:02:22 -0600 Received: from psplinux050.india.ti.com (localhost [127.0.0.1]) by dbdp31.itg.ti.com (8.13.8/8.13.8) with ESMTP id p1AG2Br4021059; Thu, 10 Feb 2011 21:32:19 +0530 (IST) From: Sanjeev Premi To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: Sanjeev Premi Subject: [PATCH 1/1] omap3: Save and restore CM_AUTOIDLE_PLL across off mode Date: Thu, 10 Feb 2011 21:32:04 +0530 Message-Id: <1297353724-11665-2-git-send-email-premi@ti.com> X-Mailer: git-send-email 1.7.2.2 In-Reply-To: <1297353724-11665-1-git-send-email-premi@ti.com> References: <1297353724-11665-1-git-send-email-premi@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]); Thu, 10 Feb 2011 16:02:28 +0000 (UTC) diff --git a/arch/arm/mach-omap2/cm2xxx_3xxx.c b/arch/arm/mach-omap2/cm2xxx_3xxx.c index 96954aa..a775d8a 100644 --- a/arch/arm/mach-omap2/cm2xxx_3xxx.c +++ b/arch/arm/mach-omap2/cm2xxx_3xxx.c @@ -178,6 +178,7 @@ struct omap3_cm_regs { u32 per_cm_clksel; u32 emu_cm_clksel; u32 emu_cm_clkstctrl; + u32 pll_cm_autoidle; u32 pll_cm_autoidle2; u32 pll_cm_clksel4; u32 pll_cm_clksel5; @@ -250,6 +251,8 @@ void omap3_cm_save_context(void) omap2_cm_read_mod_reg(OMAP3430_EMU_MOD, CM_CLKSEL1); cm_context.emu_cm_clkstctrl = omap2_cm_read_mod_reg(OMAP3430_EMU_MOD, OMAP2_CM_CLKSTCTRL); + cm_context.pll_cm_autoidle = + omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE); cm_context.pll_cm_autoidle2 = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE2); cm_context.pll_cm_clksel4 = @@ -468,4 +471,14 @@ void omap3_cm_restore_context(void) omap2_cm_write_mod_reg(cm_context.cm_clkout_ctrl, OMAP3430_CCR_MOD, OMAP3_CM_CLKOUT_CTRL_OFFSET); } + + +/** + * Returns the value corresponding to CM_AUTOIDLE_PLL from the most recent + * context saved before entering the OFF mode. + */ +u32 stored_cm_autoidle_pll(void) +{ + return cm_context.pll_cm_autoidle; +} #endif diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c index 8bb85fb..25bd230 100644 --- a/arch/arm/mach-omap2/pm34xx.c +++ b/arch/arm/mach-omap2/pm34xx.c @@ -91,6 +91,8 @@ static struct powerdomain *mpu_pwrdm, *neon_pwrdm; static struct powerdomain *core_pwrdm, *per_pwrdm; static struct powerdomain *cam_pwrdm; +extern u32 stored_cm_autoidle_pll(void); + static inline void omap3_per_save_context(void) { omap_gpio_save_context(); @@ -163,6 +165,25 @@ static void omap3_core_restore_context(void) omap_dma_global_context_restore(); } +/** + * Restore the contents of CM_AUTOIDLE_PLL register. + * + * The implementation below restores AUTO_CORE_DPLL as 'good' redundancy. + */ +static void pll_mod_restore_autoidle(void) +{ + u32 ctx = stored_cm_autoidle_pll(); + u32 val = omap2_cm_read_mod_reg(PLL_MOD, CM_AUTOIDLE); + + if (ctx & OMAP3430_AUTO_CORE_DPLL_MASK) + val |= ctx & OMAP3430_AUTO_CORE_DPLL_MASK; + + if (ctx & OMAP3430_AUTO_PERIPH_DPLL_MASK) + val |= ctx & OMAP3430_AUTO_PERIPH_DPLL_MASK; + + omap2_cm_write_mod_reg(val, PLL_MOD, CM_AUTOIDLE); +} + /* * FIXME: This function should be called before entering off-mode after * OMAP3 secure services have been accessed. Currently it is only called @@ -488,8 +509,10 @@ void omap_sram_idle(void) if (per_next_state < PWRDM_POWER_ON) { per_prev_state = pwrdm_read_prev_pwrst(per_pwrdm); omap2_gpio_resume_after_idle(); - if (per_prev_state == PWRDM_POWER_OFF) + if (per_prev_state == PWRDM_POWER_OFF) { omap3_per_restore_context(); + pll_mod_restore_autoidle(); + } omap_uart_resume_idle(2); omap_uart_resume_idle(3); }