sleep.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. /*
  2. * sleep.c - ACPI sleep support.
  3. *
  4. * Copyright (c) 2005 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
  5. * Copyright (c) 2004 David Shaohua Li <shaohua.li@intel.com>
  6. * Copyright (c) 2000-2003 Patrick Mochel
  7. * Copyright (c) 2003 Open Source Development Lab
  8. *
  9. * This file is released under the GPLv2.
  10. *
  11. */
  12. #include <linux/delay.h>
  13. #include <linux/irq.h>
  14. #include <linux/dmi.h>
  15. #include <linux/device.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/suspend.h>
  18. #include <linux/reboot.h>
  19. #include <linux/acpi.h>
  20. #include <linux/module.h>
  21. #include <linux/syscore_ops.h>
  22. #include <asm/io.h>
  23. #include <trace/events/power.h>
  24. #include "internal.h"
  25. #include "sleep.h"
  26. /*
  27. * Some HW-full platforms do not have _S5, so they may need
  28. * to leverage efi power off for a shutdown.
  29. */
  30. bool acpi_no_s5;
  31. static u8 sleep_states[ACPI_S_STATE_COUNT];
  32. static void acpi_sleep_tts_switch(u32 acpi_state)
  33. {
  34. acpi_status status;
  35. status = acpi_execute_simple_method(NULL, "\\_TTS", acpi_state);
  36. if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
  37. /*
  38. * OS can't evaluate the _TTS object correctly. Some warning
  39. * message will be printed. But it won't break anything.
  40. */
  41. printk(KERN_NOTICE "Failure in evaluating _TTS object\n");
  42. }
  43. }
  44. static int tts_notify_reboot(struct notifier_block *this,
  45. unsigned long code, void *x)
  46. {
  47. acpi_sleep_tts_switch(ACPI_STATE_S5);
  48. return NOTIFY_DONE;
  49. }
  50. static struct notifier_block tts_notifier = {
  51. .notifier_call = tts_notify_reboot,
  52. .next = NULL,
  53. .priority = 0,
  54. };
  55. static int acpi_sleep_prepare(u32 acpi_state)
  56. {
  57. #ifdef CONFIG_ACPI_SLEEP
  58. /* do we have a wakeup address for S2 and S3? */
  59. if (acpi_state == ACPI_STATE_S3) {
  60. if (!acpi_wakeup_address)
  61. return -EFAULT;
  62. acpi_set_waking_vector(acpi_wakeup_address);
  63. }
  64. ACPI_FLUSH_CPU_CACHE();
  65. #endif
  66. printk(KERN_INFO PREFIX "Preparing to enter system sleep state S%d\n",
  67. acpi_state);
  68. acpi_enable_wakeup_devices(acpi_state);
  69. acpi_enter_sleep_state_prep(acpi_state);
  70. return 0;
  71. }
  72. static bool acpi_sleep_state_supported(u8 sleep_state)
  73. {
  74. acpi_status status;
  75. u8 type_a, type_b;
  76. status = acpi_get_sleep_type_data(sleep_state, &type_a, &type_b);
  77. return ACPI_SUCCESS(status) && (!acpi_gbl_reduced_hardware
  78. || (acpi_gbl_FADT.sleep_control.address
  79. && acpi_gbl_FADT.sleep_status.address));
  80. }
  81. #ifdef CONFIG_ACPI_SLEEP
  82. static u32 acpi_target_sleep_state = ACPI_STATE_S0;
  83. u32 acpi_target_system_state(void)
  84. {
  85. return acpi_target_sleep_state;
  86. }
  87. EXPORT_SYMBOL_GPL(acpi_target_system_state);
  88. static bool pwr_btn_event_pending;
  89. /*
  90. * The ACPI specification wants us to save NVS memory regions during hibernation
  91. * and to restore them during the subsequent resume. Windows does that also for
  92. * suspend to RAM. However, it is known that this mechanism does not work on
  93. * all machines, so we allow the user to disable it with the help of the
  94. * 'acpi_sleep=nonvs' kernel command line option.
  95. */
  96. static bool nvs_nosave;
  97. void __init acpi_nvs_nosave(void)
  98. {
  99. nvs_nosave = true;
  100. }
  101. /*
  102. * The ACPI specification wants us to save NVS memory regions during hibernation
  103. * but says nothing about saving NVS during S3. Not all versions of Windows
  104. * save NVS on S3 suspend either, and it is clear that not all systems need
  105. * NVS to be saved at S3 time. To improve suspend/resume time, allow the
  106. * user to disable saving NVS on S3 if their system does not require it, but
  107. * continue to save/restore NVS for S4 as specified.
  108. */
  109. static bool nvs_nosave_s3;
  110. void __init acpi_nvs_nosave_s3(void)
  111. {
  112. nvs_nosave_s3 = true;
  113. }
  114. static int __init init_nvs_save_s3(const struct dmi_system_id *d)
  115. {
  116. nvs_nosave_s3 = false;
  117. return 0;
  118. }
  119. /*
  120. * ACPI 1.0 wants us to execute _PTS before suspending devices, so we allow the
  121. * user to request that behavior by using the 'acpi_old_suspend_ordering'
  122. * kernel command line option that causes the following variable to be set.
  123. */
  124. static bool old_suspend_ordering;
  125. void __init acpi_old_suspend_ordering(void)
  126. {
  127. old_suspend_ordering = true;
  128. }
  129. static int __init init_old_suspend_ordering(const struct dmi_system_id *d)
  130. {
  131. acpi_old_suspend_ordering();
  132. return 0;
  133. }
  134. static int __init init_nvs_nosave(const struct dmi_system_id *d)
  135. {
  136. acpi_nvs_nosave();
  137. return 0;
  138. }
  139. static bool acpi_sleep_no_lps0;
  140. static int __init init_no_lps0(const struct dmi_system_id *d)
  141. {
  142. acpi_sleep_no_lps0 = true;
  143. return 0;
  144. }
  145. static const struct dmi_system_id acpisleep_dmi_table[] __initconst = {
  146. {
  147. .callback = init_old_suspend_ordering,
  148. .ident = "Abit KN9 (nForce4 variant)",
  149. .matches = {
  150. DMI_MATCH(DMI_BOARD_VENDOR, "http://www.abit.com.tw/"),
  151. DMI_MATCH(DMI_BOARD_NAME, "KN9 Series(NF-CK804)"),
  152. },
  153. },
  154. {
  155. .callback = init_old_suspend_ordering,
  156. .ident = "HP xw4600 Workstation",
  157. .matches = {
  158. DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"),
  159. DMI_MATCH(DMI_PRODUCT_NAME, "HP xw4600 Workstation"),
  160. },
  161. },
  162. {
  163. .callback = init_old_suspend_ordering,
  164. .ident = "Asus Pundit P1-AH2 (M2N8L motherboard)",
  165. .matches = {
  166. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTek Computer INC."),
  167. DMI_MATCH(DMI_BOARD_NAME, "M2N8L"),
  168. },
  169. },
  170. {
  171. .callback = init_old_suspend_ordering,
  172. .ident = "Panasonic CF51-2L",
  173. .matches = {
  174. DMI_MATCH(DMI_BOARD_VENDOR,
  175. "Matsushita Electric Industrial Co.,Ltd."),
  176. DMI_MATCH(DMI_BOARD_NAME, "CF51-2L"),
  177. },
  178. },
  179. {
  180. .callback = init_nvs_nosave,
  181. .ident = "Sony Vaio VGN-FW41E_H",
  182. .matches = {
  183. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  184. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW41E_H"),
  185. },
  186. },
  187. {
  188. .callback = init_nvs_nosave,
  189. .ident = "Sony Vaio VGN-FW21E",
  190. .matches = {
  191. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  192. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21E"),
  193. },
  194. },
  195. {
  196. .callback = init_nvs_nosave,
  197. .ident = "Sony Vaio VGN-FW21M",
  198. .matches = {
  199. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  200. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW21M"),
  201. },
  202. },
  203. {
  204. .callback = init_nvs_nosave,
  205. .ident = "Sony Vaio VPCEB17FX",
  206. .matches = {
  207. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  208. DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB17FX"),
  209. },
  210. },
  211. {
  212. .callback = init_nvs_nosave,
  213. .ident = "Sony Vaio VGN-SR11M",
  214. .matches = {
  215. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  216. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR11M"),
  217. },
  218. },
  219. {
  220. .callback = init_nvs_nosave,
  221. .ident = "Everex StepNote Series",
  222. .matches = {
  223. DMI_MATCH(DMI_SYS_VENDOR, "Everex Systems, Inc."),
  224. DMI_MATCH(DMI_PRODUCT_NAME, "Everex StepNote Series"),
  225. },
  226. },
  227. {
  228. .callback = init_nvs_nosave,
  229. .ident = "Sony Vaio VPCEB1Z1E",
  230. .matches = {
  231. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  232. DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1Z1E"),
  233. },
  234. },
  235. {
  236. .callback = init_nvs_nosave,
  237. .ident = "Sony Vaio VGN-NW130D",
  238. .matches = {
  239. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  240. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-NW130D"),
  241. },
  242. },
  243. {
  244. .callback = init_nvs_nosave,
  245. .ident = "Sony Vaio VPCCW29FX",
  246. .matches = {
  247. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  248. DMI_MATCH(DMI_PRODUCT_NAME, "VPCCW29FX"),
  249. },
  250. },
  251. {
  252. .callback = init_nvs_nosave,
  253. .ident = "Averatec AV1020-ED2",
  254. .matches = {
  255. DMI_MATCH(DMI_SYS_VENDOR, "AVERATEC"),
  256. DMI_MATCH(DMI_PRODUCT_NAME, "1000 Series"),
  257. },
  258. },
  259. {
  260. .callback = init_old_suspend_ordering,
  261. .ident = "Asus A8N-SLI DELUXE",
  262. .matches = {
  263. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  264. DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI DELUXE"),
  265. },
  266. },
  267. {
  268. .callback = init_old_suspend_ordering,
  269. .ident = "Asus A8N-SLI Premium",
  270. .matches = {
  271. DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer INC."),
  272. DMI_MATCH(DMI_BOARD_NAME, "A8N-SLI Premium"),
  273. },
  274. },
  275. {
  276. .callback = init_nvs_nosave,
  277. .ident = "Sony Vaio VGN-SR26GN_P",
  278. .matches = {
  279. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  280. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-SR26GN_P"),
  281. },
  282. },
  283. {
  284. .callback = init_nvs_nosave,
  285. .ident = "Sony Vaio VPCEB1S1E",
  286. .matches = {
  287. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  288. DMI_MATCH(DMI_PRODUCT_NAME, "VPCEB1S1E"),
  289. },
  290. },
  291. {
  292. .callback = init_nvs_nosave,
  293. .ident = "Sony Vaio VGN-FW520F",
  294. .matches = {
  295. DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
  296. DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FW520F"),
  297. },
  298. },
  299. {
  300. .callback = init_nvs_nosave,
  301. .ident = "Asus K54C",
  302. .matches = {
  303. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
  304. DMI_MATCH(DMI_PRODUCT_NAME, "K54C"),
  305. },
  306. },
  307. {
  308. .callback = init_nvs_nosave,
  309. .ident = "Asus K54HR",
  310. .matches = {
  311. DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK Computer Inc."),
  312. DMI_MATCH(DMI_PRODUCT_NAME, "K54HR"),
  313. },
  314. },
  315. /*
  316. * https://bugzilla.kernel.org/show_bug.cgi?id=189431
  317. * Lenovo G50-45 is a platform later than 2012, but needs nvs memory
  318. * saving during S3.
  319. */
  320. {
  321. .callback = init_nvs_save_s3,
  322. .ident = "Lenovo G50-45",
  323. .matches = {
  324. DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
  325. DMI_MATCH(DMI_PRODUCT_NAME, "80E3"),
  326. },
  327. },
  328. /*
  329. * https://bugzilla.kernel.org/show_bug.cgi?id=196907
  330. * Some Dell XPS13 9360 cannot do suspend-to-idle using the Low Power
  331. * S0 Idle firmware interface.
  332. */
  333. {
  334. .callback = init_no_lps0,
  335. .ident = "Dell XPS13 9360",
  336. .matches = {
  337. DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
  338. DMI_MATCH(DMI_PRODUCT_NAME, "XPS 13 9360"),
  339. },
  340. },
  341. {},
  342. };
  343. static void __init acpi_sleep_dmi_check(void)
  344. {
  345. int year;
  346. if (dmi_get_date(DMI_BIOS_DATE, &year, NULL, NULL) && year >= 2012)
  347. acpi_nvs_nosave_s3();
  348. dmi_check_system(acpisleep_dmi_table);
  349. }
  350. /**
  351. * acpi_pm_freeze - Disable the GPEs and suspend EC transactions.
  352. */
  353. static int acpi_pm_freeze(void)
  354. {
  355. acpi_disable_all_gpes();
  356. acpi_os_wait_events_complete();
  357. acpi_ec_block_transactions();
  358. return 0;
  359. }
  360. /**
  361. * acpi_pre_suspend - Enable wakeup devices, "freeze" EC and save NVS.
  362. */
  363. static int acpi_pm_pre_suspend(void)
  364. {
  365. acpi_pm_freeze();
  366. return suspend_nvs_save();
  367. }
  368. /**
  369. * __acpi_pm_prepare - Prepare the platform to enter the target state.
  370. *
  371. * If necessary, set the firmware waking vector and do arch-specific
  372. * nastiness to get the wakeup code to the waking vector.
  373. */
  374. static int __acpi_pm_prepare(void)
  375. {
  376. int error = acpi_sleep_prepare(acpi_target_sleep_state);
  377. if (error)
  378. acpi_target_sleep_state = ACPI_STATE_S0;
  379. return error;
  380. }
  381. /**
  382. * acpi_pm_prepare - Prepare the platform to enter the target sleep
  383. * state and disable the GPEs.
  384. */
  385. static int acpi_pm_prepare(void)
  386. {
  387. int error = __acpi_pm_prepare();
  388. if (!error)
  389. error = acpi_pm_pre_suspend();
  390. return error;
  391. }
  392. static int find_powerf_dev(struct device *dev, void *data)
  393. {
  394. struct acpi_device *device = to_acpi_device(dev);
  395. const char *hid = acpi_device_hid(device);
  396. return !strcmp(hid, ACPI_BUTTON_HID_POWERF);
  397. }
  398. /**
  399. * acpi_pm_finish - Instruct the platform to leave a sleep state.
  400. *
  401. * This is called after we wake back up (or if entering the sleep state
  402. * failed).
  403. */
  404. static void acpi_pm_finish(void)
  405. {
  406. struct device *pwr_btn_dev;
  407. u32 acpi_state = acpi_target_sleep_state;
  408. acpi_ec_unblock_transactions();
  409. suspend_nvs_free();
  410. if (acpi_state == ACPI_STATE_S0)
  411. return;
  412. printk(KERN_INFO PREFIX "Waking up from system sleep state S%d\n",
  413. acpi_state);
  414. acpi_disable_wakeup_devices(acpi_state);
  415. acpi_leave_sleep_state(acpi_state);
  416. /* reset firmware waking vector */
  417. acpi_set_waking_vector(0);
  418. acpi_target_sleep_state = ACPI_STATE_S0;
  419. acpi_resume_power_resources();
  420. /* If we were woken with the fixed power button, provide a small
  421. * hint to userspace in the form of a wakeup event on the fixed power
  422. * button device (if it can be found).
  423. *
  424. * We delay the event generation til now, as the PM layer requires
  425. * timekeeping to be running before we generate events. */
  426. if (!pwr_btn_event_pending)
  427. return;
  428. pwr_btn_event_pending = false;
  429. pwr_btn_dev = bus_find_device(&acpi_bus_type, NULL, NULL,
  430. find_powerf_dev);
  431. if (pwr_btn_dev) {
  432. pm_wakeup_event(pwr_btn_dev, 0);
  433. put_device(pwr_btn_dev);
  434. }
  435. }
  436. /**
  437. * acpi_pm_start - Start system PM transition.
  438. */
  439. static void acpi_pm_start(u32 acpi_state)
  440. {
  441. acpi_target_sleep_state = acpi_state;
  442. acpi_sleep_tts_switch(acpi_target_sleep_state);
  443. acpi_scan_lock_acquire();
  444. }
  445. /**
  446. * acpi_pm_end - Finish up system PM transition.
  447. */
  448. static void acpi_pm_end(void)
  449. {
  450. acpi_turn_off_unused_power_resources();
  451. acpi_scan_lock_release();
  452. /*
  453. * This is necessary in case acpi_pm_finish() is not called during a
  454. * failing transition to a sleep state.
  455. */
  456. acpi_target_sleep_state = ACPI_STATE_S0;
  457. acpi_sleep_tts_switch(acpi_target_sleep_state);
  458. }
  459. #else /* !CONFIG_ACPI_SLEEP */
  460. #define acpi_target_sleep_state ACPI_STATE_S0
  461. #define acpi_sleep_no_lps0 (false)
  462. static inline void acpi_sleep_dmi_check(void) {}
  463. #endif /* CONFIG_ACPI_SLEEP */
  464. #ifdef CONFIG_SUSPEND
  465. static u32 acpi_suspend_states[] = {
  466. [PM_SUSPEND_ON] = ACPI_STATE_S0,
  467. [PM_SUSPEND_STANDBY] = ACPI_STATE_S1,
  468. [PM_SUSPEND_MEM] = ACPI_STATE_S3,
  469. [PM_SUSPEND_MAX] = ACPI_STATE_S5
  470. };
  471. /**
  472. * acpi_suspend_begin - Set the target system sleep state to the state
  473. * associated with given @pm_state, if supported.
  474. */
  475. static int acpi_suspend_begin(suspend_state_t pm_state)
  476. {
  477. u32 acpi_state = acpi_suspend_states[pm_state];
  478. int error;
  479. error = (nvs_nosave || nvs_nosave_s3) ? 0 : suspend_nvs_alloc();
  480. if (error)
  481. return error;
  482. if (!sleep_states[acpi_state]) {
  483. pr_err("ACPI does not support sleep state S%u\n", acpi_state);
  484. return -ENOSYS;
  485. }
  486. if (acpi_state > ACPI_STATE_S1)
  487. pm_set_suspend_via_firmware();
  488. acpi_pm_start(acpi_state);
  489. return 0;
  490. }
  491. /**
  492. * acpi_suspend_enter - Actually enter a sleep state.
  493. * @pm_state: ignored
  494. *
  495. * Flush caches and go to sleep. For STR we have to call arch-specific
  496. * assembly, which in turn call acpi_enter_sleep_state().
  497. * It's unfortunate, but it works. Please fix if you're feeling frisky.
  498. */
  499. static int acpi_suspend_enter(suspend_state_t pm_state)
  500. {
  501. acpi_status status = AE_OK;
  502. u32 acpi_state = acpi_target_sleep_state;
  503. int error;
  504. ACPI_FLUSH_CPU_CACHE();
  505. trace_suspend_resume(TPS("acpi_suspend"), acpi_state, true);
  506. switch (acpi_state) {
  507. case ACPI_STATE_S1:
  508. barrier();
  509. status = acpi_enter_sleep_state(acpi_state);
  510. break;
  511. case ACPI_STATE_S3:
  512. if (!acpi_suspend_lowlevel)
  513. return -ENOSYS;
  514. error = acpi_suspend_lowlevel();
  515. if (error)
  516. return error;
  517. pr_info(PREFIX "Low-level resume complete\n");
  518. pm_set_resume_via_firmware();
  519. break;
  520. }
  521. trace_suspend_resume(TPS("acpi_suspend"), acpi_state, false);
  522. /* This violates the spec but is required for bug compatibility. */
  523. acpi_write_bit_register(ACPI_BITREG_SCI_ENABLE, 1);
  524. /* Reprogram control registers */
  525. acpi_leave_sleep_state_prep(acpi_state);
  526. /* ACPI 3.0 specs (P62) says that it's the responsibility
  527. * of the OSPM to clear the status bit [ implying that the
  528. * POWER_BUTTON event should not reach userspace ]
  529. *
  530. * However, we do generate a small hint for userspace in the form of
  531. * a wakeup event. We flag this condition for now and generate the
  532. * event later, as we're currently too early in resume to be able to
  533. * generate wakeup events.
  534. */
  535. if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3)) {
  536. acpi_event_status pwr_btn_status = ACPI_EVENT_FLAG_DISABLED;
  537. acpi_get_event_status(ACPI_EVENT_POWER_BUTTON, &pwr_btn_status);
  538. if (pwr_btn_status & ACPI_EVENT_FLAG_STATUS_SET) {
  539. acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
  540. /* Flag for later */
  541. pwr_btn_event_pending = true;
  542. }
  543. }
  544. /*
  545. * Disable and clear GPE status before interrupt is enabled. Some GPEs
  546. * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
  547. * acpi_leave_sleep_state will reenable specific GPEs later
  548. */
  549. acpi_disable_all_gpes();
  550. /* Allow EC transactions to happen. */
  551. acpi_ec_unblock_transactions();
  552. suspend_nvs_restore();
  553. return ACPI_SUCCESS(status) ? 0 : -EFAULT;
  554. }
  555. static int acpi_suspend_state_valid(suspend_state_t pm_state)
  556. {
  557. u32 acpi_state;
  558. switch (pm_state) {
  559. case PM_SUSPEND_ON:
  560. case PM_SUSPEND_STANDBY:
  561. case PM_SUSPEND_MEM:
  562. acpi_state = acpi_suspend_states[pm_state];
  563. return sleep_states[acpi_state];
  564. default:
  565. return 0;
  566. }
  567. }
  568. static const struct platform_suspend_ops acpi_suspend_ops = {
  569. .valid = acpi_suspend_state_valid,
  570. .begin = acpi_suspend_begin,
  571. .prepare_late = acpi_pm_prepare,
  572. .enter = acpi_suspend_enter,
  573. .wake = acpi_pm_finish,
  574. .end = acpi_pm_end,
  575. };
  576. /**
  577. * acpi_suspend_begin_old - Set the target system sleep state to the
  578. * state associated with given @pm_state, if supported, and
  579. * execute the _PTS control method. This function is used if the
  580. * pre-ACPI 2.0 suspend ordering has been requested.
  581. */
  582. static int acpi_suspend_begin_old(suspend_state_t pm_state)
  583. {
  584. int error = acpi_suspend_begin(pm_state);
  585. if (!error)
  586. error = __acpi_pm_prepare();
  587. return error;
  588. }
  589. /*
  590. * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
  591. * been requested.
  592. */
  593. static const struct platform_suspend_ops acpi_suspend_ops_old = {
  594. .valid = acpi_suspend_state_valid,
  595. .begin = acpi_suspend_begin_old,
  596. .prepare_late = acpi_pm_pre_suspend,
  597. .enter = acpi_suspend_enter,
  598. .wake = acpi_pm_finish,
  599. .end = acpi_pm_end,
  600. .recover = acpi_pm_finish,
  601. };
  602. static bool s2idle_in_progress;
  603. static bool s2idle_wakeup;
  604. /*
  605. * On platforms supporting the Low Power S0 Idle interface there is an ACPI
  606. * device object with the PNP0D80 compatible device ID (System Power Management
  607. * Controller) and a specific _DSM method under it. That method, if present,
  608. * can be used to indicate to the platform that the OS is transitioning into a
  609. * low-power state in which certain types of activity are not desirable or that
  610. * it is leaving such a state, which allows the platform to adjust its operation
  611. * mode accordingly.
  612. */
  613. static const struct acpi_device_id lps0_device_ids[] = {
  614. {"PNP0D80", },
  615. {"", },
  616. };
  617. #define ACPI_LPS0_DSM_UUID "c4eb40a0-6cd2-11e2-bcfd-0800200c9a66"
  618. #define ACPI_LPS0_GET_DEVICE_CONSTRAINTS 1
  619. #define ACPI_LPS0_SCREEN_OFF 3
  620. #define ACPI_LPS0_SCREEN_ON 4
  621. #define ACPI_LPS0_ENTRY 5
  622. #define ACPI_LPS0_EXIT 6
  623. #define ACPI_S2IDLE_FUNC_MASK ((1 << ACPI_LPS0_ENTRY) | (1 << ACPI_LPS0_EXIT))
  624. static acpi_handle lps0_device_handle;
  625. static guid_t lps0_dsm_guid;
  626. static char lps0_dsm_func_mask;
  627. /* Device constraint entry structure */
  628. struct lpi_device_info {
  629. char *name;
  630. int enabled;
  631. union acpi_object *package;
  632. };
  633. /* Constraint package structure */
  634. struct lpi_device_constraint {
  635. int uid;
  636. int min_dstate;
  637. int function_states;
  638. };
  639. struct lpi_constraints {
  640. acpi_handle handle;
  641. int min_dstate;
  642. };
  643. static struct lpi_constraints *lpi_constraints_table;
  644. static int lpi_constraints_table_size;
  645. static void lpi_device_get_constraints(void)
  646. {
  647. union acpi_object *out_obj;
  648. int i;
  649. out_obj = acpi_evaluate_dsm_typed(lps0_device_handle, &lps0_dsm_guid,
  650. 1, ACPI_LPS0_GET_DEVICE_CONSTRAINTS,
  651. NULL, ACPI_TYPE_PACKAGE);
  652. acpi_handle_debug(lps0_device_handle, "_DSM function 1 eval %s\n",
  653. out_obj ? "successful" : "failed");
  654. if (!out_obj)
  655. return;
  656. lpi_constraints_table = kcalloc(out_obj->package.count,
  657. sizeof(*lpi_constraints_table),
  658. GFP_KERNEL);
  659. if (!lpi_constraints_table)
  660. goto free_acpi_buffer;
  661. acpi_handle_debug(lps0_device_handle, "LPI: constraints list begin:\n");
  662. for (i = 0; i < out_obj->package.count; i++) {
  663. struct lpi_constraints *constraint;
  664. acpi_status status;
  665. union acpi_object *package = &out_obj->package.elements[i];
  666. struct lpi_device_info info = { };
  667. int package_count = 0, j;
  668. if (!package)
  669. continue;
  670. for (j = 0; j < package->package.count; ++j) {
  671. union acpi_object *element =
  672. &(package->package.elements[j]);
  673. switch (element->type) {
  674. case ACPI_TYPE_INTEGER:
  675. info.enabled = element->integer.value;
  676. break;
  677. case ACPI_TYPE_STRING:
  678. info.name = element->string.pointer;
  679. break;
  680. case ACPI_TYPE_PACKAGE:
  681. package_count = element->package.count;
  682. info.package = element->package.elements;
  683. break;
  684. }
  685. }
  686. if (!info.enabled || !info.package || !info.name)
  687. continue;
  688. constraint = &lpi_constraints_table[lpi_constraints_table_size];
  689. status = acpi_get_handle(NULL, info.name, &constraint->handle);
  690. if (ACPI_FAILURE(status))
  691. continue;
  692. acpi_handle_debug(lps0_device_handle,
  693. "index:%d Name:%s\n", i, info.name);
  694. constraint->min_dstate = -1;
  695. for (j = 0; j < package_count; ++j) {
  696. union acpi_object *info_obj = &info.package[j];
  697. union acpi_object *cnstr_pkg;
  698. union acpi_object *obj;
  699. struct lpi_device_constraint dev_info;
  700. switch (info_obj->type) {
  701. case ACPI_TYPE_INTEGER:
  702. /* version */
  703. break;
  704. case ACPI_TYPE_PACKAGE:
  705. if (info_obj->package.count < 2)
  706. break;
  707. cnstr_pkg = info_obj->package.elements;
  708. obj = &cnstr_pkg[0];
  709. dev_info.uid = obj->integer.value;
  710. obj = &cnstr_pkg[1];
  711. dev_info.min_dstate = obj->integer.value;
  712. acpi_handle_debug(lps0_device_handle,
  713. "uid:%d min_dstate:%s\n",
  714. dev_info.uid,
  715. acpi_power_state_string(dev_info.min_dstate));
  716. constraint->min_dstate = dev_info.min_dstate;
  717. break;
  718. }
  719. }
  720. if (constraint->min_dstate < 0) {
  721. acpi_handle_debug(lps0_device_handle,
  722. "Incomplete constraint defined\n");
  723. continue;
  724. }
  725. lpi_constraints_table_size++;
  726. }
  727. acpi_handle_debug(lps0_device_handle, "LPI: constraints list end\n");
  728. free_acpi_buffer:
  729. ACPI_FREE(out_obj);
  730. }
  731. static void lpi_check_constraints(void)
  732. {
  733. int i;
  734. for (i = 0; i < lpi_constraints_table_size; ++i) {
  735. struct acpi_device *adev;
  736. if (acpi_bus_get_device(lpi_constraints_table[i].handle, &adev))
  737. continue;
  738. acpi_handle_debug(adev->handle,
  739. "LPI: required min power state:%s current power state:%s\n",
  740. acpi_power_state_string(lpi_constraints_table[i].min_dstate),
  741. acpi_power_state_string(adev->power.state));
  742. if (!adev->flags.power_manageable) {
  743. acpi_handle_info(adev->handle, "LPI: Device not power manageble\n");
  744. continue;
  745. }
  746. if (adev->power.state < lpi_constraints_table[i].min_dstate)
  747. acpi_handle_info(adev->handle,
  748. "LPI: Constraint not met; min power state:%s current power state:%s\n",
  749. acpi_power_state_string(lpi_constraints_table[i].min_dstate),
  750. acpi_power_state_string(adev->power.state));
  751. }
  752. }
  753. static void acpi_sleep_run_lps0_dsm(unsigned int func)
  754. {
  755. union acpi_object *out_obj;
  756. if (!(lps0_dsm_func_mask & (1 << func)))
  757. return;
  758. out_obj = acpi_evaluate_dsm(lps0_device_handle, &lps0_dsm_guid, 1, func, NULL);
  759. ACPI_FREE(out_obj);
  760. acpi_handle_debug(lps0_device_handle, "_DSM function %u evaluation %s\n",
  761. func, out_obj ? "successful" : "failed");
  762. }
  763. static int lps0_device_attach(struct acpi_device *adev,
  764. const struct acpi_device_id *not_used)
  765. {
  766. union acpi_object *out_obj;
  767. if (lps0_device_handle)
  768. return 0;
  769. if (acpi_sleep_no_lps0) {
  770. acpi_handle_info(adev->handle,
  771. "Low Power S0 Idle interface disabled\n");
  772. return 0;
  773. }
  774. if (!(acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0))
  775. return 0;
  776. guid_parse(ACPI_LPS0_DSM_UUID, &lps0_dsm_guid);
  777. /* Check if the _DSM is present and as expected. */
  778. out_obj = acpi_evaluate_dsm(adev->handle, &lps0_dsm_guid, 1, 0, NULL);
  779. if (out_obj && out_obj->type == ACPI_TYPE_BUFFER) {
  780. char bitmask = *(char *)out_obj->buffer.pointer;
  781. if ((bitmask & ACPI_S2IDLE_FUNC_MASK) == ACPI_S2IDLE_FUNC_MASK) {
  782. lps0_dsm_func_mask = bitmask;
  783. lps0_device_handle = adev->handle;
  784. /*
  785. * Use suspend-to-idle by default if the default
  786. * suspend mode was not set from the command line.
  787. */
  788. if (mem_sleep_default > PM_SUSPEND_MEM)
  789. mem_sleep_current = PM_SUSPEND_TO_IDLE;
  790. }
  791. acpi_handle_debug(adev->handle, "_DSM function mask: 0x%x\n",
  792. bitmask);
  793. } else {
  794. acpi_handle_debug(adev->handle,
  795. "_DSM function 0 evaluation failed\n");
  796. }
  797. ACPI_FREE(out_obj);
  798. lpi_device_get_constraints();
  799. return 0;
  800. }
  801. static struct acpi_scan_handler lps0_handler = {
  802. .ids = lps0_device_ids,
  803. .attach = lps0_device_attach,
  804. };
  805. static int acpi_s2idle_begin(void)
  806. {
  807. acpi_scan_lock_acquire();
  808. s2idle_in_progress = true;
  809. return 0;
  810. }
  811. static int acpi_s2idle_prepare(void)
  812. {
  813. if (lps0_device_handle) {
  814. acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF);
  815. acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY);
  816. } else {
  817. /*
  818. * The configuration of GPEs is changed here to avoid spurious
  819. * wakeups, but that should not be necessary if this is a
  820. * "low-power S0" platform and the low-power S0 _DSM is present.
  821. */
  822. acpi_enable_all_wakeup_gpes();
  823. acpi_os_wait_events_complete();
  824. }
  825. if (acpi_sci_irq_valid())
  826. enable_irq_wake(acpi_sci_irq);
  827. return 0;
  828. }
  829. static void acpi_s2idle_wake(void)
  830. {
  831. if (pm_debug_messages_on)
  832. lpi_check_constraints();
  833. /*
  834. * If IRQD_WAKEUP_ARMED is not set for the SCI at this point, it means
  835. * that the SCI has triggered while suspended, so cancel the wakeup in
  836. * case it has not been a wakeup event (the GPEs will be checked later).
  837. */
  838. if (acpi_sci_irq_valid() &&
  839. !irqd_is_wakeup_armed(irq_get_irq_data(acpi_sci_irq))) {
  840. pm_system_cancel_wakeup();
  841. s2idle_wakeup = true;
  842. }
  843. }
  844. static void acpi_s2idle_sync(void)
  845. {
  846. /*
  847. * Process all pending events in case there are any wakeup ones.
  848. *
  849. * The EC driver uses the system workqueue and an additional special
  850. * one, so those need to be flushed too.
  851. */
  852. acpi_ec_flush_work();
  853. acpi_os_wait_events_complete();
  854. s2idle_wakeup = false;
  855. }
  856. static void acpi_s2idle_restore(void)
  857. {
  858. if (acpi_sci_irq_valid())
  859. disable_irq_wake(acpi_sci_irq);
  860. if (lps0_device_handle) {
  861. acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT);
  862. acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON);
  863. } else {
  864. acpi_enable_all_runtime_gpes();
  865. }
  866. }
  867. static void acpi_s2idle_end(void)
  868. {
  869. s2idle_in_progress = false;
  870. acpi_scan_lock_release();
  871. }
  872. static const struct platform_s2idle_ops acpi_s2idle_ops = {
  873. .begin = acpi_s2idle_begin,
  874. .prepare = acpi_s2idle_prepare,
  875. .wake = acpi_s2idle_wake,
  876. .sync = acpi_s2idle_sync,
  877. .restore = acpi_s2idle_restore,
  878. .end = acpi_s2idle_end,
  879. };
  880. static void acpi_sleep_suspend_setup(void)
  881. {
  882. int i;
  883. for (i = ACPI_STATE_S1; i < ACPI_STATE_S4; i++)
  884. if (acpi_sleep_state_supported(i))
  885. sleep_states[i] = 1;
  886. suspend_set_ops(old_suspend_ordering ?
  887. &acpi_suspend_ops_old : &acpi_suspend_ops);
  888. acpi_scan_add_handler(&lps0_handler);
  889. s2idle_set_ops(&acpi_s2idle_ops);
  890. }
  891. #else /* !CONFIG_SUSPEND */
  892. #define s2idle_in_progress (false)
  893. #define s2idle_wakeup (false)
  894. #define lps0_device_handle (NULL)
  895. static inline void acpi_sleep_suspend_setup(void) {}
  896. #endif /* !CONFIG_SUSPEND */
  897. bool acpi_s2idle_wakeup(void)
  898. {
  899. return s2idle_wakeup;
  900. }
  901. bool acpi_sleep_no_ec_events(void)
  902. {
  903. return !s2idle_in_progress || !lps0_device_handle;
  904. }
  905. #ifdef CONFIG_PM_SLEEP
  906. static u32 saved_bm_rld;
  907. static int acpi_save_bm_rld(void)
  908. {
  909. acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &saved_bm_rld);
  910. return 0;
  911. }
  912. static void acpi_restore_bm_rld(void)
  913. {
  914. u32 resumed_bm_rld = 0;
  915. acpi_read_bit_register(ACPI_BITREG_BUS_MASTER_RLD, &resumed_bm_rld);
  916. if (resumed_bm_rld == saved_bm_rld)
  917. return;
  918. acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, saved_bm_rld);
  919. }
  920. static struct syscore_ops acpi_sleep_syscore_ops = {
  921. .suspend = acpi_save_bm_rld,
  922. .resume = acpi_restore_bm_rld,
  923. };
  924. static void acpi_sleep_syscore_init(void)
  925. {
  926. register_syscore_ops(&acpi_sleep_syscore_ops);
  927. }
  928. #else
  929. static inline void acpi_sleep_syscore_init(void) {}
  930. #endif /* CONFIG_PM_SLEEP */
  931. #ifdef CONFIG_HIBERNATION
  932. static unsigned long s4_hardware_signature;
  933. static struct acpi_table_facs *facs;
  934. static bool nosigcheck;
  935. void __init acpi_no_s4_hw_signature(void)
  936. {
  937. nosigcheck = true;
  938. }
  939. static int acpi_hibernation_begin(void)
  940. {
  941. int error;
  942. error = nvs_nosave ? 0 : suspend_nvs_alloc();
  943. if (!error)
  944. acpi_pm_start(ACPI_STATE_S4);
  945. return error;
  946. }
  947. static int acpi_hibernation_enter(void)
  948. {
  949. acpi_status status = AE_OK;
  950. ACPI_FLUSH_CPU_CACHE();
  951. /* This shouldn't return. If it returns, we have a problem */
  952. status = acpi_enter_sleep_state(ACPI_STATE_S4);
  953. /* Reprogram control registers */
  954. acpi_leave_sleep_state_prep(ACPI_STATE_S4);
  955. return ACPI_SUCCESS(status) ? 0 : -EFAULT;
  956. }
  957. static void acpi_hibernation_leave(void)
  958. {
  959. pm_set_resume_via_firmware();
  960. /*
  961. * If ACPI is not enabled by the BIOS and the boot kernel, we need to
  962. * enable it here.
  963. */
  964. acpi_enable();
  965. /* Reprogram control registers */
  966. acpi_leave_sleep_state_prep(ACPI_STATE_S4);
  967. /* Check the hardware signature */
  968. if (facs && s4_hardware_signature != facs->hardware_signature)
  969. pr_crit("ACPI: Hardware changed while hibernated, success doubtful!\n");
  970. /* Restore the NVS memory area */
  971. suspend_nvs_restore();
  972. /* Allow EC transactions to happen. */
  973. acpi_ec_unblock_transactions();
  974. }
  975. static void acpi_pm_thaw(void)
  976. {
  977. acpi_ec_unblock_transactions();
  978. acpi_enable_all_runtime_gpes();
  979. }
  980. static const struct platform_hibernation_ops acpi_hibernation_ops = {
  981. .begin = acpi_hibernation_begin,
  982. .end = acpi_pm_end,
  983. .pre_snapshot = acpi_pm_prepare,
  984. .finish = acpi_pm_finish,
  985. .prepare = acpi_pm_prepare,
  986. .enter = acpi_hibernation_enter,
  987. .leave = acpi_hibernation_leave,
  988. .pre_restore = acpi_pm_freeze,
  989. .restore_cleanup = acpi_pm_thaw,
  990. };
  991. /**
  992. * acpi_hibernation_begin_old - Set the target system sleep state to
  993. * ACPI_STATE_S4 and execute the _PTS control method. This
  994. * function is used if the pre-ACPI 2.0 suspend ordering has been
  995. * requested.
  996. */
  997. static int acpi_hibernation_begin_old(void)
  998. {
  999. int error;
  1000. /*
  1001. * The _TTS object should always be evaluated before the _PTS object.
  1002. * When the old_suspended_ordering is true, the _PTS object is
  1003. * evaluated in the acpi_sleep_prepare.
  1004. */
  1005. acpi_sleep_tts_switch(ACPI_STATE_S4);
  1006. error = acpi_sleep_prepare(ACPI_STATE_S4);
  1007. if (!error) {
  1008. if (!nvs_nosave)
  1009. error = suspend_nvs_alloc();
  1010. if (!error) {
  1011. acpi_target_sleep_state = ACPI_STATE_S4;
  1012. acpi_scan_lock_acquire();
  1013. }
  1014. }
  1015. return error;
  1016. }
  1017. /*
  1018. * The following callbacks are used if the pre-ACPI 2.0 suspend ordering has
  1019. * been requested.
  1020. */
  1021. static const struct platform_hibernation_ops acpi_hibernation_ops_old = {
  1022. .begin = acpi_hibernation_begin_old,
  1023. .end = acpi_pm_end,
  1024. .pre_snapshot = acpi_pm_pre_suspend,
  1025. .prepare = acpi_pm_freeze,
  1026. .finish = acpi_pm_finish,
  1027. .enter = acpi_hibernation_enter,
  1028. .leave = acpi_hibernation_leave,
  1029. .pre_restore = acpi_pm_freeze,
  1030. .restore_cleanup = acpi_pm_thaw,
  1031. .recover = acpi_pm_finish,
  1032. };
  1033. static void acpi_sleep_hibernate_setup(void)
  1034. {
  1035. if (!acpi_sleep_state_supported(ACPI_STATE_S4))
  1036. return;
  1037. hibernation_set_ops(old_suspend_ordering ?
  1038. &acpi_hibernation_ops_old : &acpi_hibernation_ops);
  1039. sleep_states[ACPI_STATE_S4] = 1;
  1040. if (nosigcheck)
  1041. return;
  1042. acpi_get_table(ACPI_SIG_FACS, 1, (struct acpi_table_header **)&facs);
  1043. if (facs)
  1044. s4_hardware_signature = facs->hardware_signature;
  1045. }
  1046. #else /* !CONFIG_HIBERNATION */
  1047. static inline void acpi_sleep_hibernate_setup(void) {}
  1048. #endif /* !CONFIG_HIBERNATION */
  1049. static void acpi_power_off_prepare(void)
  1050. {
  1051. /* Prepare to power off the system */
  1052. acpi_sleep_prepare(ACPI_STATE_S5);
  1053. acpi_disable_all_gpes();
  1054. acpi_os_wait_events_complete();
  1055. }
  1056. static void acpi_power_off(void)
  1057. {
  1058. /* acpi_sleep_prepare(ACPI_STATE_S5) should have already been called */
  1059. printk(KERN_DEBUG "%s called\n", __func__);
  1060. local_irq_disable();
  1061. acpi_enter_sleep_state(ACPI_STATE_S5);
  1062. }
  1063. int __init acpi_sleep_init(void)
  1064. {
  1065. char supported[ACPI_S_STATE_COUNT * 3 + 1];
  1066. char *pos = supported;
  1067. int i;
  1068. acpi_sleep_dmi_check();
  1069. sleep_states[ACPI_STATE_S0] = 1;
  1070. acpi_sleep_syscore_init();
  1071. acpi_sleep_suspend_setup();
  1072. acpi_sleep_hibernate_setup();
  1073. if (acpi_sleep_state_supported(ACPI_STATE_S5)) {
  1074. sleep_states[ACPI_STATE_S5] = 1;
  1075. pm_power_off_prepare = acpi_power_off_prepare;
  1076. pm_power_off = acpi_power_off;
  1077. } else {
  1078. acpi_no_s5 = true;
  1079. }
  1080. supported[0] = 0;
  1081. for (i = 0; i < ACPI_S_STATE_COUNT; i++) {
  1082. if (sleep_states[i])
  1083. pos += sprintf(pos, " S%d", i);
  1084. }
  1085. pr_info(PREFIX "(supports%s)\n", supported);
  1086. /*
  1087. * Register the tts_notifier to reboot notifier list so that the _TTS
  1088. * object can also be evaluated when the system enters S5.
  1089. */
  1090. register_reboot_notifier(&tts_notifier);
  1091. return 0;
  1092. }