blob: 9dd5b75961f84c19ba9a731eb071f15950577d75 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
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
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -050021#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
22#define ACPI_PSD_REV0_ENTRIES 5
23
24/*
25 * Types of coordination defined in ACPI 3.0. Same macros can be used across
26 * P, C and T states
27 */
28#define DOMAIN_COORD_TYPE_SW_ALL 0xfc
29#define DOMAIN_COORD_TYPE_SW_ANY 0xfd
30#define DOMAIN_COORD_TYPE_HW_ALL 0xfe
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032/* Power Management */
33
34struct acpi_processor_cx;
35
36struct acpi_power_register {
Len Brown4be44fc2005-08-05 00:44:28 -040037 u8 descriptor;
38 u16 length;
39 u8 space_id;
40 u8 bit_width;
41 u8 bit_offset;
42 u8 reserved;
43 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070044} __attribute__ ((packed));
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046struct acpi_processor_cx_policy {
Len Brown4be44fc2005-08-05 00:44:28 -040047 u32 count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 struct acpi_processor_cx *state;
49 struct {
Len Brown4be44fc2005-08-05 00:44:28 -040050 u32 time;
51 u32 ticks;
52 u32 count;
53 u32 bm;
54 } threshold;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055};
56
57struct acpi_processor_cx {
Len Brown4be44fc2005-08-05 00:44:28 -040058 u8 valid;
59 u8 type;
60 u32 address;
61 u32 latency;
62 u32 latency_ticks;
63 u32 power;
64 u32 usage;
Dominik Brodowskia3c65982006-06-24 19:37:00 -040065 u64 time;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066 struct acpi_processor_cx_policy promotion;
67 struct acpi_processor_cx_policy demotion;
68};
69
70struct acpi_processor_power {
71 struct acpi_processor_cx *state;
Len Brown4be44fc2005-08-05 00:44:28 -040072 unsigned long bm_check_timestamp;
73 u32 default_state;
74 u32 bm_activity;
75 int count;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
77};
78
79/* Performance Management */
80
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -050081struct acpi_psd_package {
82 acpi_integer num_entries;
83 acpi_integer revision;
84 acpi_integer domain;
85 acpi_integer coord_type;
86 acpi_integer num_processors;
87} __attribute__ ((packed));
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089struct acpi_pct_register {
Len Brown4be44fc2005-08-05 00:44:28 -040090 u8 descriptor;
91 u16 length;
92 u8 space_id;
93 u8 bit_width;
94 u8 bit_offset;
95 u8 reserved;
96 u64 address;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097} __attribute__ ((packed));
98
99struct acpi_processor_px {
Len Brown4be44fc2005-08-05 00:44:28 -0400100 acpi_integer core_frequency; /* megahertz */
101 acpi_integer power; /* milliWatts */
102 acpi_integer transition_latency; /* microseconds */
103 acpi_integer bus_master_latency; /* microseconds */
104 acpi_integer control; /* control value */
105 acpi_integer status; /* success indicator */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106};
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108struct acpi_processor_performance {
Len Brown4be44fc2005-08-05 00:44:28 -0400109 unsigned int state;
110 unsigned int platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 struct acpi_pct_register control_register;
112 struct acpi_pct_register status_register;
Len Brown4be44fc2005-08-05 00:44:28 -0400113 unsigned int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 struct acpi_processor_px *states;
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500115 struct acpi_psd_package domain_info;
116 cpumask_t shared_cpu_map;
117 unsigned int shared_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118};
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120/* Throttling Control */
121
122struct acpi_processor_tx {
Len Brown4be44fc2005-08-05 00:44:28 -0400123 u16 power;
124 u16 performance;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125};
126
127struct acpi_processor_throttling {
Len Brown4be44fc2005-08-05 00:44:28 -0400128 int state;
129 u32 address;
130 u8 duty_offset;
131 u8 duty_width;
132 int state_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
134};
135
136/* Limit Interface */
137
138struct acpi_processor_lx {
Len Brown4be44fc2005-08-05 00:44:28 -0400139 int px; /* performace state */
140 int tx; /* throttle level */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141};
142
143struct acpi_processor_limit {
Len Brown4be44fc2005-08-05 00:44:28 -0400144 struct acpi_processor_lx state; /* current limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 struct acpi_processor_lx thermal; /* thermal limit */
Len Brown4be44fc2005-08-05 00:44:28 -0400146 struct acpi_processor_lx user; /* user limit */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147};
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149struct acpi_processor_flags {
Len Brown4be44fc2005-08-05 00:44:28 -0400150 u8 power:1;
151 u8 performance:1;
152 u8 throttling:1;
153 u8 limit:1;
154 u8 bm_control:1;
155 u8 bm_check:1;
156 u8 has_cst:1;
157 u8 power_setup_done:1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158};
159
160struct acpi_processor {
Len Brown4be44fc2005-08-05 00:44:28 -0400161 acpi_handle handle;
162 u32 acpi_id;
163 u32 id;
164 u32 pblk;
165 int performance_platform_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 struct acpi_processor_flags flags;
167 struct acpi_processor_power power;
168 struct acpi_processor_performance *performance;
169 struct acpi_processor_throttling throttling;
170 struct acpi_processor_limit limit;
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400171
172 /* the _PDC objects for this processor, if any */
173 struct acpi_object_list *pdc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174};
175
176struct acpi_processor_errata {
Len Brown4be44fc2005-08-05 00:44:28 -0400177 u8 smp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 struct {
Len Brown4be44fc2005-08-05 00:44:28 -0400179 u8 throttle:1;
180 u8 fdma:1;
181 u8 reserved:6;
182 u32 bmisx;
183 } piix4;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184};
185
Venkatesh Pallipadi3b2d9942005-12-14 15:05:00 -0500186extern int acpi_processor_preregister_performance(
187 struct acpi_processor_performance **performance);
188
Len Brown4be44fc2005-08-05 00:44:28 -0400189extern int acpi_processor_register_performance(struct acpi_processor_performance
190 *performance, unsigned int cpu);
191extern void acpi_processor_unregister_performance(struct
192 acpi_processor_performance
193 *performance,
194 unsigned int cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196/* note: this locks both the calling module and the processor module
197 if a _PPC object exists, rmmod is disallowed then */
198int acpi_processor_notify_smm(struct module *calling_module);
199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200/* for communication between multiple parts of the processor kernel module */
Len Brown4be44fc2005-08-05 00:44:28 -0400201extern struct acpi_processor *processors[NR_CPUS];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202extern struct acpi_processor_errata errata;
203
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400204void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400205
Venkatesh Pallipadi05131ec2005-10-23 16:31:00 -0400206#ifdef ARCH_HAS_POWER_INIT
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400207void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
Len Brown4be44fc2005-08-05 00:44:28 -0400208 unsigned int cpu);
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400209#else
Len Brown4be44fc2005-08-05 00:44:28 -0400210static inline void acpi_processor_power_init_bm_check(struct
211 acpi_processor_flags
212 *flags, unsigned int cpu)
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400213{
214 flags->bm_check = 1;
215 return;
216}
217#endif
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219/* in processor_perflib.c */
Venkatesh Pallipadi02df8b92005-04-15 15:07:10 -0400220
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221#ifdef CONFIG_CPU_FREQ
222void acpi_processor_ppc_init(void);
223void acpi_processor_ppc_exit(void);
224int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
225#else
Len Brown4be44fc2005-08-05 00:44:28 -0400226static inline void acpi_processor_ppc_init(void)
227{
228 return;
229}
230static inline void acpi_processor_ppc_exit(void)
231{
232 return;
233}
234static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
235{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 static unsigned int printout = 1;
237 if (printout) {
Len Brown4be44fc2005-08-05 00:44:28 -0400238 printk(KERN_WARNING
239 "Warning: Processor Platform Limit event detected, but not handled.\n");
240 printk(KERN_WARNING
241 "Consider compiling CPUfreq support into your kernel.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 printout = 0;
243 }
244 return 0;
245}
Len Brown4be44fc2005-08-05 00:44:28 -0400246#endif /* CONFIG_CPU_FREQ */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248/* in processor_throttling.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400249int acpi_processor_get_throttling_info(struct acpi_processor *pr);
250int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251extern struct file_operations acpi_processor_throttling_fops;
252
253/* in processor_idle.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400254int acpi_processor_power_init(struct acpi_processor *pr,
255 struct acpi_device *device);
256int acpi_processor_cst_has_changed(struct acpi_processor *pr);
257int acpi_processor_power_exit(struct acpi_processor *pr,
258 struct acpi_device *device);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259
260/* in processor_thermal.c */
Len Brown4be44fc2005-08-05 00:44:28 -0400261int acpi_processor_get_limit_info(struct acpi_processor *pr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262extern struct file_operations acpi_processor_limit_fops;
263
264#ifdef CONFIG_CPU_FREQ
265void acpi_thermal_cpufreq_init(void);
266void acpi_thermal_cpufreq_exit(void);
267#else
Len Brown4be44fc2005-08-05 00:44:28 -0400268static inline void acpi_thermal_cpufreq_init(void)
269{
270 return;
271}
272static inline void acpi_thermal_cpufreq_exit(void)
273{
274 return;
275}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276#endif
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278#endif