blob: 1a9e8dd194ff87b09025990d89a3774ad12156b8 [file] [log] [blame]
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +09001/* linux/arch/arm/mach-s3c2416/pm.c
2 *
3 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
4 * http://www.samsung.com
5 *
6 * S3C2416 - PM support (Based on Ben Dooks' S3C2412 PM support)
7 *
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.
11*/
12
Kay Sievers4a858cf2011-12-21 16:01:38 -080013#include <linux/device.h>
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020014#include <linux/syscore_ops.h>
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090015#include <linux/io.h>
16
17#include <asm/cacheflush.h>
18
19#include <mach/regs-power.h>
20#include <mach/regs-s3c2443-clock.h>
21
22#include <plat/cpu.h>
23#include <plat/pm.h>
24
25extern void s3c2412_sleep_enter(void);
26
Russell King29cb3cd2011-07-02 09:54:01 +010027static int s3c2416_cpu_suspend(unsigned long arg)
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090028{
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090029 /* enable wakeup sources regardless of battery state */
30 __raw_writel(S3C2443_PWRCFG_SLEEP, S3C2443_PWRCFG);
31
32 /* set the mode as sleep, 2BED represents "Go to BED" */
33 __raw_writel(0x2BED, S3C2443_PWRMODE);
34
35 s3c2412_sleep_enter();
Russell King29cb3cd2011-07-02 09:54:01 +010036
Abhilash Kesavand3fcacf2013-01-25 10:40:19 -080037 pr_info("Failed to suspend the system\n");
38 return 1; /* Aborting suspend */
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090039}
40
41static void s3c2416_pm_prepare(void)
42{
43 /*
44 * write the magic value u-boot uses to check for resume into
45 * the INFORM0 register, and ensure INFORM1 is set to the
46 * correct address to resume from.
47 */
48 __raw_writel(0x2BED, S3C2412_INFORM0);
49 __raw_writel(virt_to_phys(s3c_cpu_resume), S3C2412_INFORM1);
50}
51
Heiko Stuebner04511a62012-01-27 15:35:25 +090052static int s3c2416_pm_add(struct device *dev, struct subsys_interface *sif)
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090053{
54 pm_cpu_prep = s3c2416_pm_prepare;
55 pm_cpu_sleep = s3c2416_cpu_suspend;
56
57 return 0;
58}
59
Kay Sievers4a858cf2011-12-21 16:01:38 -080060static struct subsys_interface s3c2416_pm_interface = {
61 .name = "s3c2416_pm",
62 .subsys = &s3c2416_subsys,
63 .add_dev = s3c2416_pm_add,
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090064};
65
66static __init int s3c2416_pm_init(void)
67{
Kay Sievers4a858cf2011-12-21 16:01:38 -080068 return subsys_interface_register(&s3c2416_pm_interface);
Abhilash Kesavan6436b6a2010-10-20 19:43:35 +090069}
70
71arch_initcall(s3c2416_pm_init);
Rafael J. Wysockibb072c32011-04-22 22:03:21 +020072
73
74static void s3c2416_pm_resume(void)
75{
76 /* unset the return-from-sleep amd inform flags */
77 __raw_writel(0x0, S3C2443_PWRMODE);
78 __raw_writel(0x0, S3C2412_INFORM0);
79 __raw_writel(0x0, S3C2412_INFORM1);
80}
81
82struct syscore_ops s3c2416_pm_syscore_ops = {
83 .resume = s3c2416_pm_resume,
84};