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