Merge remote-tracking branch 's5p/for-next'
[linux-2.6/next.git] / arch / arm / mach-s3c2416 / pm.c
blob9ec54f1d8e75349a665f5cd1dcd40742da7d1808
1 /* linux/arch/arm/mach-s3c2416/pm.c
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
6 * S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/sysdev.h>
14 #include <linux/syscore_ops.h>
15 #include <linux/io.h>
17 #include <asm/cacheflush.h>
19 #include <mach/regs-power.h>
20 #include <mach/regs-s3c2443-clock.h>
22 #include <plat/cpu.h>
23 #include <plat/pm.h>
25 extern void s3c2412_sleep_enter(void);
27 static int s3c2416_cpu_suspend(unsigned long arg)
29 /* enable wakeup sources regardless of battery state */
30 __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
32 /* set the mode as sleep, 2BED represents "Go to BED" */
33 __raw_writel(0x2BED, S3C2443_PWRMODE);
35 s3c2412_sleep_enter();
37 panic("sleep resumed to originator?");
40 static void s3c2416_pm_prepare(void)
43 * write the magic value u-boot uses to check for resume into
44 * the INFORM0 register, and ensure INFORM1 is set to the
45 * correct address to resume from.
47 __raw_writel(0x2BED, S3C2412_INFORM0);
48 __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
51 static int s3c2416_pm_add(struct sys_device *sysdev)
53 pm_cpu_prep = s3c2416_pm_prepare;
54 pm_cpu_sleep = s3c2416_cpu_suspend;
56 return 0;
59 static struct sysdev_driver s3c2416_pm_driver = {
60 .add = s3c2416_pm_add,
63 static __init int s3c2416_pm_init(void)
65 return sysdev_driver_register(&s3c2416_sysclass, &s3c2416_pm_driver);
68 arch_initcall(s3c2416_pm_init);
71 static void s3c2416_pm_resume(void)
73 /* unset the return-from-sleep amd inform flags */
74 __raw_writel(0x0, S3C2443_PWRMODE);
75 __raw_writel(0x0, S3C2412_INFORM0);
76 __raw_writel(0x0, S3C2412_INFORM1);
79 struct syscore_ops s3c2416_pm_syscore_ops = {
80 .resume = s3c2416_pm_resume,