diff options
Diffstat (limited to 'drivers/acpi/sleep/main.c')
-rw-r--r-- | drivers/acpi/sleep/main.c | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c index f8c63410bcbf..52b23471dd69 100644 --- a/drivers/acpi/sleep/main.c +++ b/drivers/acpi/sleep/main.c | |||
@@ -29,7 +29,6 @@ static u32 acpi_suspend_states[] = { | |||
29 | [PM_SUSPEND_ON] = ACPI_STATE_S0, | 29 | [PM_SUSPEND_ON] = ACPI_STATE_S0, |
30 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, | 30 | [PM_SUSPEND_STANDBY] = ACPI_STATE_S1, |
31 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, | 31 | [PM_SUSPEND_MEM] = ACPI_STATE_S3, |
32 | [PM_SUSPEND_DISK] = ACPI_STATE_S4, | ||
33 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 | 32 | [PM_SUSPEND_MAX] = ACPI_STATE_S5 |
34 | }; | 33 | }; |
35 | 34 | ||
@@ -94,14 +93,6 @@ static int acpi_pm_enter(suspend_state_t pm_state) | |||
94 | do_suspend_lowlevel(); | 93 | do_suspend_lowlevel(); |
95 | break; | 94 | break; |
96 | 95 | ||
97 | case PM_SUSPEND_DISK: | ||
98 | if (acpi_pm_ops.pm_disk_mode == PM_DISK_PLATFORM) | ||
99 | status = acpi_enter_sleep_state(acpi_state); | ||
100 | break; | ||
101 | case PM_SUSPEND_MAX: | ||
102 | acpi_power_off(); | ||
103 | break; | ||
104 | |||
105 | default: | 96 | default: |
106 | return -EINVAL; | 97 | return -EINVAL; |
107 | } | 98 | } |
@@ -157,12 +148,13 @@ int acpi_suspend(u32 acpi_state) | |||
157 | suspend_state_t states[] = { | 148 | suspend_state_t states[] = { |
158 | [1] = PM_SUSPEND_STANDBY, | 149 | [1] = PM_SUSPEND_STANDBY, |
159 | [3] = PM_SUSPEND_MEM, | 150 | [3] = PM_SUSPEND_MEM, |
160 | [4] = PM_SUSPEND_DISK, | ||
161 | [5] = PM_SUSPEND_MAX | 151 | [5] = PM_SUSPEND_MAX |
162 | }; | 152 | }; |
163 | 153 | ||
164 | if (acpi_state < 6 && states[acpi_state]) | 154 | if (acpi_state < 6 && states[acpi_state]) |
165 | return pm_suspend(states[acpi_state]); | 155 | return pm_suspend(states[acpi_state]); |
156 | if (acpi_state == 4) | ||
157 | return hibernate(); | ||
166 | return -EINVAL; | 158 | return -EINVAL; |
167 | } | 159 | } |
168 | 160 | ||
@@ -189,6 +181,49 @@ static struct pm_ops acpi_pm_ops = { | |||
189 | .finish = acpi_pm_finish, | 181 | .finish = acpi_pm_finish, |
190 | }; | 182 | }; |
191 | 183 | ||
184 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
185 | static int acpi_hibernation_prepare(void) | ||
186 | { | ||
187 | return acpi_sleep_prepare(ACPI_STATE_S4); | ||
188 | } | ||
189 | |||
190 | static int acpi_hibernation_enter(void) | ||
191 | { | ||
192 | acpi_status status = AE_OK; | ||
193 | unsigned long flags = 0; | ||
194 | |||
195 | ACPI_FLUSH_CPU_CACHE(); | ||
196 | |||
197 | local_irq_save(flags); | ||
198 | acpi_enable_wakeup_device(ACPI_STATE_S4); | ||
199 | /* This shouldn't return. If it returns, we have a problem */ | ||
200 | status = acpi_enter_sleep_state(ACPI_STATE_S4); | ||
201 | local_irq_restore(flags); | ||
202 | |||
203 | return ACPI_SUCCESS(status) ? 0 : -EFAULT; | ||
204 | } | ||
205 | |||
206 | static void acpi_hibernation_finish(void) | ||
207 | { | ||
208 | acpi_leave_sleep_state(ACPI_STATE_S4); | ||
209 | acpi_disable_wakeup_device(ACPI_STATE_S4); | ||
210 | |||
211 | /* reset firmware waking vector */ | ||
212 | acpi_set_firmware_waking_vector((acpi_physical_address) 0); | ||
213 | |||
214 | if (init_8259A_after_S1) { | ||
215 | printk("Broken toshiba laptop -> kicking interrupts\n"); | ||
216 | init_8259A(0); | ||
217 | } | ||
218 | } | ||
219 | |||
220 | static struct hibernation_ops acpi_hibernation_ops = { | ||
221 | .prepare = acpi_hibernation_prepare, | ||
222 | .enter = acpi_hibernation_enter, | ||
223 | .finish = acpi_hibernation_finish, | ||
224 | }; | ||
225 | #endif /* CONFIG_SOFTWARE_SUSPEND */ | ||
226 | |||
192 | /* | 227 | /* |
193 | * Toshiba fails to preserve interrupts over S1, reinitialization | 228 | * Toshiba fails to preserve interrupts over S1, reinitialization |
194 | * of 8259 is needed after S1 resume. | 229 | * of 8259 is needed after S1 resume. |
@@ -227,14 +262,18 @@ int __init acpi_sleep_init(void) | |||
227 | sleep_states[i] = 1; | 262 | sleep_states[i] = 1; |
228 | printk(" S%d", i); | 263 | printk(" S%d", i); |
229 | } | 264 | } |
230 | if (i == ACPI_STATE_S4) { | ||
231 | if (sleep_states[i]) | ||
232 | acpi_pm_ops.pm_disk_mode = PM_DISK_PLATFORM; | ||
233 | } | ||
234 | } | 265 | } |
235 | printk(")\n"); | 266 | printk(")\n"); |
236 | 267 | ||
237 | pm_set_ops(&acpi_pm_ops); | 268 | pm_set_ops(&acpi_pm_ops); |
269 | |||
270 | #ifdef CONFIG_SOFTWARE_SUSPEND | ||
271 | if (sleep_states[ACPI_STATE_S4]) | ||
272 | hibernation_set_ops(&acpi_hibernation_ops); | ||
273 | #else | ||
274 | sleep_states[ACPI_STATE_S4] = 0; | ||
275 | #endif | ||
276 | |||
238 | return 0; | 277 | return 0; |
239 | } | 278 | } |
240 | 279 | ||