File Index
Files and directories
Sign in
FILE

s2idle.c

File preview with syntax highlighting.

linux-6.19.14/drivers/acpi/x86/s2idle.c C
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Architecture-specific ACPI-based support for suspend-to-idle.
  4 *
  5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  6 * Author: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
  7 * Author: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
  8 *
  9 * On platforms supporting the Low Power S0 Idle interface there is an ACPI
 10 * device object with the PNP0D80 compatible device ID (System Power Management
 11 * Controller) and a specific _DSM method under it.  That method, if present,
 12 * can be used to indicate to the platform that the OS is transitioning into a
 13 * low-power state in which certain types of activity are not desirable or that
 14 * it is leaving such a state, which allows the platform to adjust its operation
 15 * mode accordingly.
 16 */
 17
 18#include <linux/acpi.h>
 19#include <linux/device.h>
 20#include <linux/dmi.h>
 21#include <linux/suspend.h>
 22
 23#include "../sleep.h"
 24
 25#ifdef CONFIG_SUSPEND
 26
 27static bool sleep_no_lps0 __read_mostly;
 28module_param(sleep_no_lps0, bool, 0644);
 29MODULE_PARM_DESC(sleep_no_lps0, "Do not use the special LPS0 device interface");
 30
 31static bool check_lps0_constraints __read_mostly;
 32module_param(check_lps0_constraints, bool, 0644);
 33MODULE_PARM_DESC(check_lps0_constraints, "Check LPS0 device constraints");
 34
 35static const struct acpi_device_id lps0_device_ids[] = {
 36	{"PNP0D80", },
 37	{"", },
 38};
 39
 40/* Microsoft platform agnostic UUID */
 41#define ACPI_LPS0_DSM_UUID_MICROSOFT      "11e00d56-ce64-47ce-837b-1f898f9aa461"
 42
 43#define ACPI_LPS0_DSM_UUID	"c4eb40a0-6cd2-11e2-bcfd-0800200c9a66"
 44
 45#define ACPI_LPS0_GET_DEVICE_CONSTRAINTS	1
 46#define ACPI_LPS0_SCREEN_OFF	3
 47#define ACPI_LPS0_SCREEN_ON	4
 48#define ACPI_LPS0_ENTRY		5
 49#define ACPI_LPS0_EXIT		6
 50#define ACPI_LPS0_MS_ENTRY      7
 51#define ACPI_LPS0_MS_EXIT       8
 52#define ACPI_MS_TURN_ON_DISPLAY 9
 53
 54/* AMD */
 55#define ACPI_LPS0_DSM_UUID_AMD      "e3f32452-febc-43ce-9039-932122d37721"
 56#define ACPI_LPS0_ENTRY_AMD         2
 57#define ACPI_LPS0_EXIT_AMD          3
 58#define ACPI_LPS0_SCREEN_OFF_AMD    4
 59#define ACPI_LPS0_SCREEN_ON_AMD     5
 60
 61static acpi_handle lps0_device_handle;
 62static guid_t lps0_dsm_guid;
 63static int lps0_dsm_func_mask;
 64
 65static guid_t lps0_dsm_guid_microsoft;
 66static int lps0_dsm_func_mask_microsoft;
 67static int lps0_dsm_state;
 68
 69/* Device constraint entry structure */
 70struct lpi_device_info {
 71	char *name;
 72	int enabled;
 73	union acpi_object *package;
 74};
 75
 76/* Constraint package structure */
 77struct lpi_device_constraint {
 78	int uid;
 79	int min_dstate;
 80	int function_states;
 81};
 82
 83struct lpi_constraints {
 84	acpi_handle handle;
 85	int min_dstate;
 86};
 87
 88/* AMD Constraint package structure */
 89struct lpi_device_constraint_amd {
 90	char *name;
 91	int enabled;
 92	int function_states;
 93	int min_dstate;
 94};
 95
 96static LIST_HEAD(lps0_s2idle_devops_head);
 97
 98static struct lpi_constraints *lpi_constraints_table;
 99static int lpi_constraints_table_size;
