blob: a7417c479ffeeb5f7a1b30bf4ea631ca61c2f18f [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/mach-s3c2412/pm.c
Ben Dooks4b053e72006-09-22 15:42:18 +01002 *
3 * Copyright (c) 2006 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * http://armlinux.simtec.co.uk/.
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
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/list.h>
17#include <linux/timer.h>
18#include <linux/init.h>
19#include <linux/sysdev.h>
20#include <linux/platform_device.h>
Russell Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010022
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/hardware.h>
Ben Dooksdc8fc7e2009-04-28 10:06:00 +010024#include <asm/cacheflush.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010025#include <asm/irq.h>
26
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/regs-power.h>
28#include <mach/regs-gpioj.h>
29#include <mach/regs-gpio.h>
30#include <mach/regs-dsc.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010031
Ben Dooksa2b7ba92008-10-07 22:26:09 +010032#include <plat/cpu.h>
33#include <plat/pm.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010034
Ben Dooksd5120ae2008-10-07 23:09:51 +010035#include <plat/s3c2412.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010036
Ben Dooks33234952007-12-23 03:09:34 +010037extern void s3c2412_sleep_enter(void);
38
Ben Dooks4b053e72006-09-22 15:42:18 +010039static void s3c2412_cpu_suspend(void)
40{
41 unsigned long tmp;
42
Ben Dooksdc8fc7e2009-04-28 10:06:00 +010043 flush_cache_all();
44
Ben Dooks4b053e72006-09-22 15:42:18 +010045 /* set our standby method to sleep */
46
47 tmp = __raw_readl(S3C2412_PWRCFG);
48 tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
49 __raw_writel(tmp, S3C2412_PWRCFG);
50
Ben Dooks33234952007-12-23 03:09:34 +010051 s3c2412_sleep_enter();
Ben Dooks4b053e72006-09-22 15:42:18 +010052}
53
54static void s3c2412_pm_prepare(void)
55{
56}
57
58static int s3c2412_pm_add(struct sys_device *sysdev)
59{
60 pm_cpu_prep = s3c2412_pm_prepare;
61 pm_cpu_sleep = s3c2412_cpu_suspend;
62
63 return 0;
64}
65
66static struct sleep_save s3c2412_sleep[] = {
67 SAVE_ITEM(S3C2412_DSC0),
68 SAVE_ITEM(S3C2412_DSC1),
69 SAVE_ITEM(S3C2413_GPJDAT),
70 SAVE_ITEM(S3C2413_GPJCON),
71 SAVE_ITEM(S3C2413_GPJUP),
72
73 /* save the PWRCFG to get back to original sleep method */
74
75 SAVE_ITEM(S3C2412_PWRCFG),
76
77 /* save the sleep configuration anyway, just in case these
78 * get damaged during wakeup */
79
80 SAVE_ITEM(S3C2412_GPBSLPCON),
81 SAVE_ITEM(S3C2412_GPCSLPCON),
82 SAVE_ITEM(S3C2412_GPDSLPCON),
Ben Dooks4b053e72006-09-22 15:42:18 +010083 SAVE_ITEM(S3C2412_GPFSLPCON),
84 SAVE_ITEM(S3C2412_GPGSLPCON),
85 SAVE_ITEM(S3C2412_GPHSLPCON),
86 SAVE_ITEM(S3C2413_GPJSLPCON),
87};
88
89static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
90{
Ben Dooks64197112008-12-12 00:24:06 +000091 s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
Ben Dooks4b053e72006-09-22 15:42:18 +010092 return 0;
93}
94
95static int s3c2412_pm_resume(struct sys_device *dev)
96{
97 unsigned long tmp;
98
99 tmp = __raw_readl(S3C2412_PWRCFG);
100 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
101 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
102 __raw_writel(tmp, S3C2412_PWRCFG);
103
Ben Dooks64197112008-12-12 00:24:06 +0000104 s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
Ben Dooks4b053e72006-09-22 15:42:18 +0100105 return 0;
106}
107
108static struct sysdev_driver s3c2412_pm_driver = {
109 .add = s3c2412_pm_add,
110 .suspend = s3c2412_pm_suspend,
111 .resume = s3c2412_pm_resume,
112};
113
114static __init int s3c2412_pm_init(void)
115{
116 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
117}
118
119arch_initcall(s3c2412_pm_init);