aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/sleep/main.c
diff options
context:
space:
mode:
authorAlexey Starikovskiy <alexey.y.starikovskiy@intel.com>2005-03-18 16:20:46 -0500
committerLen Brown <len.brown@intel.com>2005-07-11 23:20:49 -0400
commite2a5b420f716cd1a46674b1a90389612eced916f (patch)
tree96f363f2e402d53428c046269514a82856b0cb34 /drivers/acpi/sleep/main.c
parentbe91492ca871e58f61b517cfba541095bb60001c (diff)
[ACPI] ACPI poweroff fix
Register an "acpi" system device to be notified of shutdown preparation. This depends on CONFIG_PM http://bugzilla.kernel.org/show_bug.cgi?id=4041 Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/sleep/main.c')
-rw-r--r--drivers/acpi/sleep/main.c74
1 files changed, 32 insertions, 42 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);
27extern void do_suspend_lowlevel(void); 27extern void do_suspend_lowlevel(void);
28 28
29static u32 acpi_suspend_states[] = { 29static 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
36static int init_8259A_after_S1; 37static 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
48extern int acpi_sleep_prepare(u32 acpi_state);
49extern void acpi_power_off(void);
50
47static int acpi_pm_prepare(suspend_state_t pm_state) 51static 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
160int acpi_suspend(u32 acpi_state) 150int 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
173static struct pm_ops acpi_pm_ops = { 164static 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
191static struct dmi_system_id __initdata acpisleep_dmi_table[] = { 181static 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
200static int __init acpi_sleep_init(void) 190static 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);