Skip to content

Commit 4a55026

Browse files
FrancescoVirlinzipmundt
authored andcommitted
sh: clkfwk: Add resume from hibernation support.
This patch adds PM support to the clock framework. With this, resume from hibernation is properly supported. Signed-off-by: Francesco Virlinzi <francesco.virlinzi@st.com> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent d680c76 commit 4a55026

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

‎arch/sh/kernel/cpu/clock.c‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <linux/mutex.h>
2121
#include <linux/list.h>
2222
#include <linux/kref.h>
23+
#include <linux/kobject.h>
24+
#include <linux/sysdev.h>
2325
#include <linux/seq_file.h>
2426
#include <linux/err.h>
2527
#include <linux/platform_device.h>
@@ -358,6 +360,68 @@ static int show_clocks(char *buf, char **start, off_t off,
358360
return p - buf;
359361
}
360362

363+
#ifdef CONFIG_PM
364+
static int clks_sysdev_suspend(struct sys_device *dev, pm_message_t state)
365+
{
366+
static pm_message_t prev_state;
367+
struct clk *clkp;
368+
369+
switch (state.event) {
370+
case PM_EVENT_ON:
371+
/* Resumeing from hibernation */
372+
if (prev_state.event == PM_EVENT_FREEZE) {
373+
list_for_each_entry(clkp, &clock_list, node)
374+
if (likely(clkp->ops)) {
375+
if (likely(clkp->ops->set_parent))
376+
clkp->ops->set_parent(clkp,
377+
clkp->parent);
378+
if (likely(clkp->ops->set_rate))
379+
clkp->ops->set_rate(clkp,
380+
clkp->rate, NO_CHANGE);
381+
else if (likely(clkp->ops->recalc))
382+
clkp->ops->recalc(clkp);
383+
}
384+
}
385+
break;
386+
case PM_EVENT_FREEZE:
387+
break;
388+
case PM_EVENT_SUSPEND:
389+
break;
390+
}
391+
392+
prev_state = state;
393+
return 0;
394+
}
395+
396+
static int clks_sysdev_resume(struct sys_device *dev)
397+
{
398+
return clks_sysdev_suspend(dev, PMSG_ON);
399+
}
400+
401+
static struct sysdev_class clks_sysdev_class = {
402+
.name = "clks",
403+
};
404+
405+
static struct sysdev_driver clks_sysdev_driver = {
406+
.suspend = clks_sysdev_suspend,
407+
.resume = clks_sysdev_resume,
408+
};
409+
410+
static struct sys_device clks_sysdev_dev = {
411+
.cls = &clks_sysdev_class,
412+
};
413+
414+
static int __init clk_sysdev_init(void)
415+
{
416+
sysdev_class_register(&clks_sysdev_class);
417+
sysdev_driver_register(&clks_sysdev_class, &clks_sysdev_driver);
418+
sysdev_register(&clks_sysdev_dev);
419+
420+
return 0;
421+
}
422+
subsys_initcall(clk_sysdev_init);
423+
#endif
424+
361425
int __init clk_init(void)
362426
{
363427
int i, ret = 0;

0 commit comments

Comments
 (0)