aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2010-08-14 23:55:44 -0400
committerLen Brown <len.brown@intel.com>2010-08-14 23:55:44 -0400
commitf2a66185bed21427d8d347a42eaf0ad1d3d9fc63 (patch)
treede49c1ea5b87273596725d9bb1b0188ae2bbf3c9
parent9fe6206f400646a2322096b56c59891d530e8d51 (diff)
parent618d7fd0d4e51a45d25d9bc6097a0cb1e5a2f226 (diff)
Merge branch 'nvs' into release
-rw-r--r--drivers/acpi/sleep.c60
-rw-r--r--drivers/acpi/sleep.h5
-rw-r--r--drivers/acpi/wakeup.c48
3 files changed, 33 insertions, 80 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c
index 2862c781b372..e4625f919814 100644
--- a/drivers/acpi/sleep.c
+++ b/drivers/acpi/sleep.c
@@ -70,10 +70,10 @@ static int acpi_sleep_prepare(u32 acpi_state)
70 70
71 } 71 }
72 ACPI_FLUSH_CPU_CACHE(); 72 ACPI_FLUSH_CPU_CACHE();
73 acpi_enable_wakeup_device_prep(acpi_state);
74#endif 73#endif
75 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n", 74 printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
76 acpi_state); 75 acpi_state);
76 acpi_enable_wakeup_devices(acpi_state);
77 acpi_enter_sleep_state_prep(acpi_state); 77 acpi_enter_sleep_state_prep(acpi_state);
78 return 0; 78 return 0;
79} 79}
@@ -119,6 +119,16 @@ static int acpi_pm_freeze(void)
119} 119}
120 120
121/** 121/**
122 * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
123 */
124static int acpi_pm_pre_suspend(void)
125{
126 acpi_pm_freeze();
127 suspend_nvs_save();
128 return 0;
129}
130
131/**
122 * __acpi_pm_prepare - Prepare the platform to enter the target state. 132 * __acpi_pm_prepare - Prepare the platform to enter the target state.
123 * 133 *
124 * If necessary, set the firmware waking vector and do arch-specific 134 * If necessary, set the firmware waking vector and do arch-specific
@@ -127,11 +137,9 @@ static int acpi_pm_freeze(void)
127static int __acpi_pm_prepare(void) 137static int __acpi_pm_prepare(void)
128{ 138{
129 int error = acpi_sleep_prepare(acpi_target_sleep_state); 139 int error = acpi_sleep_prepare(acpi_target_sleep_state);
130
131 suspend_nvs_save();
132
133 if (error) 140 if (error)
134 acpi_target_sleep_state = ACPI_STATE_S0; 141 acpi_target_sleep_state = ACPI_STATE_S0;
142
135 return error; 143 return error;
136} 144}
137 145
@@ -142,9 +150,8 @@ static int __acpi_pm_prepare(void)
142static int acpi_pm_prepare(void) 150static int acpi_pm_prepare(void)
143{ 151{
144 int error = __acpi_pm_prepare(); 152 int error = __acpi_pm_prepare();
145
146 if (!error) 153 if (!error)
147 acpi_pm_freeze(); 154 acpi_pm_pre_suspend();
148 155
149 return error; 156 return error;
150} 157}
@@ -159,7 +166,6 @@ static void acpi_pm_finish(void)
159{ 166{
160 u32 acpi_state = acpi_target_sleep_state; 167 u32 acpi_state = acpi_target_sleep_state;
161 168
162 suspend_nvs_free();
163 acpi_ec_unblock_transactions(); 169 acpi_ec_unblock_transactions();
164 170
165 if (acpi_state == ACPI_STATE_S0) 171 if (acpi_state == ACPI_STATE_S0)
@@ -167,7 +173,7 @@ static void acpi_pm_finish(void)
167 173
168 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n", 174 printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n",
169 acpi_state); 175 acpi_state);
170 acpi_disable_wakeup_device(acpi_state); 176 acpi_disable_wakeup_devices(acpi_state);
171 acpi_leave_sleep_state(acpi_state); 177 acpi_leave_sleep_state(acpi_state);
172 178
173 /* reset firmware waking vector */ 179 /* reset firmware waking vector */
@@ -181,6 +187,7 @@ static void acpi_pm_finish(void)
181 */ 187 */
182static void acpi_pm_end(void) 188static void acpi_pm_end(void)
183{ 189{
190 suspend_nvs_free();
184 /* 191 /*
185 * This is necessary in case acpi_pm_finish() is not called during a 192 * This is necessary in case acpi_pm_finish() is not called during a
186 * failing transition to a sleep state. 193 * failing transition to a sleep state.
@@ -251,7 +258,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
251 } 258 }
252 259
253 local_irq_save(flags); 260 local_irq_save(flags);
254 acpi_enable_wakeup_device(acpi_state);
255 switch (acpi_state) { 261 switch (acpi_state) {
256 case ACPI_STATE_S1: 262 case ACPI_STATE_S1:
257 barrier(); 263 barrier();
@@ -297,11 +303,6 @@ static int acpi_suspend_enter(suspend_state_t pm_state)
297 return ACPI_SUCCESS(status) ? 0 : -EFAULT; 303 return ACPI_SUCCESS(status) ? 0 : -EFAULT;
298} 304}
299 305
300static void acpi_suspend_finish(void)
301{
302 acpi_pm_finish();
303}
304
305static int acpi_suspend_state_valid(suspend_state_t pm_state) 306static int acpi_suspend_state_valid(suspend_state_t pm_state)
306{ 307{
307 u32 acpi_state; 308 u32 acpi_state;
@@ -323,7 +324,7 @@ static struct platform_suspend_ops acpi_suspend_ops = {
323 .begin = acpi_suspend_begin, 324 .begin = acpi_suspend_begin,
324 .prepare_late = acpi_pm_prepare, 325 .prepare_late = acpi_pm_prepare,
325 .enter = acpi_suspend_enter, 326 .enter = acpi_suspend_enter,
326 .wake = acpi_suspend_finish, 327 .wake = acpi_pm_finish,
327 .end = acpi_pm_end, 328 .end = acpi_pm_end,
328}; 329};
329 330
@@ -336,9 +337,9 @@ static struct platform_suspend_ops acpi_suspend_ops = {
336static int acpi_suspend_begin_old(suspend_state_t pm_state) 337static int acpi_suspend_begin_old(suspend_state_t pm_state)
337{ 338{
338 int error = acpi_suspend_begin(pm_state); 339 int error = acpi_suspend_begin(pm_state);
339
340 if (!error) 340 if (!error)
341 error = __acpi_pm_prepare(); 341 error = __acpi_pm_prepare();
342
342 return error; 343 return error;
343} 344}
344 345
@@ -349,9 +350,9 @@ static int acpi_suspend_begin_old(suspend_state_t pm_state)
349static struct platform_suspend_ops acpi_suspend_ops_old = { 350static struct platform_suspend_ops acpi_suspend_ops_old = {
350 .valid = acpi_suspend_state_valid, 351 .valid = acpi_suspend_state_valid,
351 .begin = acpi_suspend_begin_old, 352 .begin = acpi_suspend_begin_old,
352 .prepare_late = acpi_pm_freeze, 353 .prepare_late = acpi_pm_pre_suspend,
353 .enter = acpi_suspend_enter, 354 .enter = acpi_suspend_enter,
354 .wake = acpi_suspend_finish, 355 .wake = acpi_pm_finish,
355 .end = acpi_pm_end, 356 .end = acpi_pm_end,
356 .recover = acpi_pm_finish, 357 .recover = acpi_pm_finish,
357}; 358};
@@ -423,16 +424,6 @@ static int acpi_hibernation_begin(void)
423 return error; 424 return error;
424} 425}
425 426
426static int acpi_hibernation_pre_snapshot(void)
427{
428 int error = acpi_pm_prepare();
429
430 if (!error)
431 suspend_nvs_save();
432
433 return error;
434}
435
436static int acpi_hibernation_enter(void) 427static int acpi_hibernation_enter(void)
437{ 428{
438 acpi_status status = AE_OK; 429 acpi_status status = AE_OK;
@@ -441,7 +432,6 @@ static int acpi_hibernation_enter(void)
441 ACPI_FLUSH_CPU_CACHE(); 432 ACPI_FLUSH_CPU_CACHE();
442 433
443 local_irq_save(flags); 434 local_irq_save(flags);
444 acpi_enable_wakeup_device(ACPI_STATE_S4);
445 /* This shouldn't return. If it returns, we have a problem */ 435 /* This shouldn't return. If it returns, we have a problem */
446 status = acpi_enter_sleep_state(ACPI_STATE_S4); 436 status = acpi_enter_sleep_state(ACPI_STATE_S4);
447 /* Reprogram control registers and execute _BFS */ 437 /* Reprogram control registers and execute _BFS */
@@ -481,7 +471,7 @@ static void acpi_pm_thaw(void)
481static struct platform_hibernation_ops acpi_hibernation_ops = { 471static struct platform_hibernation_ops acpi_hibernation_ops = {
482 .begin = acpi_hibernation_begin, 472 .begin = acpi_hibernation_begin,
483 .end = acpi_pm_end, 473 .end = acpi_pm_end,
484 .pre_snapshot = acpi_hibernation_pre_snapshot, 474 .pre_snapshot = acpi_pm_prepare,
485 .finish = acpi_pm_finish, 475 .finish = acpi_pm_finish,
486 .prepare = acpi_pm_prepare, 476 .prepare = acpi_pm_prepare,
487 .enter = acpi_hibernation_enter, 477 .enter = acpi_hibernation_enter,
@@ -517,13 +507,6 @@ static int acpi_hibernation_begin_old(void)
517 return error; 507 return error;
518} 508}
519 509
520static int acpi_hibernation_pre_snapshot_old(void)
521{
522 acpi_pm_freeze();
523 suspend_nvs_save();
524 return 0;
525}
526
527/* 510/*
528 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has 511 * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
529 * been requested. 512 * been requested.
@@ -531,7 +514,7 @@ static int acpi_hibernation_pre_snapshot_old(void)
531static struct platform_hibernation_ops acpi_hibernation_ops_old = { 514static struct platform_hibernation_ops acpi_hibernation_ops_old = {
532 .begin = acpi_hibernation_begin_old, 515 .begin = acpi_hibernation_begin_old,
533 .end = acpi_pm_end, 516 .end = acpi_pm_end,
534 .pre_snapshot = acpi_hibernation_pre_snapshot_old, 517 .pre_snapshot = acpi_pm_pre_suspend,
535 .prepare = acpi_pm_freeze, 518 .prepare = acpi_pm_freeze,
536 .finish = acpi_pm_finish, 519 .finish = acpi_pm_finish,
537 .enter = acpi_hibernation_enter, 520 .enter = acpi_hibernation_enter,
@@ -695,7 +678,6 @@ static void acpi_power_off(void)
695 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ 678 /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
696 printk(KERN_DEBUG "%s called\n", __func__); 679 printk(KERN_DEBUG "%s called\n", __func__);
697 local_irq_disable(); 680 local_irq_disable();
698 acpi_enable_wakeup_device(ACPI_STATE_S5);
699 acpi_enter_sleep_state(ACPI_STATE_S5); 681 acpi_enter_sleep_state(ACPI_STATE_S5);
700} 682}
701 683
diff --git a/drivers/acpi/sleep.h b/drivers/acpi/sleep.h
index 25b8bd149284..d8821805c3bc 100644
--- a/drivers/acpi/sleep.h
+++ b/drivers/acpi/sleep.h
@@ -2,9 +2,8 @@
2extern u8 sleep_states[]; 2extern u8 sleep_states[];
3extern int acpi_suspend(u32 state); 3extern int acpi_suspend(u32 state);
4 4
5extern void acpi_enable_wakeup_device_prep(u8 sleep_state); 5extern void acpi_enable_wakeup_devices(u8 sleep_state);
6extern void acpi_enable_wakeup_device(u8 sleep_state); 6extern void acpi_disable_wakeup_devices(u8 sleep_state);
7extern void acpi_disable_wakeup_device(u8 sleep_state);
8 7
9extern struct list_head acpi_wakeup_device_list; 8extern struct list_head acpi_wakeup_device_list;
10extern struct mutex acpi_device_lock; 9extern struct mutex acpi_device_lock;
diff --git a/drivers/acpi/wakeup.c b/drivers/acpi/wakeup.c
index 388747a7ef4f..dc6d1d9112fb 100644
--- a/drivers/acpi/wakeup.c
+++ b/drivers/acpi/wakeup.c
@@ -21,46 +21,18 @@
21ACPI_MODULE_NAME("wakeup_devices") 21ACPI_MODULE_NAME("wakeup_devices")
22 22
23/** 23/**
24 * acpi_enable_wakeup_device_prep - Prepare wake-up devices. 24 * acpi_enable_wakeup_devices - Enable wake-up device GPEs.
25 * @sleep_state: ACPI system sleep state. 25 * @sleep_state: ACPI system sleep state.
26 * 26 *
27 * Enable all wake-up devices' power, unless the requested system sleep state is 27 * Enable wakeup device power of devices with the state.enable flag set and set
28 * too deep. 28 * the wakeup enable mask bits in the GPE registers that correspond to wakeup
29 * devices.
29 */ 30 */
30void acpi_enable_wakeup_device_prep(u8 sleep_state) 31void acpi_enable_wakeup_devices(u8 sleep_state)
31{ 32{
32 struct list_head *node, *next; 33 struct list_head *node, *next;
33 34
34 list_for_each_safe(node, next, &acpi_wakeup_device_list) { 35 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
35 struct acpi_device *dev = container_of(node,
36 struct acpi_device,
37 wakeup_list);
38
39 if (!dev->wakeup.flags.valid || !dev->wakeup.state.enabled
40 || (sleep_state > (u32) dev->wakeup.sleep_state))
41 continue;
42
43 acpi_enable_wakeup_device_power(dev, sleep_state);
44 }
45}
46
47/**
48 * acpi_enable_wakeup_device - Enable wake-up device GPEs.
49 * @sleep_state: ACPI system sleep state.
50 *
51 * Enable all wake-up devices' GPEs, with the assumption that
52 * acpi_disable_all_gpes() was executed before, so we don't need to disable any
53 * GPEs here.
54 */
55void acpi_enable_wakeup_device(u8 sleep_state)
56{
57 struct list_head *node, *next;
58
59 /*
60 * Caution: this routine must be invoked when interrupt is disabled
61 * Refer ACPI2.0: P212
62 */
63 list_for_each_safe(node, next, &acpi_wakeup_device_list) {
64 struct acpi_device *dev = 36 struct acpi_device *dev =
65 container_of(node, struct acpi_device, wakeup_list); 37 container_of(node, struct acpi_device, wakeup_list);
66 38
@@ -68,6 +40,9 @@ void acpi_enable_wakeup_device(u8 sleep_state)
68 || sleep_state > (u32) dev->wakeup.sleep_state) 40 || sleep_state > (u32) dev->wakeup.sleep_state)
69 continue; 41 continue;
70 42
43 if (dev->wakeup.state.enabled)
44 acpi_enable_wakeup_device_power(dev, sleep_state);
45
71 /* The wake-up power should have been enabled already. */ 46 /* The wake-up power should have been enabled already. */
72 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number, 47 acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number,
73 ACPI_GPE_TYPE_WAKE); 48 ACPI_GPE_TYPE_WAKE);
@@ -75,13 +50,10 @@ void acpi_enable_wakeup_device(u8 sleep_state)
75} 50}
76 51
77/** 52/**
78 * acpi_disable_wakeup_device - Disable devices' wakeup capability. 53 * acpi_disable_wakeup_devices - Disable devices' wakeup capability.
79 * @sleep_state: ACPI system sleep state. 54 * @sleep_state: ACPI system sleep state.
80 *
81 * This function only affects devices with wakeup.state.enabled set, which means
82 * that it reverses the changes made by acpi_enable_wakeup_device_prep().
83 */ 55 */
84void acpi_disable_wakeup_device(u8 sleep_state) 56void acpi_disable_wakeup_devices(u8 sleep_state)
85{ 57{
86 struct list_head *node, *next; 58 struct list_head *node, *next;
87 59