hwsleep.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. /******************************************************************************
  2. *
  3. * Name: hwsleep.c - ACPI Hardware Sleep/Wake Interface
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2011, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "actables.h"
  45. #include <linux/tboot.h>
  46. #define _COMPONENT ACPI_HARDWARE
  47. ACPI_MODULE_NAME("hwsleep")
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_set_firmware_waking_vector
  51. *
  52. * PARAMETERS: physical_address - 32-bit physical address of ACPI real mode
  53. * entry point.
  54. *
  55. * RETURN: Status
  56. *
  57. * DESCRIPTION: Sets the 32-bit firmware_waking_vector field of the FACS
  58. *
  59. ******************************************************************************/
  60. acpi_status
  61. acpi_set_firmware_waking_vector(u32 physical_address)
  62. {
  63. ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector);
  64. /*
  65. * According to the ACPI specification 2.0c and later, the 64-bit
  66. * waking vector should be cleared and the 32-bit waking vector should
  67. * be used, unless we want the wake-up code to be called by the BIOS in
  68. * Protected Mode. Some systems (for example HP dv5-1004nr) are known
  69. * to fail to resume if the 64-bit vector is used.
  70. */
  71. /* Set the 32-bit vector */
  72. acpi_gbl_FACS->firmware_waking_vector = physical_address;
  73. /* Clear the 64-bit vector if it exists */
  74. if ((acpi_gbl_FACS->length > 32) && (acpi_gbl_FACS->version >= 1)) {
  75. acpi_gbl_FACS->xfirmware_waking_vector = 0;
  76. }
  77. return_ACPI_STATUS(AE_OK);
  78. }
  79. ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector)
  80. #if ACPI_MACHINE_WIDTH == 64
  81. /*******************************************************************************
  82. *
  83. * FUNCTION: acpi_set_firmware_waking_vector64
  84. *
  85. * PARAMETERS: physical_address - 64-bit physical address of ACPI protected
  86. * mode entry point.
  87. *
  88. * RETURN: Status
  89. *
  90. * DESCRIPTION: Sets the 64-bit X_firmware_waking_vector field of the FACS, if
  91. * it exists in the table. This function is intended for use with
  92. * 64-bit host operating systems.
  93. *
  94. ******************************************************************************/
  95. acpi_status
  96. acpi_set_firmware_waking_vector64(u64 physical_address)
  97. {
  98. ACPI_FUNCTION_TRACE(acpi_set_firmware_waking_vector64);
  99. /* Determine if the 64-bit vector actually exists */
  100. if ((acpi_gbl_FACS->length <= 32) || (acpi_gbl_FACS->version < 1)) {
  101. return_ACPI_STATUS(AE_NOT_EXIST);
  102. }
  103. /* Clear 32-bit vector, set the 64-bit X_ vector */
  104. acpi_gbl_FACS->firmware_waking_vector = 0;
  105. acpi_gbl_FACS->xfirmware_waking_vector = physical_address;
  106. return_ACPI_STATUS(AE_OK);
  107. }
  108. ACPI_EXPORT_SYMBOL(acpi_set_firmware_waking_vector64)
  109. #endif
  110. /*******************************************************************************
  111. *
  112. * FUNCTION: acpi_enter_sleep_state_prep
  113. *
  114. * PARAMETERS: sleep_state - Which sleep state to enter
  115. *
  116. * RETURN: Status
  117. *
  118. * DESCRIPTION: Prepare to enter a system sleep state (see ACPI 2.0 spec p 231)
  119. * This function must execute with interrupts enabled.
  120. * We break sleeping into 2 stages so that OSPM can handle
  121. * various OS-specific tasks between the two steps.
  122. *
  123. ******************************************************************************/
  124. acpi_status acpi_enter_sleep_state_prep(u8 sleep_state)
  125. {
  126. acpi_status status;
  127. struct acpi_object_list arg_list;
  128. union acpi_object arg;
  129. ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_prep);
  130. /* _PSW methods could be run here to enable wake-on keyboard, LAN, etc. */
  131. status = acpi_get_sleep_type_data(sleep_state,
  132. &acpi_gbl_sleep_type_a,
  133. &acpi_gbl_sleep_type_b);
  134. if (ACPI_FAILURE(status)) {
  135. return_ACPI_STATUS(status);
  136. }
  137. /* Setup parameter object */
  138. arg_list.count = 1;
  139. arg_list.pointer = &arg;
  140. arg.type = ACPI_TYPE_INTEGER;
  141. arg.integer.value = sleep_state;
  142. /* Run the _PTS method */
  143. status = acpi_evaluate_object(NULL, METHOD_NAME__PTS, &arg_list, NULL);
  144. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  145. return_ACPI_STATUS(status);
  146. }
  147. /* Setup the argument to _SST */
  148. switch (sleep_state) {
  149. case ACPI_STATE_S0:
  150. arg.integer.value = ACPI_SST_WORKING;
  151. break;
  152. case ACPI_STATE_S1:
  153. case ACPI_STATE_S2:
  154. case ACPI_STATE_S3:
  155. arg.integer.value = ACPI_SST_SLEEPING;
  156. break;
  157. case ACPI_STATE_S4:
  158. arg.integer.value = ACPI_SST_SLEEP_CONTEXT;
  159. break;
  160. default:
  161. arg.integer.value = ACPI_SST_INDICATOR_OFF; /* Default is off */
  162. break;
  163. }
  164. /*
  165. * Set the system indicators to show the desired sleep state.
  166. * _SST is an optional method (return no error if not found)
  167. */
  168. status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
  169. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  170. ACPI_EXCEPTION((AE_INFO, status,
  171. "While executing method _SST"));
  172. }
  173. return_ACPI_STATUS(AE_OK);
  174. }
  175. ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_prep)
  176. static unsigned int gts, bfs;
  177. module_param(gts, uint, 0644);
  178. module_param(bfs, uint, 0644);
  179. MODULE_PARM_DESC(gts, "Enable evaluation of _GTS on suspend.");
  180. MODULE_PARM_DESC(bfs, "Enable evaluation of _BFS on resume".);
  181. /*******************************************************************************
  182. *
  183. * FUNCTION: acpi_enter_sleep_state
  184. *
  185. * PARAMETERS: sleep_state - Which sleep state to enter
  186. *
  187. * RETURN: Status
  188. *
  189. * DESCRIPTION: Enter a system sleep state (see ACPI 2.0 spec p 231)
  190. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
  191. *
  192. ******************************************************************************/
  193. acpi_status asmlinkage acpi_enter_sleep_state(u8 sleep_state)
  194. {
  195. u32 pm1a_control;
  196. u32 pm1b_control;
  197. struct acpi_bit_register_info *sleep_type_reg_info;
  198. struct acpi_bit_register_info *sleep_enable_reg_info;
  199. u32 in_value;
  200. struct acpi_object_list arg_list;
  201. union acpi_object arg;
  202. acpi_status status;
  203. ACPI_FUNCTION_TRACE(acpi_enter_sleep_state);
  204. if ((acpi_gbl_sleep_type_a > ACPI_SLEEP_TYPE_MAX) ||
  205. (acpi_gbl_sleep_type_b > ACPI_SLEEP_TYPE_MAX)) {
  206. ACPI_ERROR((AE_INFO, "Sleep values out of range: A=0x%X B=0x%X",
  207. acpi_gbl_sleep_type_a, acpi_gbl_sleep_type_b));
  208. return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
  209. }
  210. sleep_type_reg_info =
  211. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
  212. sleep_enable_reg_info =
  213. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
  214. /* Clear wake status */
  215. status =
  216. acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
  217. if (ACPI_FAILURE(status)) {
  218. return_ACPI_STATUS(status);
  219. }
  220. /* Clear all fixed and general purpose status bits */
  221. status = acpi_hw_clear_acpi_status();
  222. if (ACPI_FAILURE(status)) {
  223. return_ACPI_STATUS(status);
  224. }
  225. /*
  226. * 1) Disable/Clear all GPEs
  227. * 2) Enable all wakeup GPEs
  228. */
  229. status = acpi_hw_disable_all_gpes();
  230. if (ACPI_FAILURE(status)) {
  231. return_ACPI_STATUS(status);
  232. }
  233. acpi_gbl_system_awake_and_running = FALSE;
  234. status = acpi_hw_enable_all_wakeup_gpes();
  235. if (ACPI_FAILURE(status)) {
  236. return_ACPI_STATUS(status);
  237. }
  238. if (gts) {
  239. /* Execute the _GTS method */
  240. arg_list.count = 1;
  241. arg_list.pointer = &arg;
  242. arg.type = ACPI_TYPE_INTEGER;
  243. arg.integer.value = sleep_state;
  244. status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
  245. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  246. return_ACPI_STATUS(status);
  247. }
  248. }
  249. /* Get current value of PM1A control */
  250. status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
  251. &pm1a_control);
  252. if (ACPI_FAILURE(status)) {
  253. return_ACPI_STATUS(status);
  254. }
  255. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  256. "Entering sleep state [S%u]\n", sleep_state));
  257. /* Clear the SLP_EN and SLP_TYP fields */
  258. pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
  259. sleep_enable_reg_info->access_bit_mask);
  260. pm1b_control = pm1a_control;
  261. /* Insert the SLP_TYP bits */
  262. pm1a_control |=
  263. (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
  264. pm1b_control |=
  265. (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
  266. /*
  267. * We split the writes of SLP_TYP and SLP_EN to workaround
  268. * poorly implemented hardware.
  269. */
  270. /* Write #1: write the SLP_TYP data to the PM1 Control registers */
  271. status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
  272. if (ACPI_FAILURE(status)) {
  273. return_ACPI_STATUS(status);
  274. }
  275. /* Insert the sleep enable (SLP_EN) bit */
  276. pm1a_control |= sleep_enable_reg_info->access_bit_mask;
  277. pm1b_control |= sleep_enable_reg_info->access_bit_mask;
  278. /* Flush caches, as per ACPI specification */
  279. ACPI_FLUSH_CPU_CACHE();
  280. tboot_sleep(sleep_state, pm1a_control, pm1b_control);
  281. /* Write #2: Write both SLP_TYP + SLP_EN */
  282. status = acpi_hw_write_pm1_control(pm1a_control, pm1b_control);
  283. if (ACPI_FAILURE(status)) {
  284. return_ACPI_STATUS(status);
  285. }
  286. if (sleep_state > ACPI_STATE_S3) {
  287. /*
  288. * We wanted to sleep > S3, but it didn't happen (by virtue of the
  289. * fact that we are still executing!)
  290. *
  291. * Wait ten seconds, then try again. This is to get S4/S5 to work on
  292. * all machines.
  293. *
  294. * We wait so long to allow chipsets that poll this reg very slowly
  295. * to still read the right value. Ideally, this block would go
  296. * away entirely.
  297. */
  298. acpi_os_stall(10000000);
  299. status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
  300. sleep_enable_reg_info->
  301. access_bit_mask);
  302. if (ACPI_FAILURE(status)) {
  303. return_ACPI_STATUS(status);
  304. }
  305. }
  306. /* Wait until we enter sleep state */
  307. do {
  308. status = acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS,
  309. &in_value);
  310. if (ACPI_FAILURE(status)) {
  311. return_ACPI_STATUS(status);
  312. }
  313. /* Spin until we wake */
  314. } while (!in_value);
  315. return_ACPI_STATUS(AE_OK);
  316. }
  317. ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
  318. /*******************************************************************************
  319. *
  320. * FUNCTION: acpi_enter_sleep_state_s4bios
  321. *
  322. * PARAMETERS: None
  323. *
  324. * RETURN: Status
  325. *
  326. * DESCRIPTION: Perform a S4 bios request.
  327. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
  328. *
  329. ******************************************************************************/
  330. acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
  331. {
  332. u32 in_value;
  333. acpi_status status;
  334. ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
  335. /* Clear the wake status bit (PM1) */
  336. status =
  337. acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, ACPI_CLEAR_STATUS);
  338. if (ACPI_FAILURE(status)) {
  339. return_ACPI_STATUS(status);
  340. }
  341. status = acpi_hw_clear_acpi_status();
  342. if (ACPI_FAILURE(status)) {
  343. return_ACPI_STATUS(status);
  344. }
  345. /*
  346. * 1) Disable/Clear all GPEs
  347. * 2) Enable all wakeup GPEs
  348. */
  349. status = acpi_hw_disable_all_gpes();
  350. if (ACPI_FAILURE(status)) {
  351. return_ACPI_STATUS(status);
  352. }
  353. acpi_gbl_system_awake_and_running = FALSE;
  354. status = acpi_hw_enable_all_wakeup_gpes();
  355. if (ACPI_FAILURE(status)) {
  356. return_ACPI_STATUS(status);
  357. }
  358. ACPI_FLUSH_CPU_CACHE();
  359. status = acpi_hw_write_port(acpi_gbl_FADT.smi_command,
  360. (u32) acpi_gbl_FADT.S4bios_request, 8);
  361. do {
  362. acpi_os_stall(1000);
  363. status =
  364. acpi_read_bit_register(ACPI_BITREG_WAKE_STATUS, &in_value);
  365. if (ACPI_FAILURE(status)) {
  366. return_ACPI_STATUS(status);
  367. }
  368. } while (!in_value);
  369. return_ACPI_STATUS(AE_OK);
  370. }
  371. ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
  372. /*******************************************************************************
  373. *
  374. * FUNCTION: acpi_leave_sleep_state_prep
  375. *
  376. * PARAMETERS: sleep_state - Which sleep state we are exiting
  377. *
  378. * RETURN: Status
  379. *
  380. * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
  381. * sleep.
  382. * Called with interrupts DISABLED.
  383. *
  384. ******************************************************************************/
  385. acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
  386. {
  387. struct acpi_object_list arg_list;
  388. union acpi_object arg;
  389. acpi_status status;
  390. struct acpi_bit_register_info *sleep_type_reg_info;
  391. struct acpi_bit_register_info *sleep_enable_reg_info;
  392. u32 pm1a_control;
  393. u32 pm1b_control;
  394. ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
  395. /*
  396. * Set SLP_TYPE and SLP_EN to state S0.
  397. * This is unclear from the ACPI Spec, but it is required
  398. * by some machines.
  399. */
  400. status = acpi_get_sleep_type_data(ACPI_STATE_S0,
  401. &acpi_gbl_sleep_type_a,
  402. &acpi_gbl_sleep_type_b);
  403. if (ACPI_SUCCESS(status)) {
  404. sleep_type_reg_info =
  405. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE);
  406. sleep_enable_reg_info =
  407. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
  408. /* Get current value of PM1A control */
  409. status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
  410. &pm1a_control);
  411. if (ACPI_SUCCESS(status)) {
  412. /* Clear the SLP_EN and SLP_TYP fields */
  413. pm1a_control &= ~(sleep_type_reg_info->access_bit_mask |
  414. sleep_enable_reg_info->
  415. access_bit_mask);
  416. pm1b_control = pm1a_control;
  417. /* Insert the SLP_TYP bits */
  418. pm1a_control |= (acpi_gbl_sleep_type_a <<
  419. sleep_type_reg_info->bit_position);
  420. pm1b_control |= (acpi_gbl_sleep_type_b <<
  421. sleep_type_reg_info->bit_position);
  422. /* Write the control registers and ignore any errors */
  423. (void)acpi_hw_write_pm1_control(pm1a_control,
  424. pm1b_control);
  425. }
  426. }
  427. if (bfs) {
  428. /* Execute the _BFS method */
  429. arg_list.count = 1;
  430. arg_list.pointer = &arg;
  431. arg.type = ACPI_TYPE_INTEGER;
  432. arg.integer.value = sleep_state;
  433. status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
  434. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  435. ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
  436. }
  437. }
  438. return_ACPI_STATUS(status);
  439. }
  440. /*******************************************************************************
  441. *
  442. * FUNCTION: acpi_leave_sleep_state
  443. *
  444. * PARAMETERS: sleep_state - Which sleep state we just exited
  445. *
  446. * RETURN: Status
  447. *
  448. * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
  449. * Called with interrupts ENABLED.
  450. *
  451. ******************************************************************************/
  452. acpi_status acpi_leave_sleep_state(u8 sleep_state)
  453. {
  454. struct acpi_object_list arg_list;
  455. union acpi_object arg;
  456. acpi_status status;
  457. ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
  458. /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
  459. acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
  460. /* Setup parameter object */
  461. arg_list.count = 1;
  462. arg_list.pointer = &arg;
  463. arg.type = ACPI_TYPE_INTEGER;
  464. /* Ignore any errors from these methods */
  465. arg.integer.value = ACPI_SST_WAKING;
  466. status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
  467. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  468. ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
  469. }
  470. /*
  471. * GPEs must be enabled before _WAK is called as GPEs
  472. * might get fired there
  473. *
  474. * Restore the GPEs:
  475. * 1) Disable/Clear all GPEs
  476. * 2) Enable all runtime GPEs
  477. */
  478. status = acpi_hw_disable_all_gpes();
  479. if (ACPI_FAILURE(status)) {
  480. return_ACPI_STATUS(status);
  481. }
  482. status = acpi_hw_enable_all_runtime_gpes();
  483. if (ACPI_FAILURE(status)) {
  484. return_ACPI_STATUS(status);
  485. }
  486. arg.integer.value = sleep_state;
  487. status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
  488. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  489. ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
  490. }
  491. /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
  492. /*
  493. * Some BIOSes assume that WAK_STS will be cleared on resume and use
  494. * it to determine whether the system is rebooting or resuming. Clear
  495. * it for compatibility.
  496. */
  497. acpi_write_bit_register(ACPI_BITREG_WAKE_STATUS, 1);
  498. acpi_gbl_system_awake_and_running = TRUE;
  499. /* Enable power button */
  500. (void)
  501. acpi_write_bit_register(acpi_gbl_fixed_event_info
  502. [ACPI_EVENT_POWER_BUTTON].
  503. enable_register_id, ACPI_ENABLE_EVENT);
  504. (void)
  505. acpi_write_bit_register(acpi_gbl_fixed_event_info
  506. [ACPI_EVENT_POWER_BUTTON].
  507. status_register_id, ACPI_CLEAR_STATUS);
  508. arg.integer.value = ACPI_SST_WORKING;
  509. status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
  510. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  511. ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
  512. }
  513. return_ACPI_STATUS(status);
  514. }
  515. ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)