From: Francesco VIRLINZI <francesco.virlinzi@st.com>
To: linux-sh@vger.kernel.org
Subject: Re: [PATCH] sh: hibernation support
Date: Tue, 10 Mar 2009 13:19:50 +0000 [thread overview]
Message-ID: <49B668F6.3020405@st.com> (raw)
In-Reply-To: <20090306064156.27281.35572.sendpatchset@rx1.opensource.se>
[-- Attachment #1: Type: text/plain, Size: 799 bytes --]
Hi Magnus
In the clock framework I would propose the attached solution
Regards
Francesco
Magnus Damm ha scritto:
> On Mon, Mar 9, 2009 at 7:03 PM, Francesco VIRLINZI
> <francesco.virlinzi@st.com> wrote:
>
>> I'm sorry if I'm stressing you but you will have similar problem also with
>> the clock framework.
>> A simple
>> - clk_get_rate(...)
>> could return a wrong value if in the previous session someone changed the
>> clock rate (from init value) and
>> you don't force again in the hw the resumed "clk->rate".
>>
>
> Yeah, the clock framework needs more work. =)
>
> / magnus
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sh" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
[-- Attachment #2: 0003-sh_clk-Added-clks-sysdevice-to-support-hibernation.patch --]
[-- Type: text/x-patch, Size: 2544 bytes --]
From 7d2249e98d304181b3deaa806ee475873e822328 Mon Sep 17 00:00:00 2001
From: Francesco Virlinzi <francesco.virlinzi@st.com>
Date: Tue, 10 Mar 2009 10:23:23 +0100
Subject: [PATCH] sh_clk: Added clks sysdevice to support hibernation
This patch adds the clk_sysdev device to restore the right clocks
setting after a resume from hibernation.
Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com>
---
arch/sh/kernel/cpu/clock.c | 62 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index dc53def..06fcbf0 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -20,6 +20,8 @@
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/kref.h>
+#include <linux/kobject.h>
+#include <linux/sysdev.h>
#include <linux/seq_file.h>
#include <linux/err.h>
#include <linux/platform_device.h>
@@ -382,6 +384,56 @@ static int show_clocks(char *buf, char **start, off_t off,
return p - buf;
}
+static int clks_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);
+ 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_resume(struct sys_device *dev)
+{
+ return clks_suspend(dev, PMSG_ON);
+}
+
+static struct sysdev_class clks_class = {
+ .kset.kobj.name = "clks",
+};
+
+static struct sysdev_driver clks_driver = {
+ .suspend = clks_suspend,
+ .resume = clks_resume,
+};
+
+static struct sys_device clks_dev = {
+ .cls = &clks_class,
+};
+
int __init clk_init(void)
{
int i, ret = 0;
@@ -404,6 +456,16 @@ int __init clk_init(void)
return ret;
}
+static int __init clk_sysdev_init(void)
+{
+
+ sysdev_class_register(&clks_class);
+ sysdev_driver_register(&clks_class, &clks_driver);
+ sysdev_register(&clks_dev);
+ return 0;
+}
+subsys_initcall(clk_sysdev_init);
+
static int __init clk_proc_init(void)
{
struct proc_dir_entry *p;
--
1.5.6.6
next prev parent reply other threads:[~2009-03-10 13:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-06 6:41 [PATCH] sh: hibernation support Magnus Damm
2009-03-06 6:57 ` Paul Mundt
2009-03-06 7:06 ` Francesco VIRLINZI
2009-03-06 9:53 ` Magnus Damm
2009-03-06 10:05 ` Francesco VIRLINZI
2009-03-06 10:17 ` Francesco VIRLINZI
2009-03-06 17:29 ` Jean-Christophe PLAGNIOL-VILLARD
2009-03-07 6:12 ` Paul Mundt
2009-03-07 6:20 ` Paul Mundt
2009-03-09 9:12 ` Francesco VIRLINZI
2009-03-09 9:16 ` Magnus Damm
2009-03-09 9:27 ` Francesco VIRLINZI
2009-03-09 10:03 ` Francesco VIRLINZI
2009-03-09 10:57 ` Magnus Damm
2009-03-09 17:35 ` Paul Mundt
2009-03-10 13:19 ` Francesco VIRLINZI [this message]
2009-03-11 4:26 ` Magnus Damm
2009-03-11 6:50 ` Francesco VIRLINZI
2009-03-11 7:29 ` Magnus Damm
2009-03-11 13:20 ` Francesco VIRLINZI
2009-03-12 5:47 ` Magnus Damm
2009-03-12 8:54 ` Francesco VIRLINZI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49B668F6.3020405@st.com \
--to=francesco.virlinzi@st.com \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox