aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/hardware/hwsleep.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/hardware/hwsleep.c')
-rw-r--r--drivers/acpi/hardware/hwsleep.c415
1 files changed, 208 insertions, 207 deletions
diff --git a/drivers/acpi/hardware/hwsleep.c b/drivers/acpi/hardware/hwsleep.c
index cedee0c43b5f..34519069050c 100644
--- a/drivers/acpi/hardware/hwsleep.c
+++ b/drivers/acpi/hardware/hwsleep.c
@@ -46,8 +46,7 @@
46#include <acpi/acpi.h> 46#include <acpi/acpi.h>
47 47
48#define _COMPONENT ACPI_HARDWARE 48#define _COMPONENT ACPI_HARDWARE
49 ACPI_MODULE_NAME ("hwsleep") 49ACPI_MODULE_NAME("hwsleep")
50
51 50
52/******************************************************************************* 51/*******************************************************************************
53 * 52 *
@@ -61,30 +60,25 @@
61 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS 60 * DESCRIPTION: Access function for the firmware_waking_vector field in FACS
62 * 61 *
63 ******************************************************************************/ 62 ******************************************************************************/
64
65acpi_status 63acpi_status
66acpi_set_firmware_waking_vector ( 64acpi_set_firmware_waking_vector(acpi_physical_address physical_address)
67 acpi_physical_address physical_address)
68{ 65{
69 66
70 ACPI_FUNCTION_TRACE ("acpi_set_firmware_waking_vector"); 67 ACPI_FUNCTION_TRACE("acpi_set_firmware_waking_vector");
71
72 68
73 /* Set the vector */ 69 /* Set the vector */
74 70
75 if (acpi_gbl_common_fACS.vector_width == 32) { 71 if (acpi_gbl_common_fACS.vector_width == 32) {
76 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)) 72 *(ACPI_CAST_PTR
77 = (u32) physical_address; 73 (u32, acpi_gbl_common_fACS.firmware_waking_vector))
78 } 74 = (u32) physical_address;
79 else { 75 } else {
80 *acpi_gbl_common_fACS.firmware_waking_vector 76 *acpi_gbl_common_fACS.firmware_waking_vector = physical_address;
81 = physical_address;
82 } 77 }
83 78
84 return_ACPI_STATUS (AE_OK); 79 return_ACPI_STATUS(AE_OK);
85} 80}
86 81
87
88/******************************************************************************* 82/*******************************************************************************
89 * 83 *
90 * FUNCTION: acpi_get_firmware_waking_vector 84 * FUNCTION: acpi_get_firmware_waking_vector
@@ -101,33 +95,31 @@ acpi_set_firmware_waking_vector (
101 95
102#ifdef ACPI_FUTURE_USAGE 96#ifdef ACPI_FUTURE_USAGE
103acpi_status 97acpi_status
104acpi_get_firmware_waking_vector ( 98acpi_get_firmware_waking_vector(acpi_physical_address * physical_address)
105 acpi_physical_address *physical_address)
106{ 99{
107 100
108 ACPI_FUNCTION_TRACE ("acpi_get_firmware_waking_vector"); 101 ACPI_FUNCTION_TRACE("acpi_get_firmware_waking_vector");
109
110 102
111 if (!physical_address) { 103 if (!physical_address) {
112 return_ACPI_STATUS (AE_BAD_PARAMETER); 104 return_ACPI_STATUS(AE_BAD_PARAMETER);
113 } 105 }
114 106
115 /* Get the vector */ 107 /* Get the vector */
116 108
117 if (acpi_gbl_common_fACS.vector_width == 32) { 109 if (acpi_gbl_common_fACS.vector_width == 32) {
118 *physical_address = (acpi_physical_address) 110 *physical_address = (acpi_physical_address)
119 *(ACPI_CAST_PTR (u32, acpi_gbl_common_fACS.firmware_waking_vector)); 111 *
120 } 112 (ACPI_CAST_PTR
121 else { 113 (u32, acpi_gbl_common_fACS.firmware_waking_vector));
114 } else {
122 *physical_address = 115 *physical_address =
123 *acpi_gbl_common_fACS.firmware_waking_vector; 116 *acpi_gbl_common_fACS.firmware_waking_vector;
124 } 117 }
125 118
126 return_ACPI_STATUS (AE_OK); 119 return_ACPI_STATUS(AE_OK);
127} 120}
128#endif 121#endif
129 122
130
131/******************************************************************************* 123/*******************************************************************************
132 * 124 *
133 * FUNCTION: acpi_enter_sleep_state_prep 125 * FUNCTION: acpi_enter_sleep_state_prep
@@ -143,25 +135,22 @@ acpi_get_firmware_waking_vector (
143 * 135 *
144 ******************************************************************************/ 136 ******************************************************************************/
145 137
146acpi_status 138acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
147acpi_enter_sleep_state_prep (
148 u8 sleep_state)
149{ 139{
150 acpi_status status; 140 acpi_status status;
151 struct acpi_object_list arg_list; 141 struct acpi_object_list arg_list;
152 union acpi_object arg; 142 union acpi_object arg;
153
154
155 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_prep");
156 143
144 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_prep");
157 145
158 /* 146 /*
159 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc. 147 * _PSW methods could be run here to enable wake-on keyboard, LAN, etc.
160 */ 148 */
161 status = acpi_get_sleep_type_data (sleep_state, 149 status = acpi_get_sleep_type_data(sleep_state,
162 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 150 &acpi_gbl_sleep_type_a,
163 if (ACPI_FAILURE (status)) { 151 &acpi_gbl_sleep_type_b);
164 return_ACPI_STATUS (status); 152 if (ACPI_FAILURE(status)) {
153 return_ACPI_STATUS(status);
165 } 154 }
166 155
167 /* Setup parameter object */ 156 /* Setup parameter object */
@@ -174,14 +163,14 @@ acpi_enter_sleep_state_prep (
174 163
175 /* Run the _PTS and _GTS methods */ 164 /* Run the _PTS and _GTS methods */
176 165
177 status = acpi_evaluate_object (NULL, METHOD_NAME__PTS, &arg_list, NULL); 166 status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
178 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 167 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
179 return_ACPI_STATUS (status); 168 return_ACPI_STATUS(status);
180 } 169 }
181 170
182 status = acpi_evaluate_object (NULL, METHOD_NAME__GTS, &arg_list, NULL); 171 status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
183 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 172 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
184 return_ACPI_STATUS (status); 173 return_ACPI_STATUS(status);
185 } 174 }
186 175
187 /* Setup the argument to _SST */ 176 /* Setup the argument to _SST */
@@ -202,22 +191,21 @@ acpi_enter_sleep_state_prep (
202 break; 191 break;
203 192
204 default: 193 default:
205 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */ 194 arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
206 break; 195 break;
207 } 196 }
208 197
209 /* Set the system indicators to show the desired sleep state. */ 198 /* Set the system indicators to show the desired sleep state. */
210 199
211 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 200 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
212 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 201 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
213 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 202 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
214 acpi_format_exception (status))); 203 acpi_format_exception(status)));
215 } 204 }
216 205
217 return_ACPI_STATUS (AE_OK); 206 return_ACPI_STATUS(AE_OK);
218} 207}
219 208
220
221/******************************************************************************* 209/*******************************************************************************
222 * 210 *
223 * FUNCTION: acpi_enter_sleep_state 211 * FUNCTION: acpi_enter_sleep_state
@@ -231,80 +219,82 @@ acpi_enter_sleep_state_prep (
231 * 219 *
232 ******************************************************************************/ 220 ******************************************************************************/
233 221
234acpi_status asmlinkage 222acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
235acpi_enter_sleep_state (
236 u8 sleep_state)
237{ 223{
238 u32 PM1Acontrol; 224 u32 PM1Acontrol;
239 u32 PM1Bcontrol; 225 u32 PM1Bcontrol;
240 struct acpi_bit_register_info *sleep_type_reg_info; 226 struct acpi_bit_register_info *sleep_type_reg_info;
241 struct acpi_bit_register_info *sleep_enable_reg_info; 227 struct acpi_bit_register_info *sleep_enable_reg_info;
242 u32 in_value; 228 u32 in_value;
243 acpi_status status; 229 acpi_status status;
244
245
246 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state");
247 230
231 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state");
248 232
249 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) || 233 if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
250 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) { 234 (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
251 ACPI_REPORT_ERROR (("Sleep values out of range: A=%X B=%X\n", 235 ACPI_REPORT_ERROR(("Sleep values out of range: A=%X B=%X\n",
252 acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b)); 236 acpi_gbl_sleep_type_a,
253 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 237 acpi_gbl_sleep_type_b));
238 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
254 } 239 }
255 240
256 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 241 sleep_type_reg_info =
257 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 242 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
243 sleep_enable_reg_info =
244 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
258 245
259 /* Clear wake status */ 246 /* Clear wake status */
260 247
261 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 248 status =
262 if (ACPI_FAILURE (status)) { 249 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
263 return_ACPI_STATUS (status); 250 if (ACPI_FAILURE(status)) {
251 return_ACPI_STATUS(status);
264 } 252 }
265 253
266 /* Clear all fixed and general purpose status bits */ 254 /* Clear all fixed and general purpose status bits */
267 255
268 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 256 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
269 if (ACPI_FAILURE (status)) { 257 if (ACPI_FAILURE(status)) {
270 return_ACPI_STATUS (status); 258 return_ACPI_STATUS(status);
271 } 259 }
272 260
273 /* 261 /*
274 * 1) Disable/Clear all GPEs 262 * 1) Disable/Clear all GPEs
275 * 2) Enable all wakeup GPEs 263 * 2) Enable all wakeup GPEs
276 */ 264 */
277 status = acpi_hw_disable_all_gpes (); 265 status = acpi_hw_disable_all_gpes();
278 if (ACPI_FAILURE (status)) { 266 if (ACPI_FAILURE(status)) {
279 return_ACPI_STATUS (status); 267 return_ACPI_STATUS(status);
280 } 268 }
281 acpi_gbl_system_awake_and_running = FALSE; 269 acpi_gbl_system_awake_and_running = FALSE;
282 270
283 status = acpi_hw_enable_all_wakeup_gpes (); 271 status = acpi_hw_enable_all_wakeup_gpes();
284 if (ACPI_FAILURE (status)) { 272 if (ACPI_FAILURE(status)) {
285 return_ACPI_STATUS (status); 273 return_ACPI_STATUS(status);
286 } 274 }
287 275
288 /* Get current value of PM1A control */ 276 /* Get current value of PM1A control */
289 277
290 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 278 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
291 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 279 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
292 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
293 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
294 } 282 }
295 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, 283 ACPI_DEBUG_PRINT((ACPI_DB_INIT,
296 "Entering sleep state [S%d]\n", sleep_state)); 284 "Entering sleep state [S%d]\n", sleep_state));
297 285
298 /* Clear SLP_EN and SLP_TYP fields */ 286 /* Clear SLP_EN and SLP_TYP fields */
299 287
300 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 288 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
301 sleep_enable_reg_info->access_bit_mask); 289 sleep_enable_reg_info->access_bit_mask);
302 PM1Bcontrol = PM1Acontrol; 290 PM1Bcontrol = PM1Acontrol;
303 291
304 /* Insert SLP_TYP bits */ 292 /* Insert SLP_TYP bits */
305 293
306 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 294 PM1Acontrol |=
307 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 295 (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
296 PM1Bcontrol |=
297 (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
308 298
309 /* 299 /*
310 * We split the writes of SLP_TYP and SLP_EN to workaround 300 * We split the writes of SLP_TYP and SLP_EN to workaround
@@ -313,16 +303,18 @@ acpi_enter_sleep_state (
313 303
314 /* Write #1: fill in SLP_TYP data */ 304 /* Write #1: fill in SLP_TYP data */
315 305
316 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 306 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
317 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 307 ACPI_REGISTER_PM1A_CONTROL,
318 if (ACPI_FAILURE (status)) { 308 PM1Acontrol);
319 return_ACPI_STATUS (status); 309 if (ACPI_FAILURE(status)) {
310 return_ACPI_STATUS(status);
320 } 311 }
321 312
322 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 313 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
323 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 314 ACPI_REGISTER_PM1B_CONTROL,
324 if (ACPI_FAILURE (status)) { 315 PM1Bcontrol);
325 return_ACPI_STATUS (status); 316 if (ACPI_FAILURE(status)) {
317 return_ACPI_STATUS(status);
326 } 318 }
327 319
328 /* Insert SLP_ENABLE bit */ 320 /* Insert SLP_ENABLE bit */
@@ -332,18 +324,20 @@ acpi_enter_sleep_state (
332 324
333 /* Write #2: SLP_TYP + SLP_EN */ 325 /* Write #2: SLP_TYP + SLP_EN */
334 326
335 ACPI_FLUSH_CPU_CACHE (); 327 ACPI_FLUSH_CPU_CACHE();
336 328
337 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 329 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
338 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 330 ACPI_REGISTER_PM1A_CONTROL,
339 if (ACPI_FAILURE (status)) { 331 PM1Acontrol);
340 return_ACPI_STATUS (status); 332 if (ACPI_FAILURE(status)) {
333 return_ACPI_STATUS(status);
341 } 334 }
342 335
343 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 336 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
344 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 337 ACPI_REGISTER_PM1B_CONTROL,
345 if (ACPI_FAILURE (status)) { 338 PM1Bcontrol);
346 return_ACPI_STATUS (status); 339 if (ACPI_FAILURE(status)) {
340 return_ACPI_STATUS(status);
347 } 341 }
348 342
349 if (sleep_state > ACPI_STATE_S3) { 343 if (sleep_state > ACPI_STATE_S3) {
@@ -358,33 +352,34 @@ acpi_enter_sleep_state (
358 * still read the right value. Ideally, this block would go 352 * still read the right value. Ideally, this block would go
359 * away entirely. 353 * away entirely.
360 */ 354 */
361 acpi_os_stall (10000000); 355 acpi_os_stall(10000000);
362 356
363 status = acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 357 status = acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
364 ACPI_REGISTER_PM1_CONTROL, 358 ACPI_REGISTER_PM1_CONTROL,
365 sleep_enable_reg_info->access_bit_mask); 359 sleep_enable_reg_info->
366 if (ACPI_FAILURE (status)) { 360 access_bit_mask);
367 return_ACPI_STATUS (status); 361 if (ACPI_FAILURE(status)) {
362 return_ACPI_STATUS(status);
368 } 363 }
369 } 364 }
370 365
371 /* Wait until we enter sleep state */ 366 /* Wait until we enter sleep state */
372 367
373 do { 368 do {
374 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 369 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
375 ACPI_MTX_DO_NOT_LOCK); 370 ACPI_MTX_DO_NOT_LOCK);
376 if (ACPI_FAILURE (status)) { 371 if (ACPI_FAILURE(status)) {
377 return_ACPI_STATUS (status); 372 return_ACPI_STATUS(status);
378 } 373 }
379 374
380 /* Spin until we wake */ 375 /* Spin until we wake */
381 376
382 } while (!in_value); 377 } while (!in_value);
383 378
384 return_ACPI_STATUS (AE_OK); 379 return_ACPI_STATUS(AE_OK);
385} 380}
386EXPORT_SYMBOL(acpi_enter_sleep_state);
387 381
382EXPORT_SYMBOL(acpi_enter_sleep_state);
388 383
389/******************************************************************************* 384/*******************************************************************************
390 * 385 *
@@ -399,60 +394,57 @@ EXPORT_SYMBOL(acpi_enter_sleep_state);
399 * 394 *
400 ******************************************************************************/ 395 ******************************************************************************/
401 396
402acpi_status asmlinkage 397acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
403acpi_enter_sleep_state_s4bios (
404 void)
405{ 398{
406 u32 in_value; 399 u32 in_value;
407 acpi_status status; 400 acpi_status status;
408
409 401
410 ACPI_FUNCTION_TRACE ("acpi_enter_sleep_state_s4bios"); 402 ACPI_FUNCTION_TRACE("acpi_enter_sleep_state_s4bios");
411 403
412 404 status =
413 status = acpi_set_register (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK); 405 acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
414 if (ACPI_FAILURE (status)) { 406 if (ACPI_FAILURE(status)) {
415 return_ACPI_STATUS (status); 407 return_ACPI_STATUS(status);
416 } 408 }
417 409
418 status = acpi_hw_clear_acpi_status (ACPI_MTX_DO_NOT_LOCK); 410 status = acpi_hw_clear_acpi_status(ACPI_MTX_DO_NOT_LOCK);
419 if (ACPI_FAILURE (status)) { 411 if (ACPI_FAILURE(status)) {
420 return_ACPI_STATUS (status); 412 return_ACPI_STATUS(status);
421 } 413 }
422 414
423 /* 415 /*
424 * 1) Disable/Clear all GPEs 416 * 1) Disable/Clear all GPEs
425 * 2) Enable all wakeup GPEs 417 * 2) Enable all wakeup GPEs
426 */ 418 */
427 status = acpi_hw_disable_all_gpes (); 419 status = acpi_hw_disable_all_gpes();
428 if (ACPI_FAILURE (status)) { 420 if (ACPI_FAILURE(status)) {
429 return_ACPI_STATUS (status); 421 return_ACPI_STATUS(status);
430 } 422 }
431 acpi_gbl_system_awake_and_running = FALSE; 423 acpi_gbl_system_awake_and_running = FALSE;
432 424
433 status = acpi_hw_enable_all_wakeup_gpes (); 425 status = acpi_hw_enable_all_wakeup_gpes();
434 if (ACPI_FAILURE (status)) { 426 if (ACPI_FAILURE(status)) {
435 return_ACPI_STATUS (status); 427 return_ACPI_STATUS(status);
436 } 428 }
437 429
438 ACPI_FLUSH_CPU_CACHE (); 430 ACPI_FLUSH_CPU_CACHE();
439 431
440 status = acpi_os_write_port (acpi_gbl_FADT->smi_cmd, 432 status = acpi_os_write_port(acpi_gbl_FADT->smi_cmd,
441 (u32) acpi_gbl_FADT->S4bios_req, 8); 433 (u32) acpi_gbl_FADT->S4bios_req, 8);
442 434
443 do { 435 do {
444 acpi_os_stall(1000); 436 acpi_os_stall(1000);
445 status = acpi_get_register (ACPI_BITREG_WAKE_STATUS, &in_value, 437 status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value,
446 ACPI_MTX_DO_NOT_LOCK); 438 ACPI_MTX_DO_NOT_LOCK);
447 if (ACPI_FAILURE (status)) { 439 if (ACPI_FAILURE(status)) {
448 return_ACPI_STATUS (status); 440 return_ACPI_STATUS(status);
449 } 441 }
450 } while (!in_value); 442 } while (!in_value);
451 443
452 return_ACPI_STATUS (AE_OK); 444 return_ACPI_STATUS(AE_OK);
453} 445}
454EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
455 446
447EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
456 448
457/******************************************************************************* 449/*******************************************************************************
458 * 450 *
@@ -467,55 +459,62 @@ EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios);
467 * 459 *
468 ******************************************************************************/ 460 ******************************************************************************/
469 461
470acpi_status 462acpi_status acpi_leave_sleep_state(u8 sleep_state)
471acpi_leave_sleep_state (
472 u8 sleep_state)
473{ 463{
474 struct acpi_object_list arg_list; 464 struct acpi_object_list arg_list;
475 union acpi_object arg; 465 union acpi_object arg;
476 acpi_status status; 466 acpi_status status;
477 struct acpi_bit_register_info *sleep_type_reg_info; 467 struct acpi_bit_register_info *sleep_type_reg_info;
478 struct acpi_bit_register_info *sleep_enable_reg_info; 468 struct acpi_bit_register_info *sleep_enable_reg_info;
479 u32 PM1Acontrol; 469 u32 PM1Acontrol;
480 u32 PM1Bcontrol; 470 u32 PM1Bcontrol;
481
482
483 ACPI_FUNCTION_TRACE ("acpi_leave_sleep_state");
484 471
472 ACPI_FUNCTION_TRACE("acpi_leave_sleep_state");
485 473
486 /* 474 /*
487 * Set SLP_TYPE and SLP_EN to state S0. 475 * Set SLP_TYPE and SLP_EN to state S0.
488 * This is unclear from the ACPI Spec, but it is required 476 * This is unclear from the ACPI Spec, but it is required
489 * by some machines. 477 * by some machines.
490 */ 478 */
491 status = acpi_get_sleep_type_data (ACPI_STATE_S0, 479 status = acpi_get_sleep_type_data(ACPI_STATE_S0,
492 &acpi_gbl_sleep_type_a, &acpi_gbl_sleep_type_b); 480 &acpi_gbl_sleep_type_a,
493 if (ACPI_SUCCESS (status)) { 481 &acpi_gbl_sleep_type_b);
494 sleep_type_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_TYPE_A); 482 if (ACPI_SUCCESS(status)) {
495 sleep_enable_reg_info = acpi_hw_get_bit_register_info (ACPI_BITREG_SLEEP_ENABLE); 483 sleep_type_reg_info =
484 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
485 sleep_enable_reg_info =
486 acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
496 487
497 /* Get current value of PM1A control */ 488 /* Get current value of PM1A control */
498 489
499 status = acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK, 490 status = acpi_hw_register_read(ACPI_MTX_DO_NOT_LOCK,
500 ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol); 491 ACPI_REGISTER_PM1_CONTROL,
501 if (ACPI_SUCCESS (status)) { 492 &PM1Acontrol);
493 if (ACPI_SUCCESS(status)) {
502 /* Clear SLP_EN and SLP_TYP fields */ 494 /* Clear SLP_EN and SLP_TYP fields */
503 495
504 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask | 496 PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
505 sleep_enable_reg_info->access_bit_mask); 497 sleep_enable_reg_info->
498 access_bit_mask);
506 PM1Bcontrol = PM1Acontrol; 499 PM1Bcontrol = PM1Acontrol;
507 500
508 /* Insert SLP_TYP bits */ 501 /* Insert SLP_TYP bits */
509 502
510 PM1Acontrol |= (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position); 503 PM1Acontrol |=
511 PM1Bcontrol |= (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position); 504 (acpi_gbl_sleep_type_a << sleep_type_reg_info->
505 bit_position);
506 PM1Bcontrol |=
507 (acpi_gbl_sleep_type_b << sleep_type_reg_info->
508 bit_position);
512 509
513 /* Just ignore any errors */ 510 /* Just ignore any errors */
514 511
515 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 512 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1A_CONTROL, PM1Acontrol); 513 ACPI_REGISTER_PM1A_CONTROL,
517 (void) acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK, 514 PM1Acontrol);
518 ACPI_REGISTER_PM1B_CONTROL, PM1Bcontrol); 515 (void)acpi_hw_register_write(ACPI_MTX_DO_NOT_LOCK,
516 ACPI_REGISTER_PM1B_CONTROL,
517 PM1Bcontrol);
519 } 518 }
520 } 519 }
521 520
@@ -532,23 +531,23 @@ acpi_leave_sleep_state (
532 /* Ignore any errors from these methods */ 531 /* Ignore any errors from these methods */
533 532
534 arg.integer.value = ACPI_SST_WAKING; 533 arg.integer.value = ACPI_SST_WAKING;
535 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 534 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
536 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 535 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
537 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 536 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
538 acpi_format_exception (status))); 537 acpi_format_exception(status)));
539 } 538 }
540 539
541 arg.integer.value = sleep_state; 540 arg.integer.value = sleep_state;
542 status = acpi_evaluate_object (NULL, METHOD_NAME__BFS, &arg_list, NULL); 541 status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
543 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 542 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
544 ACPI_REPORT_ERROR (("Method _BFS failed, %s\n", 543 ACPI_REPORT_ERROR(("Method _BFS failed, %s\n",
545 acpi_format_exception (status))); 544 acpi_format_exception(status)));
546 } 545 }
547 546
548 status = acpi_evaluate_object (NULL, METHOD_NAME__WAK, &arg_list, NULL); 547 status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
549 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 548 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
550 ACPI_REPORT_ERROR (("Method _WAK failed, %s\n", 549 ACPI_REPORT_ERROR(("Method _WAK failed, %s\n",
551 acpi_format_exception (status))); 550 acpi_format_exception(status)));
552 } 551 }
553 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */ 552 /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
554 553
@@ -557,33 +556,35 @@ acpi_leave_sleep_state (
557 * 1) Disable/Clear all GPEs 556 * 1) Disable/Clear all GPEs
558 * 2) Enable all runtime GPEs 557 * 2) Enable all runtime GPEs
559 */ 558 */
560 status = acpi_hw_disable_all_gpes (); 559 status = acpi_hw_disable_all_gpes();
561 if (ACPI_FAILURE (status)) { 560 if (ACPI_FAILURE(status)) {
562 return_ACPI_STATUS (status); 561 return_ACPI_STATUS(status);
563 } 562 }
564 acpi_gbl_system_awake_and_running = TRUE; 563 acpi_gbl_system_awake_and_running = TRUE;
565 564
566 status = acpi_hw_enable_all_runtime_gpes (); 565 status = acpi_hw_enable_all_runtime_gpes();
567 if (ACPI_FAILURE (status)) { 566 if (ACPI_FAILURE(status)) {
568 return_ACPI_STATUS (status); 567 return_ACPI_STATUS(status);
569 } 568 }
570 569
571 /* Enable power button */ 570 /* Enable power button */
572 571
573 (void) acpi_set_register( 572 (void)
574 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].enable_register_id, 573 acpi_set_register(acpi_gbl_fixed_event_info
575 1, ACPI_MTX_DO_NOT_LOCK); 574 [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1,
575 ACPI_MTX_DO_NOT_LOCK);
576 576
577 (void) acpi_set_register( 577 (void)
578 acpi_gbl_fixed_event_info[ACPI_EVENT_POWER_BUTTON].status_register_id, 578 acpi_set_register(acpi_gbl_fixed_event_info
579 1, ACPI_MTX_DO_NOT_LOCK); 579 [ACPI_EVENT_POWER_BUTTON].status_register_id, 1,
580 ACPI_MTX_DO_NOT_LOCK);
580 581
581 arg.integer.value = ACPI_SST_WORKING; 582 arg.integer.value = ACPI_SST_WORKING;
582 status = acpi_evaluate_object (NULL, METHOD_NAME__SST, &arg_list, NULL); 583 status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
583 if (ACPI_FAILURE (status) && status != AE_NOT_FOUND) { 584 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
584 ACPI_REPORT_ERROR (("Method _SST failed, %s\n", 585 ACPI_REPORT_ERROR(("Method _SST failed, %s\n",
585 acpi_format_exception (status))); 586 acpi_format_exception(status)));
586 } 587 }
587 588
588 return_ACPI_STATUS (status); 589 return_ACPI_STATUS(status);
589} 590}