blob: 0787635a11aa52ba473c162aa77ec36329d937d9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ACPI_PROCESSOR_H
2#define __ACPI_PROCESSOR_H
3
4#include <linux/kernel.h>
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -05005#include <linux/cpu.h>
Len Brown4f86d3a2007-10-03 18:58:00 -04006#include <linux/cpuidle.h>
Zhang Ruid9460fd222008-01-17 15:51:23 +08007#include <linux/thermal.h>
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -04008#include <asm/acpi.h>
9
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#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
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -040020#define ACPI_PDC_REVISION_ID 0x1
21
Len Brownfd350942007-05-09 23:34:35 -040022#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -050023#define ACPI_PSD_REV0_ENTRIES 5
24
Luming Yu01854e62007-05-26 22:49:58 +080025#define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
26#define ACPI_TSD_REV0_ENTRIES 5
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -050027/*
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
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -070035#define ACPI_CSTATE_SYSTEMIO (0)
36#define ACPI_CSTATE_FFH (1)
37
Linus Torvalds1da177e2005-04-16 15:20:36 -070038/* Power Management */
39
40struct acpi_processor_cx;
41
42struct acpi_power_register {
Len Brown4be44fc2005-08-05 00:44:28 -040043 u8 descriptor;
44 u16 length;
45 u8 space_id;
46 u8 bit_width;
47 u8 bit_offset;
48 u8 reserved;
49 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050} __attribute__ ((packed));
51
Linus Torvalds1da177e2005-04-16 15:20:36 -070052struct acpi_processor_cx_policy {
Len Brown4be44fc2005-08-05 00:44:28 -040053 u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 struct acpi_processor_cx *state;
55 struct {
Len Brown4be44fc2005-08-05 00:44:28 -040056 u32 time;
57 u32 ticks;
58 u32 count;
59 u32 bm;
60 } threshold;
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
63struct acpi_processor_cx {
Len Brown4be44fc2005-08-05 00:44:28 -040064 u8 valid;
65 u8 type;
66 u32 address;
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -070067 u8 space_id;
68 u8 index;
Len Brown4be44fc2005-08-05 00:44:28 -040069 u32 latency;
70 u32 latency_ticks;
71 u32 power;
72 u32 usage;
Dominik Brodowskia3c65982006-06-24 19:37:00 -040073 u64 time;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 struct acpi_processor_cx_policy promotion;
75 struct acpi_processor_cx_policy demotion;
76};
77
78struct acpi_processor_power {
Len Brown4f86d3a2007-10-03 18:58:00 -040079 struct cpuidle_device dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct acpi_processor_cx *state;
Len Brown4be44fc2005-08-05 00:44:28 -040081 unsigned long bm_check_timestamp;
82 u32 default_state;
83 u32 bm_activity;
84 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
Thomas Gleixner169a0ab2007-02-16 01:27:55 -080086 int timer_broadcast_on_state;
Linus Torvalds1da177e2005-04-16 15:20:36 -070087};
88
89/* Performance Management */
90
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -050091struct 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070099struct acpi_pct_register {
Len Brown4be44fc2005-08-05 00:44:28 -0400100 u8 descriptor;
101 u16 length;
102 u8 space_id;
103 u8 bit_width;
104 u8 bit_offset;
105 u8 reserved;
106 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107} __attribute__ ((packed));
108
109struct acpi_processor_px {
Len Brown4be44fc2005-08-05 00:44:28 -0400110 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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116};
117
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118struct acpi_processor_performance {
Len Brown4be44fc2005-08-05 00:44:28 -0400119 unsigned int state;
120 unsigned int platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 struct acpi_pct_register control_register;
122 struct acpi_pct_register status_register;
Len Brown4be44fc2005-08-05 00:44:28 -0400123 unsigned int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124 struct acpi_processor_px *states;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500125 struct acpi_psd_package domain_info;
126 cpumask_t shared_cpu_map;
127 unsigned int shared_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128};
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130/* Throttling Control */
131
Luming Yu01854e62007-05-26 22:49:58 +0800132struct 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};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157struct acpi_processor_tx {
Len Brown4be44fc2005-08-05 00:44:28 -0400158 u16 power;
159 u16 performance;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160};
161
Luming Yu01854e62007-05-26 22:49:58 +0800162struct acpi_processor;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163struct acpi_processor_throttling {
Luming Yu01854e62007-05-26 22:49:58 +0800164 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;
Len Brownff55a9c2007-06-02 00:15:25 -0400172 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
173 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
174 int state);
Luming Yu01854e62007-05-26 22:49:58 +0800175
Len Brown4be44fc2005-08-05 00:44:28 -0400176 u32 address;
177 u8 duty_offset;
178 u8 duty_width;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
180};
181
182/* Limit Interface */
183
184struct acpi_processor_lx {
Len Brown4be44fc2005-08-05 00:44:28 -0400185 int px; /* performace state */
186 int tx; /* throttle level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187};
188
189struct acpi_processor_limit {
Len Brown4be44fc2005-08-05 00:44:28 -0400190 struct acpi_processor_lx state; /* current limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 struct acpi_processor_lx thermal; /* thermal limit */
Len Brown4be44fc2005-08-05 00:44:28 -0400192 struct acpi_processor_lx user; /* user limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193};
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195struct acpi_processor_flags {
Len Brown4be44fc2005-08-05 00:44:28 -0400196 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;
Len Brown4f86d3a2007-10-03 18:58:00 -0400204 u8 bm_rld_set:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205};
206
207struct acpi_processor {
Len Brown4be44fc2005-08-05 00:44:28 -0400208 acpi_handle handle;
209 u32 acpi_id;
210 u32 id;
211 u32 pblk;
212 int performance_platform_limit;
Luming Yu01854e62007-05-26 22:49:58 +0800213 int throttling_platform_limit;
Len Brownff55a9c2007-06-02 00:15:25 -0400214 /* 0 - states 0..n-th state available */
Luming Yu01854e62007-05-26 22:49:58 +0800215
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 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;
Zhang Ruid9460fd222008-01-17 15:51:23 +0800221 struct thermal_cooling_device *cdev;
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400222 /* the _PDC objects for this processor, if any */
223 struct acpi_object_list *pdc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224};
225
226struct acpi_processor_errata {
Len Brown4be44fc2005-08-05 00:44:28 -0400227 u8 smp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 struct {
Len Brown4be44fc2005-08-05 00:44:28 -0400229 u8 throttle:1;
230 u8 fdma:1;
231 u8 reserved:6;
232 u32 bmisx;
233 } piix4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234};
235
Len Brownfd350942007-05-09 23:34:35 -0400236extern int acpi_processor_preregister_performance(struct
237 acpi_processor_performance
Fenghua Yu50109292007-08-07 18:40:30 -0400238 *performance);
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500239
Len Brown4be44fc2005-08-05 00:44:28 -0400240extern 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);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246
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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251/* for communication between multiple parts of the processor kernel module */
Len Brown4be44fc2005-08-05 00:44:28 -0400252extern struct acpi_processor *processors[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253extern struct acpi_processor_errata errata;
254
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400255void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400256
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400257#ifdef ARCH_HAS_POWER_INIT
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400258void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
Len Brown4be44fc2005-08-05 00:44:28 -0400259 unsigned int cpu);
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -0700260int acpi_processor_ffh_cstate_probe(unsigned int cpu,
Len Brownfd350942007-05-09 23:34:35 -0400261 struct acpi_processor_cx *cx,
262 struct acpi_power_register *reg);
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -0700263void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400264#else
Len Brown4be44fc2005-08-05 00:44:28 -0400265static inline void acpi_processor_power_init_bm_check(struct
266 acpi_processor_flags
267 *flags, unsigned int cpu)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400268{
269 flags->bm_check = 1;
270 return;
271}
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -0700272static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
Len Brownfd350942007-05-09 23:34:35 -0400273 struct acpi_processor_cx *cx,
274 struct acpi_power_register
275 *reg)
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -0700276{
277 return -1;
278}
Len Brownfd350942007-05-09 23:34:35 -0400279static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
280 *cstate)
Venkatesh Pallipadi991528d2006-09-25 16:28:13 -0700281{
282 return;
283}
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400284#endif
285
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286/* in processor_perflib.c */
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400287
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288#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
Len Brown4be44fc2005-08-05 00:44:28 -0400293static 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{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 static unsigned int printout = 1;
304 if (printout) {
Len Brown4be44fc2005-08-05 00:44:28 -0400305 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");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 printout = 0;
310 }
311 return 0;
312}
Len Brown4be44fc2005-08-05 00:44:28 -0400313#endif /* CONFIG_CPU_FREQ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314
315/* in processor_throttling.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400316int acpi_processor_get_throttling_info(struct acpi_processor *pr);
Luming Yu01854e62007-05-26 22:49:58 +0800317extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318extern struct file_operations acpi_processor_throttling_fops;
319
320/* in processor_idle.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400321int 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);
Thomas Gleixnerb04e7bd2007-09-22 22:29:05 +0000326int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
327int acpi_processor_resume(struct acpi_device * device);
Len Brown4f86d3a2007-10-03 18:58:00 -0400328extern struct cpuidle_driver acpi_idle_driver;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
330/* in processor_thermal.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400331int acpi_processor_get_limit_info(struct acpi_processor *pr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332extern struct file_operations acpi_processor_limit_fops;
Zhang Ruid9460fd222008-01-17 15:51:23 +0800333extern struct thermal_cooling_device_ops processor_cooling_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334#ifdef CONFIG_CPU_FREQ
335void acpi_thermal_cpufreq_init(void);
336void acpi_thermal_cpufreq_exit(void);
337#else
Len Brown4be44fc2005-08-05 00:44:28 -0400338static inline void acpi_thermal_cpufreq_init(void)
339{
340 return;
341}
342static inline void acpi_thermal_cpufreq_exit(void)
343{
344 return;
345}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346#endif
347
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348#endif