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> | |
4a858cfc | 19 | #include <linux/device.h> |
bb072c3c | 20 | #include <linux/syscore_ops.h> |
4b053e7a | 21 | #include <linux/platform_device.h> |
fced80c7 | 22 | #include <linux/io.h> |
4b053e7a | 23 | |
dc8fc7ed | 24 | #include <asm/cacheflush.h> |
4b053e7a BD |
25 | #include <asm/irq.h> |
26 | ||
b4353784 | 27 | #include <mach/hardware.h> |
a09e64fb | 28 | #include <mach/regs-gpio.h> |
4b053e7a | 29 | |
a2b7ba9c BD |
30 | #include <plat/cpu.h> |
31 | #include <plat/pm.h> | |
59295708 | 32 | #include <plat/wakeup-mask.h> |
4b053e7a | 33 | |
b4353784 | 34 | #include "regs-dsc.h" |
14cce0e7 | 35 | #include "s3c2412-power.h" |
b4353784 | 36 | |
33234951 BD |
37 | extern void s3c2412_sleep_enter(void); |
38 | ||
29cb3cd2 | 39 | static int s3c2412_cpu_suspend(unsigned long arg) |
4b053e7a BD |
40 | { |
41 | unsigned long tmp; | |
42 | ||
43 | /* set our standby method to sleep */ | |
44 | ||
45 | tmp = __raw_readl(S3C2412_PWRCFG); | |
46 | tmp |= S3C2412_PWRCFG_STANDBYWFI_SLEEP; | |
47 | __raw_writel(tmp, S3C2412_PWRCFG); | |
48 | ||
33234951 | 49 | s3c2412_sleep_enter(); |
29cb3cd2 | 50 | |
d3fcacf5 AK |
51 | pr_info("Failed to suspend the system\n"); |
52 | return 1; /* Aborting suspend */ | |
4b053e7a BD |
53 | } |
54 | ||
59295708 HS |
55 | /* mapping of interrupts to parts of the wakeup mask */ |
56 | static struct samsung_wakeup_mask wake_irqs[] = { | |
57 | { .irq = IRQ_RTC, .bit = S3C2412_PWRCFG_RTC_MASKIRQ, }, | |
58 | }; | |
59 | ||
4b053e7a BD |
60 | static void s3c2412_pm_prepare(void) |
61 | { | |
59295708 HS |
62 | samsung_sync_wakemask(S3C2412_PWRCFG, |
63 | wake_irqs, ARRAY_SIZE(wake_irqs)); | |
4b053e7a BD |
64 | } |
65 | ||
04511a6f | 66 | static int s3c2412_pm_add(struct device *dev, struct subsys_interface *sif) |
4b053e7a BD |
67 | { |
68 | pm_cpu_prep = s3c2412_pm_prepare; | |
69 | pm_cpu_sleep = s3c2412_cpu_suspend; | |
70 | ||
71 | return 0; | |
72 | } | |
73 | ||
74 | static struct sleep_save s3c2412_sleep[] = { | |
75 | SAVE_ITEM(S3C2412_DSC0), | |
76 | SAVE_ITEM(S3C2412_DSC1), | |
77 | SAVE_ITEM(S3C2413_GPJDAT), | |
78 | SAVE_ITEM(S3C2413_GPJCON), | |
79 | SAVE_ITEM(S3C2413_GPJUP), | |
80 | ||
81 | /* save the PWRCFG to get back to original sleep method */ | |
82 | ||
83 | SAVE_ITEM(S3C2412_PWRCFG), | |
84 | ||
85 | /* save the sleep configuration anyway, just in case these | |
86 | * get damaged during wakeup */ | |
87 | ||
88 | SAVE_ITEM(S3C2412_GPBSLPCON), | |
89 | SAVE_ITEM(S3C2412_GPCSLPCON), | |
90 | SAVE_ITEM(S3C2412_GPDSLPCON), | |
4b053e7a BD |
91 | SAVE_ITEM(S3C2412_GPFSLPCON), |
92 | SAVE_ITEM(S3C2412_GPGSLPCON), | |
93 | SAVE_ITEM(S3C2412_GPHSLPCON), | |
94 | SAVE_ITEM(S3C2413_GPJSLPCON), | |
95 | }; | |
96 | ||
4a858cfc KS |
97 | static struct subsys_interface s3c2412_pm_interface = { |
98 | .name = "s3c2412_pm", | |
99 | .subsys = &s3c2412_subsys, | |
100 | .add_dev = s3c2412_pm_add, | |
bb072c3c RW |
101 | }; |
102 | ||
103 | static __init int s3c2412_pm_init(void) | |
104 | { | |
ea04018e | 105 | return subsys_interface_register(&s3c2412_pm_interface); |
bb072c3c RW |
106 | } |
107 | ||
108 | arch_initcall(s3c2412_pm_init); | |
109 | ||
110 | static int s3c2412_pm_suspend(void) | |
4b053e7a | 111 | { |
6419711a | 112 | s3c_pm_do_save(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
4b053e7a BD |
113 | return 0; |
114 | } | |
115 | ||
bb072c3c | 116 | static void s3c2412_pm_resume(void) |
4b053e7a BD |
117 | { |
118 | unsigned long tmp; | |
119 | ||
120 | tmp = __raw_readl(S3C2412_PWRCFG); | |
121 | tmp &= ~S3C2412_PWRCFG_STANDBYWFI_MASK; | |
122 | tmp |= S3C2412_PWRCFG_STANDBYWFI_IDLE; | |
123 | __raw_writel(tmp, S3C2412_PWRCFG); | |
124 | ||
6419711a | 125 | s3c_pm_do_restore(s3c2412_sleep, ARRAY_SIZE(s3c2412_sleep)); |
4b053e7a BD |
126 | } |
127 | ||
bb072c3c | 128 | struct syscore_ops s3c2412_pm_syscore_ops = { |
4b053e7a BD |
129 | .suspend = s3c2412_pm_suspend, |
130 | .resume = s3c2412_pm_resume, | |
131 | }; |