1 /*
2  * cpuidle.h - xen idle state module derived from Linux
3  *
4  * (C) 2007 Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
5  *          Shaohua Li <shaohua.li@intel.com>
6  *          Adam Belay <abelay@novell.com>
7  *  Copyright (C) 2008 Intel Corporation
8  *
9  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or (at
14  *  your option) any later version.
15  *
16  *  This program is distributed in the hope that it will be useful, but
17  *  WITHOUT ANY WARRANTY; without even the implied warranty of
18  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  *  General Public License for more details.
20  *
21  *  You should have received a copy of the GNU General Public License along
22  *  with this program; If not, see <http://www.gnu.org/licenses/>.
23  *
24  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
25  */
26 #ifndef _XEN_CPUIDLE_H
27 #define _XEN_CPUIDLE_H
28 
29 #include <xen/cpumask.h>
30 #include <xen/spinlock.h>
31 
32 #define ACPI_PROCESSOR_MAX_POWER        8
33 #define CPUIDLE_NAME_LEN                16
34 
35 #define ACPI_CSTATE_EM_NONE     0
36 #define ACPI_CSTATE_EM_SYSIO    1
37 #define ACPI_CSTATE_EM_FFH      2
38 #define ACPI_CSTATE_EM_HALT     3
39 
40 struct acpi_processor_cx
41 {
42     u8 idx;
43     u8 type;         /* ACPI_STATE_Cn */
44     u8 entry_method; /* ACPI_CSTATE_EM_xxx */
45     u32 address;
46     u32 latency;
47     u32 target_residency;
48     u32 usage;
49     u64 time;
50 };
51 
52 struct acpi_processor_flags
53 {
54     u8 bm_control:1;
55     u8 bm_check:1;
56     u8 has_cst:1;
57     u8 power_setup_done:1;
58     u8 bm_rld_set:1;
59 };
60 
61 struct acpi_processor_power
62 {
63     unsigned int cpu;
64     struct acpi_processor_flags flags;
65     struct acpi_processor_cx *last_state;
66     struct acpi_processor_cx *safe_state;
67     void *gdata; /* governor specific data */
68     u64 last_state_update_tick;
69     u32 last_residency;
70     u32 count;
71     spinlock_t stat_lock;
72     struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
73 };
74 
75 struct cpuidle_governor
76 {
77     char                    name[CPUIDLE_NAME_LEN];
78     unsigned int            rating;
79 
80     int  (*enable)          (struct acpi_processor_power *dev);
81     void (*disable)         (struct acpi_processor_power *dev);
82 
83     int  (*select)          (struct acpi_processor_power *dev);
84     void (*reflect)         (struct acpi_processor_power *dev);
85 };
86 
87 extern s8 xen_cpuidle;
88 extern struct cpuidle_governor *cpuidle_current_governor;
89 
90 bool cpuidle_using_deep_cstate(void);
91 void cpuidle_disable_deep_cstate(void);
92 
93 extern void cpuidle_wakeup_mwait(cpumask_t *mask);
94 
95 #define CPUIDLE_DRIVER_STATE_START  1
96 
97 extern void menu_get_trace_data(u32 *expected, u32 *pred);
98 
99 #endif /* _XEN_CPUIDLE_H */
100