From patchwork Wed Mar 11 07:42:05 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Francesco VIRLINZI X-Patchwork-Id: 11074 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 n2B7f34A004312 for ; Wed, 11 Mar 2009 07:42:12 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750835AbZCKHmN (ORCPT ); Wed, 11 Mar 2009 03:42:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751260AbZCKHmN (ORCPT ); Wed, 11 Mar 2009 03:42:13 -0400 Received: from eu1sys200aog118.obsmtp.com ([207.126.144.145]:55506 "EHLO eu1sys200aog118.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbZCKHmM (ORCPT ); Wed, 11 Mar 2009 03:42:12 -0400 Received: from source ([164.129.1.35]) (using TLSv1) by eu1sys200aob118.postini.com ([207.126.147.11]) with SMTP ID DSNKSbdrUaF5uf3qgCPM7xtFYpPyi6D/m/qS@postini.com; Wed, 11 Mar 2009 07:42:10 UTC Received: from zeta.dmz-eu.st.com (ns2.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 659AADA88 for ; Wed, 11 Mar 2009 07:41:12 +0000 (GMT) Received: from mail1.ctn.st.com (mail1.ctn.st.com [164.130.116.128]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B79F04BE84 for ; Wed, 11 Mar 2009 07:42:07 +0000 (GMT) Received: from [10.52.139.41] (mdt-dhcp41.ctn.st.com [10.52.139.41]) by mail1.ctn.st.com (MOS 3.8.7a) with ESMTP id CZV34868 (AUTH virlinzi); Wed, 11 Mar 2009 08:42:07 +0100 (CET) Message-ID: <49B76B4D.60104@st.com> Date: Wed, 11 Mar 2009 08:42:05 +0100 From: Francesco VIRLINZI User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: linux-sh@vger.kernel.org Subject: [PATCH] sh_clk: Added resume from hibernation support in the clk framework v2 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org From da85a159444a638aef1b1d83d9d786265febf8e2 Mon Sep 17 00:00:00 2001 From: Francesco Virlinzi Date: Wed, 11 Mar 2009 08:37:20 +0100 Subject: [PATCH] sh_clk: Added hibernation support in the clock framework This patch adds the hibernation support in the clock framework Signed-off-by: Francesco Virlinzi --- arch/sh/kernel/cpu/clock.c | 65 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0 deletions(-) diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c index 332a179..7ed0e45 100644 --- a/arch/sh/kernel/cpu/clock.c +++ b/arch/sh/kernel/cpu/clock.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include #include #include @@ -358,6 +360,69 @@ static int show_clocks(char *buf, char **start, off_t off, return p - buf; } +#ifdef CONFIG_PM +static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state) +{ + static pm_message_t prev_state; + struct clk *clkp; + + switch (state.event) { + case PM_EVENT_ON: + /* Resumeing from hibernation */ + if (prev_state.event == PM_EVENT_FREEZE) { + list_for_each_entry(clkp, &clock_list, node) + if (likely(clkp->ops)) { + if (likely(clkp->ops->set_parent)) + clkp->ops->set_parent(clkp, + clkp->parent); + if (likely(clkp->ops->set_rate)) + clkp->ops->set_rate(clkp, + clkp->rate, NO_CHANGE); + else if (likely(clkp->ops->recalc)) + clkp->ops->recalc(clkp); + } + } + break; + case PM_EVENT_FREEZE: + break; + case PM_EVENT_SUSPEND: + break; + } + + prev_state = state; + return 0; +} + +static int clks_sysdev_resume(struct sys_device *dev) +{ + return clks_sysdev_suspend(dev, PMSG_ON); +} + +static struct sysdev_class clks_sysdev_class = { + .name = "clks", +}; + +static struct sysdev_driver clks_sysdev_driver = { + .suspend = clks_sysdev_suspend, + .resume = clks_sysdev_resume, +}; + +static struct sys_device clks_sysdev_dev = { + .cls = &clks_sysdev_class, +}; + +static int __init clk_sysdev_init(void) +{ + + sysdev_class_register(&clks_sysdev_class); + sysdev_driver_register(&clks_sysdev_class, &clks_sysdev_driver); + sysdev_register(&clks_sysdev_dev); + return 0; +} + +subsys_initcall(clk_sysdev_init); +#endif + int __init clk_init(void) { int i, ret = 0; -- 1.5.6.6