diff options
Diffstat (limited to 'drivers/acpi/sleep')
-rw-r--r-- | drivers/acpi/sleep/main.c | 74 | ||||
-rw-r--r-- | drivers/acpi/sleep/poweroff.c | 81 | ||||
-rw-r--r-- | drivers/acpi/sleep/proc.c | 9 |
3 files changed, 114 insertions, 50 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index 0a5d2a94131e..7249ba2b7a27 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * sleep.c - ACPI sleep support. | 2 | * sleep.c - ACPI sleep support. |
3 | * | 3 | * |
4 | * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> | ||
4 | * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com> | 5 | * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com> |
5 | * Copyright (c) 2000-2003 Patrick Mochel | 6 | * Copyright (c) 2000-2003 Patrick Mochel |
6 | * Copyright (c) 2003 Open Source Development Lab | 7 | * Copyright (c) 2003 Open Source Development Lab |
@@ -14,7 +15,6 @@ | |||
14 | #include <linux/dmi.h> | 15 | #include <linux/dmi.h> |
15 | #include <linux/device.h> | 16 | #include <linux/device.h> |
16 | #include <linux/suspend.h> | 17 | #include <linux/suspend.h> |
17 | #include <asm/io.h> | ||
18 | #include <acpi/acpi_bus.h> | 18 | #include <acpi/acpi_bus.h> |
19 | #include <acpi/acpi_drivers.h> | 19 | #include <acpi/acpi_drivers.h> |
20 | #include "sleep.h" | 20 | #include "sleep.h" |
@@ -27,10 +27,11 @@ extern void do_suspend_lowlevel_s4bios(void); | |||
27 | extern void do_suspend_lowlevel(void); | 27 | extern void do_suspend_lowlevel(void); |
28 | 28 | ||
29 | static u32 acpi_suspend_states[] = { | 29 | static u32 acpi_suspend_states[] = { |
30 | [PM_SUSPEND_ON] = ACPI_STATE_S0, | 30 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
31 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, | 31 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, |
32 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, | 32 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, |
33 | [PM_SUSPEND_DISK] = ACPI_STATE_S4, | 33 | [PM_SUSPEND_DISK] = ACPI_STATE_S4, |
34 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 | ||
34 | }; | 35 | }; |
35 | 36 | ||
36 | static int init_8259A_after_S1; | 37 | static int init_8259A_after_S1; |
@@ -44,30 +45,20 @@ static int init_8259A_after_S1; | |||
44 | * wakeup code to the waking vector. | 45 | * wakeup code to the waking vector. |
45 | */ | 46 | */ |
46 | 47 | ||
48 | extern int acpi_sleep_prepare(u32 acpi_state); | ||
49 | extern void acpi_power_off(void); | ||
50 | |||
47 | static int acpi_pm_prepare(suspend_state_t pm_state) | 51 | static int acpi_pm_prepare(suspend_state_t pm_state) |
48 | { | 52 | { |
49 | u32 acpi_state = acpi_suspend_states[pm_state]; | 53 | u32 acpi_state = acpi_suspend_states[pm_state]; |
50 | 54 | ||
51 | if (!sleep_states[acpi_state]) | 55 | if (!sleep_states[acpi_state]) { |
56 | printk("acpi_pm_prepare does not support %d \n", pm_state); | ||
52 | return -EPERM; | 57 | return -EPERM; |
53 | |||
54 | /* do we have a wakeup address for S2 and S3? */ | ||
55 | /* Here, we support only S4BIOS, those we set the wakeup address */ | ||
56 | /* S4OS is only supported for now via swsusp.. */ | ||
57 | if (pm_state == PM_SUSPEND_MEM || pm_state == PM_SUSPEND_DISK) { | ||
58 | if (!acpi_wakeup_address) | ||
59 | return -EFAULT; | ||
60 | acpi_set_firmware_waking_vector( | ||
61 | (acpi_physical_address) virt_to_phys( | ||
62 | (void *)acpi_wakeup_address)); | ||
63 | } | 58 | } |
64 | ACPI_FLUSH_CPU_CACHE(); | 59 | return acpi_sleep_prepare(acpi_state); |
65 | acpi_enable_wakeup_device_prep(acpi_state); | ||
66 | acpi_enter_sleep_state_prep(acpi_state); | ||
67 | return 0; | ||
68 | } | 60 | } |
69 | 61 | ||
70 | |||
71 | /** | 62 | /** |
72 | * acpi_pm_enter - Actually enter a sleep state. | 63 | * acpi_pm_enter - Actually enter a sleep state. |
73 | * @pm_state: State we're entering. | 64 | * @pm_state: State we're entering. |
@@ -92,11 +83,9 @@ static int acpi_pm_enter(suspend_state_t pm_state) | |||
92 | return error; | 83 | return error; |
93 | } | 84 | } |
94 | 85 | ||
95 | |||
96 | local_irq_save(flags); | 86 | local_irq_save(flags); |
97 | acpi_enable_wakeup_device(acpi_state); | 87 | acpi_enable_wakeup_device(acpi_state); |
98 | switch (pm_state) | 88 | switch (pm_state) { |
99 | { | ||
100 | case PM_SUSPEND_STANDBY: | 89 | case PM_SUSPEND_STANDBY: |
101 | barrier(); | 90 | barrier(); |
102 | status = acpi_enter_sleep_state(acpi_state); | 91 | status = acpi_enter_sleep_state(acpi_state); |
@@ -112,6 +101,10 @@ static int acpi_pm_enter(suspend_state_t pm_state) | |||
112 | else | 101 | else |
113 | do_suspend_lowlevel_s4bios(); | 102 | do_suspend_lowlevel_s4bios(); |
114 | break; | 103 | break; |
104 | case PM_SUSPEND_MAX: | ||
105 | acpi_power_off(); | ||
106 | break; | ||
107 | |||
115 | default: | 108 | default: |
116 | return -EINVAL; | 109 | return -EINVAL; |
117 | } | 110 | } |
@@ -126,11 +119,9 @@ static int acpi_pm_enter(suspend_state_t pm_state) | |||
126 | if (pm_state > PM_SUSPEND_STANDBY) | 119 | if (pm_state > PM_SUSPEND_STANDBY) |
127 | acpi_restore_state_mem(); | 120 | acpi_restore_state_mem(); |
128 | 121 | ||
129 | |||
130 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | 122 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; |
131 | } | 123 | } |
132 | 124 | ||
133 | |||
134 | /** | 125 | /** |
135 | * acpi_pm_finish - Finish up suspend sequence. | 126 | * acpi_pm_finish - Finish up suspend sequence. |
136 | * @pm_state: State we're coming out of. | 127 | * @pm_state: State we're coming out of. |
@@ -156,27 +147,26 @@ static int acpi_pm_finish(suspend_state_t pm_state) | |||
156 | return 0; | 147 | return 0; |
157 | } | 148 | } |
158 | 149 | ||
159 | |||
160 | int acpi_suspend(u32 acpi_state) | 150 | int acpi_suspend(u32 acpi_state) |
161 | { | 151 | { |
162 | suspend_state_t states[] = { | 152 | suspend_state_t states[] = { |
163 | [1] = PM_SUSPEND_STANDBY, | 153 | [1] = PM_SUSPEND_STANDBY, |
164 | [3] = PM_SUSPEND_MEM, | 154 | [3] = PM_SUSPEND_MEM, |
165 | [4] = PM_SUSPEND_DISK, | 155 | [4] = PM_SUSPEND_DISK, |
156 | [5] = PM_SUSPEND_MAX | ||
166 | }; | 157 | }; |
167 | 158 | ||
168 | if (acpi_state <= 4 && states[acpi_state]) | 159 | if (acpi_state < 6 && states[acpi_state]) |
169 | return pm_suspend(states[acpi_state]); | 160 | return pm_suspend(states[acpi_state]); |
170 | return -EINVAL; | 161 | return -EINVAL; |
171 | } | 162 | } |
172 | 163 | ||
173 | static struct pm_ops acpi_pm_ops = { | 164 | static struct pm_ops acpi_pm_ops = { |
174 | .prepare = acpi_pm_prepare, | 165 | .prepare = acpi_pm_prepare, |
175 | .enter = acpi_pm_enter, | 166 | .enter = acpi_pm_enter, |
176 | .finish = acpi_pm_finish, | 167 | .finish = acpi_pm_finish, |
177 | }; | 168 | }; |
178 | 169 | ||
179 | |||
180 | /* | 170 | /* |
181 | * Toshiba fails to preserve interrupts over S1, reinitialization | 171 | * Toshiba fails to preserve interrupts over S1, reinitialization |
182 | * of 8259 is needed after S1 resume. | 172 | * of 8259 is needed after S1 resume. |
@@ -190,16 +180,16 @@ static int __init init_ints_after_s1(struct dmi_system_id *d) | |||
190 | 180 | ||
191 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { | 181 | static struct dmi_system_id __initdata acpisleep_dmi_table[] = { |
192 | { | 182 | { |
193 | .callback = init_ints_after_s1, | 183 | .callback = init_ints_after_s1, |
194 | .ident = "Toshiba Satellite 4030cdt", | 184 | .ident = "Toshiba Satellite 4030cdt", |
195 | .matches = { DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"), }, | 185 | .matches = {DMI_MATCH(DMI_PRODUCT_NAME, "S4030CDT/4.3"),}, |
196 | }, | 186 | }, |
197 | { }, | 187 | {}, |
198 | }; | 188 | }; |
199 | 189 | ||
200 | static int __init acpi_sleep_init(void) | 190 | static int __init acpi_sleep_init(void) |
201 | { | 191 | { |
202 | int i = 0; | 192 | int i = 0; |
203 | 193 | ||
204 | dmi_check_system(acpisleep_dmi_table); | 194 | dmi_check_system(acpisleep_dmi_table); |
205 | 195 | ||
@@ -207,7 +197,7 @@ static int __init acpi_sleep_init(void) | |||
207 | return 0; | 197 | return 0; |
208 | 198 | ||
209 | printk(KERN_INFO PREFIX "(supports"); | 199 | printk(KERN_INFO PREFIX "(supports"); |
210 | for (i=0; i < ACPI_S_STATE_COUNT; i++) { | 200 | for (i = 0; i < ACPI_S_STATE_COUNT; i++) { |
211 | acpi_status status; | 201 | acpi_status status; |
212 | u8 type_a, type_b; | 202 | u8 type_a, type_b; |
213 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); | 203 | status = acpi_get_sleep_type_data(i, &type_a, &type_b); |
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index da237754ded9..1fc86e6b5ab9 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c | |||
@@ -3,35 +3,100 @@ | |||
3 | * | 3 | * |
4 | * AKA S5, but it is independent of whether or not the kernel supports | 4 | * AKA S5, but it is independent of whether or not the kernel supports |
5 | * any other sleep support in the system. | 5 | * any other sleep support in the system. |
6 | * | ||
7 | * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> | ||
8 | * | ||
9 | * This file is released under the GPLv2. | ||
6 | */ | 10 | */ |
7 | 11 | ||
8 | #include <linux/pm.h> | 12 | #include <linux/pm.h> |
9 | #include <linux/init.h> | 13 | #include <linux/init.h> |
10 | #include <acpi/acpi_bus.h> | 14 | #include <acpi/acpi_bus.h> |
11 | #include <linux/sched.h> | 15 | #include <linux/sched.h> |
16 | #include <linux/sysdev.h> | ||
17 | #include <asm/io.h> | ||
12 | #include "sleep.h" | 18 | #include "sleep.h" |
13 | 19 | ||
14 | static void | 20 | int acpi_sleep_prepare(u32 acpi_state) |
15 | acpi_power_off (void) | 21 | { |
22 | /* Flag to do not allow second time invocation for S5 state */ | ||
23 | static int shutdown_prepared = 0; | ||
24 | #ifdef CONFIG_ACPI_SLEEP | ||
25 | /* do we have a wakeup address for S2 and S3? */ | ||
26 | /* Here, we support only S4BIOS, those we set the wakeup address */ | ||
27 | /* S4OS is only supported for now via swsusp.. */ | ||
28 | if (acpi_state == ACPI_STATE_S3 || acpi_state == ACPI_STATE_S4) { | ||
29 | if (!acpi_wakeup_address) { | ||
30 | return -EFAULT; | ||
31 | } | ||
32 | acpi_set_firmware_waking_vector((acpi_physical_address) | ||
33 | virt_to_phys((void *) | ||
34 | acpi_wakeup_address)); | ||
35 | |||
36 | } | ||
37 | ACPI_FLUSH_CPU_CACHE(); | ||
38 | acpi_enable_wakeup_device_prep(acpi_state); | ||
39 | #endif | ||
40 | if (acpi_state == ACPI_STATE_S5) { | ||
41 | /* Check if we were already called */ | ||
42 | if (shutdown_prepared) | ||
43 | return 0; | ||
44 | acpi_wakeup_gpe_poweroff_prepare(); | ||
45 | shutdown_prepared = 1; | ||
46 | } | ||
47 | acpi_enter_sleep_state_prep(acpi_state); | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | void acpi_power_off(void) | ||
16 | { | 52 | { |
17 | printk("%s called\n",__FUNCTION__); | 53 | printk("%s called\n", __FUNCTION__); |
54 | acpi_sleep_prepare(ACPI_STATE_S5); | ||
55 | local_irq_disable(); | ||
18 | /* Some SMP machines only can poweroff in boot CPU */ | 56 | /* Some SMP machines only can poweroff in boot CPU */ |
19 | set_cpus_allowed(current, cpumask_of_cpu(0)); | 57 | set_cpus_allowed(current, cpumask_of_cpu(0)); |
20 | acpi_wakeup_gpe_poweroff_prepare(); | ||
21 | acpi_enter_sleep_state_prep(ACPI_STATE_S5); | ||
22 | ACPI_DISABLE_IRQS(); | ||
23 | acpi_enter_sleep_state(ACPI_STATE_S5); | 58 | acpi_enter_sleep_state(ACPI_STATE_S5); |
24 | } | 59 | } |
25 | 60 | ||
61 | #ifdef CONFIG_PM | ||
62 | |||
63 | static int acpi_shutdown(struct sys_device *x) | ||
64 | { | ||
65 | return acpi_sleep_prepare(ACPI_STATE_S5); | ||
66 | } | ||
67 | |||
68 | static struct sysdev_class acpi_sysclass = { | ||
69 | set_kset_name("acpi"), | ||
70 | .shutdown = acpi_shutdown | ||
71 | }; | ||
72 | |||
73 | static struct sys_device device_acpi = { | ||
74 | .id = 0, | ||
75 | .cls = &acpi_sysclass, | ||
76 | }; | ||
77 | |||
78 | #endif | ||
79 | |||
26 | static int acpi_poweroff_init(void) | 80 | static int acpi_poweroff_init(void) |
27 | { | 81 | { |
28 | if (!acpi_disabled) { | 82 | if (!acpi_disabled) { |
29 | u8 type_a, type_b; | 83 | u8 type_a, type_b; |
30 | acpi_status status; | 84 | acpi_status status; |
31 | 85 | ||
32 | status = acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 86 | status = |
33 | if (ACPI_SUCCESS(status)) | 87 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
88 | if (ACPI_SUCCESS(status)) { | ||
34 | pm_power_off = acpi_power_off; | 89 | pm_power_off = acpi_power_off; |
90 | #ifdef CONFIG_PM | ||
91 | { | ||
92 | int error; | ||
93 | error = sysdev_class_register(&acpi_sysclass); | ||
94 | if (!error) | ||
95 | error = sysdev_register(&device_acpi); | ||
96 | return error; | ||
97 | } | ||
98 | #endif | ||
99 | } | ||
35 | } | 100 | } |
36 | return 0; | 101 | return 0; |
37 | } | 102 | } |
diff --git a/drivers/acpi/sleep/proc.c b/drivers/acpi/sleep/proc.c index fd7c5a0649af..1be99f0996d6 100644 --- a/drivers/acpi/sleep/proc.c +++ b/drivers/acpi/sleep/proc.c | |||
@@ -13,13 +13,17 @@ | |||
13 | 13 | ||
14 | #include "sleep.h" | 14 | #include "sleep.h" |
15 | 15 | ||
16 | #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP | ||
16 | #define ACPI_SYSTEM_FILE_SLEEP "sleep" | 17 | #define ACPI_SYSTEM_FILE_SLEEP "sleep" |
18 | #endif | ||
19 | |||
17 | #define ACPI_SYSTEM_FILE_ALARM "alarm" | 20 | #define ACPI_SYSTEM_FILE_ALARM "alarm" |
18 | #define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup" | 21 | #define ACPI_SYSTEM_FILE_WAKEUP_DEVICE "wakeup" |
19 | 22 | ||
20 | #define _COMPONENT ACPI_SYSTEM_COMPONENT | 23 | #define _COMPONENT ACPI_SYSTEM_COMPONENT |
21 | ACPI_MODULE_NAME ("sleep") | 24 | ACPI_MODULE_NAME ("sleep") |
22 | 25 | ||
26 | #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP | ||
23 | 27 | ||
24 | static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) | 28 | static int acpi_system_sleep_seq_show(struct seq_file *seq, void *offset) |
25 | { | 29 | { |
@@ -78,6 +82,7 @@ acpi_system_write_sleep ( | |||
78 | Done: | 82 | Done: |
79 | return error ? error : count; | 83 | return error ? error : count; |
80 | } | 84 | } |
85 | #endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ | ||
81 | 86 | ||
82 | static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) | 87 | static int acpi_system_alarm_seq_show(struct seq_file *seq, void *offset) |
83 | { | 88 | { |
@@ -452,6 +457,7 @@ static struct file_operations acpi_system_wakeup_device_fops = { | |||
452 | .release = single_release, | 457 | .release = single_release, |
453 | }; | 458 | }; |
454 | 459 | ||
460 | #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP | ||
455 | static struct file_operations acpi_system_sleep_fops = { | 461 | static struct file_operations acpi_system_sleep_fops = { |
456 | .open = acpi_system_sleep_open_fs, | 462 | .open = acpi_system_sleep_open_fs, |
457 | .read = seq_read, | 463 | .read = seq_read, |
@@ -459,6 +465,7 @@ static struct file_operations acpi_system_sleep_fops = { | |||
459 | .llseek = seq_lseek, | 465 | .llseek = seq_lseek, |
460 | .release = single_release, | 466 | .release = single_release, |
461 | }; | 467 | }; |
468 | #endif /* CONFIG_ACPI_SLEEP_PROC_SLEEP */ | ||
462 | 469 | ||
463 | static struct file_operations acpi_system_alarm_fops = { | 470 | static struct file_operations acpi_system_alarm_fops = { |
464 | .open = acpi_system_alarm_open_fs, | 471 | .open = acpi_system_alarm_open_fs, |
@@ -484,11 +491,13 @@ static int acpi_sleep_proc_init(void) | |||
484 | if (acpi_disabled) | 491 | if (acpi_disabled) |
485 | return 0; | 492 | return 0; |
486 | 493 | ||
494 | #ifdef CONFIG_ACPI_SLEEP_PROC_SLEEP | ||
487 | /* 'sleep' [R/W]*/ | 495 | /* 'sleep' [R/W]*/ |
488 | entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, | 496 | entry = create_proc_entry(ACPI_SYSTEM_FILE_SLEEP, |
489 | S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); | 497 | S_IFREG|S_IRUGO|S_IWUSR, acpi_root_dir); |
490 | if (entry) | 498 | if (entry) |
491 | entry->proc_fops = &acpi_system_sleep_fops; | 499 | entry->proc_fops = &acpi_system_sleep_fops; |
500 | #endif | ||
492 | 501 | ||
493 | /* 'alarm' [R/W] */ | 502 | /* 'alarm' [R/W] */ |
494 | entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, | 503 | entry = create_proc_entry(ACPI_SYSTEM_FILE_ALARM, |