hwsleep.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  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. * 1) Disable/Clear all GPEs
  244. * 2) Enable all wakeup GPEs
  245. */
  246. status = acpi_hw_disable_all_gpes();
  247. if (ACPI_FAILURE(status)) {
  248. return_ACPI_STATUS(status);
  249. }
  250. acpi_gbl_system_awake_and_running = FALSE;
  251. status = acpi_hw_enable_all_wakeup_gpes();
  252. if (ACPI_FAILURE(status)) {
  253. return_ACPI_STATUS(status);
  254. }
  255. /* Execute the _GTS method */
  256. arg_list.count = 1;
  257. arg_list.pointer = &arg;
  258. arg.type = ACPI_TYPE_INTEGER;
  259. arg.integer.value = sleep_state;
  260. status = acpi_evaluate_object(NULL, METHOD_NAME__GTS, &arg_list, NULL);
  261. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  262. return_ACPI_STATUS(status);
  263. }
  264. /* Get current value of PM1A control */
  265. status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL, &PM1Acontrol);
  266. if (ACPI_FAILURE(status)) {
  267. return_ACPI_STATUS(status);
  268. }
  269. ACPI_DEBUG_PRINT((ACPI_DB_INIT,
  270. "Entering sleep state [S%d]\n", sleep_state));
  271. /* Clear SLP_EN and SLP_TYP fields */
  272. PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
  273. sleep_enable_reg_info->access_bit_mask);
  274. PM1Bcontrol = PM1Acontrol;
  275. /* Insert SLP_TYP bits */
  276. PM1Acontrol |=
  277. (acpi_gbl_sleep_type_a << sleep_type_reg_info->bit_position);
  278. PM1Bcontrol |=
  279. (acpi_gbl_sleep_type_b << sleep_type_reg_info->bit_position);
  280. /*
  281. * We split the writes of SLP_TYP and SLP_EN to workaround
  282. * poorly implemented hardware.
  283. */
  284. /* Write #1: fill in SLP_TYP data */
  285. status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
  286. PM1Acontrol);
  287. if (ACPI_FAILURE(status)) {
  288. return_ACPI_STATUS(status);
  289. }
  290. status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
  291. PM1Bcontrol);
  292. if (ACPI_FAILURE(status)) {
  293. return_ACPI_STATUS(status);
  294. }
  295. /* Insert SLP_ENABLE bit */
  296. PM1Acontrol |= sleep_enable_reg_info->access_bit_mask;
  297. PM1Bcontrol |= sleep_enable_reg_info->access_bit_mask;
  298. /* Write #2: SLP_TYP + SLP_EN */
  299. ACPI_FLUSH_CPU_CACHE();
  300. status = acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
  301. PM1Acontrol);
  302. if (ACPI_FAILURE(status)) {
  303. return_ACPI_STATUS(status);
  304. }
  305. status = acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
  306. PM1Bcontrol);
  307. if (ACPI_FAILURE(status)) {
  308. return_ACPI_STATUS(status);
  309. }
  310. if (sleep_state > ACPI_STATE_S3) {
  311. /*
  312. * We wanted to sleep > S3, but it didn't happen (by virtue of the
  313. * fact that we are still executing!)
  314. *
  315. * Wait ten seconds, then try again. This is to get S4/S5 to work on
  316. * all machines.
  317. *
  318. * We wait so long to allow chipsets that poll this reg very slowly to
  319. * still read the right value. Ideally, this block would go
  320. * away entirely.
  321. */
  322. acpi_os_stall(10000000);
  323. status = acpi_hw_register_write(ACPI_REGISTER_PM1_CONTROL,
  324. sleep_enable_reg_info->
  325. access_bit_mask);
  326. if (ACPI_FAILURE(status)) {
  327. return_ACPI_STATUS(status);
  328. }
  329. }
  330. /* Wait until we enter sleep state */
  331. do {
  332. status = acpi_get_register_unlocked(ACPI_BITREG_WAKE_STATUS,
  333. &in_value);
  334. if (ACPI_FAILURE(status)) {
  335. return_ACPI_STATUS(status);
  336. }
  337. /* Spin until we wake */
  338. } while (!in_value);
  339. return_ACPI_STATUS(AE_OK);
  340. }
  341. ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state)
  342. /*******************************************************************************
  343. *
  344. * FUNCTION: acpi_enter_sleep_state_s4bios
  345. *
  346. * PARAMETERS: None
  347. *
  348. * RETURN: Status
  349. *
  350. * DESCRIPTION: Perform a S4 bios request.
  351. * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
  352. *
  353. ******************************************************************************/
  354. acpi_status asmlinkage acpi_enter_sleep_state_s4bios(void)
  355. {
  356. u32 in_value;
  357. acpi_status status;
  358. ACPI_FUNCTION_TRACE(acpi_enter_sleep_state_s4bios);
  359. status = acpi_set_register(ACPI_BITREG_WAKE_STATUS, 1);
  360. if (ACPI_FAILURE(status)) {
  361. return_ACPI_STATUS(status);
  362. }
  363. status = acpi_hw_clear_acpi_status();
  364. if (ACPI_FAILURE(status)) {
  365. return_ACPI_STATUS(status);
  366. }
  367. /*
  368. * 1) Disable/Clear all GPEs
  369. * 2) Enable all wakeup GPEs
  370. */
  371. status = acpi_hw_disable_all_gpes();
  372. if (ACPI_FAILURE(status)) {
  373. return_ACPI_STATUS(status);
  374. }
  375. acpi_gbl_system_awake_and_running = FALSE;
  376. status = acpi_hw_enable_all_wakeup_gpes();
  377. if (ACPI_FAILURE(status)) {
  378. return_ACPI_STATUS(status);
  379. }
  380. ACPI_FLUSH_CPU_CACHE();
  381. status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
  382. (u32) acpi_gbl_FADT.S4bios_request, 8);
  383. do {
  384. acpi_os_stall(1000);
  385. status = acpi_get_register(ACPI_BITREG_WAKE_STATUS, &in_value);
  386. if (ACPI_FAILURE(status)) {
  387. return_ACPI_STATUS(status);
  388. }
  389. } while (!in_value);
  390. return_ACPI_STATUS(AE_OK);
  391. }
  392. ACPI_EXPORT_SYMBOL(acpi_enter_sleep_state_s4bios)
  393. /*******************************************************************************
  394. *
  395. * FUNCTION: acpi_leave_sleep_state_prep
  396. *
  397. * PARAMETERS: sleep_state - Which sleep state we are exiting
  398. *
  399. * RETURN: Status
  400. *
  401. * DESCRIPTION: Perform the first state of OS-independent ACPI cleanup after a
  402. * sleep.
  403. * Called with interrupts DISABLED.
  404. *
  405. ******************************************************************************/
  406. acpi_status acpi_leave_sleep_state_prep(u8 sleep_state)
  407. {
  408. struct acpi_object_list arg_list;
  409. union acpi_object arg;
  410. acpi_status status;
  411. struct acpi_bit_register_info *sleep_type_reg_info;
  412. struct acpi_bit_register_info *sleep_enable_reg_info;
  413. u32 PM1Acontrol;
  414. u32 PM1Bcontrol;
  415. ACPI_FUNCTION_TRACE(acpi_leave_sleep_state_prep);
  416. /*
  417. * Set SLP_TYPE and SLP_EN to state S0.
  418. * This is unclear from the ACPI Spec, but it is required
  419. * by some machines.
  420. */
  421. status = acpi_get_sleep_type_data(ACPI_STATE_S0,
  422. &acpi_gbl_sleep_type_a,
  423. &acpi_gbl_sleep_type_b);
  424. if (ACPI_SUCCESS(status)) {
  425. sleep_type_reg_info =
  426. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_TYPE_A);
  427. sleep_enable_reg_info =
  428. acpi_hw_get_bit_register_info(ACPI_BITREG_SLEEP_ENABLE);
  429. /* Get current value of PM1A control */
  430. status = acpi_hw_register_read(ACPI_REGISTER_PM1_CONTROL,
  431. &PM1Acontrol);
  432. if (ACPI_SUCCESS(status)) {
  433. /* Clear SLP_EN and SLP_TYP fields */
  434. PM1Acontrol &= ~(sleep_type_reg_info->access_bit_mask |
  435. sleep_enable_reg_info->
  436. access_bit_mask);
  437. PM1Bcontrol = PM1Acontrol;
  438. /* Insert SLP_TYP bits */
  439. PM1Acontrol |=
  440. (acpi_gbl_sleep_type_a << sleep_type_reg_info->
  441. bit_position);
  442. PM1Bcontrol |=
  443. (acpi_gbl_sleep_type_b << sleep_type_reg_info->
  444. bit_position);
  445. /* Just ignore any errors */
  446. (void)acpi_hw_register_write(ACPI_REGISTER_PM1A_CONTROL,
  447. PM1Acontrol);
  448. (void)acpi_hw_register_write(ACPI_REGISTER_PM1B_CONTROL,
  449. PM1Bcontrol);
  450. }
  451. }
  452. /* Execute the _BFS method */
  453. arg_list.count = 1;
  454. arg_list.pointer = &arg;
  455. arg.type = ACPI_TYPE_INTEGER;
  456. arg.integer.value = sleep_state;
  457. status = acpi_evaluate_object(NULL, METHOD_NAME__BFS, &arg_list, NULL);
  458. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  459. ACPI_EXCEPTION((AE_INFO, status, "During Method _BFS"));
  460. }
  461. return_ACPI_STATUS(status);
  462. }
  463. /*******************************************************************************
  464. *
  465. * FUNCTION: acpi_leave_sleep_state
  466. *
  467. * PARAMETERS: sleep_state - Which sleep state we just exited
  468. *
  469. * RETURN: Status
  470. *
  471. * DESCRIPTION: Perform OS-independent ACPI cleanup after a sleep
  472. * Called with interrupts ENABLED.
  473. *
  474. ******************************************************************************/
  475. acpi_status acpi_leave_sleep_state(u8 sleep_state)
  476. {
  477. struct acpi_object_list arg_list;
  478. union acpi_object arg;
  479. acpi_status status;
  480. ACPI_FUNCTION_TRACE(acpi_leave_sleep_state);
  481. /* Ensure enter_sleep_state_prep -> enter_sleep_state ordering */
  482. acpi_gbl_sleep_type_a = ACPI_SLEEP_TYPE_INVALID;
  483. /* Setup parameter object */
  484. arg_list.count = 1;
  485. arg_list.pointer = &arg;
  486. arg.type = ACPI_TYPE_INTEGER;
  487. /* Ignore any errors from these methods */
  488. arg.integer.value = ACPI_SST_WAKING;
  489. status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
  490. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  491. ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
  492. }
  493. /*
  494. * GPEs must be enabled before _WAK is called as GPEs
  495. * might get fired there
  496. *
  497. * Restore the GPEs:
  498. * 1) Disable/Clear all GPEs
  499. * 2) Enable all runtime GPEs
  500. */
  501. status = acpi_hw_disable_all_gpes();
  502. if (ACPI_FAILURE(status)) {
  503. return_ACPI_STATUS(status);
  504. }
  505. status = acpi_hw_enable_all_runtime_gpes();
  506. if (ACPI_FAILURE(status)) {
  507. return_ACPI_STATUS(status);
  508. }
  509. arg.integer.value = sleep_state;
  510. status = acpi_evaluate_object(NULL, METHOD_NAME__WAK, &arg_list, NULL);
  511. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  512. ACPI_EXCEPTION((AE_INFO, status, "During Method _WAK"));
  513. }
  514. /* TBD: _WAK "sometimes" returns stuff - do we want to look at it? */
  515. acpi_gbl_system_awake_and_running = TRUE;
  516. /* Enable power button */
  517. (void)
  518. acpi_set_register(acpi_gbl_fixed_event_info
  519. [ACPI_EVENT_POWER_BUTTON].enable_register_id, 1);
  520. (void)
  521. acpi_set_register(acpi_gbl_fixed_event_info
  522. [ACPI_EVENT_POWER_BUTTON].status_register_id, 1);
  523. arg.integer.value = ACPI_SST_WORKING;
  524. status = acpi_evaluate_object(NULL, METHOD_NAME__SST, &arg_list, NULL);
  525. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  526. ACPI_EXCEPTION((AE_INFO, status, "During Method _SST"));
  527. }
  528. return_ACPI_STATUS(status);
  529. }
  530. ACPI_EXPORT_SYMBOL(acpi_leave_sleep_state)