ACPI: idle: Fix acpi_safe_halt usages and interrupt enabling/disabling
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / include / acpi / processor.h
CommitLineData
1da177e4
LT
1#ifndef __ACPI_PROCESSOR_H
2#define __ACPI_PROCESSOR_H
3
4#include <linux/kernel.h>
3b2d9942 5#include <linux/cpu.h>
4f86d3a8 6#include <linux/cpuidle.h>
1da177e4 7
02df8b93
VP
8#include <asm/acpi.h>
9
1da177e4
LT
10#define ACPI_PROCESSOR_BUSY_METRIC 10
11
12#define ACPI_PROCESSOR_MAX_POWER 8
13#define ACPI_PROCESSOR_MAX_C2_LATENCY 100
14#define ACPI_PROCESSOR_MAX_C3_LATENCY 1000
15
16#define ACPI_PROCESSOR_MAX_THROTTLING 16
17#define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */
18#define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4
19
02df8b93
VP
20#define ACPI_PDC_REVISION_ID 0x1
21
fd350943 22#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
3b2d9942
VP
23#define ACPI_PSD_REV0_ENTRIES 5
24
01854e69
LY
25#define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
26#define ACPI_TSD_REV0_ENTRIES 5
3b2d9942
VP
27/*
28 * Types of coordination defined in ACPI 3.0. Same macros can be used across
29 * P, C and T states
30 */
31#define DOMAIN_COORD_TYPE_SW_ALL 0xfc
32#define DOMAIN_COORD_TYPE_SW_ANY 0xfd
33#define DOMAIN_COORD_TYPE_HW_ALL 0xfe
34
991528d7
VP
35#define ACPI_CSTATE_SYSTEMIO (0)
36#define ACPI_CSTATE_FFH (1)
37
1da177e4
LT
38/* Power Management */
39
40struct acpi_processor_cx;
41
42struct acpi_power_register {
4be44fcd
LB
43 u8 descriptor;
44 u16 length;
45 u8 space_id;
46 u8 bit_width;
47 u8 bit_offset;
48 u8 reserved;
49 u64 address;
1da177e4
LT
50} __attribute__ ((packed));
51
1da177e4 52struct acpi_processor_cx_policy {
4be44fcd 53 u32 count;
1da177e4
LT
54 struct acpi_processor_cx *state;
55 struct {
4be44fcd
LB
56 u32 time;
57 u32 ticks;
58 u32 count;
59 u32 bm;
60 } threshold;
1da177e4
LT
61};
62
63struct acpi_processor_cx {
4be44fcd
LB
64 u8 valid;
65 u8 type;
66 u32 address;
991528d7
VP
67 u8 space_id;
68 u8 index;
4be44fcd
LB
69 u32 latency;
70 u32 latency_ticks;
71 u32 power;
72 u32 usage;
a3c6598f 73 u64 time;
1da177e4
LT
74 struct acpi_processor_cx_policy promotion;
75 struct acpi_processor_cx_policy demotion;
76};
77
78struct acpi_processor_power {
4f86d3a8 79 struct cpuidle_device dev;
1da177e4 80 struct acpi_processor_cx *state;
4be44fcd
LB
81 unsigned long bm_check_timestamp;
82 u32 default_state;
83 u32 bm_activity;
84 int count;
1da177e4 85 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
169a0abb 86 int timer_broadcast_on_state;
1da177e4
LT
87};
88
89/* Performance Management */
90
3b2d9942
VP
91struct acpi_psd_package {
92 acpi_integer num_entries;
93 acpi_integer revision;
94 acpi_integer domain;
95 acpi_integer coord_type;
96 acpi_integer num_processors;
97} __attribute__ ((packed));
98
1da177e4 99struct acpi_pct_register {
4be44fcd
LB
100 u8 descriptor;
101 u16 length;
102 u8 space_id;
103 u8 bit_width;
104 u8 bit_offset;
105 u8 reserved;
106 u64 address;
1da177e4
LT
107} __attribute__ ((packed));
108
109struct acpi_processor_px {
4be44fcd
LB
110 acpi_integer core_frequency; /* megahertz */
111 acpi_integer power; /* milliWatts */
112 acpi_integer transition_latency; /* microseconds */
113 acpi_integer bus_master_latency; /* microseconds */
114 acpi_integer control; /* control value */
115 acpi_integer status; /* success indicator */
1da177e4
LT
116};
117
1da177e4 118struct acpi_processor_performance {
4be44fcd
LB
119 unsigned int state;
120 unsigned int platform_limit;
1da177e4
LT
121 struct acpi_pct_register control_register;
122 struct acpi_pct_register status_register;
4be44fcd 123 unsigned int state_count;
1da177e4 124 struct acpi_processor_px *states;
3b2d9942
VP
125 struct acpi_psd_package domain_info;
126 cpumask_t shared_cpu_map;
127 unsigned int shared_type;
1da177e4
LT
128};
129
1da177e4
LT
130/* Throttling Control */
131
01854e69
LY
132struct acpi_tsd_package {
133 acpi_integer num_entries;
134 acpi_integer revision;
135 acpi_integer domain;
136 acpi_integer coord_type;
137 acpi_integer num_processors;
138} __attribute__ ((packed));
139
140struct acpi_ptc_register {
141 u8 descriptor;
142 u16 length;
143 u8 space_id;
144 u8 bit_width;
145 u8 bit_offset;
146 u8 reserved;
147 u64 address;
148} __attribute__ ((packed));
149
150struct acpi_processor_tx_tss {
151 acpi_integer freqpercentage; /* */
152 acpi_integer power; /* milliWatts */
153 acpi_integer transition_latency; /* microseconds */
154 acpi_integer control; /* control value */
155 acpi_integer status; /* success indicator */
156};
1da177e4 157struct acpi_processor_tx {
4be44fcd
LB
158 u16 power;
159 u16 performance;
1da177e4
LT
160};
161
01854e69 162struct acpi_processor;
1da177e4 163struct acpi_processor_throttling {
01854e69
LY
164 unsigned int state;
165 unsigned int platform_limit;
166 struct acpi_pct_register control_register;
167 struct acpi_pct_register status_register;
168 unsigned int state_count;
169 struct acpi_processor_tx_tss *states_tss;
170 struct acpi_tsd_package domain_info;
171 cpumask_t shared_cpu_map;
ff55a9ce
LB
172 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
173 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
174 int state);
01854e69 175
4be44fcd
LB
176 u32 address;
177 u8 duty_offset;
178 u8 duty_width;
1da177e4
LT
179 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
180};
181
182/* Limit Interface */
183
184struct acpi_processor_lx {
aee07ba6 185 int px; /* performance state */
4be44fcd 186 int tx; /* throttle level */
1da177e4
LT
187};
188
189struct acpi_processor_limit {
4be44fcd 190 struct acpi_processor_lx state; /* current limit */
1da177e4 191 struct acpi_processor_lx thermal; /* thermal limit */
4be44fcd 192 struct acpi_processor_lx user; /* user limit */
1da177e4
LT
193};
194
1da177e4 195struct acpi_processor_flags {
4be44fcd
LB
196 u8 power:1;
197 u8 performance:1;
198 u8 throttling:1;
199 u8 limit:1;
200 u8 bm_control:1;
201 u8 bm_check:1;
202 u8 has_cst:1;
203 u8 power_setup_done:1;
4f86d3a8 204 u8 bm_rld_set:1;
1da177e4
LT
205};
206
207struct acpi_processor {
4be44fcd
LB
208 acpi_handle handle;
209 u32 acpi_id;
210 u32 id;
211 u32 pblk;
212 int performance_platform_limit;
01854e69 213 int throttling_platform_limit;
ff55a9ce 214 /* 0 - states 0..n-th state available */
01854e69 215
1da177e4
LT
216 struct acpi_processor_flags flags;
217 struct acpi_processor_power power;
218 struct acpi_processor_performance *performance;
219 struct acpi_processor_throttling throttling;
220 struct acpi_processor_limit limit;
05131ecc
VP
221
222 /* the _PDC objects for this processor, if any */
223 struct acpi_object_list *pdc;
1da177e4
LT
224};
225
226struct acpi_processor_errata {
4be44fcd 227 u8 smp;
1da177e4 228 struct {
4be44fcd
LB
229 u8 throttle:1;
230 u8 fdma:1;
231 u8 reserved:6;
232 u32 bmisx;
233 } piix4;
1da177e4
LT
234};
235
fd350943
LB
236extern int acpi_processor_preregister_performance(struct
237 acpi_processor_performance
50109292 238 *performance);
3b2d9942 239
4be44fcd
LB
240extern int acpi_processor_register_performance(struct acpi_processor_performance
241 *performance, unsigned int cpu);
242extern void acpi_processor_unregister_performance(struct
243 acpi_processor_performance
244 *performance,
245 unsigned int cpu);
1da177e4
LT
246
247/* note: this locks both the calling module and the processor module
248 if a _PPC object exists, rmmod is disallowed then */
249int acpi_processor_notify_smm(struct module *calling_module);
250
1da177e4 251/* for communication between multiple parts of the processor kernel module */
4be44fcd 252extern struct acpi_processor *processors[NR_CPUS];
1da177e4
LT
253extern struct acpi_processor_errata errata;
254
05131ecc 255void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
02df8b93 256
05131ecc 257#ifdef ARCH_HAS_POWER_INIT
02df8b93 258void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
4be44fcd 259 unsigned int cpu);
991528d7 260int acpi_processor_ffh_cstate_probe(unsigned int cpu,
fd350943
LB
261 struct acpi_processor_cx *cx,
262 struct acpi_power_register *reg);
991528d7 263void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
02df8b93 264#else
4be44fcd
LB
265static inline void acpi_processor_power_init_bm_check(struct
266 acpi_processor_flags
267 *flags, unsigned int cpu)
02df8b93
VP
268{
269 flags->bm_check = 1;
270 return;
271}
991528d7 272static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
fd350943
LB
273 struct acpi_processor_cx *cx,
274 struct acpi_power_register
275 *reg)
991528d7
VP
276{
277 return -1;
278}
fd350943
LB
279static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
280 *cstate)
991528d7
VP
281{
282 return;
283}
02df8b93
VP
284#endif
285
1da177e4 286/* in processor_perflib.c */
02df8b93 287
1da177e4
LT
288#ifdef CONFIG_CPU_FREQ
289void acpi_processor_ppc_init(void);
290void acpi_processor_ppc_exit(void);
291int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
292#else
4be44fcd
LB
293static inline void acpi_processor_ppc_init(void)
294{
295 return;
296}
297static inline void acpi_processor_ppc_exit(void)
298{
299 return;
300}
301static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
302{
1da177e4
LT
303 static unsigned int printout = 1;
304 if (printout) {
4be44fcd
LB
305 printk(KERN_WARNING
306 "Warning: Processor Platform Limit event detected, but not handled.\n");
307 printk(KERN_WARNING
308 "Consider compiling CPUfreq support into your kernel.\n");
1da177e4
LT
309 printout = 0;
310 }
311 return 0;
312}
4be44fcd 313#endif /* CONFIG_CPU_FREQ */
1da177e4
LT
314
315/* in processor_throttling.c */
4be44fcd 316int acpi_processor_get_throttling_info(struct acpi_processor *pr);
01854e69 317extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
1da177e4
LT
318extern struct file_operations acpi_processor_throttling_fops;
319
320/* in processor_idle.c */
4be44fcd
LB
321int acpi_processor_power_init(struct acpi_processor *pr,
322 struct acpi_device *device);
323int acpi_processor_cst_has_changed(struct acpi_processor *pr);
324int acpi_processor_power_exit(struct acpi_processor *pr,
325 struct acpi_device *device);
b04e7bdb
TG
326int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
327int acpi_processor_resume(struct acpi_device * device);
4f86d3a8 328extern struct cpuidle_driver acpi_idle_driver;
1da177e4
LT
329
330/* in processor_thermal.c */
4be44fcd 331int acpi_processor_get_limit_info(struct acpi_processor *pr);
1da177e4
LT
332extern struct file_operations acpi_processor_limit_fops;
333
334#ifdef CONFIG_CPU_FREQ
335void acpi_thermal_cpufreq_init(void);
336void acpi_thermal_cpufreq_exit(void);
337#else
4be44fcd
LB
338static inline void acpi_thermal_cpufreq_init(void)
339{
340 return;
341}
342static inline void acpi_thermal_cpufreq_exit(void)
343{
344 return;
345}
1da177e4
LT
346#endif
347
1da177e4 348#endif