xref: /OK3568_Linux_fs/kernel/include/xen/acpi.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /******************************************************************************
2*4882a593Smuzhiyun  * acpi.h
3*4882a593Smuzhiyun  * acpi file for domain 0 kernel
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Copyright (c) 2011 Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
6*4882a593Smuzhiyun  * Copyright (c) 2011 Yu Ke <ke.yu@intel.com>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * This program is free software; you can redistribute it and/or
9*4882a593Smuzhiyun  * modify it under the terms of the GNU General Public License version 2
10*4882a593Smuzhiyun  * as published by the Free Software Foundation; or, when distributed
11*4882a593Smuzhiyun  * separately from the Linux kernel or incorporated into other
12*4882a593Smuzhiyun  * software packages, subject to the following license:
13*4882a593Smuzhiyun  *
14*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a copy
15*4882a593Smuzhiyun  * of this source file (the "Software"), to deal in the Software without
16*4882a593Smuzhiyun  * restriction, including without limitation the rights to use, copy, modify,
17*4882a593Smuzhiyun  * merge, publish, distribute, sublicense, and/or sell copies of the Software,
18*4882a593Smuzhiyun  * and to permit persons to whom the Software is furnished to do so, subject to
19*4882a593Smuzhiyun  * the following conditions:
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
22*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
23*4882a593Smuzhiyun  *
24*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27*4882a593Smuzhiyun  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28*4882a593Smuzhiyun  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29*4882a593Smuzhiyun  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
30*4882a593Smuzhiyun  * IN THE SOFTWARE.
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #ifndef _XEN_ACPI_H
34*4882a593Smuzhiyun #define _XEN_ACPI_H
35*4882a593Smuzhiyun 
36*4882a593Smuzhiyun #include <linux/types.h>
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #ifdef CONFIG_XEN_DOM0
39*4882a593Smuzhiyun #include <asm/xen/hypervisor.h>
40*4882a593Smuzhiyun #include <xen/xen.h>
41*4882a593Smuzhiyun #include <linux/acpi.h>
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun #define ACPI_MEMORY_DEVICE_CLASS        "memory"
44*4882a593Smuzhiyun #define ACPI_MEMORY_DEVICE_HID          "PNP0C80"
45*4882a593Smuzhiyun #define ACPI_MEMORY_DEVICE_NAME         "Hotplug Mem Device"
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun int xen_stub_memory_device_init(void);
48*4882a593Smuzhiyun void xen_stub_memory_device_exit(void);
49*4882a593Smuzhiyun 
50*4882a593Smuzhiyun #define ACPI_PROCESSOR_CLASS            "processor"
51*4882a593Smuzhiyun #define ACPI_PROCESSOR_DEVICE_HID       "ACPI0007"
52*4882a593Smuzhiyun #define ACPI_PROCESSOR_DEVICE_NAME      "Processor"
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun int xen_stub_processor_init(void);
55*4882a593Smuzhiyun void xen_stub_processor_exit(void);
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun void xen_pcpu_hotplug_sync(void);
58*4882a593Smuzhiyun int xen_pcpu_id(uint32_t acpi_id);
59*4882a593Smuzhiyun 
xen_acpi_get_pxm(acpi_handle h)60*4882a593Smuzhiyun static inline int xen_acpi_get_pxm(acpi_handle h)
61*4882a593Smuzhiyun {
62*4882a593Smuzhiyun 	unsigned long long pxm;
63*4882a593Smuzhiyun 	acpi_status status;
64*4882a593Smuzhiyun 	acpi_handle handle;
65*4882a593Smuzhiyun 	acpi_handle phandle = h;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	do {
68*4882a593Smuzhiyun 		handle = phandle;
69*4882a593Smuzhiyun 		status = acpi_evaluate_integer(handle, "_PXM", NULL, &pxm);
70*4882a593Smuzhiyun 		if (ACPI_SUCCESS(status))
71*4882a593Smuzhiyun 			return pxm;
72*4882a593Smuzhiyun 		status = acpi_get_parent(handle, &phandle);
73*4882a593Smuzhiyun 	} while (ACPI_SUCCESS(status));
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun 	return -ENXIO;
76*4882a593Smuzhiyun }
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun int xen_acpi_notify_hypervisor_sleep(u8 sleep_state,
79*4882a593Smuzhiyun 				     u32 pm1a_cnt, u32 pm1b_cnd);
80*4882a593Smuzhiyun int xen_acpi_notify_hypervisor_extended_sleep(u8 sleep_state,
81*4882a593Smuzhiyun 				     u32 val_a, u32 val_b);
82*4882a593Smuzhiyun 
xen_acpi_suspend_lowlevel(void)83*4882a593Smuzhiyun static inline int xen_acpi_suspend_lowlevel(void)
84*4882a593Smuzhiyun {
85*4882a593Smuzhiyun 	/*
86*4882a593Smuzhiyun 	* Xen will save and restore CPU context, so
87*4882a593Smuzhiyun 	* we can skip that and just go straight to
88*4882a593Smuzhiyun 	* the suspend.
89*4882a593Smuzhiyun 	*/
90*4882a593Smuzhiyun 	acpi_enter_sleep_state(ACPI_STATE_S3);
91*4882a593Smuzhiyun 	return 0;
92*4882a593Smuzhiyun }
93*4882a593Smuzhiyun 
xen_acpi_sleep_register(void)94*4882a593Smuzhiyun static inline void xen_acpi_sleep_register(void)
95*4882a593Smuzhiyun {
96*4882a593Smuzhiyun 	if (xen_initial_domain()) {
97*4882a593Smuzhiyun 		acpi_os_set_prepare_sleep(
98*4882a593Smuzhiyun 			&xen_acpi_notify_hypervisor_sleep);
99*4882a593Smuzhiyun 		acpi_os_set_prepare_extended_sleep(
100*4882a593Smuzhiyun 			&xen_acpi_notify_hypervisor_extended_sleep);
101*4882a593Smuzhiyun 
102*4882a593Smuzhiyun 		acpi_suspend_lowlevel = xen_acpi_suspend_lowlevel;
103*4882a593Smuzhiyun 	}
104*4882a593Smuzhiyun }
105*4882a593Smuzhiyun #else
xen_acpi_sleep_register(void)106*4882a593Smuzhiyun static inline void xen_acpi_sleep_register(void)
107*4882a593Smuzhiyun {
108*4882a593Smuzhiyun }
109*4882a593Smuzhiyun #endif
110*4882a593Smuzhiyun 
111*4882a593Smuzhiyun #endif	/* _XEN_ACPI_H */
112