100static int rev_id;
101
102#define for_each_lpi_constraint(entry)						\
103	for (int i = 0;								\
104	     entry = &lpi_constraints_table[i], i < lpi_constraints_table_size;	\
105	     i++)
106
107static void lpi_device_get_constraints_amd(void)
108{
109	union acpi_object *out_obj;
110	int i, j, k;
111
112	out_obj = acpi_evaluate_dsm_typed(lps0_device_handle, &lps0_dsm_guid,
113					  rev_id, ACPI_LPS0_GET_DEVICE_CONSTRAINTS,
114					  NULL, ACPI_TYPE_PACKAGE);
115
116	acpi_handle_debug(lps0_device_handle, "_DSM function 1 eval %s\n",
117			  out_obj ? "successful" : "failed");
118
119	if (!out_obj)
120		return;
121
122	for (i = 0; i < out_obj->package.count; i++) {
123		union acpi_object *package = &out_obj->package.elements[i];
124
125		if (package->type == ACPI_TYPE_PACKAGE) {
126			if (lpi_constraints_table) {
127				acpi_handle_err(lps0_device_handle,
128						"Duplicate constraints list\n");
129				goto free_acpi_buffer;
130			}
131
132			lpi_constraints_table = kcalloc(package->package.count,
133							sizeof(*lpi_constraints_table),
134							GFP_KERNEL);
135
136			if (!lpi_constraints_table)
137				goto free_acpi_buffer;
138
139			acpi_handle_debug(lps0_device_handle,
140					  "LPI: constraints list begin:\n");
141
142			for (j = 0; j < package->package.count; j++) {
143				union acpi_object *info_obj = &package->package.elements[j];
144				struct lpi_device_constraint_amd dev_info = {};
145				struct lpi_constraints *list;
146				acpi_status status;
147
148				list = &lpi_constraints_table[lpi_constraints_table_size];
149
150				for (k = 0; k < info_obj->package.count; k++) {
151					union acpi_object *obj = &info_obj->package.elements[k];
152
153					switch (k) {
154					case 0:
155						dev_info.enabled = obj->integer.value;
156						break;
157					case 1:
158						dev_info.name = obj->string.pointer;
159						break;
160					case 2:
161						dev_info.function_states = obj->integer.value;
162						break;
163					case 3:
164						dev_info.min_dstate = obj->integer.value;
165						break;
166					}
167				}
168
169				acpi_handle_debug(lps0_device_handle,
170						  "Name:%s, Enabled: %d, States: %d, MinDstate: %d\n",
171						  dev_info.name,
172						  dev_info.enabled,
173						  dev_info.function_states,
174						  dev_info.min_dstate);
175
176				if (!dev_info.enabled || !dev_info.name ||
177				    !dev_info.min_dstate)
178					continue;
179
180				status = acpi_get_handle(NULL, dev_info.name, &list->handle);
181				if (ACPI_FAILURE(status))
182					continue;
183
184				list->min_dstate = dev_info.min_dstate;
185
186				lpi_constraints_table_size++;
187			}
188		}
189	}
190
191	acpi_handle_debug(lps0_device_handle, "LPI: constraints list end\n");
192
193free_acpi_buffer:
194	ACPI_FREE(out_obj);
195}
196
197static void lpi_device_get_constraints(void)
198{
199	union acpi_object *out_obj;
200	int i;
201
202	out_obj = acpi_evaluate_dsm_typed(lps0_device_handle, &lps0_dsm_guid,
203					  1, ACPI_LPS0_GET_DEVICE_CONSTRAINTS,
204					  NULL, ACPI_TYPE_PACKAGE);
205
206	acpi_handle_debug(lps0_device_handle, "_DSM function 1 eval %s\n",
207			  out_obj ? "successful" : "failed");
208
209	if (!out_obj)
210		return;
211
212	lpi_constraints_table = kcalloc(out_obj->package.count,
213					sizeof(*lpi_constraints_table),
214					GFP_KERNEL);
215	if (!lpi_constraints_table)
216		goto free_acpi_buffer;
217
218	acpi_handle_debug(lps0_device_handle, "LPI: constraints list begin:\n");
219
220	for (i = 0; i < out_obj->package.count; i++) {
221		struct lpi_constraints *constraint;
222		acpi_status status;
223		union acpi_object *package = &out_obj->package.elements[i];
224		struct lpi_device_info info = { };
225		int package_count = 0, j;
226
227		if (!package)
228			continue;
229
230		for (j = 0; j < package->package.count; j++) {
231			union acpi_object *element =
232					&(package->package.elements[j]);
233
234			switch (element->type) {
235			case ACPI_TYPE_INTEGER:
236				info.enabled = element->integer.value;
237				break;
238			case ACPI_TYPE_STRING:
239				info.name = element->string.pointer;
240				break;
241			case ACPI_TYPE_PACKAGE:
242				package_count = element->package.count;
243				info.package = element->package.elements;
244				break;
245			}
246		}
247
248		if (!info.enabled || !info.package || !info.name)
249			continue;
250
251		constraint = &lpi_constraints_table[lpi_constraints_table_size];
252
253		status = acpi_get_handle(NULL, info.name, &constraint->handle);
254		if (ACPI_FAILURE(status))
255			continue;
256
257		acpi_handle_debug(lps0_device_handle,
258				  "index:%d Name:%s\n", i, info.name);
259
260		constraint->min_dstate = -1;
261
262		for (j = 0; j < package_count; j++) {
263			union acpi_object *info_obj = &info.package[j];
264			union acpi_object *cnstr_pkg;
265			union acpi_object *obj;
266			struct lpi_device_constraint dev_info;
267
268			switch (info_obj->type) {
269			case ACPI_TYPE_INTEGER:
270				/* version */
271				break;
272			case ACPI_TYPE_PACKAGE:
273				if (info_obj->package.count < 2)
274					break;
275
276				cnstr_pkg = info_obj->package.elements;
277				obj = &cnstr_pkg[0];
278				dev_info.uid = obj->integer.value;
279				obj = &cnstr_pkg[1];
280				dev_info.min_dstate = obj->integer.value;
281
282				acpi_handle_debug(lps0_device_handle,
283					"uid:%d min_dstate:%s\n",
284					dev_info.uid,
285					acpi_power_state_string(dev_info.min_dstate));
286
287				constraint->min_dstate = dev_info.min_dstate;
288				break;
289			}
290		}
291
292		if (constraint->min_dstate < 0) {
293			acpi_handle_debug(lps0_device_handle,
294					  "Incomplete constraint defined\n");
295			continue;
296		}
297
298		lpi_constraints_table_size++;
299	}
300
301	acpi_handle_debug(lps0_device_handle, "LPI: constraints list end\n");
302
303free_acpi_buffer:
304	ACPI_FREE(out_obj);
305}
306
307static void lpi_check_constraints(void)
308{
309	struct lpi_constraints *entry;
310
311	if (IS_ERR_OR_NULL(lpi_constraints_table))
312		return;
313
314	for_each_lpi_constraint(entry) {
315		struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle);
316
317		if (!adev)
318			continue;
319
320		acpi_handle_debug(entry->handle,
321			"LPI: required min power state:%s current power state:%s\n",
322			acpi_power_state_string(entry->min_dstate),
323			acpi_power_state_string(adev->power.state));
324
325		if (!adev->flags.power_manageable) {
326			acpi_handle_info(entry->handle, "LPI: Device not power manageable\n");
327			entry->handle = NULL;
328			continue;
329		}
330
331		if (adev->power.state < entry->min_dstate)
332			acpi_handle_info(entry->handle,
333				"LPI: Constraint not met; min power state:%s current power state:%s\n",
334				acpi_power_state_string(entry->min_dstate),
335				acpi_power_state_string(adev->power.state));
336	}
337}
338
339static bool acpi_s2idle_vendor_amd(void)
340{
341	return boot_cpu_data.x86_vendor == X86_VENDOR_AMD;
342}
343
344static const char *acpi_sleep_dsm_state_to_str(unsigned int state)
345{
346	if (lps0_dsm_func_mask_microsoft || !acpi_s2idle_vendor_amd()) {
347		switch (state) {
348		case ACPI_LPS0_SCREEN_OFF:
349			return "screen off";
350		case ACPI_LPS0_SCREEN_ON:
351			return "screen on";
352		case ACPI_LPS0_ENTRY:
353			return "lps0 entry";
354		case ACPI_LPS0_EXIT:
355			return "lps0 exit";
356		case ACPI_LPS0_MS_ENTRY:
357			return "lps0 ms entry";
358		case ACPI_LPS0_MS_EXIT:
359			return "lps0 ms exit";
360		case ACPI_MS_TURN_ON_DISPLAY:
361			return "lps0 ms turn on display";
362		}
363	} else {
364		switch (state) {
365		case ACPI_LPS0_SCREEN_ON_AMD:
366			return "screen on";
367		case ACPI_LPS0_SCREEN_OFF_AMD:
368			return "screen off";
369		case ACPI_LPS0_ENTRY_AMD:
370			return "lps0 entry";
371		case ACPI_LPS0_EXIT_AMD:
372			return "lps0 exit";
373		}
374	}
375
376	return "unknown";
377}
378
379static void acpi_sleep_run_lps0_dsm(unsigned int func, unsigned int func_mask, guid_t dsm_guid)
380{
381	union acpi_object *out_obj;
382
383	if (!(func_mask & (1 << func)))
384		return;
385
386	out_obj = acpi_evaluate_dsm(lps0_device_handle, &dsm_guid,
387					rev_id, func, NULL);
388	ACPI_FREE(out_obj);
389
390	lps0_dsm_state = func;
391	if (pm_debug_messages_on) {
392		acpi_handle_info(lps0_device_handle,
393				"%s transitioned to state %s\n",
394				 out_obj ? "Successfully" : "Failed to",
395				 acpi_sleep_dsm_state_to_str(lps0_dsm_state));
396	}
397}
398
399
400static int validate_dsm(acpi_handle handle, const char *uuid, int rev, guid_t *dsm_guid)
401{
402	union acpi_object *obj;
403	int ret = -EINVAL;
404
405	guid_parse(uuid, dsm_guid);
406
407	/* Check if the _DSM is present and as expected. */
408	obj = acpi_evaluate_dsm_typed(handle, dsm_guid, rev, 0, NULL, ACPI_TYPE_BUFFER);
409	if (!obj || obj->buffer.length == 0 || obj->buffer.length > sizeof(u32)) {
410		acpi_handle_debug(handle,
411				"_DSM UUID %s rev %d function 0 evaluation failed\n", uuid, rev);
412		goto out;
413	}
414
415	ret = *(int *)obj->buffer.pointer;
416	acpi_handle_debug(handle, "_DSM UUID %s rev %d function mask: 0x%x\n", uuid, rev, ret);
417
418out:
419	ACPI_FREE(obj);
420	return ret;
421}
422
423struct amd_lps0_hid_device_data {
424	const bool check_off_by_one;
425};
426
427static const struct amd_lps0_hid_device_data amd_picasso = {
428	.check_off_by_one = true,
429};
430
431static const struct amd_lps0_hid_device_data amd_cezanne = {
432	.check_off_by_one = false,
433};
434
435static const struct acpi_device_id amd_hid_ids[] = {
436	{"AMD0004",	(kernel_ulong_t)&amd_picasso,	},
437	{"AMD0005",	(kernel_ulong_t)&amd_picasso,	},
438	{"AMDI0005",	(kernel_ulong_t)&amd_picasso,	},
439	{"AMDI0006",	(kernel_ulong_t)&amd_cezanne,	},
440	{}
441};
442
443static int lps0_device_attach(struct acpi_device *adev,
444			      const struct acpi_device_id *not_used)
445{
446	if (lps0_device_handle)
447		return 0;
448
449	lps0_dsm_func_mask_microsoft = validate_dsm(adev->handle,
450						    ACPI_LPS0_DSM_UUID_MICROSOFT, 0,
451						    &lps0_dsm_guid_microsoft);
452	if (acpi_s2idle_vendor_amd()) {
453		static const struct acpi_device_id *dev_id;
454		const struct amd_lps0_hid_device_data *data;
455
456		for (dev_id = &amd_hid_ids[0]; dev_id->id[0]; dev_id++)
457			if (acpi_dev_hid_uid_match(adev, dev_id->id, NULL))
458				break;
459		if (dev_id->id[0])
460			data = (const struct amd_lps0_hid_device_data *) dev_id->driver_data;
461		else
462			data = &amd_cezanne;
463		lps0_dsm_func_mask = validate_dsm(adev->handle,
464					ACPI_LPS0_DSM_UUID_AMD, rev_id, &lps0_dsm_guid);
465		if (lps0_dsm_func_mask > 0x3 && data->check_off_by_one) {
466			lps0_dsm_func_mask = (lps0_dsm_func_mask << 1) | 0x1;
467			acpi_handle_debug(adev->handle, "_DSM UUID %s: Adjusted function mask: 0x%x\n",
468					  ACPI_LPS0_DSM_UUID_AMD, lps0_dsm_func_mask);
469		} else if (lps0_dsm_func_mask_microsoft > 0 && rev_id) {
470			lps0_dsm_func_mask_microsoft = -EINVAL;
471			acpi_handle_debug(adev->handle, "_DSM Using AMD method\n");
472		}
473	} else {
474		rev_id = 1;
475		lps0_dsm_func_mask = validate_dsm(adev->handle,
476					ACPI_LPS0_DSM_UUID, rev_id, &lps0_dsm_guid);
477		if (lps0_dsm_func_mask > 0 && lps0_dsm_func_mask_microsoft > 0) {
478			unsigned int func_mask;
479
480			/*
481			 * Log a message if the _DSM function sets for two
482			 * different UUIDs overlap.
483			 */
484			func_mask = lps0_dsm_func_mask & lps0_dsm_func_mask_microsoft;
485			if (func_mask)
486				acpi_handle_info(adev->handle,
487						 "Duplicate LPS0 _DSM functions (mask: 0x%x)\n",
488						 func_mask);
489		}
490	}
491
492	if (lps0_dsm_func_mask < 0 && lps0_dsm_func_mask_microsoft < 0)
493		return 0; //function evaluation failed
494
495	lps0_device_handle = adev->handle;
496
497	/*
498	 * Use suspend-to-idle by default if ACPI_FADT_LOW_POWER_S0 is set in
499	 * the FADT and the default suspend mode was not set from the command
500	 * line.
501	 */
502	if ((acpi_gbl_FADT.flags & ACPI_FADT_LOW_POWER_S0) &&
503	    mem_sleep_default > PM_SUSPEND_MEM && !acpi_sleep_default_s3) {
504		mem_sleep_current = PM_SUSPEND_TO_IDLE;
505		pr_info("Low-power S0 idle used by default for system suspend\n");
506	}
507
508	/*
509	 * Some LPS0 systems, like ASUS Zenbook UX430UNR/i7-8550U, require the
510	 * EC GPE to be enabled while suspended for certain wakeup devices to
511	 * work, so mark it as wakeup-capable.
512	 */
513	acpi_ec_mark_gpe_for_wake();
514
515	return 0;
516}
517
518static struct acpi_scan_handler lps0_handler = {
519	.ids = lps0_device_ids,
520	.attach = lps0_device_attach,
521};
522
523static int acpi_s2idle_begin_lps0(void)
524{
525	if (lps0_device_handle && !sleep_no_lps0 && check_lps0_constraints &&
526	    !lpi_constraints_table) {
527		if (acpi_s2idle_vendor_amd())
528			lpi_device_get_constraints_amd();
529		else
530			lpi_device_get_constraints();
531
532		/*
533		 * Try to retrieve the constraints only once because failures
534		 * to do so usually are sticky.
535		 */
536		if (!lpi_constraints_table)
537			lpi_constraints_table = ERR_PTR(-ENODATA);
538	}
539
540	return acpi_s2idle_begin();
541}
542
543static int acpi_s2idle_prepare_late_lps0(void)
544{
545	struct acpi_s2idle_dev_ops *handler;
546
547	if (!lps0_device_handle || sleep_no_lps0)
548		return 0;
549
550	if (check_lps0_constraints)
551		lpi_check_constraints();
552
553	/* Screen off */
554	if (lps0_dsm_func_mask > 0)
555		acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
556					ACPI_LPS0_SCREEN_OFF_AMD :
557					ACPI_LPS0_SCREEN_OFF,
558					lps0_dsm_func_mask, lps0_dsm_guid);
559
560	if (lps0_dsm_func_mask_microsoft > 0)
561		acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_OFF,
562				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
563
564	/* LPS0 entry */
565	if (lps0_dsm_func_mask > 0 && acpi_s2idle_vendor_amd())
566		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY_AMD,
567					lps0_dsm_func_mask, lps0_dsm_guid);
568
569	if (lps0_dsm_func_mask_microsoft > 0) {
570		/* Modern Standby entry */
571		acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_ENTRY,
572				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
573		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
574				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
575	}
576
577	if (lps0_dsm_func_mask > 0 && !acpi_s2idle_vendor_amd())
578		acpi_sleep_run_lps0_dsm(ACPI_LPS0_ENTRY,
579					lps0_dsm_func_mask, lps0_dsm_guid);
580
581	list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) {
582		if (handler->prepare)
583			handler->prepare();
584	}
585
586	return 0;
587}
588
589static void acpi_s2idle_check_lps0(void)
590{
591	struct acpi_s2idle_dev_ops *handler;
592
593	if (!lps0_device_handle || sleep_no_lps0)
594		return;
595
596	list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node) {
597		if (handler->check)
598			handler->check();
599	}
600}
601
602static void acpi_s2idle_restore_early_lps0(void)
603{
604	struct acpi_s2idle_dev_ops *handler;
605
606	if (!lps0_device_handle || sleep_no_lps0)
607		return;
608
609	list_for_each_entry(handler, &lps0_s2idle_devops_head, list_node)
610		if (handler->restore)
611			handler->restore();
612
613	/* LPS0 exit */
614	if (lps0_dsm_func_mask > 0)
615		acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
616					ACPI_LPS0_EXIT_AMD :
617					ACPI_LPS0_EXIT,
618					lps0_dsm_func_mask, lps0_dsm_guid);
619
620	if (lps0_dsm_func_mask_microsoft > 0) {
621		acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT,
622				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
623		/* Intent to turn on display */
624		acpi_sleep_run_lps0_dsm(ACPI_MS_TURN_ON_DISPLAY,
625				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
626		/* Modern Standby exit */
627		acpi_sleep_run_lps0_dsm(ACPI_LPS0_MS_EXIT,
628				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
629	}
630
631	/* Screen on */
632	if (lps0_dsm_func_mask_microsoft > 0)
633		acpi_sleep_run_lps0_dsm(ACPI_LPS0_SCREEN_ON,
634				lps0_dsm_func_mask_microsoft, lps0_dsm_guid_microsoft);
635	if (lps0_dsm_func_mask > 0)
636		acpi_sleep_run_lps0_dsm(acpi_s2idle_vendor_amd() ?
637					ACPI_LPS0_SCREEN_ON_AMD :
638					ACPI_LPS0_SCREEN_ON,
639					lps0_dsm_func_mask, lps0_dsm_guid);
640}
641
642static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
643	.begin = acpi_s2idle_begin_lps0,
644	.prepare = acpi_s2idle_prepare,
645	.prepare_late = acpi_s2idle_prepare_late_lps0,
646	.check = acpi_s2idle_check_lps0,
647	.wake = acpi_s2idle_wake,
648	.restore_early = acpi_s2idle_restore_early_lps0,
649	.restore = acpi_s2idle_restore,
650	.end = acpi_s2idle_end,
651};
652
653void __init acpi_s2idle_setup(void)
654{
655	acpi_scan_add_handler(&lps0_handler);
656	s2idle_set_ops(&acpi_s2idle_ops_lps0);
657}
658
659int acpi_register_lps0_dev(struct acpi_s2idle_dev_ops *arg)
660{
661	unsigned int sleep_flags;
662
663	if (!lps0_device_handle || sleep_no_lps0)
664		return -ENODEV;
665
666	sleep_flags = lock_system_sleep();
667	list_add(&arg->list_node, &lps0_s2idle_devops_head);
668	unlock_system_sleep(sleep_flags);
669
670	return 0;
671}
672EXPORT_SYMBOL_GPL(acpi_register_lps0_dev);
673
674void acpi_unregister_lps0_dev(struct acpi_s2idle_dev_ops *arg)
675{
676	unsigned int sleep_flags;
677
678	if (!lps0_device_handle || sleep_no_lps0)
679		return;
680
681	sleep_flags = lock_system_sleep();
682	list_del(&arg->list_node);
683	unlock_system_sleep(sleep_flags);
684}
685EXPORT_SYMBOL_GPL(acpi_unregister_lps0_dev);
686
687#endif /* CONFIG_SUSPEND */
~/ Read-only file preview.