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