Commit | Line | Data |
---|---|---|
a21765a7 | 1 | /* linux/arch/arm/mach-s3c2412/pm.c |
4b053e7a BD |
2 | * |
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> | |
21 | ||
a09e64fb | 22 | #include <mach/hardware.h> |
4b053e7a BD |
23 | #include <asm/io.h> |
24 | #include <asm/irq.h> | |
25 | ||
a09e64fb RK |
26 | #include <mach/regs-power.h> |
27 | #include <mach/regs-gpioj.h> | |
28 | #include <mach/regs-gpio.h> | |
29 | #include <mach/regs-dsc.h> | |
4b053e7a | 30 | |
a2b7ba9c BD |
31 | #include <plat/cpu.h> |
32 | #include <plat/pm.h> | |
4b053e7a | 33 | |
d5120ae7 | 34 | #include <plat/s3c2412.h> |
4b053e7a | 35 | |
33234951 BD |
36 | extern void s3c2412_sleep_enter(void); |
37 | ||
4b053e7a BD |
38 | static 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 | ||
33234951 | 48 | s3c2412_sleep_enter(); |
4b053e7a BD |
49 | } |
50 | ||
51 | static void s3c2412_pm_prepare(void) | |
52 | { | |
53 | } | |
54 | ||
55 | static 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 | ||
63 | static 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), | |
4b053e7a BD |
80 | SAVE_ITEM(S3C2412_GPFSLPCON), |
81 | SAVE_ITEM(S3C2412_GPGSLPCON), | |
82 | SAVE_ITEM(S3C2412_GPHSLPCON), | |
83 | SAVE_ITEM(S3C2413_GPJSLPCON), | |
84 | }; | |
85 | ||
86 | static 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 | ||
92 | static 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 | ||
105 | static struct sysdev_driver s3c2412_pm_driver = { | |
106 | .add = s3c2412_pm_add, | |
107 | .suspend = s3c2412_pm_suspend, | |
108 | .resume = s3c2412_pm_resume, | |
109 | }; | |
110 | ||
111 | static __init int s3c2412_pm_init(void) | |
112 | { | |
113 | return sysdev_driver_register(&s3c2412_sysclass, &s3c2412_pm_driver); | |
114 | } | |
115 | ||
116 | arch_initcall(s3c2412_pm_init); |