Blame view
include/acpi/processor.h
11 KB
b24413180
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c
|
2 3 4 5 |
#ifndef __ACPI_PROCESSOR_H #define __ACPI_PROCESSOR_H #include <linux/kernel.h> |
3b2d99429
|
6 |
#include <linux/cpu.h> |
d9460fd22
|
7 |
#include <linux/thermal.h> |
02df8b938
|
8 |
#include <asm/acpi.h> |
ac212b698
|
9 10 11 |
#define ACPI_PROCESSOR_CLASS "processor" #define ACPI_PROCESSOR_DEVICE_NAME "Processor" #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" |
db62fda31
|
12 |
#define ACPI_PROCESSOR_CONTAINER_HID "ACPI0010" |
ac212b698
|
13 |
|
1da177e4c
|
14 15 16 17 18 19 20 21 22 |
#define ACPI_PROCESSOR_BUSY_METRIC 10 #define ACPI_PROCESSOR_MAX_POWER 8 #define ACPI_PROCESSOR_MAX_C2_LATENCY 100 #define ACPI_PROCESSOR_MAX_C3_LATENCY 1000 #define ACPI_PROCESSOR_MAX_THROTTLING 16 #define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */ #define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4 |
02df8b938
|
23 |
#define ACPI_PDC_REVISION_ID 0x1 |
fd3509436
|
24 |
#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ |
3b2d99429
|
25 |
#define ACPI_PSD_REV0_ENTRIES 5 |
01854e697
|
26 27 |
#define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ #define ACPI_TSD_REV0_ENTRIES 5 |
3b2d99429
|
28 29 30 31 32 33 34 |
/* * Types of coordination defined in ACPI 3.0. Same macros can be used across * P, C and T states */ #define DOMAIN_COORD_TYPE_SW_ALL 0xfc #define DOMAIN_COORD_TYPE_SW_ANY 0xfd #define DOMAIN_COORD_TYPE_HW_ALL 0xfe |
4fcb2fcd4
|
35 36 37 |
#define ACPI_CSTATE_SYSTEMIO 0 #define ACPI_CSTATE_FFH 1 #define ACPI_CSTATE_HALT 2 |
a36a7fecf
|
38 |
#define ACPI_CSTATE_INTEGER 3 |
4fcb2fcd4
|
39 40 |
#define ACPI_CX_DESC_LEN 32 |
991528d73
|
41 |
|
1da177e4c
|
42 43 44 45 46 |
/* Power Management */ struct acpi_processor_cx; struct acpi_power_register { |
4be44fcd3
|
47 48 49 50 51 |
u8 descriptor; u16 length; u8 space_id; u8 bit_width; u8 bit_offset; |
718be4aaf
|
52 |
u8 access_size; |
4be44fcd3
|
53 |
u64 address; |
92c4d2ad3
|
54 |
} __packed; |
1da177e4c
|
55 |
|
1da177e4c
|
56 |
struct acpi_processor_cx { |
4be44fcd3
|
57 58 59 |
u8 valid; u8 type; u32 address; |
bc71bec91
|
60 |
u8 entry_method; |
991528d73
|
61 |
u8 index; |
4be44fcd3
|
62 |
u32 latency; |
718be4aaf
|
63 |
u8 bm_sts_skip; |
4fcb2fcd4
|
64 |
char desc[ACPI_CX_DESC_LEN]; |
1da177e4c
|
65 |
}; |
a36a7fecf
|
66 67 68 69 70 71 72 73 74 75 76 77 |
struct acpi_lpi_state { u32 min_residency; u32 wake_latency; /* worst case */ u32 flags; u32 arch_flags; u32 res_cnt_freq; u32 enable_parent_state; u64 address; u8 index; u8 entry_method; char desc[ACPI_CX_DESC_LEN]; }; |
1da177e4c
|
78 |
struct acpi_processor_power { |
4be44fcd3
|
79 |
int count; |
a36a7fecf
|
80 81 82 83 |
union { struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; struct acpi_lpi_state lpi_states[ACPI_PROCESSOR_MAX_POWER]; }; |
169a0abbe
|
84 |
int timer_broadcast_on_state; |
1da177e4c
|
85 86 87 |
}; /* Performance Management */ |
3b2d99429
|
88 |
struct acpi_psd_package { |
439913fff
|
89 90 91 92 93 |
u64 num_entries; u64 revision; u64 domain; u64 coord_type; u64 num_processors; |
92c4d2ad3
|
94 |
} __packed; |
3b2d99429
|
95 |
|
1da177e4c
|
96 |
struct acpi_pct_register { |
4be44fcd3
|
97 98 99 100 101 102 103 |
u8 descriptor; u16 length; u8 space_id; u8 bit_width; u8 bit_offset; u8 reserved; u64 address; |
92c4d2ad3
|
104 |
} __packed; |
1da177e4c
|
105 106 |
struct acpi_processor_px { |
439913fff
|
107 108 109 110 111 112 |
u64 core_frequency; /* megahertz */ u64 power; /* milliWatts */ u64 transition_latency; /* microseconds */ u64 bus_master_latency; /* microseconds */ u64 control; /* control value */ u64 status; /* success indicator */ |
1da177e4c
|
113 |
}; |
1da177e4c
|
114 |
struct acpi_processor_performance { |
4be44fcd3
|
115 116 |
unsigned int state; unsigned int platform_limit; |
1da177e4c
|
117 118 |
struct acpi_pct_register control_register; struct acpi_pct_register status_register; |
4be44fcd3
|
119 |
unsigned int state_count; |
1da177e4c
|
120 |
struct acpi_processor_px *states; |
3b2d99429
|
121 |
struct acpi_psd_package domain_info; |
2fdf66b49
|
122 |
cpumask_var_t shared_cpu_map; |
3b2d99429
|
123 |
unsigned int shared_type; |
1da177e4c
|
124 |
}; |
1da177e4c
|
125 |
/* Throttling Control */ |
01854e697
|
126 |
struct acpi_tsd_package { |
439913fff
|
127 128 129 130 131 |
u64 num_entries; u64 revision; u64 domain; u64 coord_type; u64 num_processors; |
92c4d2ad3
|
132 |
} __packed; |
01854e697
|
133 134 135 136 137 138 139 140 141 |
struct acpi_ptc_register { u8 descriptor; u16 length; u8 space_id; u8 bit_width; u8 bit_offset; u8 reserved; u64 address; |
92c4d2ad3
|
142 |
} __packed; |
01854e697
|
143 144 |
struct acpi_processor_tx_tss { |
439913fff
|
145 146 147 148 149 |
u64 freqpercentage; /* */ u64 power; /* milliWatts */ u64 transition_latency; /* microseconds */ u64 control; /* control value */ u64 status; /* success indicator */ |
01854e697
|
150 |
}; |
1da177e4c
|
151 |
struct acpi_processor_tx { |
4be44fcd3
|
152 153 |
u16 power; u16 performance; |
1da177e4c
|
154 |
}; |
01854e697
|
155 |
struct acpi_processor; |
1da177e4c
|
156 |
struct acpi_processor_throttling { |
01854e697
|
157 158 159 160 161 162 163 |
unsigned int state; unsigned int platform_limit; struct acpi_pct_register control_register; struct acpi_pct_register status_register; unsigned int state_count; struct acpi_processor_tx_tss *states_tss; struct acpi_tsd_package domain_info; |
2fdf66b49
|
164 |
cpumask_var_t shared_cpu_map; |
ff55a9ceb
|
165 166 |
int (*acpi_processor_get_throttling) (struct acpi_processor * pr); int (*acpi_processor_set_throttling) (struct acpi_processor * pr, |
2a908002c
|
167 |
int state, bool force); |
01854e697
|
168 |
|
4be44fcd3
|
169 170 171 |
u32 address; u8 duty_offset; u8 duty_width; |
1180509f6
|
172 173 |
u8 tsd_valid_flag; unsigned int shared_type; |
1da177e4c
|
174 175 176 177 178 179 |
struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; }; /* Limit Interface */ struct acpi_processor_lx { |
aee07ba68
|
180 |
int px; /* performance state */ |
4be44fcd3
|
181 |
int tx; /* throttle level */ |
1da177e4c
|
182 183 184 |
}; struct acpi_processor_limit { |
4be44fcd3
|
185 |
struct acpi_processor_lx state; /* current limit */ |
1da177e4c
|
186 |
struct acpi_processor_lx thermal; /* thermal limit */ |
4be44fcd3
|
187 |
struct acpi_processor_lx user; /* user limit */ |
1da177e4c
|
188 |
}; |
1da177e4c
|
189 |
struct acpi_processor_flags { |
4be44fcd3
|
190 191 192 193 194 195 196 |
u8 power:1; u8 performance:1; u8 throttling:1; u8 limit:1; u8 bm_control:1; u8 bm_check:1; u8 has_cst:1; |
a36a7fecf
|
197 |
u8 has_lpi:1; |
4be44fcd3
|
198 |
u8 power_setup_done:1; |
4f86d3a8e
|
199 |
u8 bm_rld_set:1; |
99b725084
|
200 |
u8 need_hotplug_init:1; |
1da177e4c
|
201 202 203 |
}; struct acpi_processor { |
4be44fcd3
|
204 205 |
acpi_handle handle; u32 acpi_id; |
828aef376
|
206 |
phys_cpuid_t phys_id; /* CPU hardware ID such as APIC ID for x86 */ |
af8f3f514
|
207 |
u32 id; /* CPU logical ID allocated by OS */ |
4be44fcd3
|
208 209 |
u32 pblk; int performance_platform_limit; |
01854e697
|
210 |
int throttling_platform_limit; |
ff55a9ceb
|
211 |
/* 0 - states 0..n-th state available */ |
01854e697
|
212 |
|
1da177e4c
|
213 214 215 216 217 |
struct acpi_processor_flags flags; struct acpi_processor_power power; struct acpi_processor_performance *performance; struct acpi_processor_throttling throttling; struct acpi_processor_limit limit; |
d9460fd22
|
218 |
struct thermal_cooling_device *cdev; |
ac212b698
|
219 |
struct device *dev; /* Processor device. */ |
1da177e4c
|
220 221 222 |
}; struct acpi_processor_errata { |
4be44fcd3
|
223 |
u8 smp; |
1da177e4c
|
224 |
struct { |
4be44fcd3
|
225 226 227 228 229 |
u8 throttle:1; u8 fdma:1; u8 reserved:6; u32 bmisx; } piix4; |
1da177e4c
|
230 |
}; |
fd3509436
|
231 232 |
extern int acpi_processor_preregister_performance(struct acpi_processor_performance |
a29d8b8e2
|
233 |
__percpu *performance); |
3b2d99429
|
234 |
|
4be44fcd3
|
235 236 |
extern int acpi_processor_register_performance(struct acpi_processor_performance *performance, unsigned int cpu); |
b2f8dc4ce
|
237 |
extern void acpi_processor_unregister_performance(unsigned int cpu); |
1da177e4c
|
238 |
|
d0ea59e18
|
239 |
int acpi_processor_pstate_control(void); |
1da177e4c
|
240 241 242 |
/* note: this locks both the calling module and the processor module if a _PPC object exists, rmmod is disallowed then */ int acpi_processor_notify_smm(struct module *calling_module); |
4d0f1ce69
|
243 244 |
int acpi_processor_get_psd(acpi_handle handle, struct acpi_psd_package *pdomain); |
1da177e4c
|
245 |
|
c705c78c0
|
246 247 |
/* parsing the _P* objects. */ extern int acpi_processor_get_performance_info(struct acpi_processor *pr); |
1da177e4c
|
248 |
/* for communication between multiple parts of the processor kernel module */ |
706546d02
|
249 |
DECLARE_PER_CPU(struct acpi_processor *, processors); |
1da177e4c
|
250 |
extern struct acpi_processor_errata errata; |
35ae71335
|
251 |
#if defined(ARCH_HAS_POWER_INIT) && defined(CONFIG_ACPI_PROCESSOR_CSTATE) |
02df8b938
|
252 |
void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, |
4be44fcd3
|
253 |
unsigned int cpu); |
991528d73
|
254 |
int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
fd3509436
|
255 256 |
struct acpi_processor_cx *cx, struct acpi_power_register *reg); |
991528d73
|
257 |
void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate); |
02df8b938
|
258 |
#else |
4be44fcd3
|
259 260 261 |
static inline void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, unsigned int cpu) |
02df8b938
|
262 263 264 265 |
{ flags->bm_check = 1; return; } |
991528d73
|
266 |
static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
fd3509436
|
267 268 269 |
struct acpi_processor_cx *cx, struct acpi_power_register *reg) |
991528d73
|
270 271 272 |
{ return -1; } |
fd3509436
|
273 274 |
static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate) |
991528d73
|
275 276 277 |
{ return; } |
02df8b938
|
278 |
#endif |
1da177e4c
|
279 |
/* in processor_perflib.c */ |
02df8b938
|
280 |
|
1da177e4c
|
281 282 283 |
#ifdef CONFIG_CPU_FREQ void acpi_processor_ppc_init(void); void acpi_processor_ppc_exit(void); |
bca5f557d
|
284 |
void acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag); |
e2f74f355
|
285 |
extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit); |
1da177e4c
|
286 |
#else |
4be44fcd3
|
287 288 289 290 291 292 293 294 |
static inline void acpi_processor_ppc_init(void) { return; } static inline void acpi_processor_ppc_exit(void) { return; } |
a507a3065
|
295 |
static inline void acpi_processor_ppc_has_changed(struct acpi_processor *pr, |
d81c45e1c
|
296 |
int event_flag) |
4be44fcd3
|
297 |
{ |
1da177e4c
|
298 299 |
static unsigned int printout = 1; if (printout) { |
4be44fcd3
|
300 301 302 303 304 305 |
printk(KERN_WARNING "Warning: Processor Platform Limit event detected, but not handled. "); printk(KERN_WARNING "Consider compiling CPUfreq support into your kernel. "); |
1da177e4c
|
306 307 |
printout = 0; } |
1da177e4c
|
308 |
} |
e2f74f355
|
309 310 311 312 |
static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) { return -ENODEV; } |
4be44fcd3
|
313 |
#endif /* CONFIG_CPU_FREQ */ |
1da177e4c
|
314 |
|
4d5d4cd88
|
315 |
/* in processor_core.c */ |
828aef376
|
316 |
phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); |
fb7c2bae8
|
317 |
phys_cpuid_t acpi_map_madt_entry(u32 acpi_id); |
828aef376
|
318 |
int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id); |
2e9d5e4ef
|
319 |
int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); |
78f169965
|
320 |
|
4f2f75735
|
321 322 323 324 325 326 327 328 329 330 331 332 333 |
#ifdef CONFIG_ACPI_CPPC_LIB extern int acpi_cppc_processor_probe(struct acpi_processor *pr); extern void acpi_cppc_processor_exit(struct acpi_processor *pr); #else static inline int acpi_cppc_processor_probe(struct acpi_processor *pr) { return 0; } static inline void acpi_cppc_processor_exit(struct acpi_processor *pr) { return; } #endif /* CONFIG_ACPI_CPPC_LIB */ |
24119a882
|
334 335 |
/* in processor_pdc.c */ void acpi_processor_set_pdc(acpi_handle handle); |
1da177e4c
|
336 |
/* in processor_throttling.c */ |
239708a3a
|
337 |
#ifdef CONFIG_ACPI_CPU_FREQ_PSS |
a66b34b26
|
338 |
int acpi_processor_tstate_has_changed(struct acpi_processor *pr); |
4be44fcd3
|
339 |
int acpi_processor_get_throttling_info(struct acpi_processor *pr); |
2a908002c
|
340 341 |
extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state, bool force); |
5a344a505
|
342 343 344 345 346 |
/* * Reevaluate whether the T-state is invalid after one cpu is * onlined/offlined. In such case the flags.throttling will be updated. */ extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr, |
64f3bf2f8
|
347 |
bool is_dead); |
070d8eb1f
|
348 |
extern const struct file_operations acpi_processor_throttling_fops; |
1180509f6
|
349 |
extern void acpi_processor_throttling_init(void); |
239708a3a
|
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 |
#else static inline int acpi_processor_tstate_has_changed(struct acpi_processor *pr) { return 0; } static inline int acpi_processor_get_throttling_info(struct acpi_processor *pr) { return -ENODEV; } static inline int acpi_processor_set_throttling(struct acpi_processor *pr, int state, bool force) { return -ENODEV; } static inline void acpi_processor_reevaluate_tstate(struct acpi_processor *pr, |
64f3bf2f8
|
368 |
bool is_dead) {} |
239708a3a
|
369 370 371 |
static inline void acpi_processor_throttling_init(void) {} #endif /* CONFIG_ACPI_CPU_FREQ_PSS */ |
1da177e4c
|
372 |
/* in processor_idle.c */ |
5f05586c6
|
373 374 |
extern struct cpuidle_driver acpi_idle_driver; #ifdef CONFIG_ACPI_PROCESSOR_IDLE |
38a991b62
|
375 376 |
int acpi_processor_power_init(struct acpi_processor *pr); int acpi_processor_power_exit(struct acpi_processor *pr); |
a36a7fecf
|
377 |
int acpi_processor_power_state_has_changed(struct acpi_processor *pr); |
46bcfad7a
|
378 |
int acpi_processor_hotplug(struct acpi_processor *pr); |
5f05586c6
|
379 380 381 382 383 384 385 386 387 388 |
#else static inline int acpi_processor_power_init(struct acpi_processor *pr) { return -ENODEV; } static inline int acpi_processor_power_exit(struct acpi_processor *pr) { return -ENODEV; } |
a36a7fecf
|
389 |
static inline int acpi_processor_power_state_has_changed(struct acpi_processor *pr) |
5f05586c6
|
390 391 392 393 394 395 396 397 398 |
{ return -ENODEV; } static inline int acpi_processor_hotplug(struct acpi_processor *pr) { return -ENODEV; } #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ |
1da177e4c
|
399 400 |
/* in processor_thermal.c */ |
4be44fcd3
|
401 |
int acpi_processor_get_limit_info(struct acpi_processor *pr); |
9c8b04be4
|
402 |
extern const struct thermal_cooling_device_ops processor_cooling_ops; |
239708a3a
|
403 |
#if defined(CONFIG_ACPI_CPU_FREQ_PSS) & defined(CONFIG_CPU_FREQ) |
1da177e4c
|
404 405 406 |
void acpi_thermal_cpufreq_init(void); void acpi_thermal_cpufreq_exit(void); #else |
4be44fcd3
|
407 408 409 410 411 412 413 414 |
static inline void acpi_thermal_cpufreq_init(void) { return; } static inline void acpi_thermal_cpufreq_exit(void) { return; } |
239708a3a
|
415 |
#endif /* CONFIG_ACPI_CPU_FREQ_PSS */ |
1da177e4c
|
416 |
|
1da177e4c
|
417 |
#endif |