diff options
Diffstat (limited to 'drivers/acpi/sleep.c')
-rw-r--r-- | drivers/acpi/sleep.c | 535 |
1 files changed, 199 insertions, 336 deletions
diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c index fdcdbb652915..2fcc67d34b11 100644 --- a/drivers/acpi/sleep.c +++ b/drivers/acpi/sleep.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/reboot.h> | 18 | #include <linux/reboot.h> |
19 | #include <linux/acpi.h> | 19 | #include <linux/acpi.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/pm_runtime.h> | ||
22 | 21 | ||
23 | #include <asm/io.h> | 22 | #include <asm/io.h> |
24 | 23 | ||
@@ -81,6 +80,12 @@ static int acpi_sleep_prepare(u32 acpi_state) | |||
81 | 80 | ||
82 | #ifdef CONFIG_ACPI_SLEEP | 81 | #ifdef CONFIG_ACPI_SLEEP |
83 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; | 82 | static u32 acpi_target_sleep_state = ACPI_STATE_S0; |
83 | |||
84 | u32 acpi_target_system_state(void) | ||
85 | { | ||
86 | return acpi_target_sleep_state; | ||
87 | } | ||
88 | |||
84 | static bool pwr_btn_event_pending; | 89 | static bool pwr_btn_event_pending; |
85 | 90 | ||
86 | /* | 91 | /* |
@@ -98,6 +103,21 @@ void __init acpi_nvs_nosave(void) | |||
98 | } | 103 | } |
99 | 104 | ||
100 | /* | 105 | /* |
106 | * The ACPI specification wants us to save NVS memory regions during hibernation | ||
107 | * but says nothing about saving NVS during S3. Not all versions of Windows | ||
108 | * save NVS on S3 suspend either, and it is clear that not all systems need | ||
109 | * NVS to be saved at S3 time. To improve suspend/resume time, allow the | ||
110 | * user to disable saving NVS on S3 if their system does not require it, but | ||
111 | * continue to save/restore NVS for S4 as specified. | ||
112 | */ | ||
113 | static bool nvs_nosave_s3; | ||
114 | |||
115 | void __init acpi_nvs_nosave_s3(void) | ||
116 | { | ||
117 | nvs_nosave_s3 = true; | ||
118 | } | ||
119 | |||
120 | /* | ||
101 | * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the | 121 | * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the |
102 | * user to request that behavior by using the 'acpi_old_suspend_ordering' | 122 | * user to request that behavior by using the 'acpi_old_suspend_ordering' |
103 | * kernel command line option that causes the following variable to be set. | 123 | * kernel command line option that causes the following variable to be set. |
@@ -109,6 +129,180 @@ void __init acpi_old_suspend_ordering(void) | |||
109 | old_suspend_ordering = true; | 129 | old_suspend_ordering = true; |
110 | } | 130 | } |
111 | 131 | ||
132 | static int __init init_old_suspend_ordering(const struct dmi_system_id *d) | ||
133 | { | ||
134 | acpi_old_suspend_ordering(); | ||
135 | return 0; | ||
136 | } | ||
137 | |||
138 | static int __init init_nvs_nosave(const struct dmi_system_id *d) | ||
139 | { | ||
140 | acpi_nvs_nosave(); | ||
141 | return 0; | ||
142 | } | ||
143 | |||
144 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | ||
145 | { | ||
146 | .callback = init_old_suspend_ordering, | ||
147 | .ident = "Abit KN9 (nForce4 variant)", | ||
148 | .matches = { | ||
149 | DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"), | ||
150 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), | ||
151 | }, | ||
152 | }, | ||
153 | { | ||
154 | .callback = init_old_suspend_ordering, | ||
155 | .ident = "HP xw4600 Workstation", | ||
156 | .matches = { | ||
157 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
158 | DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), | ||
159 | }, | ||
160 | }, | ||
161 | { | ||
162 | .callback = init_old_suspend_ordering, | ||
163 | .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)", | ||
164 | .matches = { | ||
165 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."), | ||
166 | DMI_MATCH(DMI_BOARD_NAME, "M2N8L"), | ||
167 | }, | ||
168 | }, | ||
169 | { | ||
170 | .callback = init_old_suspend_ordering, | ||
171 | .ident = "Panasonic CF51-2L", | ||
172 | .matches = { | ||
173 | DMI_MATCH(DMI_BOARD_VENDOR, | ||
174 | "Matsushita Electric Industrial Co.,Ltd."), | ||
175 | DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), | ||
176 | }, | ||
177 | }, | ||
178 | { | ||
179 | .callback = init_nvs_nosave, | ||
180 | .ident = "Sony Vaio VGN-FW21E", | ||
181 | .matches = { | ||
182 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
183 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"), | ||
184 | }, | ||
185 | }, | ||
186 | { | ||
187 | .callback = init_nvs_nosave, | ||
188 | .ident = "Sony Vaio VPCEB17FX", | ||
189 | .matches = { | ||
190 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
191 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"), | ||
192 | }, | ||
193 | }, | ||
194 | { | ||
195 | .callback = init_nvs_nosave, | ||
196 | .ident = "Sony Vaio VGN-SR11M", | ||
197 | .matches = { | ||
198 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
199 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"), | ||
200 | }, | ||
201 | }, | ||
202 | { | ||
203 | .callback = init_nvs_nosave, | ||
204 | .ident = "Everex StepNote Series", | ||
205 | .matches = { | ||
206 | DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."), | ||
207 | DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"), | ||
208 | }, | ||
209 | }, | ||
210 | { | ||
211 | .callback = init_nvs_nosave, | ||
212 | .ident = "Sony Vaio VPCEB1Z1E", | ||
213 | .matches = { | ||
214 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
215 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"), | ||
216 | }, | ||
217 | }, | ||
218 | { | ||
219 | .callback = init_nvs_nosave, | ||
220 | .ident = "Sony Vaio VGN-NW130D", | ||
221 | .matches = { | ||
222 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
223 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"), | ||
224 | }, | ||
225 | }, | ||
226 | { | ||
227 | .callback = init_nvs_nosave, | ||
228 | .ident = "Sony Vaio VPCCW29FX", | ||
229 | .matches = { | ||
230 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
231 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"), | ||
232 | }, | ||
233 | }, | ||
234 | { | ||
235 | .callback = init_nvs_nosave, | ||
236 | .ident = "Averatec AV1020-ED2", | ||
237 | .matches = { | ||
238 | DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"), | ||
239 | DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"), | ||
240 | }, | ||
241 | }, | ||
242 | { | ||
243 | .callback = init_old_suspend_ordering, | ||
244 | .ident = "Asus A8N-SLI DELUXE", | ||
245 | .matches = { | ||
246 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | ||
247 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"), | ||
248 | }, | ||
249 | }, | ||
250 | { | ||
251 | .callback = init_old_suspend_ordering, | ||
252 | .ident = "Asus A8N-SLI Premium", | ||
253 | .matches = { | ||
254 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | ||
255 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"), | ||
256 | }, | ||
257 | }, | ||
258 | { | ||
259 | .callback = init_nvs_nosave, | ||
260 | .ident = "Sony Vaio VGN-SR26GN_P", | ||
261 | .matches = { | ||
262 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
263 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"), | ||
264 | }, | ||
265 | }, | ||
266 | { | ||
267 | .callback = init_nvs_nosave, | ||
268 | .ident = "Sony Vaio VPCEB1S1E", | ||
269 | .matches = { | ||
270 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
271 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1S1E"), | ||
272 | }, | ||
273 | }, | ||
274 | { | ||
275 | .callback = init_nvs_nosave, | ||
276 | .ident = "Sony Vaio VGN-FW520F", | ||
277 | .matches = { | ||
278 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
279 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"), | ||
280 | }, | ||
281 | }, | ||
282 | { | ||
283 | .callback = init_nvs_nosave, | ||
284 | .ident = "Asus K54C", | ||
285 | .matches = { | ||
286 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), | ||
287 | DMI_MATCH(DMI_PRODUCT_NAME, "K54C"), | ||
288 | }, | ||
289 | }, | ||
290 | { | ||
291 | .callback = init_nvs_nosave, | ||
292 | .ident = "Asus K54HR", | ||
293 | .matches = { | ||
294 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), | ||
295 | DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"), | ||
296 | }, | ||
297 | }, | ||
298 | {}, | ||
299 | }; | ||
300 | |||
301 | static void acpi_sleep_dmi_check(void) | ||
302 | { | ||
303 | dmi_check_system(acpisleep_dmi_table); | ||
304 | } | ||
305 | |||
112 | /** | 306 | /** |
113 | * acpi_pm_freeze - Disable the GPEs and suspend EC transactions. | 307 | * acpi_pm_freeze - Disable the GPEs and suspend EC transactions. |
114 | */ | 308 | */ |
@@ -224,6 +418,7 @@ static void acpi_pm_end(void) | |||
224 | } | 418 | } |
225 | #else /* !CONFIG_ACPI_SLEEP */ | 419 | #else /* !CONFIG_ACPI_SLEEP */ |
226 | #define acpi_target_sleep_state ACPI_STATE_S0 | 420 | #define acpi_target_sleep_state ACPI_STATE_S0 |
421 | static inline void acpi_sleep_dmi_check(void) {} | ||
227 | #endif /* CONFIG_ACPI_SLEEP */ | 422 | #endif /* CONFIG_ACPI_SLEEP */ |
228 | 423 | ||
229 | #ifdef CONFIG_SUSPEND | 424 | #ifdef CONFIG_SUSPEND |
@@ -243,7 +438,7 @@ static int acpi_suspend_begin(suspend_state_t pm_state) | |||
243 | u32 acpi_state = acpi_suspend_states[pm_state]; | 438 | u32 acpi_state = acpi_suspend_states[pm_state]; |
244 | int error = 0; | 439 | int error = 0; |
245 | 440 | ||
246 | error = nvs_nosave ? 0 : suspend_nvs_alloc(); | 441 | error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc(); |
247 | if (error) | 442 | if (error) |
248 | return error; | 443 | return error; |
249 | 444 | ||
@@ -382,167 +577,6 @@ static const struct platform_suspend_ops acpi_suspend_ops_old = { | |||
382 | .end = acpi_pm_end, | 577 | .end = acpi_pm_end, |
383 | .recover = acpi_pm_finish, | 578 | .recover = acpi_pm_finish, |
384 | }; | 579 | }; |
385 | |||
386 | static int __init init_old_suspend_ordering(const struct dmi_system_id *d) | ||
387 | { | ||
388 | old_suspend_ordering = true; | ||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static int __init init_nvs_nosave(const struct dmi_system_id *d) | ||
393 | { | ||
394 | acpi_nvs_nosave(); | ||
395 | return 0; | ||
396 | } | ||
397 | |||
398 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | ||
399 | { | ||
400 | .callback = init_old_suspend_ordering, | ||
401 | .ident = "Abit KN9 (nForce4 variant)", | ||
402 | .matches = { | ||
403 | DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"), | ||
404 | DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"), | ||
405 | }, | ||
406 | }, | ||
407 | { | ||
408 | .callback = init_old_suspend_ordering, | ||
409 | .ident = "HP xw4600 Workstation", | ||
410 | .matches = { | ||
411 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
412 | DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"), | ||
413 | }, | ||
414 | }, | ||
415 | { | ||
416 | .callback = init_old_suspend_ordering, | ||
417 | .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)", | ||
418 | .matches = { | ||
419 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."), | ||
420 | DMI_MATCH(DMI_BOARD_NAME, "M2N8L"), | ||
421 | }, | ||
422 | }, | ||
423 | { | ||
424 | .callback = init_old_suspend_ordering, | ||
425 | .ident = "Panasonic CF51-2L", | ||
426 | .matches = { | ||
427 | DMI_MATCH(DMI_BOARD_VENDOR, | ||
428 | "Matsushita Electric Industrial Co.,Ltd."), | ||
429 | DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"), | ||
430 | }, | ||
431 | }, | ||
432 | { | ||
433 | .callback = init_nvs_nosave, | ||
434 | .ident = "Sony Vaio VGN-FW21E", | ||
435 | .matches = { | ||
436 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
437 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"), | ||
438 | }, | ||
439 | }, | ||
440 | { | ||
441 | .callback = init_nvs_nosave, | ||
442 | .ident = "Sony Vaio VPCEB17FX", | ||
443 | .matches = { | ||
444 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
445 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"), | ||
446 | }, | ||
447 | }, | ||
448 | { | ||
449 | .callback = init_nvs_nosave, | ||
450 | .ident = "Sony Vaio VGN-SR11M", | ||
451 | .matches = { | ||
452 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
453 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"), | ||
454 | }, | ||
455 | }, | ||
456 | { | ||
457 | .callback = init_nvs_nosave, | ||
458 | .ident = "Everex StepNote Series", | ||
459 | .matches = { | ||
460 | DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."), | ||
461 | DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"), | ||
462 | }, | ||
463 | }, | ||
464 | { | ||
465 | .callback = init_nvs_nosave, | ||
466 | .ident = "Sony Vaio VPCEB1Z1E", | ||
467 | .matches = { | ||
468 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
469 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"), | ||
470 | }, | ||
471 | }, | ||
472 | { | ||
473 | .callback = init_nvs_nosave, | ||
474 | .ident = "Sony Vaio VGN-NW130D", | ||
475 | .matches = { | ||
476 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
477 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"), | ||
478 | }, | ||
479 | }, | ||
480 | { | ||
481 | .callback = init_nvs_nosave, | ||
482 | .ident = "Sony Vaio VPCCW29FX", | ||
483 | .matches = { | ||
484 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
485 | DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"), | ||
486 | }, | ||
487 | }, | ||
488 | { | ||
489 | .callback = init_nvs_nosave, | ||
490 | .ident = "Averatec AV1020-ED2", | ||
491 | .matches = { | ||
492 | DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"), | ||
493 | DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"), | ||
494 | }, | ||
495 | }, | ||
496 | { | ||
497 | .callback = init_old_suspend_ordering, | ||
498 | .ident = "Asus A8N-SLI DELUXE", | ||
499 | .matches = { | ||
500 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | ||
501 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"), | ||
502 | }, | ||
503 | }, | ||
504 | { | ||
505 | .callback = init_old_suspend_ordering, | ||
506 | .ident = "Asus A8N-SLI Premium", | ||
507 | .matches = { | ||
508 | DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."), | ||
509 | DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"), | ||
510 | }, | ||
511 | }, | ||
512 | { | ||
513 | .callback = init_nvs_nosave, | ||
514 | .ident = "Sony Vaio VGN-SR26GN_P", | ||
515 | .matches = { | ||
516 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
517 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"), | ||
518 | }, | ||
519 | }, | ||
520 | { | ||
521 | .callback = init_nvs_nosave, | ||
522 | .ident = "Sony Vaio VGN-FW520F", | ||
523 | .matches = { | ||
524 | DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), | ||
525 | DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"), | ||
526 | }, | ||
527 | }, | ||
528 | { | ||
529 | .callback = init_nvs_nosave, | ||
530 | .ident = "Asus K54C", | ||
531 | .matches = { | ||
532 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), | ||
533 | DMI_MATCH(DMI_PRODUCT_NAME, "K54C"), | ||
534 | }, | ||
535 | }, | ||
536 | { | ||
537 | .callback = init_nvs_nosave, | ||
538 | .ident = "Asus K54HR", | ||
539 | .matches = { | ||
540 | DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."), | ||
541 | DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"), | ||
542 | }, | ||
543 | }, | ||
544 | {}, | ||
545 | }; | ||
546 | #endif /* CONFIG_SUSPEND */ | 580 | #endif /* CONFIG_SUSPEND */ |
547 | 581 | ||
548 | #ifdef CONFIG_HIBERNATION | 582 | #ifdef CONFIG_HIBERNATION |
@@ -681,177 +715,6 @@ int acpi_suspend(u32 acpi_state) | |||
681 | return -EINVAL; | 715 | return -EINVAL; |
682 | } | 716 | } |
683 | 717 | ||
684 | #ifdef CONFIG_PM | ||
685 | /** | ||
686 | * acpi_pm_device_sleep_state - return preferred power state of ACPI device | ||
687 | * in the system sleep state given by %acpi_target_sleep_state | ||
688 | * @dev: device to examine; its driver model wakeup flags control | ||
689 | * whether it should be able to wake up the system | ||
690 | * @d_min_p: used to store the upper limit of allowed states range | ||
691 | * @d_max_in: specify the lowest allowed states | ||
692 | * Return value: preferred power state of the device on success, -ENODEV | ||
693 | * (ie. if there's no 'struct acpi_device' for @dev) or -EINVAL on failure | ||
694 | * | ||
695 | * Find the lowest power (highest number) ACPI device power state that | ||
696 | * device @dev can be in while the system is in the sleep state represented | ||
697 | * by %acpi_target_sleep_state. If @wake is nonzero, the device should be | ||
698 | * able to wake up the system from this sleep state. If @d_min_p is set, | ||
699 | * the highest power (lowest number) device power state of @dev allowed | ||
700 | * in this system sleep state is stored at the location pointed to by it. | ||
701 | * | ||
702 | * The caller must ensure that @dev is valid before using this function. | ||
703 | * The caller is also responsible for figuring out if the device is | ||
704 | * supposed to be able to wake up the system and passing this information | ||
705 | * via @wake. | ||
706 | */ | ||
707 | |||
708 | int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) | ||
709 | { | ||
710 | acpi_handle handle = DEVICE_ACPI_HANDLE(dev); | ||
711 | struct acpi_device *adev; | ||
712 | char acpi_method[] = "_SxD"; | ||
713 | unsigned long long d_min, d_max; | ||
714 | |||
715 | if (d_max_in < ACPI_STATE_D0 || d_max_in > ACPI_STATE_D3) | ||
716 | return -EINVAL; | ||
717 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
718 | printk(KERN_DEBUG "ACPI handle has no context!\n"); | ||
719 | return -ENODEV; | ||
720 | } | ||
721 | |||
722 | acpi_method[2] = '0' + acpi_target_sleep_state; | ||
723 | /* | ||
724 | * If the sleep state is S0, the lowest limit from ACPI is D3, | ||
725 | * but if the device has _S0W, we will use the value from _S0W | ||
726 | * as the lowest limit from ACPI. Finally, we will constrain | ||
727 | * the lowest limit with the specified one. | ||
728 | */ | ||
729 | d_min = ACPI_STATE_D0; | ||
730 | d_max = ACPI_STATE_D3; | ||
731 | |||
732 | /* | ||
733 | * If present, _SxD methods return the minimum D-state (highest power | ||
734 | * state) we can use for the corresponding S-states. Otherwise, the | ||
735 | * minimum D-state is D0 (ACPI 3.x). | ||
736 | * | ||
737 | * NOTE: We rely on acpi_evaluate_integer() not clobbering the integer | ||
738 | * provided -- that's our fault recovery, we ignore retval. | ||
739 | */ | ||
740 | if (acpi_target_sleep_state > ACPI_STATE_S0) | ||
741 | acpi_evaluate_integer(handle, acpi_method, NULL, &d_min); | ||
742 | |||
743 | /* | ||
744 | * If _PRW says we can wake up the system from the target sleep state, | ||
745 | * the D-state returned by _SxD is sufficient for that (we assume a | ||
746 | * wakeup-aware driver if wake is set). Still, if _SxW exists | ||
747 | * (ACPI 3.x), it should return the maximum (lowest power) D-state that | ||
748 | * can wake the system. _S0W may be valid, too. | ||
749 | */ | ||
750 | if (acpi_target_sleep_state == ACPI_STATE_S0 || | ||
751 | (device_may_wakeup(dev) && adev->wakeup.flags.valid && | ||
752 | adev->wakeup.sleep_state >= acpi_target_sleep_state)) { | ||
753 | acpi_status status; | ||
754 | |||
755 | acpi_method[3] = 'W'; | ||
756 | status = acpi_evaluate_integer(handle, acpi_method, NULL, | ||
757 | &d_max); | ||
758 | if (ACPI_FAILURE(status)) { | ||
759 | if (acpi_target_sleep_state != ACPI_STATE_S0 || | ||
760 | status != AE_NOT_FOUND) | ||
761 | d_max = d_min; | ||
762 | } else if (d_max < d_min) { | ||
763 | /* Warn the user of the broken DSDT */ | ||
764 | printk(KERN_WARNING "ACPI: Wrong value from %s\n", | ||
765 | acpi_method); | ||
766 | /* Sanitize it */ | ||
767 | d_min = d_max; | ||
768 | } | ||
769 | } | ||
770 | |||
771 | if (d_max_in < d_min) | ||
772 | return -EINVAL; | ||
773 | if (d_min_p) | ||
774 | *d_min_p = d_min; | ||
775 | /* constrain d_max with specified lowest limit (max number) */ | ||
776 | if (d_max > d_max_in) { | ||
777 | for (d_max = d_max_in; d_max > d_min; d_max--) { | ||
778 | if (adev->power.states[d_max].flags.valid) | ||
779 | break; | ||
780 | } | ||
781 | } | ||
782 | return d_max; | ||
783 | } | ||
784 | EXPORT_SYMBOL(acpi_pm_device_sleep_state); | ||
785 | #endif /* CONFIG_PM */ | ||
786 | |||
787 | #ifdef CONFIG_PM_SLEEP | ||
788 | /** | ||
789 | * acpi_pm_device_run_wake - Enable/disable wake-up for given device. | ||
790 | * @phys_dev: Device to enable/disable the platform to wake-up the system for. | ||
791 | * @enable: Whether enable or disable the wake-up functionality. | ||
792 | * | ||
793 | * Find the ACPI device object corresponding to @pci_dev and try to | ||
794 | * enable/disable the GPE associated with it. | ||
795 | */ | ||
796 | int acpi_pm_device_run_wake(struct device *phys_dev, bool enable) | ||
797 | { | ||
798 | struct acpi_device *dev; | ||
799 | acpi_handle handle; | ||
800 | |||
801 | if (!device_run_wake(phys_dev)) | ||
802 | return -EINVAL; | ||
803 | |||
804 | handle = DEVICE_ACPI_HANDLE(phys_dev); | ||
805 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &dev))) { | ||
806 | dev_dbg(phys_dev, "ACPI handle has no context in %s!\n", | ||
807 | __func__); | ||
808 | return -ENODEV; | ||
809 | } | ||
810 | |||
811 | if (enable) { | ||
812 | acpi_enable_wakeup_device_power(dev, ACPI_STATE_S0); | ||
813 | acpi_enable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
814 | } else { | ||
815 | acpi_disable_gpe(dev->wakeup.gpe_device, dev->wakeup.gpe_number); | ||
816 | acpi_disable_wakeup_device_power(dev); | ||
817 | } | ||
818 | |||
819 | return 0; | ||
820 | } | ||
821 | EXPORT_SYMBOL(acpi_pm_device_run_wake); | ||
822 | |||
823 | /** | ||
824 | * acpi_pm_device_sleep_wake - enable or disable the system wake-up | ||
825 | * capability of given device | ||
826 | * @dev: device to handle | ||
827 | * @enable: 'true' - enable, 'false' - disable the wake-up capability | ||
828 | */ | ||
829 | int acpi_pm_device_sleep_wake(struct device *dev, bool enable) | ||
830 | { | ||
831 | acpi_handle handle; | ||
832 | struct acpi_device *adev; | ||
833 | int error; | ||
834 | |||
835 | if (!device_can_wakeup(dev)) | ||
836 | return -EINVAL; | ||
837 | |||
838 | handle = DEVICE_ACPI_HANDLE(dev); | ||
839 | if (!handle || ACPI_FAILURE(acpi_bus_get_device(handle, &adev))) { | ||
840 | dev_dbg(dev, "ACPI handle has no context in %s!\n", __func__); | ||
841 | return -ENODEV; | ||
842 | } | ||
843 | |||
844 | error = enable ? | ||
845 | acpi_enable_wakeup_device_power(adev, acpi_target_sleep_state) : | ||
846 | acpi_disable_wakeup_device_power(adev); | ||
847 | if (!error) | ||
848 | dev_info(dev, "wake-up capability %s by ACPI\n", | ||
849 | enable ? "enabled" : "disabled"); | ||
850 | |||
851 | return error; | ||
852 | } | ||
853 | #endif /* CONFIG_PM_SLEEP */ | ||
854 | |||
855 | static void acpi_power_off_prepare(void) | 718 | static void acpi_power_off_prepare(void) |
856 | { | 719 | { |
857 | /* Prepare to power off the system */ | 720 | /* Prepare to power off the system */ |
@@ -873,13 +736,13 @@ int __init acpi_sleep_init(void) | |||
873 | u8 type_a, type_b; | 736 | u8 type_a, type_b; |
874 | #ifdef CONFIG_SUSPEND | 737 | #ifdef CONFIG_SUSPEND |
875 | int i = 0; | 738 | int i = 0; |
876 | |||
877 | dmi_check_system(acpisleep_dmi_table); | ||
878 | #endif | 739 | #endif |
879 | 740 | ||
880 | if (acpi_disabled) | 741 | if (acpi_disabled) |
881 | return 0; | 742 | return 0; |
882 | 743 | ||
744 | acpi_sleep_dmi_check(); | ||
745 | |||
883 | sleep_states[ACPI_STATE_S0] = 1; | 746 | sleep_states[ACPI_STATE_S0] = 1; |
884 | printk(KERN_INFO PREFIX "(supports S0"); | 747 | printk(KERN_INFO PREFIX "(supports S0"); |
885 | 748 | ||