blob: ef7d83a414709742880ce23c36af67dcf4c29a39 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07005
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -04006#include <asm/acpi.h>
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008#define ACPI_PROCESSOR_BUSY_METRIC 10
9
10#define ACPI_PROCESSOR_MAX_POWER 8
11#define ACPI_PROCESSOR_MAX_C2_LATENCY 100
12#define ACPI_PROCESSOR_MAX_C3_LATENCY 1000
13
14#define ACPI_PROCESSOR_MAX_THROTTLING 16
15#define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */
16#define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4
17
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -040018#define ACPI_PDC_REVISION_ID 0x1
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020/* Power Management */
21
22struct acpi_processor_cx;
23
24struct acpi_power_register {
Len Brown4be44fc2005-08-05 00:44:28 -040025 u8 descriptor;
26 u16 length;
27 u8 space_id;
28 u8 bit_width;
29 u8 bit_offset;
30 u8 reserved;
31 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032} __attribute__ ((packed));
33
Linus Torvalds1da177e2005-04-16 15:20:36 -070034struct acpi_processor_cx_policy {
Len Brown4be44fc2005-08-05 00:44:28 -040035 u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 struct acpi_processor_cx *state;
37 struct {
Len Brown4be44fc2005-08-05 00:44:28 -040038 u32 time;
39 u32 ticks;
40 u32 count;
41 u32 bm;
42 } threshold;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043};
44
45struct acpi_processor_cx {
Len Brown4be44fc2005-08-05 00:44:28 -040046 u8 valid;
47 u8 type;
48 u32 address;
49 u32 latency;
50 u32 latency_ticks;
51 u32 power;
52 u32 usage;
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 struct acpi_processor_cx_policy promotion;
54 struct acpi_processor_cx_policy demotion;
55};
56
57struct acpi_processor_power {
58 struct acpi_processor_cx *state;
Len Brown4be44fc2005-08-05 00:44:28 -040059 unsigned long bm_check_timestamp;
60 u32 default_state;
61 u32 bm_activity;
62 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
64};
65
66/* Performance Management */
67
68struct acpi_pct_register {
Len Brown4be44fc2005-08-05 00:44:28 -040069 u8 descriptor;
70 u16 length;
71 u8 space_id;
72 u8 bit_width;
73 u8 bit_offset;
74 u8 reserved;
75 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076} __attribute__ ((packed));
77
78struct acpi_processor_px {
Len Brown4be44fc2005-08-05 00:44:28 -040079 acpi_integer core_frequency; /* megahertz */
80 acpi_integer power; /* milliWatts */
81 acpi_integer transition_latency; /* microseconds */
82 acpi_integer bus_master_latency; /* microseconds */
83 acpi_integer control; /* control value */
84 acpi_integer status; /* success indicator */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085};
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087struct acpi_processor_performance {
Len Brown4be44fc2005-08-05 00:44:28 -040088 unsigned int state;
89 unsigned int platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 struct acpi_pct_register control_register;
91 struct acpi_pct_register status_register;
Len Brown4be44fc2005-08-05 00:44:28 -040092 unsigned int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 struct acpi_processor_px *states;
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095};
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097/* Throttling Control */
98
99struct acpi_processor_tx {
Len Brown4be44fc2005-08-05 00:44:28 -0400100 u16 power;
101 u16 performance;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102};
103
104struct acpi_processor_throttling {
Len Brown4be44fc2005-08-05 00:44:28 -0400105 int state;
106 u32 address;
107 u8 duty_offset;
108 u8 duty_width;
109 int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
111};
112
113/* Limit Interface */
114
115struct acpi_processor_lx {
Len Brown4be44fc2005-08-05 00:44:28 -0400116 int px; /* performace state */
117 int tx; /* throttle level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118};
119
120struct acpi_processor_limit {
Len Brown4be44fc2005-08-05 00:44:28 -0400121 struct acpi_processor_lx state; /* current limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122 struct acpi_processor_lx thermal; /* thermal limit */
Len Brown4be44fc2005-08-05 00:44:28 -0400123 struct acpi_processor_lx user; /* user limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124};
125
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126struct acpi_processor_flags {
Len Brown4be44fc2005-08-05 00:44:28 -0400127 u8 power:1;
128 u8 performance:1;
129 u8 throttling:1;
130 u8 limit:1;
131 u8 bm_control:1;
132 u8 bm_check:1;
133 u8 has_cst:1;
134 u8 power_setup_done:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135};
136
137struct acpi_processor {
Len Brown4be44fc2005-08-05 00:44:28 -0400138 acpi_handle handle;
139 u32 acpi_id;
140 u32 id;
141 u32 pblk;
142 int performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 struct acpi_processor_flags flags;
144 struct acpi_processor_power power;
145 struct acpi_processor_performance *performance;
146 struct acpi_processor_throttling throttling;
147 struct acpi_processor_limit limit;
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400148
149 /* the _PDC objects for this processor, if any */
150 struct acpi_object_list *pdc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151};
152
153struct acpi_processor_errata {
Len Brown4be44fc2005-08-05 00:44:28 -0400154 u8 smp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 struct {
Len Brown4be44fc2005-08-05 00:44:28 -0400156 u8 throttle:1;
157 u8 fdma:1;
158 u8 reserved:6;
159 u32 bmisx;
160 } piix4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161};
162
Len Brown4be44fc2005-08-05 00:44:28 -0400163extern int acpi_processor_register_performance(struct acpi_processor_performance
164 *performance, unsigned int cpu);
165extern void acpi_processor_unregister_performance(struct
166 acpi_processor_performance
167 *performance,
168 unsigned int cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
170/* note: this locks both the calling module and the processor module
171 if a _PPC object exists, rmmod is disallowed then */
172int acpi_processor_notify_smm(struct module *calling_module);
173
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174/* for communication between multiple parts of the processor kernel module */
Len Brown4be44fc2005-08-05 00:44:28 -0400175extern struct acpi_processor *processors[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176extern struct acpi_processor_errata errata;
177
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400178void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400179
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400180#ifdef ARCH_HAS_POWER_INIT
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400181void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
Len Brown4be44fc2005-08-05 00:44:28 -0400182 unsigned int cpu);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400183#else
Len Brown4be44fc2005-08-05 00:44:28 -0400184static inline void acpi_processor_power_init_bm_check(struct
185 acpi_processor_flags
186 *flags, unsigned int cpu)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400187{
188 flags->bm_check = 1;
189 return;
190}
191#endif
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/* in processor_perflib.c */
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195#ifdef CONFIG_CPU_FREQ
196void acpi_processor_ppc_init(void);
197void acpi_processor_ppc_exit(void);
198int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
199#else
Len Brown4be44fc2005-08-05 00:44:28 -0400200static inline void acpi_processor_ppc_init(void)
201{
202 return;
203}
204static inline void acpi_processor_ppc_exit(void)
205{
206 return;
207}
208static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
209{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 static unsigned int printout = 1;
211 if (printout) {
Len Brown4be44fc2005-08-05 00:44:28 -0400212 printk(KERN_WARNING
213 "Warning: Processor Platform Limit event detected, but not handled.\n");
214 printk(KERN_WARNING
215 "Consider compiling CPUfreq support into your kernel.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 printout = 0;
217 }
218 return 0;
219}
Len Brown4be44fc2005-08-05 00:44:28 -0400220#endif /* CONFIG_CPU_FREQ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221
222/* in processor_throttling.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400223int acpi_processor_get_throttling_info(struct acpi_processor *pr);
224int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225extern struct file_operations acpi_processor_throttling_fops;
226
227/* in processor_idle.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400228int acpi_processor_power_init(struct acpi_processor *pr,
229 struct acpi_device *device);
230int acpi_processor_cst_has_changed(struct acpi_processor *pr);
231int acpi_processor_power_exit(struct acpi_processor *pr,
232 struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
234/* in processor_thermal.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400235int acpi_processor_get_limit_info(struct acpi_processor *pr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236extern struct file_operations acpi_processor_limit_fops;
237
238#ifdef CONFIG_CPU_FREQ
239void acpi_thermal_cpufreq_init(void);
240void acpi_thermal_cpufreq_exit(void);
241#else
Len Brown4be44fc2005-08-05 00:44:28 -0400242static inline void acpi_thermal_cpufreq_init(void)
243{
244 return;
245}
246static inline void acpi_thermal_cpufreq_exit(void)
247{
248 return;
249}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250#endif
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252#endif