blob: 50cfea4ff6ca3d1b3d35162ff9d2c56624c9e7ac [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>
5#include <linux/config.h>
6
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -04007#include <asm/acpi.h>
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009#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
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -040019#define ACPI_PDC_REVISION_ID 0x1
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021/* Power Management */
22
23struct acpi_processor_cx;
24
25struct acpi_power_register {
26 u8 descriptor;
27 u16 length;
28 u8 space_id;
29 u8 bit_width;
30 u8 bit_offset;
31 u8 reserved;
32 u64 address;
33} __attribute__ ((packed));
34
35
36struct acpi_processor_cx_policy {
37 u32 count;
38 struct acpi_processor_cx *state;
39 struct {
40 u32 time;
41 u32 ticks;
42 u32 count;
43 u32 bm;
44 } threshold;
45};
46
47struct acpi_processor_cx {
48 u8 valid;
49 u8 type;
50 u32 address;
51 u32 latency;
52 u32 latency_ticks;
53 u32 power;
54 u32 usage;
55 struct acpi_processor_cx_policy promotion;
56 struct acpi_processor_cx_policy demotion;
57};
58
59struct acpi_processor_power {
60 struct acpi_processor_cx *state;
61 unsigned long bm_check_timestamp;
62 u32 default_state;
63 u32 bm_activity;
64 int count;
65 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -040066
67 /* the _PDC objects passed by the driver, if any */
68 struct acpi_object_list *pdc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069};
70
71/* Performance Management */
72
73struct acpi_pct_register {
74 u8 descriptor;
75 u16 length;
76 u8 space_id;
77 u8 bit_width;
78 u8 bit_offset;
79 u8 reserved;
80 u64 address;
81} __attribute__ ((packed));
82
83struct acpi_processor_px {
84 acpi_integer core_frequency; /* megahertz */
85 acpi_integer power; /* milliWatts */
86 acpi_integer transition_latency; /* microseconds */
87 acpi_integer bus_master_latency; /* microseconds */
88 acpi_integer control; /* control value */
89 acpi_integer status; /* success indicator */
90};
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092struct acpi_processor_performance {
93 unsigned int state;
94 unsigned int platform_limit;
95 struct acpi_pct_register control_register;
96 struct acpi_pct_register status_register;
97 unsigned int state_count;
98 struct acpi_processor_px *states;
99
100 /* the _PDC objects passed by the driver, if any */
101 struct acpi_object_list *pdc;
102};
103
104
105
106/* Throttling Control */
107
108struct acpi_processor_tx {
109 u16 power;
110 u16 performance;
111};
112
113struct acpi_processor_throttling {
114 int state;
115 u32 address;
116 u8 duty_offset;
117 u8 duty_width;
118 int state_count;
119 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
120};
121
122/* Limit Interface */
123
124struct acpi_processor_lx {
125 int px; /* performace state */
126 int tx; /* throttle level */
127};
128
129struct acpi_processor_limit {
130 struct acpi_processor_lx state; /* current limit */
131 struct acpi_processor_lx thermal; /* thermal limit */
132 struct acpi_processor_lx user; /* user limit */
133};
134
135
136struct acpi_processor_flags {
137 u8 power:1;
138 u8 performance:1;
139 u8 throttling:1;
140 u8 limit:1;
141 u8 bm_control:1;
142 u8 bm_check:1;
143 u8 has_cst:1;
144 u8 power_setup_done:1;
145};
146
147struct acpi_processor {
148 acpi_handle handle;
149 u32 acpi_id;
150 u32 id;
151 u32 pblk;
152 int performance_platform_limit;
153 struct acpi_processor_flags flags;
154 struct acpi_processor_power power;
155 struct acpi_processor_performance *performance;
156 struct acpi_processor_throttling throttling;
157 struct acpi_processor_limit limit;
158};
159
160struct acpi_processor_errata {
161 u8 smp;
162 struct {
163 u8 throttle:1;
164 u8 fdma:1;
165 u8 reserved:6;
166 u32 bmisx;
167 } piix4;
168};
169
170extern int acpi_processor_register_performance (
171 struct acpi_processor_performance * performance,
172 unsigned int cpu);
173extern void acpi_processor_unregister_performance (
174 struct acpi_processor_performance * performance,
175 unsigned int cpu);
176
177/* note: this locks both the calling module and the processor module
178 if a _PPC object exists, rmmod is disallowed then */
179int acpi_processor_notify_smm(struct module *calling_module);
180
181
182
183/* for communication between multiple parts of the processor kernel module */
184extern struct acpi_processor *processors[NR_CPUS];
185extern struct acpi_processor_errata errata;
186
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400187int acpi_processor_set_pdc(struct acpi_processor *pr,
188 struct acpi_object_list *pdc_in);
189
190#ifdef ARCH_HAS_POWER_PDC_INIT
191void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
192 unsigned int cpu);
193void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
194 unsigned int cpu);
195#else
196static inline void acpi_processor_power_init_pdc(
197 struct acpi_processor_power *pow, unsigned int cpu)
198{
199 pow->pdc = NULL;
200 return;
201}
202
203static inline void acpi_processor_power_init_bm_check(
204 struct acpi_processor_flags *flags, unsigned int cpu)
205{
206 flags->bm_check = 1;
207 return;
208}
209#endif
210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211/* in processor_perflib.c */
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400212
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213#ifdef CONFIG_CPU_FREQ
214void acpi_processor_ppc_init(void);
215void acpi_processor_ppc_exit(void);
216int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
217#else
218static inline void acpi_processor_ppc_init(void) { return; }
219static inline void acpi_processor_ppc_exit(void) { return; }
220static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) {
221 static unsigned int printout = 1;
222 if (printout) {
223 printk(KERN_WARNING "Warning: Processor Platform Limit event detected, but not handled.\n");
224 printk(KERN_WARNING "Consider compiling CPUfreq support into your kernel.\n");
225 printout = 0;
226 }
227 return 0;
228}
229#endif /* CONFIG_CPU_FREQ */
230
231/* in processor_throttling.c */
232int acpi_processor_get_throttling_info (struct acpi_processor *pr);
233int acpi_processor_set_throttling (struct acpi_processor *pr, int state);
234ssize_t acpi_processor_write_throttling (
235 struct file *file,
236 const char __user *buffer,
237 size_t count,
238 loff_t *data);
239extern struct file_operations acpi_processor_throttling_fops;
240
241/* in processor_idle.c */
242int acpi_processor_power_init(struct acpi_processor *pr, struct acpi_device *device);
243int acpi_processor_cst_has_changed (struct acpi_processor *pr);
244int acpi_processor_power_exit(struct acpi_processor *pr, struct acpi_device *device);
245
246
247/* in processor_thermal.c */
248int acpi_processor_get_limit_info (struct acpi_processor *pr);
249ssize_t acpi_processor_write_limit (
250 struct file *file,
251 const char __user *buffer,
252 size_t count,
253 loff_t *data);
254extern struct file_operations acpi_processor_limit_fops;
255
256#ifdef CONFIG_CPU_FREQ
257void acpi_thermal_cpufreq_init(void);
258void acpi_thermal_cpufreq_exit(void);
259#else
260static inline void acpi_thermal_cpufreq_init(void) { return; }
261static inline void acpi_thermal_cpufreq_exit(void) { return; }
262#endif
263
264
265#endif