hwsleep.c 18 KB

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