diff options
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/ec.c | 17 | ||||
-rw-r--r-- | drivers/acpi/sleep/poweroff.c | 34 |
2 files changed, 15 insertions, 36 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 8e665f2e3138..fca4140a50a9 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -170,22 +170,19 @@ acpi_ec_enter_burst_mode ( | |||
170 | status = acpi_ec_read_status(ec); | 170 | status = acpi_ec_read_status(ec); |
171 | if (status != -EINVAL && | 171 | if (status != -EINVAL && |
172 | !(status & ACPI_EC_FLAG_BURST)){ | 172 | !(status & ACPI_EC_FLAG_BURST)){ |
173 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"entering burst mode \n")); | ||
174 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); | 173 | acpi_hw_low_level_write(8, ACPI_EC_BURST_ENABLE, &ec->command_addr); |
175 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); | 174 | status = acpi_ec_wait(ec, ACPI_EC_EVENT_OBF); |
176 | if (status){ | 175 | if (status){ |
177 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | 176 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
178 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR," status = %d\n", status)); | ||
179 | return_VALUE(-EINVAL); | 177 | return_VALUE(-EINVAL); |
180 | } | 178 | } |
181 | acpi_hw_low_level_read(8, &tmp, &ec->data_addr); | 179 | acpi_hw_low_level_read(8, &tmp, &ec->data_addr); |
182 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | 180 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
183 | if(tmp != 0x90 ) {/* Burst ACK byte*/ | 181 | if(tmp != 0x90 ) {/* Burst ACK byte*/ |
184 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"Ack failed \n")); | ||
185 | return_VALUE(-EINVAL); | 182 | return_VALUE(-EINVAL); |
186 | } | 183 | } |
187 | } else | 184 | } |
188 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in burst mode \n")); | 185 | |
189 | atomic_set(&ec->leaving_burst , 0); | 186 | atomic_set(&ec->leaving_burst , 0); |
190 | return_VALUE(0); | 187 | return_VALUE(0); |
191 | } | 188 | } |
@@ -202,7 +199,6 @@ acpi_ec_leave_burst_mode ( | |||
202 | status = acpi_ec_read_status(ec); | 199 | status = acpi_ec_read_status(ec); |
203 | if (status != -EINVAL && | 200 | if (status != -EINVAL && |
204 | (status & ACPI_EC_FLAG_BURST)){ | 201 | (status & ACPI_EC_FLAG_BURST)){ |
205 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n")); | ||
206 | acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); | 202 | acpi_hw_low_level_write(8, ACPI_EC_BURST_DISABLE, &ec->command_addr); |
207 | status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); | 203 | status = acpi_ec_wait(ec, ACPI_EC_FLAG_IBF); |
208 | if (status){ | 204 | if (status){ |
@@ -212,14 +208,7 @@ acpi_ec_leave_burst_mode ( | |||
212 | } | 208 | } |
213 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); | 209 | acpi_enable_gpe(NULL, ec->gpe_bit, ACPI_NOT_ISR); |
214 | status = acpi_ec_read_status(ec); | 210 | status = acpi_ec_read_status(ec); |
215 | if (status != -EINVAL && | 211 | } |
216 | (status & ACPI_EC_FLAG_BURST)) { | ||
217 | ACPI_DEBUG_PRINT((ACPI_DB_ERROR,"------->status fail\n")); | ||
218 | return_VALUE(-EINVAL); | ||
219 | } | ||
220 | }else | ||
221 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"already be in Non-burst mode \n")); | ||
222 | ACPI_DEBUG_PRINT((ACPI_DB_INFO,"leaving burst mode\n")); | ||
223 | 212 | ||
224 | return_VALUE(0); | 213 | return_VALUE(0); |
225 | } | 214 | } |
diff --git a/drivers/acpi/sleep/poweroff.c b/drivers/acpi/sleep/poweroff.c index 1fc86e6b5ab9..186b182c5825 100644 --- a/drivers/acpi/sleep/poweroff.c +++ b/drivers/acpi/sleep/poweroff.c | |||
@@ -19,8 +19,6 @@ | |||
19 | 19 | ||
20 | int acpi_sleep_prepare(u32 acpi_state) | 20 | int acpi_sleep_prepare(u32 acpi_state) |
21 | { | 21 | { |
22 | /* Flag to do not allow second time invocation for S5 state */ | ||
23 | static int shutdown_prepared = 0; | ||
24 | #ifdef CONFIG_ACPI_SLEEP | 22 | #ifdef CONFIG_ACPI_SLEEP |
25 | /* do we have a wakeup address for S2 and S3? */ | 23 | /* do we have a wakeup address for S2 and S3? */ |
26 | /* Here, we support only S4BIOS, those we set the wakeup address */ | 24 | /* Here, we support only S4BIOS, those we set the wakeup address */ |
@@ -38,28 +36,23 @@ int acpi_sleep_prepare(u32 acpi_state) | |||
38 | acpi_enable_wakeup_device_prep(acpi_state); | 36 | acpi_enable_wakeup_device_prep(acpi_state); |
39 | #endif | 37 | #endif |
40 | if (acpi_state == ACPI_STATE_S5) { | 38 | 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(); | 39 | acpi_wakeup_gpe_poweroff_prepare(); |
45 | shutdown_prepared = 1; | ||
46 | } | 40 | } |
47 | acpi_enter_sleep_state_prep(acpi_state); | 41 | acpi_enter_sleep_state_prep(acpi_state); |
48 | return 0; | 42 | return 0; |
49 | } | 43 | } |
50 | 44 | ||
45 | #ifdef CONFIG_PM | ||
46 | |||
51 | void acpi_power_off(void) | 47 | void acpi_power_off(void) |
52 | { | 48 | { |
49 | /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */ | ||
53 | printk("%s called\n", __FUNCTION__); | 50 | printk("%s called\n", __FUNCTION__); |
54 | acpi_sleep_prepare(ACPI_STATE_S5); | ||
55 | local_irq_disable(); | 51 | local_irq_disable(); |
56 | /* Some SMP machines only can poweroff in boot CPU */ | 52 | /* Some SMP machines only can poweroff in boot CPU */ |
57 | set_cpus_allowed(current, cpumask_of_cpu(0)); | ||
58 | acpi_enter_sleep_state(ACPI_STATE_S5); | 53 | acpi_enter_sleep_state(ACPI_STATE_S5); |
59 | } | 54 | } |
60 | 55 | ||
61 | #ifdef CONFIG_PM | ||
62 | |||
63 | static int acpi_shutdown(struct sys_device *x) | 56 | static int acpi_shutdown(struct sys_device *x) |
64 | { | 57 | { |
65 | return acpi_sleep_prepare(ACPI_STATE_S5); | 58 | return acpi_sleep_prepare(ACPI_STATE_S5); |
@@ -75,8 +68,6 @@ static struct sys_device device_acpi = { | |||
75 | .cls = &acpi_sysclass, | 68 | .cls = &acpi_sysclass, |
76 | }; | 69 | }; |
77 | 70 | ||
78 | #endif | ||
79 | |||
80 | static int acpi_poweroff_init(void) | 71 | static int acpi_poweroff_init(void) |
81 | { | 72 | { |
82 | if (!acpi_disabled) { | 73 | if (!acpi_disabled) { |
@@ -86,19 +77,18 @@ static int acpi_poweroff_init(void) | |||
86 | status = | 77 | status = |
87 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); | 78 | acpi_get_sleep_type_data(ACPI_STATE_S5, &type_a, &type_b); |
88 | if (ACPI_SUCCESS(status)) { | 79 | if (ACPI_SUCCESS(status)) { |
89 | pm_power_off = acpi_power_off; | 80 | int error; |
90 | #ifdef CONFIG_PM | 81 | error = sysdev_class_register(&acpi_sysclass); |
91 | { | 82 | if (!error) |
92 | int error; | 83 | error = sysdev_register(&device_acpi); |
93 | error = sysdev_class_register(&acpi_sysclass); | 84 | if (!error) |
94 | if (!error) | 85 | pm_power_off = acpi_power_off; |
95 | error = sysdev_register(&device_acpi); | 86 | return error; |
96 | return error; | ||
97 | } | ||
98 | #endif | ||
99 | } | 87 | } |
100 | } | 88 | } |
101 | return 0; | 89 | return 0; |
102 | } | 90 | } |
103 | 91 | ||
104 | late_initcall(acpi_poweroff_init); | 92 | late_initcall(acpi_poweroff_init); |
93 | |||
94 | #endif /* CONFIG_PM */ | ||