| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#define EXPORT_ACPI_INTERFACES |
| 45 |
|
| 46 |
#include "acpi.h" |
| 47 |
#include "accommon.h" |
| 48 |
|
| 49 |
#define _COMPONENT ACPI_HARDWARE |
| 50 |
ACPI_MODULE_NAME ("hwxfsleep") |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
static ACPI_STATUS |
| 55 |
AcpiHwSetFirmwareWakingVector ( |
| 56 |
ACPI_TABLE_FACS *Facs, |
| 57 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress, |
| 58 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress64); |
| 59 |
|
| 60 |
static ACPI_STATUS |
| 61 |
AcpiHwSleepDispatch ( |
| 62 |
UINT8 SleepState, |
| 63 |
UINT32 FunctionId); |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
#define ACPI_SLEEP_FUNCTION_ID 0 |
| 70 |
#define ACPI_WAKE_PREP_FUNCTION_ID 1 |
| 71 |
#define ACPI_WAKE_FUNCTION_ID 2 |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
static ACPI_SLEEP_FUNCTIONS AcpiSleepDispatch[] = |
| 76 |
{ |
| 77 |
{ACPI_STRUCT_INIT (LegacyFunction, |
| 78 |
ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacySleep)), |
| 79 |
ACPI_STRUCT_INIT (ExtendedFunction, |
| 80 |
AcpiHwExtendedSleep) }, |
| 81 |
{ACPI_STRUCT_INIT (LegacyFunction, |
| 82 |
ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWakePrep)), |
| 83 |
ACPI_STRUCT_INIT (ExtendedFunction, |
| 84 |
AcpiHwExtendedWakePrep) }, |
| 85 |
{ACPI_STRUCT_INIT (LegacyFunction, |
| 86 |
ACPI_HW_OPTIONAL_FUNCTION (AcpiHwLegacyWake)), |
| 87 |
ACPI_STRUCT_INIT (ExtendedFunction, |
| 88 |
AcpiHwExtendedWake) } |
| 89 |
}; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
static ACPI_STATUS |
| 109 |
AcpiHwSetFirmwareWakingVector ( |
| 110 |
ACPI_TABLE_FACS *Facs, |
| 111 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress, |
| 112 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress64) |
| 113 |
{ |
| 114 |
ACPI_FUNCTION_TRACE (AcpiHwSetFirmwareWakingVector); |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
Facs->FirmwareWakingVector = (UINT32) PhysicalAddress; |
| 128 |
|
| 129 |
if (Facs->Length > 32) |
| 130 |
{ |
| 131 |
if (Facs->Version >= 1) |
| 132 |
{ |
| 133 |
|
| 134 |
|
| 135 |
Facs->XFirmwareWakingVector = PhysicalAddress64; |
| 136 |
} |
| 137 |
else |
| 138 |
{ |
| 139 |
|
| 140 |
|
| 141 |
Facs->XFirmwareWakingVector = 0; |
| 142 |
} |
| 143 |
} |
| 144 |
|
| 145 |
return_ACPI_STATUS (AE_OK); |
| 146 |
} |
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
ACPI_STATUS |
| 165 |
AcpiSetFirmwareWakingVector ( |
| 166 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress, |
| 167 |
ACPI_PHYSICAL_ADDRESS PhysicalAddress64) |
| 168 |
{ |
| 169 |
|
| 170 |
ACPI_FUNCTION_TRACE (AcpiSetFirmwareWakingVector); |
| 171 |
|
| 172 |
if (AcpiGbl_FACS) |
| 173 |
{ |
| 174 |
(void) AcpiHwSetFirmwareWakingVector (AcpiGbl_FACS, |
| 175 |
PhysicalAddress, PhysicalAddress64); |
| 176 |
} |
| 177 |
|
| 178 |
return_ACPI_STATUS (AE_OK); |
| 179 |
} |
| 180 |
|
| 181 |
ACPI_EXPORT_SYMBOL (AcpiSetFirmwareWakingVector) |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
#if (!ACPI_REDUCED_HARDWARE) |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
ACPI_STATUS |
| 204 |
AcpiEnterSleepStateS4bios ( |
| 205 |
void) |
| 206 |
{ |
| 207 |
UINT32 InValue; |
| 208 |
ACPI_STATUS Status; |
| 209 |
|
| 210 |
|
| 211 |
ACPI_FUNCTION_TRACE (AcpiEnterSleepStateS4bios); |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS); |
| 217 |
if (ACPI_FAILURE (Status)) |
| 218 |
{ |
| 219 |
return_ACPI_STATUS (Status); |
| 220 |
} |
| 221 |
|
| 222 |
Status = AcpiHwClearAcpiStatus (); |
| 223 |
if (ACPI_FAILURE (Status)) |
| 224 |
{ |
| 225 |
return_ACPI_STATUS (Status); |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
Status = AcpiHwDisableAllGpes (); |
| 233 |
if (ACPI_FAILURE (Status)) |
| 234 |
{ |
| 235 |
return_ACPI_STATUS (Status); |
| 236 |
} |
| 237 |
AcpiGbl_SystemAwakeAndRunning = FALSE; |
| 238 |
|
| 239 |
Status = AcpiHwEnableAllWakeupGpes (); |
| 240 |
if (ACPI_FAILURE (Status)) |
| 241 |
{ |
| 242 |
return_ACPI_STATUS (Status); |
| 243 |
} |
| 244 |
|
| 245 |
Status = AcpiHwWritePort (AcpiGbl_FADT.SmiCommand, |
| 246 |
(UINT32) AcpiGbl_FADT.S4BiosRequest, 8); |
| 247 |
if (ACPI_FAILURE (Status)) |
| 248 |
{ |
| 249 |
return_ACPI_STATUS (Status); |
| 250 |
} |
| 251 |
|
| 252 |
do { |
| 253 |
AcpiOsStall (ACPI_USEC_PER_MSEC); |
| 254 |
Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &InValue); |
| 255 |
if (ACPI_FAILURE (Status)) |
| 256 |
{ |
| 257 |
return_ACPI_STATUS (Status); |
| 258 |
} |
| 259 |
|
| 260 |
} while (!InValue); |
| 261 |
|
| 262 |
return_ACPI_STATUS (AE_OK); |
| 263 |
} |
| 264 |
|
| 265 |
ACPI_EXPORT_SYMBOL (AcpiEnterSleepStateS4bios) |
| 266 |
|
| 267 |
#endif |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
static ACPI_STATUS |
| 285 |
AcpiHwSleepDispatch ( |
| 286 |
UINT8 SleepState, |
| 287 |
UINT32 FunctionId) |
| 288 |
{ |
| 289 |
ACPI_STATUS Status; |
| 290 |
ACPI_SLEEP_FUNCTIONS *SleepFunctions = &AcpiSleepDispatch[FunctionId]; |
| 291 |
|
| 292 |
|
| 293 |
#if (!ACPI_REDUCED_HARDWARE) |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
if (AcpiGbl_ReducedHardware) |
| 302 |
{ |
| 303 |
Status = SleepFunctions->ExtendedFunction (SleepState); |
| 304 |
} |
| 305 |
else |
| 306 |
{ |
| 307 |
|
| 308 |
|
| 309 |
Status = SleepFunctions->LegacyFunction (SleepState); |
| 310 |
} |
| 311 |
|
| 312 |
return (Status); |
| 313 |
|
| 314 |
#else |
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
Status = SleepFunctions->ExtendedFunction (SleepState); |
| 320 |
return (Status); |
| 321 |
|
| 322 |
#endif |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
ACPI_STATUS |
| 342 |
AcpiEnterSleepStatePrep ( |
| 343 |
UINT8 SleepState) |
| 344 |
{ |
| 345 |
ACPI_STATUS Status; |
| 346 |
ACPI_OBJECT_LIST ArgList; |
| 347 |
ACPI_OBJECT Arg; |
| 348 |
UINT32 SstValue; |
| 349 |
|
| 350 |
|
| 351 |
ACPI_FUNCTION_TRACE (AcpiEnterSleepStatePrep); |
| 352 |
|
| 353 |
|
| 354 |
Status = AcpiGetSleepTypeData (SleepState, |
| 355 |
&AcpiGbl_SleepTypeA, &AcpiGbl_SleepTypeB); |
| 356 |
if (ACPI_FAILURE (Status)) |
| 357 |
{ |
| 358 |
return_ACPI_STATUS (Status); |
| 359 |
} |
| 360 |
|
| 361 |
Status = AcpiGetSleepTypeData (ACPI_STATE_S0, |
| 362 |
&AcpiGbl_SleepTypeAS0, &AcpiGbl_SleepTypeBS0); |
| 363 |
if (ACPI_FAILURE (Status)) { |
| 364 |
AcpiGbl_SleepTypeAS0 = ACPI_SLEEP_TYPE_INVALID; |
| 365 |
} |
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
ArgList.Count = 1; |
| 370 |
ArgList.Pointer = &Arg; |
| 371 |
Arg.Type = ACPI_TYPE_INTEGER; |
| 372 |
Arg.Integer.Value = SleepState; |
| 373 |
|
| 374 |
Status = AcpiEvaluateObject (NULL, METHOD_PATHNAME__PTS, &ArgList, NULL); |
| 375 |
if (ACPI_FAILURE (Status) && Status != AE_NOT_FOUND) |
| 376 |
{ |
| 377 |
return_ACPI_STATUS (Status); |
| 378 |
} |
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
switch (SleepState) |
| 383 |
{ |
| 384 |
case ACPI_STATE_S0: |
| 385 |
|
| 386 |
SstValue = ACPI_SST_WORKING; |
| 387 |
break; |
| 388 |
|
| 389 |
case ACPI_STATE_S1: |
| 390 |
case ACPI_STATE_S2: |
| 391 |
case ACPI_STATE_S3: |
| 392 |
|
| 393 |
SstValue = ACPI_SST_SLEEPING; |
| 394 |
break; |
| 395 |
|
| 396 |
case ACPI_STATE_S4: |
| 397 |
|
| 398 |
SstValue = ACPI_SST_SLEEP_CONTEXT; |
| 399 |
break; |
| 400 |
|
| 401 |
default: |
| 402 |
|
| 403 |
SstValue = ACPI_SST_INDICATOR_OFF; |
| 404 |
break; |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
AcpiHwExecuteSleepMethod (METHOD_PATHNAME__SST, SstValue); |
| 412 |
return_ACPI_STATUS (AE_OK); |
| 413 |
} |
| 414 |
|
| 415 |
ACPI_EXPORT_SYMBOL (AcpiEnterSleepStatePrep) |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
ACPI_STATUS |
| 432 |
AcpiEnterSleepState ( |
| 433 |
UINT8 SleepState) |
| 434 |
{ |
| 435 |
ACPI_STATUS Status; |
| 436 |
|
| 437 |
|
| 438 |
ACPI_FUNCTION_TRACE (AcpiEnterSleepState); |
| 439 |
|
| 440 |
|
| 441 |
if ((AcpiGbl_SleepTypeA > ACPI_SLEEP_TYPE_MAX) || |
| 442 |
(AcpiGbl_SleepTypeB > ACPI_SLEEP_TYPE_MAX)) |
| 443 |
{ |
| 444 |
ACPI_ERROR ((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X", |
| 445 |
AcpiGbl_SleepTypeA, AcpiGbl_SleepTypeB)); |
| 446 |
return_ACPI_STATUS (AE_AML_OPERAND_VALUE); |
| 447 |
} |
| 448 |
|
| 449 |
Status = AcpiHwSleepDispatch (SleepState, ACPI_SLEEP_FUNCTION_ID); |
| 450 |
return_ACPI_STATUS (Status); |
| 451 |
} |
| 452 |
|
| 453 |
ACPI_EXPORT_SYMBOL (AcpiEnterSleepState) |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
ACPI_STATUS |
| 472 |
AcpiLeaveSleepStatePrep ( |
| 473 |
UINT8 SleepState) |
| 474 |
{ |
| 475 |
ACPI_STATUS Status; |
| 476 |
|
| 477 |
|
| 478 |
ACPI_FUNCTION_TRACE (AcpiLeaveSleepStatePrep); |
| 479 |
|
| 480 |
|
| 481 |
Status = AcpiHwSleepDispatch (SleepState, ACPI_WAKE_PREP_FUNCTION_ID); |
| 482 |
return_ACPI_STATUS (Status); |
| 483 |
} |
| 484 |
|
| 485 |
ACPI_EXPORT_SYMBOL (AcpiLeaveSleepStatePrep) |
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
ACPI_STATUS |
| 502 |
AcpiLeaveSleepState ( |
| 503 |
UINT8 SleepState) |
| 504 |
{ |
| 505 |
ACPI_STATUS Status; |
| 506 |
|
| 507 |
|
| 508 |
ACPI_FUNCTION_TRACE (AcpiLeaveSleepState); |
| 509 |
|
| 510 |
|
| 511 |
Status = AcpiHwSleepDispatch (SleepState, ACPI_WAKE_FUNCTION_ID); |
| 512 |
return_ACPI_STATUS (Status); |
| 513 |
} |
| 514 |
|
| 515 |
ACPI_EXPORT_SYMBOL (AcpiLeaveSleepState) |