Deleted Added
full compact
hwsleep.c (107325) hwsleep.c (114237)
1
2/******************************************************************************
3 *
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
1
2/******************************************************************************
3 *
4 * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
5 * $Revision: 47 $
5 * $Revision: 52 $
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
6 *
7 *****************************************************************************/
8
9/******************************************************************************
10 *
11 * 1. Copyright Notice
12 *
13 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 309 unchanged lines hidden (view full) ---

331 Status = AcpiHwDisableNonWakeupGpes();
332 if (ACPI_FAILURE (Status))
333 {
334 return_ACPI_STATUS (Status);
335 }
336
337 /* Get current value of PM1A control */
338
14 * All rights reserved.
15 *
16 * 2. License
17 *
18 * 2.1. This is your license from Intel Corp. under its intellectual property
19 * rights. You may have additional license terms from the party that provided
20 * you this software, covering your right to use that party's intellectual
21 * property rights.

--- 309 unchanged lines hidden (view full) ---

331 Status = AcpiHwDisableNonWakeupGpes();
332 if (ACPI_FAILURE (Status))
333 {
334 return_ACPI_STATUS (Status);
335 }
336
337 /* Get current value of PM1A control */
338
339 Status = AcpiHwRegisterRead (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl);
339 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL, &PM1AControl);
340 if (ACPI_FAILURE (Status))
341 {
342 return_ACPI_STATUS (Status);
343 }
340 if (ACPI_FAILURE (Status))
341 {
342 return_ACPI_STATUS (Status);
343 }
344 ACPI_DEBUG_PRINT ((ACPI_DB_OK, "Entering S%d\n", SleepState));
344 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "Entering sleep state [S%d]\n", SleepState));
345
346 /* Clear SLP_EN and SLP_TYP fields */
347
348 PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask);
349 PM1BControl = PM1AControl;
350
351 /* Insert SLP_TYP bits */
352
353 PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
354 PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
355
356 /* Write #1: fill in SLP_TYP data */
357
345
346 /* Clear SLP_EN and SLP_TYP fields */
347
348 PM1AControl &= ~(SleepTypeRegInfo->AccessBitMask | SleepEnableRegInfo->AccessBitMask);
349 PM1BControl = PM1AControl;
350
351 /* Insert SLP_TYP bits */
352
353 PM1AControl |= (AcpiGbl_SleepTypeA << SleepTypeRegInfo->BitPosition);
354 PM1BControl |= (AcpiGbl_SleepTypeB << SleepTypeRegInfo->BitPosition);
355
356 /* Write #1: fill in SLP_TYP data */
357
358 Status = AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
358 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
359 if (ACPI_FAILURE (Status))
360 {
361 return_ACPI_STATUS (Status);
362 }
363
359 if (ACPI_FAILURE (Status))
360 {
361 return_ACPI_STATUS (Status);
362 }
363
364 Status = AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
364 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
365 if (ACPI_FAILURE (Status))
366 {
367 return_ACPI_STATUS (Status);
368 }
369
370 /* Insert SLP_ENABLE bit */
371
372 PM1AControl |= SleepEnableRegInfo->AccessBitMask;
373 PM1BControl |= SleepEnableRegInfo->AccessBitMask;
374
375 /* Write #2: SLP_TYP + SLP_EN */
376
377 ACPI_FLUSH_CPU_CACHE ();
378
365 if (ACPI_FAILURE (Status))
366 {
367 return_ACPI_STATUS (Status);
368 }
369
370 /* Insert SLP_ENABLE bit */
371
372 PM1AControl |= SleepEnableRegInfo->AccessBitMask;
373 PM1BControl |= SleepEnableRegInfo->AccessBitMask;
374
375 /* Write #2: SLP_TYP + SLP_EN */
376
377 ACPI_FLUSH_CPU_CACHE ();
378
379 Status = AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
379 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1A_CONTROL, PM1AControl);
380 if (ACPI_FAILURE (Status))
381 {
382 return_ACPI_STATUS (Status);
383 }
384
380 if (ACPI_FAILURE (Status))
381 {
382 return_ACPI_STATUS (Status);
383 }
384
385 Status = AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
385 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1B_CONTROL, PM1BControl);
386 if (ACPI_FAILURE (Status))
387 {
388 return_ACPI_STATUS (Status);
389 }
390
391 /*
392 * Wait a second, then try again. This is to get S4/5 to work on all machines.
393 */
394 if (SleepState > ACPI_STATE_S3)
395 {
396 /*
397 * We wait so long to allow chipsets that poll this reg very slowly to
398 * still read the right value. Ideally, this entire block would go
399 * away entirely.
400 */
401 AcpiOsStall (10000000);
402
386 if (ACPI_FAILURE (Status))
387 {
388 return_ACPI_STATUS (Status);
389 }
390
391 /*
392 * Wait a second, then try again. This is to get S4/5 to work on all machines.
393 */
394 if (SleepState > ACPI_STATE_S3)
395 {
396 /*
397 * We wait so long to allow chipsets that poll this reg very slowly to
398 * still read the right value. Ideally, this entire block would go
399 * away entirely.
400 */
401 AcpiOsStall (10000000);
402
403 Status = AcpiHwRegisterWrite (ACPI_MTX_LOCK, ACPI_REGISTER_PM1_CONTROL,
403 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_CONTROL,
404 SleepEnableRegInfo->AccessBitMask);
405 if (ACPI_FAILURE (Status))
406 {
407 return_ACPI_STATUS (Status);
408 }
409 }
410
411 /* Wait until we enter sleep state */
412
413 do
414 {
404 SleepEnableRegInfo->AccessBitMask);
405 if (ACPI_FAILURE (Status))
406 {
407 return_ACPI_STATUS (Status);
408 }
409 }
410
411 /* Wait until we enter sleep state */
412
413 do
414 {
415 Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_LOCK);
415 Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK);
416 if (ACPI_FAILURE (Status))
417 {
418 return_ACPI_STATUS (Status);
419 }
420
421 /* Spin until we wake */
422
423 } while (!InValue);
424
416 if (ACPI_FAILURE (Status))
417 {
418 return_ACPI_STATUS (Status);
419 }
420
421 /* Spin until we wake */
422
423 } while (!InValue);
424
425 Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_LOCK);
425 Status = AcpiSetRegister (ACPI_BITREG_ARB_DISABLE, 0, ACPI_MTX_DO_NOT_LOCK);
426 if (ACPI_FAILURE (Status))
427 {
428 return_ACPI_STATUS (Status);
429 }
430
431 return_ACPI_STATUS (AE_OK);
432}
433
426 if (ACPI_FAILURE (Status))
427 {
428 return_ACPI_STATUS (Status);
429 }
430
431 return_ACPI_STATUS (AE_OK);
432}
433
434
434/******************************************************************************
435 *
435/******************************************************************************
436 *
437 * FUNCTION: AcpiEnterSleepStateS4bios
438 *
439 * PARAMETERS: None
440 *
441 * RETURN: Status
442 *
443 * DESCRIPTION: Perform a S4 bios request.
444 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
445 *
446 ******************************************************************************/
447
448ACPI_STATUS
449AcpiEnterSleepStateS4bios (
450 void)
451{
452 UINT32 InValue;
453 ACPI_STATUS Status;
454
455
456 ACPI_FUNCTION_TRACE ("AcpiEnterSleepStateS4bios");
457
458 AcpiSetRegister (ACPI_BITREG_WAKE_STATUS, 1, ACPI_MTX_DO_NOT_LOCK);
459 AcpiHwClearAcpiStatus();
460
461 AcpiHwDisableNonWakeupGpes();
462
463 ACPI_FLUSH_CPU_CACHE();
464
465 Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (ACPI_INTEGER) AcpiGbl_FADT->S4BiosReq, 8);
466
467 do {
468 AcpiOsStall(1000);
469 Status = AcpiGetRegister (ACPI_BITREG_WAKE_STATUS, &InValue, ACPI_MTX_DO_NOT_LOCK);
470 if (ACPI_FAILURE (Status))
471 {
472 return_ACPI_STATUS (Status);
473 }
474 } while (!InValue);
475
476 return_ACPI_STATUS (AE_OK);
477}
478
479
480/******************************************************************************
481 *
436 * FUNCTION: AcpiLeaveSleepState
437 *
438 * PARAMETERS: SleepState - Which sleep state we just exited
439 *
440 * RETURN: Status
441 *
442 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
443 *

--- 53 unchanged lines hidden ---
482 * FUNCTION: AcpiLeaveSleepState
483 *
484 * PARAMETERS: SleepState - Which sleep state we just exited
485 *
486 * RETURN: Status
487 *
488 * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
489 *

--- 53 unchanged lines hidden ---