per-zone and reclaim enhancements for memory controller: per zone lru for cgroup
[linux-2.6/linux-loongson.git] / arch / blackfin / mach-common / pm.c
blob81930f7d06f145632bc9fd203c9f2a16bff8b1aa
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
6 * Created: 2001
7 * Description: Power management for the bfin
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.
17 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
35 #include <linux/suspend.h>
36 #include <linux/sched.h>
37 #include <linux/proc_fs.h>
38 #include <linux/io.h>
39 #include <linux/irq.h>
41 #include <asm/dpmc.h>
42 #include <asm/gpio.h>
44 #ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_H
45 #define WAKEUP_TYPE PM_WAKE_HIGH
46 #endif
48 #ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_L
49 #define WAKEUP_TYPE PM_WAKE_LOW
50 #endif
52 #ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_F
53 #define WAKEUP_TYPE PM_WAKE_FALLING
54 #endif
56 #ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_R
57 #define WAKEUP_TYPE PM_WAKE_RISING
58 #endif
60 #ifdef CONFIG_PM_WAKEUP_GPIO_POLAR_EDGE_B
61 #define WAKEUP_TYPE PM_WAKE_BOTH_EDGES
62 #endif
64 void bfin_pm_suspend_standby_enter(void)
66 #ifdef CONFIG_PM_WAKEUP_BY_GPIO
67 gpio_pm_wakeup_request(CONFIG_PM_WAKEUP_GPIO_NUMBER, WAKEUP_TYPE);
68 #endif
70 #if defined(CONFIG_PM_WAKEUP_BY_GPIO) || defined(CONFIG_PM_WAKEUP_GPIO_API)
72 u32 flags;
74 local_irq_save(flags);
76 sleep_deeper(gpio_pm_setup()); /*Goto Sleep*/
78 gpio_pm_restore();
80 #if defined(CONFIG_BF54x) || defined(CONFIG_BF52x)
81 bfin_write_SIC_IWR0(IWR_ENABLE_ALL);
82 bfin_write_SIC_IWR1(IWR_ENABLE_ALL);
83 # ifdef CONFIG_BF54x
84 bfin_write_SIC_IWR2(IWR_ENABLE_ALL);
85 # endif
86 #else
87 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
88 #endif
90 local_irq_restore(flags);
92 #endif
94 #if defined(CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR)
95 sleep_deeper(CONFIG_PM_WAKEUP_SIC_IWR);
96 # if defined(CONFIG_BF54x) || defined(CONFIG_BF52x)
97 bfin_write_SIC_IWR0(IWR_ENABLE_ALL);
98 bfin_write_SIC_IWR1(IWR_ENABLE_ALL);
99 # ifdef CONFIG_BF54x
100 bfin_write_SIC_IWR2(IWR_ENABLE_ALL);
101 # endif
102 # else
103 bfin_write_SIC_IWR(IWR_ENABLE_ALL);
104 # endif
105 #endif /* CONFIG_PM_WAKEUP_GPIO_BY_SIC_IWR */
109 * bfin_pm_valid - Tell the PM core that we only support the standby sleep
110 * state
111 * @state: suspend state we're checking.
114 static int bfin_pm_valid(suspend_state_t state)
116 return (state == PM_SUSPEND_STANDBY);
120 * bfin_pm_enter - Actually enter a sleep state.
121 * @state: State we're entering.
124 static int bfin_pm_enter(suspend_state_t state)
126 switch (state) {
127 case PM_SUSPEND_STANDBY:
128 bfin_pm_suspend_standby_enter();
129 break;
131 case PM_SUSPEND_MEM:
132 return -ENOTSUPP;
134 default:
135 return -EINVAL;
138 return 0;
141 struct platform_suspend_ops bfin_pm_ops = {
142 .enter = bfin_pm_enter,
143 .valid = bfin_pm_valid,
146 static int __init bfin_pm_init(void)
148 suspend_set_ops(&bfin_pm_ops);
149 return 0;
152 __initcall(bfin_pm_init);