diff options
author | Len Brown <len.brown@intel.com> | 2010-08-14 23:55:44 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2010-08-14 23:55:44 -0400 |
commit | f2a66185bed21427d8d347a42eaf0ad1d3d9fc63 (patch) | |
tree | de49c1ea5b87273596725d9bb1b0188ae2bbf3c9 /drivers/acpi/sleep.c | |
parent | 9fe6206f400646a2322096b56c59891d530e8d51 (diff) | |
parent | 618d7fd0d4e51a45d25d9bc6097a0cb1e5a2f226 (diff) |
Merge branch 'nvs' into release
Diffstat (limited to 'drivers/acpi/sleep.c')
-rw-r--r-- | drivers/acpi/sleep.c | 60 |
1 files changed, 21 insertions, 39 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 | */ | ||
124 | static 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) | |||
127 | static int __acpi_pm_prepare(void) | 137 | static 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) | |||
142 | static int acpi_pm_prepare(void) | 150 | static 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 | */ |
182 | static void acpi_pm_end(void) | 188 | static 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 | ||
300 | static void acpi_suspend_finish(void) | ||
301 | { | ||
302 | acpi_pm_finish(); | ||
303 | } | ||
304 | |||
305 | static int acpi_suspend_state_valid(suspend_state_t pm_state) | 306 | static 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 = { | |||
336 | static int acpi_suspend_begin_old(suspend_state_t pm_state) | 337 | static 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) | |||
349 | static struct platform_suspend_ops acpi_suspend_ops_old = { | 350 | static 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 | ||
426 | static 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 | |||
436 | static int acpi_hibernation_enter(void) | 427 | static 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) | |||
481 | static struct platform_hibernation_ops acpi_hibernation_ops = { | 471 | static 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 | ||
520 | static 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) | |||
531 | static struct platform_hibernation_ops acpi_hibernation_ops_old = { | 514 | static 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 | ||