16 #include <linux/device.h>
18 #include <linux/reboot.h>
20 #include <linux/module.h>
33 static void acpi_sleep_tts_switch(
u32 acpi_state)
39 in_arg.
integer.value = acpi_state;
51 unsigned long code,
void *
x)
58 .notifier_call = tts_notify_reboot,
63 static int acpi_sleep_prepare(
u32 acpi_state)
65 #ifdef CONFIG_ACPI_SLEEP
82 #ifdef CONFIG_ACPI_SLEEP
84 static bool pwr_btn_event_pending;
93 static bool nvs_nosave;
95 void __init acpi_nvs_nosave(
void)
105 static bool old_suspend_ordering;
107 void __init acpi_old_suspend_ordering(
void)
109 old_suspend_ordering =
true;
115 static int acpi_pm_freeze(
void)
126 static int acpi_pm_pre_suspend(
void)
129 return suspend_nvs_save();
138 static int __acpi_pm_prepare(
void)
140 int error = acpi_sleep_prepare(acpi_target_sleep_state);
151 static int acpi_pm_prepare(
void)
153 int error = __acpi_pm_prepare();
155 error = acpi_pm_pre_suspend();
162 struct acpi_device *
device = to_acpi_device(dev);
174 static void acpi_pm_finish(
void)
176 struct device *pwr_btn_dev;
201 if (!pwr_btn_event_pending)
204 pwr_btn_event_pending =
false;
216 static void acpi_pm_end(
void)
223 acpi_sleep_tts_switch(acpi_target_sleep_state);
226 #define acpi_target_sleep_state ACPI_STATE_S0
229 #ifdef CONFIG_SUSPEND
230 static u32 acpi_suspend_states[] = {
243 u32 acpi_state = acpi_suspend_states[pm_state];
246 error = nvs_nosave ? 0 : suspend_nvs_alloc();
250 if (sleep_states[acpi_state]) {
251 acpi_target_sleep_state = acpi_state;
252 acpi_sleep_tts_switch(acpi_target_sleep_state);
277 switch (acpi_state) {
314 pwr_btn_event_pending =
true;
327 suspend_nvs_restore();
340 acpi_state = acpi_suspend_states[pm_state];
342 return sleep_states[acpi_state];
349 .
valid = acpi_suspend_state_valid,
350 .begin = acpi_suspend_begin,
351 .prepare_late = acpi_pm_prepare,
352 .enter = acpi_suspend_enter,
353 .wake = acpi_pm_finish,
365 int error = acpi_suspend_begin(pm_state);
367 error = __acpi_pm_prepare();
377 .
valid = acpi_suspend_state_valid,
378 .begin = acpi_suspend_begin_old,
379 .prepare_late = acpi_pm_pre_suspend,
380 .enter = acpi_suspend_enter,
381 .wake = acpi_pm_finish,
383 .recover = acpi_pm_finish,
388 old_suspend_ordering =
true;
400 .callback = init_old_suspend_ordering,
401 .ident =
"Abit KN9 (nForce4 variant)",
408 .callback = init_old_suspend_ordering,
409 .ident =
"HP xw4600 Workstation",
416 .callback = init_old_suspend_ordering,
417 .ident =
"Asus Pundit P1-AH2 (M2N8L motherboard)",
424 .callback = init_old_suspend_ordering,
425 .ident =
"Panasonic CF51-2L",
428 "Matsushita Electric Industrial Co.,Ltd."),
433 .callback = init_nvs_nosave,
434 .ident =
"Sony Vaio VGN-FW21E",
441 .callback = init_nvs_nosave,
442 .ident =
"Sony Vaio VPCEB17FX",
449 .callback = init_nvs_nosave,
450 .ident =
"Sony Vaio VGN-SR11M",
457 .callback = init_nvs_nosave,
458 .ident =
"Everex StepNote Series",
465 .callback = init_nvs_nosave,
466 .ident =
"Sony Vaio VPCEB1Z1E",
473 .callback = init_nvs_nosave,
474 .ident =
"Sony Vaio VGN-NW130D",
481 .callback = init_nvs_nosave,
482 .ident =
"Sony Vaio VPCCW29FX",
489 .callback = init_nvs_nosave,
490 .ident =
"Averatec AV1020-ED2",
497 .callback = init_old_suspend_ordering,
498 .ident =
"Asus A8N-SLI DELUXE",
505 .callback = init_old_suspend_ordering,
506 .ident =
"Asus A8N-SLI Premium",
513 .callback = init_nvs_nosave,
514 .ident =
"Sony Vaio VGN-SR26GN_P",
521 .callback = init_nvs_nosave,
522 .ident =
"Sony Vaio VPCEB1S1E",
529 .callback = init_nvs_nosave,
530 .ident =
"Sony Vaio VGN-FW520F",
537 .callback = init_nvs_nosave,
538 .ident =
"Asus K54C",
545 .callback = init_nvs_nosave,
546 .ident =
"Asus K54HR",
556 #ifdef CONFIG_HIBERNATION
557 static unsigned long s4_hardware_signature;
559 static bool nosigcheck;
561 void __init acpi_no_s4_hw_signature(
void)
566 static int acpi_hibernation_begin(
void)
570 error = nvs_nosave ? 0 : suspend_nvs_alloc();
573 acpi_sleep_tts_switch(acpi_target_sleep_state);
579 static int acpi_hibernation_enter(
void)
593 static void acpi_hibernation_leave(
void)
606 panic(
"ACPI S4 hardware signature mismatch");
609 suspend_nvs_restore();
614 static void acpi_pm_thaw(
void)
621 .
begin = acpi_hibernation_begin,
623 .pre_snapshot = acpi_pm_prepare,
624 .finish = acpi_pm_finish,
625 .prepare = acpi_pm_prepare,
626 .enter = acpi_hibernation_enter,
627 .leave = acpi_hibernation_leave,
628 .pre_restore = acpi_pm_freeze,
629 .restore_cleanup = acpi_pm_thaw,
638 static int acpi_hibernation_begin_old(
void)
652 error = suspend_nvs_alloc();
664 .
begin = acpi_hibernation_begin_old,
666 .pre_snapshot = acpi_pm_pre_suspend,
667 .prepare = acpi_pm_freeze,
668 .finish = acpi_pm_finish,
669 .enter = acpi_hibernation_enter,
670 .leave = acpi_hibernation_leave,
671 .pre_restore = acpi_pm_freeze,
672 .restore_cleanup = acpi_pm_thaw,
673 .recover = acpi_pm_finish,
685 if (acpi_state < 6 && states[acpi_state])
716 int acpi_pm_device_sleep_state(
struct device *
dev,
int *d_min_p,
int d_max_in)
719 struct acpi_device *adev;
720 char acpi_method[] =
"_SxD";
721 unsigned long long d_min, d_max;
759 (device_may_wakeup(dev) && adev->wakeup.flags.valid &&
760 adev->wakeup.sleep_state >= acpi_target_sleep_state)) {
763 acpi_method[3] =
'W';
770 }
else if (d_max < d_min) {
779 if (d_max_in < d_min)
784 if (d_max > d_max_in) {
785 for (d_max = d_max_in; d_max > d_min; d_max--) {
786 if (adev->power.states[d_max].flags.valid)
795 #ifdef CONFIG_PM_SLEEP
804 int acpi_pm_device_run_wake(
struct device *phys_dev,
bool enable)
806 struct acpi_device *
dev;
809 if (!device_run_wake(phys_dev))
812 handle = DEVICE_ACPI_HANDLE(phys_dev);
814 dev_dbg(phys_dev,
"ACPI handle has no context in %s!\n",
837 int acpi_pm_device_sleep_wake(
struct device *dev,
bool enable)
840 struct acpi_device *adev;
843 if (!device_can_wakeup(dev))
846 handle = DEVICE_ACPI_HANDLE(dev);
848 dev_dbg(dev,
"ACPI handle has no context in %s!\n", __func__);
856 dev_info(dev,
"wake-up capability %s by ACPI\n",
857 enable ?
"enabled" :
"disabled");
863 static void acpi_power_off_prepare(
void)
870 static void acpi_power_off(
void)
882 #ifdef CONFIG_SUSPEND
894 #ifdef CONFIG_SUSPEND
904 &acpi_suspend_ops_old : &acpi_suspend_ops);
907 #ifdef CONFIG_HIBERNATION
911 &acpi_hibernation_ops_old : &acpi_hibernation_ops);
918 s4_hardware_signature =