blob: 217e9e4ed45f20a9d5b0c1ce678ab752f8b4f2e5 [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 Dooks4b053e72006-09-22 15:42:18 +010024#include <asm/irq.h>
25
Russell Kinga09e64f2008-08-05 16:14:15 +010026#include <mach/regs-power.h>
27#include <mach/regs-gpioj.h>
28#include <mach/regs-gpio.h>
29#include <mach/regs-dsc.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010030
Ben Dooksa2b7ba92008-10-07 22:26:09 +010031#include <plat/cpu.h>
32#include <plat/pm.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010033
Ben Dooksd5120ae2008-10-07 23:09:51 +010034#include <plat/s3c2412.h>
Ben Dooks4b053e72006-09-22 15:42:18 +010035
Ben Dooks33234952007-12-23 03:09:34 +010036extern void s3c2412_sleep_enter(void);
37
Ben Dooks4b053e72006-09-22 15:42:18 +010038static void s3c2412_cpu_suspend(void)
39{
40 unsigned long tmp;
41
42 /* set our standby method to sleep */
43
44 tmp = __raw_readl(S3C2412_PWRCFG);
45 tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP;
46 __raw_writel(tmp, S3C2412_PWRCFG);
47
Ben Dooks33234952007-12-23 03:09:34 +010048 s3c2412_sleep_enter();
Ben Dooks4b053e72006-09-22 15:42:18 +010049}
50
51static void s3c2412_pm_prepare(void)
52{
53}
54
55static int s3c2412_pm_add(struct sys_device *sysdev)
56{
57 pm_cpu_prep = s3c2412_pm_prepare;
58 pm_cpu_sleep = s3c2412_cpu_suspend;
59
60 return 0;
61}
62
63static struct sleep_save s3c2412_sleep[] = {
64 SAVE_ITEM(S3C2412_DSC0),
65 SAVE_ITEM(S3C2412_DSC1),
66 SAVE_ITEM(S3C2413_GPJDAT),
67 SAVE_ITEM(S3C2413_GPJCON),
68 SAVE_ITEM(S3C2413_GPJUP),
69
70 /* save the PWRCFG to get back to original sleep method */
71
72 SAVE_ITEM(S3C2412_PWRCFG),
73
74 /* save the sleep configuration anyway, just in case these
75 * get damaged during wakeup */
76
77 SAVE_ITEM(S3C2412_GPBSLPCON),
78 SAVE_ITEM(S3C2412_GPCSLPCON),
79 SAVE_ITEM(S3C2412_GPDSLPCON),
Ben Dooks4b053e72006-09-22 15:42:18 +010080 SAVE_ITEM(S3C2412_GPFSLPCON),
81 SAVE_ITEM(S3C2412_GPGSLPCON),
82 SAVE_ITEM(S3C2412_GPHSLPCON),
83 SAVE_ITEM(S3C2413_GPJSLPCON),
84};
85
86static int s3c2412_pm_suspend(struct sys_device *dev, pm_message_t state)
87{
88 s3c2410_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
89 return 0;
90}
91
92static int s3c2412_pm_resume(struct sys_device *dev)
93{
94 unsigned long tmp;
95
96 tmp = __raw_readl(S3C2412_PWRCFG);
97 tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK;
98 tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE;
99 __raw_writel(tmp, S3C2412_PWRCFG);
100
101 s3c2410_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep));
102 return 0;
103}
104
105static struct sysdev_driver s3c2412_pm_driver = {
106 .add = s3c2412_pm_add,
107 .suspend = s3c2412_pm_suspend,
108 .resume = s3c2412_pm_resume,
109};
110
111static __init int s3c2412_pm_init(void)
112{
113 return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver);
114}
115
116arch_initcall(s3c2412_pm_init);