aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep/wakeup.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/sleep/wakeup.c')
-rw-r--r--drivers/acpi/sleep/wakeup.c115
1 files changed, 59 insertions, 56 deletions
diff --git a/drivers/acpi/sleep/wakeup.c b/drivers/acpi/sleep/wakeup.c
index d9b199969d5d..4134ed43d026 100644
--- a/drivers/acpi/sleep/wakeup.c
+++ b/drivers/acpi/sleep/wakeup.c
@@ -12,9 +12,9 @@
12#include "sleep.h" 12#include "sleep.h"
13 13
14#define _COMPONENT ACPI_SYSTEM_COMPONENT 14#define _COMPONENT ACPI_SYSTEM_COMPONENT
15ACPI_MODULE_NAME ("wakeup_devices") 15ACPI_MODULE_NAME("wakeup_devices")
16 16
17extern struct list_head acpi_wakeup_device_list; 17extern struct list_head acpi_wakeup_device_list;
18extern spinlock_t acpi_device_lock; 18extern spinlock_t acpi_device_lock;
19 19
20#ifdef CONFIG_ACPI_SLEEP 20#ifdef CONFIG_ACPI_SLEEP
@@ -25,22 +25,21 @@ extern spinlock_t acpi_device_lock;
25 * is higher than requested sleep level 25 * is higher than requested sleep level
26 */ 26 */
27 27
28void 28void acpi_enable_wakeup_device_prep(u8 sleep_state)
29acpi_enable_wakeup_device_prep(
30 u8 sleep_state)
31{ 29{
32 struct list_head * node, * next; 30 struct list_head *node, *next;
33 31
34 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep"); 32 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device_prep");
35 33
36 spin_lock(&acpi_device_lock); 34 spin_lock(&acpi_device_lock);
37 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
38 struct acpi_device * dev = container_of(node, 36 struct acpi_device *dev = container_of(node,
39 struct acpi_device, wakeup_list); 37 struct acpi_device,
40 38 wakeup_list);
41 if (!dev->wakeup.flags.valid || 39
42 !dev->wakeup.state.enabled || 40 if (!dev->wakeup.flags.valid ||
43 (sleep_state > (u32) dev->wakeup.sleep_state)) 41 !dev->wakeup.state.enabled ||
42 (sleep_state > (u32) dev->wakeup.sleep_state))
44 continue; 43 continue;
45 44
46 spin_unlock(&acpi_device_lock); 45 spin_unlock(&acpi_device_lock);
@@ -55,11 +54,9 @@ acpi_enable_wakeup_device_prep(
55 * @sleep_state: ACPI state 54 * @sleep_state: ACPI state
56 * Enable all wakup devices's GPE 55 * Enable all wakup devices's GPE
57 */ 56 */
58void 57void acpi_enable_wakeup_device(u8 sleep_state)
59acpi_enable_wakeup_device(
60 u8 sleep_state)
61{ 58{
62 struct list_head * node, * next; 59 struct list_head *node, *next;
63 60
64 /* 61 /*
65 * Caution: this routine must be invoked when interrupt is disabled 62 * Caution: this routine must be invoked when interrupt is disabled
@@ -68,33 +65,35 @@ acpi_enable_wakeup_device(
68 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device"); 65 ACPI_FUNCTION_TRACE("acpi_enable_wakeup_device");
69 spin_lock(&acpi_device_lock); 66 spin_lock(&acpi_device_lock);
70 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 67 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
71 struct acpi_device * dev = container_of(node, 68 struct acpi_device *dev = container_of(node,
72 struct acpi_device, wakeup_list); 69 struct acpi_device,
70 wakeup_list);
73 71
74 /* If users want to disable run-wake GPE, 72 /* If users want to disable run-wake GPE,
75 * we only disable it for wake and leave it for runtime 73 * we only disable it for wake and leave it for runtime
76 */ 74 */
77 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 75 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
78 spin_unlock(&acpi_device_lock); 76 spin_unlock(&acpi_device_lock);
79 acpi_set_gpe_type(dev->wakeup.gpe_device, 77 acpi_set_gpe_type(dev->wakeup.gpe_device,
80 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 78 dev->wakeup.gpe_number,
79 ACPI_GPE_TYPE_RUNTIME);
81 /* Re-enable it, since set_gpe_type will disable it */ 80 /* Re-enable it, since set_gpe_type will disable it */
82 acpi_enable_gpe(dev->wakeup.gpe_device, 81 acpi_enable_gpe(dev->wakeup.gpe_device,
83 dev->wakeup.gpe_number, ACPI_ISR); 82 dev->wakeup.gpe_number, ACPI_ISR);
84 spin_lock(&acpi_device_lock); 83 spin_lock(&acpi_device_lock);
85 continue; 84 continue;
86 } 85 }
87 86
88 if (!dev->wakeup.flags.valid || 87 if (!dev->wakeup.flags.valid ||
89 !dev->wakeup.state.enabled || 88 !dev->wakeup.state.enabled ||
90 (sleep_state > (u32) dev->wakeup.sleep_state)) 89 (sleep_state > (u32) dev->wakeup.sleep_state))
91 continue; 90 continue;
92 91
93 spin_unlock(&acpi_device_lock); 92 spin_unlock(&acpi_device_lock);
94 /* run-wake GPE has been enabled */ 93 /* run-wake GPE has been enabled */
95 if (!dev->wakeup.flags.run_wake) 94 if (!dev->wakeup.flags.run_wake)
96 acpi_enable_gpe(dev->wakeup.gpe_device, 95 acpi_enable_gpe(dev->wakeup.gpe_device,
97 dev->wakeup.gpe_number, ACPI_ISR); 96 dev->wakeup.gpe_number, ACPI_ISR);
98 dev->wakeup.state.active = 1; 97 dev->wakeup.state.active = 1;
99 spin_lock(&acpi_device_lock); 98 spin_lock(&acpi_device_lock);
100 } 99 }
@@ -106,43 +105,43 @@ acpi_enable_wakeup_device(
106 * @sleep_state: ACPI state 105 * @sleep_state: ACPI state
107 * Disable all wakup devices's GPE and wakeup capability 106 * Disable all wakup devices's GPE and wakeup capability
108 */ 107 */
109void 108void acpi_disable_wakeup_device(u8 sleep_state)
110acpi_disable_wakeup_device (
111 u8 sleep_state)
112{ 109{
113 struct list_head * node, * next; 110 struct list_head *node, *next;
114 111
115 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device"); 112 ACPI_FUNCTION_TRACE("acpi_disable_wakeup_device");
116 113
117 spin_lock(&acpi_device_lock); 114 spin_lock(&acpi_device_lock);
118 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 115 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
119 struct acpi_device * dev = container_of(node, 116 struct acpi_device *dev = container_of(node,
120 struct acpi_device, wakeup_list); 117 struct acpi_device,
118 wakeup_list);
121 119
122 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 120 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
123 spin_unlock(&acpi_device_lock); 121 spin_unlock(&acpi_device_lock);
124 acpi_set_gpe_type(dev->wakeup.gpe_device, 122 acpi_set_gpe_type(dev->wakeup.gpe_device,
125 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 123 dev->wakeup.gpe_number,
124 ACPI_GPE_TYPE_WAKE_RUN);
126 /* Re-enable it, since set_gpe_type will disable it */ 125 /* Re-enable it, since set_gpe_type will disable it */
127 acpi_enable_gpe(dev->wakeup.gpe_device, 126 acpi_enable_gpe(dev->wakeup.gpe_device,
128 dev->wakeup.gpe_number, ACPI_NOT_ISR); 127 dev->wakeup.gpe_number, ACPI_NOT_ISR);
129 spin_lock(&acpi_device_lock); 128 spin_lock(&acpi_device_lock);
130 continue; 129 continue;
131 } 130 }
132 131
133 if (!dev->wakeup.flags.valid || 132 if (!dev->wakeup.flags.valid ||
134 !dev->wakeup.state.active || 133 !dev->wakeup.state.active ||
135 (sleep_state > (u32) dev->wakeup.sleep_state)) 134 (sleep_state > (u32) dev->wakeup.sleep_state))
136 continue; 135 continue;
137 136
138 spin_unlock(&acpi_device_lock); 137 spin_unlock(&acpi_device_lock);
139 acpi_disable_wakeup_device_power(dev); 138 acpi_disable_wakeup_device_power(dev);
140 /* Never disable run-wake GPE */ 139 /* Never disable run-wake GPE */
141 if (!dev->wakeup.flags.run_wake) { 140 if (!dev->wakeup.flags.run_wake) {
142 acpi_disable_gpe(dev->wakeup.gpe_device, 141 acpi_disable_gpe(dev->wakeup.gpe_device,
143 dev->wakeup.gpe_number, ACPI_NOT_ISR); 142 dev->wakeup.gpe_number, ACPI_NOT_ISR);
144 acpi_clear_gpe(dev->wakeup.gpe_device, 143 acpi_clear_gpe(dev->wakeup.gpe_device,
145 dev->wakeup.gpe_number, ACPI_NOT_ISR); 144 dev->wakeup.gpe_number, ACPI_NOT_ISR);
146 } 145 }
147 dev->wakeup.state.active = 0; 146 dev->wakeup.state.active = 0;
148 spin_lock(&acpi_device_lock); 147 spin_lock(&acpi_device_lock);
@@ -152,7 +151,7 @@ acpi_disable_wakeup_device (
152 151
153static int __init acpi_wakeup_device_init(void) 152static int __init acpi_wakeup_device_init(void)
154{ 153{
155 struct list_head * node, * next; 154 struct list_head *node, *next;
156 155
157 if (acpi_disabled) 156 if (acpi_disabled)
158 return 0; 157 return 0;
@@ -160,16 +159,18 @@ static int __init acpi_wakeup_device_init(void)
160 159
161 spin_lock(&acpi_device_lock); 160 spin_lock(&acpi_device_lock);
162 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 161 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
163 struct acpi_device * dev = container_of(node, 162 struct acpi_device *dev = container_of(node,
164 struct acpi_device, wakeup_list); 163 struct acpi_device,
165 164 wakeup_list);
165
166 /* In case user doesn't load button driver */ 166 /* In case user doesn't load button driver */
167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) { 167 if (dev->wakeup.flags.run_wake && !dev->wakeup.state.enabled) {
168 spin_unlock(&acpi_device_lock); 168 spin_unlock(&acpi_device_lock);
169 acpi_set_gpe_type(dev->wakeup.gpe_device, 169 acpi_set_gpe_type(dev->wakeup.gpe_device,
170 dev->wakeup.gpe_number, ACPI_GPE_TYPE_WAKE_RUN); 170 dev->wakeup.gpe_number,
171 acpi_enable_gpe(dev->wakeup.gpe_device, 171 ACPI_GPE_TYPE_WAKE_RUN);
172 dev->wakeup.gpe_number, ACPI_NOT_ISR); 172 acpi_enable_gpe(dev->wakeup.gpe_device,
173 dev->wakeup.gpe_number, ACPI_NOT_ISR);
173 dev->wakeup.state.enabled = 1; 174 dev->wakeup.state.enabled = 1;
174 spin_lock(&acpi_device_lock); 175 spin_lock(&acpi_device_lock);
175 } 176 }
@@ -193,17 +194,19 @@ late_initcall(acpi_wakeup_device_init);
193 */ 194 */
194void acpi_wakeup_gpe_poweroff_prepare(void) 195void acpi_wakeup_gpe_poweroff_prepare(void)
195{ 196{
196 struct list_head * node, * next; 197 struct list_head *node, *next;
197 198
198 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 199 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
199 struct acpi_device * dev = container_of(node, 200 struct acpi_device *dev = container_of(node,
200 struct acpi_device, wakeup_list); 201 struct acpi_device,
202 wakeup_list);
201 203
202 /* The GPE can wakeup system from S5, don't touch it */ 204 /* The GPE can wakeup system from S5, don't touch it */
203 if ((u32)dev->wakeup.sleep_state == ACPI_STATE_S5) 205 if ((u32) dev->wakeup.sleep_state == ACPI_STATE_S5)
204 continue; 206 continue;
205 /* acpi_set_gpe_type will automatically disable GPE */ 207 /* acpi_set_gpe_type will automatically disable GPE */
206 acpi_set_gpe_type(dev->wakeup.gpe_device, 208 acpi_set_gpe_type(dev->wakeup.gpe_device,
207 dev->wakeup.gpe_number, ACPI_GPE_TYPE_RUNTIME); 209 dev->wakeup.gpe_number,
210 ACPI_GPE_TYPE_RUNTIME);
208 } 211 }
209} 212}