aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/mach-common/pm.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/mach-common/pm.c')
-rw-r--r--arch/blackfin/mach-common/pm.c181
1 files changed, 181 insertions, 0 deletions
diff --git a/arch/blackfin/mach-common/pm.c b/arch/blackfin/mach-common/pm.c
new file mode 100644
index 000000000000..deb27272c658
--- /dev/null
+++ b/arch/blackfin/mach-common/pm.c
@@ -0,0 +1,181 @@
1/*
2 * File: arch/blackfin/mach-common/pm.c
3 * Based on: arm/mach-omap/pm.c
4 * Author: Cliff Brake <cbrake@accelent.com> Copyright (c) 2001
5 *
6 * Created: 2001
7 * Description: Power management for the bfin
8 *
9 * Modified: Nicolas Pitre - PXA250 support
10 * Copyright (c) 2002 Monta Vista Software, Inc.
11 * David Singleton - OMAP1510
12 * Copyright (c) 2002 Monta Vista Software, Inc.
13 * Dirk Behme <dirk.behme@de.bosch.com> - OMAP1510/1610
14 * Copyright 2004
15 * Copyright 2004-2006 Analog Devices Inc.
16 *
17 * Bugs: Enter bugs at http://blackfin.uclinux.org/
18 *
19 * This program is free software; you can redistribute it and/or modify
20 * it under the terms of the GNU General Public License as published by
21 * the Free Software Foundation; either version 2 of the License, or
22 * (at your option) any later version.
23 *
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
28 *
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, see the file COPYING, or write
31 * to the Free Software Foundation, Inc.,
32 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#include <linux/pm.h>
36#include <linux/sched.h>
37#include <linux/proc_fs.h>
38
39#include <asm/io.h>
40#include <asm/dpmc.h>
41#include <asm/irq.h>
42
43
44#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H
45#define WAKEUP_TYPE PM_WAKE_HIGH
46#endif
47
48#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_L
49#define WAKEUP_TYPE PM_WAKE_LOW
50#endif
51
52#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_F
53#define WAKEUP_TYPE PM_WAKE_FALLING
54#endif
55
56#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_R
57#define WAKEUP_TYPE PM_WAKE_RISING
58#endif
59
60#ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_B
61#define WAKEUP_TYPE PM_WAKE_BOTH_EDGES
62#endif
63
64void bfin_pm_suspend_standby_enter(void)
65{
66#ifdef CONFIG_PM_WAKEUP_BY_GPIO
67 gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE);
68#endif
69
70#if defined(CONFIG_PM_WAKEUP_BY_GPIO) || defined(CONFIG_PM_WAKEUP_GPIO_API)
71 {
72 u32 flags;
73
74 local_irq_save(flags);
75
76 sleep_deeper(gpio_pm_setup()); /*Goto Sleep*/
77
78 gpio_pm_restore();
79
80 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
81
82 local_irq_restore(flags);
83 }
84#endif
85
86#if defined(CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR)
87 sleep_deeper(CONFIG_PM_WAKEUP_SIC_IWR);
88 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
89#endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */
90}
91
92
93/*
94 * bfin_pm_prepare - Do preliminary suspend work.
95 * @state: suspend state we're entering.
96 *
97 */
98static int bfin_pm_prepare(suspend_state_t state)
99{
100 int error = 0;
101
102 switch (state) {
103 case PM_SUSPEND_STANDBY:
104 break;
105 case PM_SUSPEND_MEM:
106 return -ENOTSUPP;
107
108 case PM_SUSPEND_DISK:
109 return -ENOTSUPP;
110
111 default:
112 return -EINVAL;
113 }
114
115 return error;
116}
117
118/*
119 * bfin_pm_enter - Actually enter a sleep state.
120 * @state: State we're entering.
121 *
122 */
123static int bfin_pm_enter(suspend_state_t state)
124{
125 switch (state) {
126 case PM_SUSPEND_STANDBY:
127 bfin_pm_suspend_standby_enter();
128 break;
129 case PM_SUSPEND_MEM:
130 return -ENOTSUPP;
131
132 case PM_SUSPEND_DISK:
133 return -ENOTSUPP;
134
135 default:
136 return -EINVAL;
137 }
138
139 return 0;
140}
141
142/*
143 * bfin_pm_finish - Finish up suspend sequence.
144 * @state: State we're coming out of.
145 *
146 * This is called after we wake back up (or if entering the sleep state
147 * failed).
148 */
149static int bfin_pm_finish(suspend_state_t state)
150{
151 switch (state) {
152 case PM_SUSPEND_STANDBY:
153 break;
154
155 case PM_SUSPEND_MEM:
156 return -ENOTSUPP;
157
158 case PM_SUSPEND_DISK:
159 return -ENOTSUPP;
160
161 default:
162 return -EINVAL;
163 }
164
165 return 0;
166}
167
168struct pm_ops bfin_pm_ops = {
169 .pm_disk_mode = PM_DISK_PLATFORM,
170 .prepare = bfin_pm_prepare,
171 .enter = bfin_pm_enter,
172 .finish = bfin_pm_finish,
173};
174
175static int __init bfin_pm_init(void)
176{
177 pm_set_ops(&bfin_pm_ops);
178 return 0;
179}
180
181__initcall(bfin_pm_init);