blob: 7a00d5089de983d0fb91f39f410aa60ee152e2e8 [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 {
Len Brown4be44fc2005-08-05 00:44:28 -040026 u8 descriptor;
27 u16 length;
28 u8 space_id;
29 u8 bit_width;
30 u8 bit_offset;
31 u8 reserved;
32 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033} __attribute__ ((packed));
34
Linus Torvalds1da177e2005-04-16 15:20:36 -070035struct acpi_processor_cx_policy {
Len Brown4be44fc2005-08-05 00:44:28 -040036 u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070037 struct acpi_processor_cx *state;
38 struct {
Len Brown4be44fc2005-08-05 00:44:28 -040039 u32 time;
40 u32 ticks;
41 u32 count;
42 u32 bm;
43 } threshold;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044};
45
46struct acpi_processor_cx {
Len Brown4be44fc2005-08-05 00:44:28 -040047 u8 valid;
48 u8 type;
49 u32 address;
50 u32 latency;
51 u32 latency_ticks;
52 u32 power;
53 u32 usage;
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 struct acpi_processor_cx_policy promotion;
55 struct acpi_processor_cx_policy demotion;
56};
57
58struct acpi_processor_power {
59 struct acpi_processor_cx *state;
Len Brown4be44fc2005-08-05 00:44:28 -040060 unsigned long bm_check_timestamp;
61 u32 default_state;
62 u32 bm_activity;
63 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -040065
66 /* the _PDC objects passed by the driver, if any */
67 struct acpi_object_list *pdc;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068};
69
70/* Performance Management */
71
72struct acpi_pct_register {
Len Brown4be44fc2005-08-05 00:44:28 -040073 u8 descriptor;
74 u16 length;
75 u8 space_id;
76 u8 bit_width;
77 u8 bit_offset;
78 u8 reserved;
79 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080} __attribute__ ((packed));
81
82struct acpi_processor_px {
Len Brown4be44fc2005-08-05 00:44:28 -040083 acpi_integer core_frequency; /* megahertz */
84 acpi_integer power; /* milliWatts */
85 acpi_integer transition_latency; /* microseconds */
86 acpi_integer bus_master_latency; /* microseconds */
87 acpi_integer control; /* control value */
88 acpi_integer status; /* success indicator */
Linus Torvalds1da177e2005-04-16 15:20:36 -070089};
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091struct acpi_processor_performance {
Len Brown4be44fc2005-08-05 00:44:28 -040092 unsigned int state;
93 unsigned int platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 struct acpi_pct_register control_register;
95 struct acpi_pct_register status_register;
Len Brown4be44fc2005-08-05 00:44:28 -040096 unsigned int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 struct acpi_processor_px *states;
98
99 /* the _PDC objects passed by the driver, if any */
100 struct acpi_object_list *pdc;
101};
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103/* Throttling Control */
104
105struct acpi_processor_tx {
Len Brown4be44fc2005-08-05 00:44:28 -0400106 u16 power;
107 u16 performance;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108};
109
110struct acpi_processor_throttling {
Len Brown4be44fc2005-08-05 00:44:28 -0400111 int state;
112 u32 address;
113 u8 duty_offset;
114 u8 duty_width;
115 int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
117};
118
119/* Limit Interface */
120
121struct acpi_processor_lx {
Len Brown4be44fc2005-08-05 00:44:28 -0400122 int px; /* performace state */
123 int tx; /* throttle level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124};
125
126struct acpi_processor_limit {
Len Brown4be44fc2005-08-05 00:44:28 -0400127 struct acpi_processor_lx state; /* current limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 struct acpi_processor_lx thermal; /* thermal limit */
Len Brown4be44fc2005-08-05 00:44:28 -0400129 struct acpi_processor_lx user; /* user limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130};
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132struct acpi_processor_flags {
Len Brown4be44fc2005-08-05 00:44:28 -0400133 u8 power:1;
134 u8 performance:1;
135 u8 throttling:1;
136 u8 limit:1;
137 u8 bm_control:1;
138 u8 bm_check:1;
139 u8 has_cst:1;
140 u8 power_setup_done:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141};
142
143struct acpi_processor {
Len Brown4be44fc2005-08-05 00:44:28 -0400144 acpi_handle handle;
145 u32 acpi_id;
146 u32 id;
147 u32 pblk;
148 int performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 struct acpi_processor_flags flags;
150 struct acpi_processor_power power;
151 struct acpi_processor_performance *performance;
152 struct acpi_processor_throttling throttling;
153 struct acpi_processor_limit limit;
154};
155
156struct acpi_processor_errata {
Len Brown4be44fc2005-08-05 00:44:28 -0400157 u8 smp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 struct {
Len Brown4be44fc2005-08-05 00:44:28 -0400159 u8 throttle:1;
160 u8 fdma:1;
161 u8 reserved:6;
162 u32 bmisx;
163 } piix4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164};
165
Len Brown4be44fc2005-08-05 00:44:28 -0400166extern int acpi_processor_register_performance(struct acpi_processor_performance
167 *performance, unsigned int cpu);
168extern void acpi_processor_unregister_performance(struct
169 acpi_processor_performance
170 *performance,
171 unsigned int cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
173/* note: this locks both the calling module and the processor module
174 if a _PPC object exists, rmmod is disallowed then */
175int acpi_processor_notify_smm(struct module *calling_module);
176
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177/* for communication between multiple parts of the processor kernel module */
Len Brown4be44fc2005-08-05 00:44:28 -0400178extern struct acpi_processor *processors[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179extern struct acpi_processor_errata errata;
180
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400181int acpi_processor_set_pdc(struct acpi_processor *pr,
Len Brown4be44fc2005-08-05 00:44:28 -0400182 struct acpi_object_list *pdc_in);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400183
184#ifdef ARCH_HAS_POWER_PDC_INIT
185void acpi_processor_power_init_pdc(struct acpi_processor_power *pow,
Len Brown4be44fc2005-08-05 00:44:28 -0400186 unsigned int cpu);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400187void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
Len Brown4be44fc2005-08-05 00:44:28 -0400188 unsigned int cpu);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400189#else
Len Brown4be44fc2005-08-05 00:44:28 -0400190static inline void acpi_processor_power_init_pdc(struct acpi_processor_power
191 *pow, unsigned int cpu)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400192{
193 pow->pdc = NULL;
194 return;
195}
196
Len Brown4be44fc2005-08-05 00:44:28 -0400197static inline void acpi_processor_power_init_bm_check(struct
198 acpi_processor_flags
199 *flags, unsigned int cpu)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400200{
201 flags->bm_check = 1;
202 return;
203}
204#endif
205
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206/* in processor_perflib.c */
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400207
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208#ifdef CONFIG_CPU_FREQ
209void acpi_processor_ppc_init(void);
210void acpi_processor_ppc_exit(void);
211int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
212#else
Len Brown4be44fc2005-08-05 00:44:28 -0400213static inline void acpi_processor_ppc_init(void)
214{
215 return;
216}
217static inline void acpi_processor_ppc_exit(void)
218{
219 return;
220}
221static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
222{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 static unsigned int printout = 1;
224 if (printout) {
Len Brown4be44fc2005-08-05 00:44:28 -0400225 printk(KERN_WARNING
226 "Warning: Processor Platform Limit event detected, but not handled.\n");
227 printk(KERN_WARNING
228 "Consider compiling CPUfreq support into your kernel.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 printout = 0;
230 }
231 return 0;
232}
Len Brown4be44fc2005-08-05 00:44:28 -0400233#endif /* CONFIG_CPU_FREQ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235/* in processor_throttling.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400236int acpi_processor_get_throttling_info(struct acpi_processor *pr);
237int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
238ssize_t acpi_processor_write_throttling(struct file *file,
239 const char __user * buffer,
240 size_t count, loff_t * data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241extern struct file_operations acpi_processor_throttling_fops;
242
243/* in processor_idle.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400244int acpi_processor_power_init(struct acpi_processor *pr,
245 struct acpi_device *device);
246int acpi_processor_cst_has_changed(struct acpi_processor *pr);
247int acpi_processor_power_exit(struct acpi_processor *pr,
248 struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
250/* in processor_thermal.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400251int acpi_processor_get_limit_info(struct acpi_processor *pr);
252ssize_t acpi_processor_write_limit(struct file *file,
253 const char __user * buffer,
254 size_t count, loff_t * data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255extern struct file_operations acpi_processor_limit_fops;
256
257#ifdef CONFIG_CPU_FREQ
258void acpi_thermal_cpufreq_init(void);
259void acpi_thermal_cpufreq_exit(void);
260#else
Len Brown4be44fc2005-08-05 00:44:28 -0400261static inline void acpi_thermal_cpufreq_init(void)
262{
263 return;
264}
265static inline void acpi_thermal_cpufreq_exit(void)
266{
267 return;
268}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269#endif
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271#endif