cpuidle / ACPI : remove power from acpi_processor_cx structure
[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>
d9460fd2 7#include <linux/thermal.h>
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
4fcb2fcd
VP
35#define ACPI_CSTATE_SYSTEMIO 0
36#define ACPI_CSTATE_FFH 1
37#define ACPI_CSTATE_HALT 2
38
39#define ACPI_CX_DESC_LEN 32
991528d7 40
1da177e4
LT
41/* Power Management */
42
43struct acpi_processor_cx;
44
45struct acpi_power_register {
4be44fcd
LB
46 u8 descriptor;
47 u16 length;
48 u8 space_id;
49 u8 bit_width;
50 u8 bit_offset;
718be4aa 51 u8 access_size;
4be44fcd 52 u64 address;
1da177e4
LT
53} __attribute__ ((packed));
54
1da177e4 55struct acpi_processor_cx {
4be44fcd
LB
56 u8 valid;
57 u8 type;
58 u32 address;
bc71bec9 59 u8 entry_method;
991528d7 60 u8 index;
4be44fcd 61 u32 latency;
718be4aa 62 u8 bm_sts_skip;
4fcb2fcd 63 char desc[ACPI_CX_DESC_LEN];
1da177e4
LT
64};
65
66struct acpi_processor_power {
4f86d3a8 67 struct cpuidle_device dev;
1da177e4 68 struct acpi_processor_cx *state;
4be44fcd
LB
69 unsigned long bm_check_timestamp;
70 u32 default_state;
4be44fcd 71 int count;
1da177e4 72 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
169a0abb 73 int timer_broadcast_on_state;
1da177e4
LT
74};
75
76/* Performance Management */
77
3b2d9942 78struct acpi_psd_package {
439913ff
LM
79 u64 num_entries;
80 u64 revision;
81 u64 domain;
82 u64 coord_type;
83 u64 num_processors;
3b2d9942
VP
84} __attribute__ ((packed));
85
1da177e4 86struct acpi_pct_register {
4be44fcd
LB
87 u8 descriptor;
88 u16 length;
89 u8 space_id;
90 u8 bit_width;
91 u8 bit_offset;
92 u8 reserved;
93 u64 address;
1da177e4
LT
94} __attribute__ ((packed));
95
96struct acpi_processor_px {
439913ff
LM
97 u64 core_frequency; /* megahertz */
98 u64 power; /* milliWatts */
99 u64 transition_latency; /* microseconds */
100 u64 bus_master_latency; /* microseconds */
101 u64 control; /* control value */
102 u64 status; /* success indicator */
1da177e4
LT
103};
104
1da177e4 105struct acpi_processor_performance {
4be44fcd
LB
106 unsigned int state;
107 unsigned int platform_limit;
1da177e4
LT
108 struct acpi_pct_register control_register;
109 struct acpi_pct_register status_register;
4be44fcd 110 unsigned int state_count;
1da177e4 111 struct acpi_processor_px *states;
3b2d9942 112 struct acpi_psd_package domain_info;
2fdf66b4 113 cpumask_var_t shared_cpu_map;
3b2d9942 114 unsigned int shared_type;
1da177e4
LT
115};
116
1da177e4
LT
117/* Throttling Control */
118
01854e69 119struct acpi_tsd_package {
439913ff
LM
120 u64 num_entries;
121 u64 revision;
122 u64 domain;
123 u64 coord_type;
124 u64 num_processors;
01854e69
LY
125} __attribute__ ((packed));
126
127struct acpi_ptc_register {
128 u8 descriptor;
129 u16 length;
130 u8 space_id;
131 u8 bit_width;
132 u8 bit_offset;
133 u8 reserved;
134 u64 address;
135} __attribute__ ((packed));
136
137struct acpi_processor_tx_tss {
439913ff
LM
138 u64 freqpercentage; /* */
139 u64 power; /* milliWatts */
140 u64 transition_latency; /* microseconds */
141 u64 control; /* control value */
142 u64 status; /* success indicator */
01854e69 143};
1da177e4 144struct acpi_processor_tx {
4be44fcd
LB
145 u16 power;
146 u16 performance;
1da177e4
LT
147};
148
01854e69 149struct acpi_processor;
1da177e4 150struct acpi_processor_throttling {
01854e69
LY
151 unsigned int state;
152 unsigned int platform_limit;
153 struct acpi_pct_register control_register;
154 struct acpi_pct_register status_register;
155 unsigned int state_count;
156 struct acpi_processor_tx_tss *states_tss;
157 struct acpi_tsd_package domain_info;
2fdf66b4 158 cpumask_var_t shared_cpu_map;
ff55a9ce
LB
159 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
160 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
2a908002 161 int state, bool force);
01854e69 162
4be44fcd
LB
163 u32 address;
164 u8 duty_offset;
165 u8 duty_width;
1180509f
ZY
166 u8 tsd_valid_flag;
167 unsigned int shared_type;
1da177e4
LT
168 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
169};
170
171/* Limit Interface */
172
173struct acpi_processor_lx {
aee07ba6 174 int px; /* performance state */
4be44fcd 175 int tx; /* throttle level */
1da177e4
LT
176};
177
178struct acpi_processor_limit {
4be44fcd 179 struct acpi_processor_lx state; /* current limit */
1da177e4 180 struct acpi_processor_lx thermal; /* thermal limit */
4be44fcd 181 struct acpi_processor_lx user; /* user limit */
1da177e4
LT
182};
183
1da177e4 184struct acpi_processor_flags {
4be44fcd
LB
185 u8 power:1;
186 u8 performance:1;
187 u8 throttling:1;
188 u8 limit:1;
189 u8 bm_control:1;
190 u8 bm_check:1;
191 u8 has_cst:1;
192 u8 power_setup_done:1;
4f86d3a8 193 u8 bm_rld_set:1;
99b72508 194 u8 need_hotplug_init:1;
1da177e4
LT
195};
196
197struct acpi_processor {
4be44fcd
LB
198 acpi_handle handle;
199 u32 acpi_id;
200 u32 id;
201 u32 pblk;
202 int performance_platform_limit;
01854e69 203 int throttling_platform_limit;
ff55a9ce 204 /* 0 - states 0..n-th state available */
01854e69 205
1da177e4
LT
206 struct acpi_processor_flags flags;
207 struct acpi_processor_power power;
208 struct acpi_processor_performance *performance;
209 struct acpi_processor_throttling throttling;
210 struct acpi_processor_limit limit;
d9460fd2 211 struct thermal_cooling_device *cdev;
1da177e4
LT
212};
213
214struct acpi_processor_errata {
4be44fcd 215 u8 smp;
1da177e4 216 struct {
4be44fcd
LB
217 u8 throttle:1;
218 u8 fdma:1;
219 u8 reserved:6;
220 u32 bmisx;
221 } piix4;
1da177e4
LT
222};
223
9061e0e1 224extern void acpi_processor_load_module(struct acpi_processor *pr);
fd350943
LB
225extern int acpi_processor_preregister_performance(struct
226 acpi_processor_performance
a29d8b8e 227 __percpu *performance);
3b2d9942 228
4be44fcd
LB
229extern int acpi_processor_register_performance(struct acpi_processor_performance
230 *performance, unsigned int cpu);
231extern void acpi_processor_unregister_performance(struct
232 acpi_processor_performance
233 *performance,
234 unsigned int cpu);
1da177e4
LT
235
236/* note: this locks both the calling module and the processor module
237 if a _PPC object exists, rmmod is disallowed then */
238int acpi_processor_notify_smm(struct module *calling_module);
239
1da177e4 240/* for communication between multiple parts of the processor kernel module */
706546d0 241DECLARE_PER_CPU(struct acpi_processor *, processors);
1da177e4
LT
242extern struct acpi_processor_errata errata;
243
05131ecc 244#ifdef ARCH_HAS_POWER_INIT
02df8b93 245void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
4be44fcd 246 unsigned int cpu);
991528d7 247int acpi_processor_ffh_cstate_probe(unsigned int cpu,
fd350943
LB
248 struct acpi_processor_cx *cx,
249 struct acpi_power_register *reg);
991528d7 250void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
02df8b93 251#else
4be44fcd
LB
252static inline void acpi_processor_power_init_bm_check(struct
253 acpi_processor_flags
254 *flags, unsigned int cpu)
02df8b93
VP
255{
256 flags->bm_check = 1;
257 return;
258}
991528d7 259static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
fd350943
LB
260 struct acpi_processor_cx *cx,
261 struct acpi_power_register
262 *reg)
991528d7
VP
263{
264 return -1;
265}
fd350943
LB
266static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
267 *cstate)
991528d7
VP
268{
269 return;
270}
02df8b93
VP
271#endif
272
1da177e4 273/* in processor_perflib.c */
02df8b93 274
1da177e4
LT
275#ifdef CONFIG_CPU_FREQ
276void acpi_processor_ppc_init(void);
277void acpi_processor_ppc_exit(void);
d81c45e1 278int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag);
e2f74f35 279extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit);
1da177e4 280#else
4be44fcd
LB
281static inline void acpi_processor_ppc_init(void)
282{
283 return;
284}
285static inline void acpi_processor_ppc_exit(void)
286{
287 return;
288}
d81c45e1
ZY
289static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
290 int event_flag)
4be44fcd 291{
1da177e4
LT
292 static unsigned int printout = 1;
293 if (printout) {
4be44fcd
LB
294 printk(KERN_WARNING
295 "Warning: Processor Platform Limit event detected, but not handled.\n");
296 printk(KERN_WARNING
297 "Consider compiling CPUfreq support into your kernel.\n");
1da177e4
LT
298 printout = 0;
299 }
300 return 0;
301}
e2f74f35
TR
302static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
303{
304 return -ENODEV;
305}
306
4be44fcd 307#endif /* CONFIG_CPU_FREQ */
1da177e4 308
4d5d4cd8 309/* in processor_core.c */
43bab25c 310void acpi_processor_set_pdc(acpi_handle handle);
2e9d5e4e 311int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
78f16996 312
1da177e4 313/* in processor_throttling.c */
a66b34b2 314int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
4be44fcd 315int acpi_processor_get_throttling_info(struct acpi_processor *pr);
2a908002
FP
316extern int acpi_processor_set_throttling(struct acpi_processor *pr,
317 int state, bool force);
5a344a50
ZY
318/*
319 * Reevaluate whether the T-state is invalid after one cpu is
320 * onlined/offlined. In such case the flags.throttling will be updated.
321 */
322extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
323 unsigned long action);
070d8eb1 324extern const struct file_operations acpi_processor_throttling_fops;
1180509f 325extern void acpi_processor_throttling_init(void);
1da177e4 326/* in processor_idle.c */
4be44fcd
LB
327int acpi_processor_power_init(struct acpi_processor *pr,
328 struct acpi_device *device);
329int acpi_processor_cst_has_changed(struct acpi_processor *pr);
46bcfad7 330int acpi_processor_hotplug(struct acpi_processor *pr);
4be44fcd
LB
331int acpi_processor_power_exit(struct acpi_processor *pr,
332 struct acpi_device *device);
e8110b64
RW
333int acpi_processor_suspend(struct device *dev);
334int acpi_processor_resume(struct device *dev);
4f86d3a8 335extern struct cpuidle_driver acpi_idle_driver;
1da177e4
LT
336
337/* in processor_thermal.c */
4be44fcd 338int acpi_processor_get_limit_info(struct acpi_processor *pr);
9c8b04be 339extern const struct thermal_cooling_device_ops processor_cooling_ops;
1da177e4
LT
340#ifdef CONFIG_CPU_FREQ
341void acpi_thermal_cpufreq_init(void);
342void acpi_thermal_cpufreq_exit(void);
343#else
4be44fcd
LB
344static inline void acpi_thermal_cpufreq_init(void)
345{
346 return;
347}
348static inline void acpi_thermal_cpufreq_exit(void)
349{
350 return;
351}
1da177e4
LT
352#endif
353
1da177e4 354#endif