Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ACPI_PROCESSOR_H |
| 2 | #define __ACPI_PROCESSOR_H |
| 3 | |
| 4 | #include <linux/kernel.h> |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 5 | #include <linux/cpu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 7 | #include <asm/acpi.h> |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #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 Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 19 | #define ACPI_PDC_REVISION_ID 0x1 |
| 20 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 21 | #define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 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 | |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 32 | #define ACPI_CSTATE_SYSTEMIO (0) |
| 33 | #define ACPI_CSTATE_FFH (1) |
| 34 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | /* Power Management */ |
| 36 | |
| 37 | struct acpi_processor_cx; |
| 38 | |
| 39 | struct acpi_power_register { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 40 | u8 descriptor; |
| 41 | u16 length; |
| 42 | u8 space_id; |
| 43 | u8 bit_width; |
| 44 | u8 bit_offset; |
| 45 | u8 reserved; |
| 46 | u64 address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | } __attribute__ ((packed)); |
| 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | struct acpi_processor_cx_policy { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | u32 count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | struct acpi_processor_cx *state; |
| 52 | struct { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 53 | u32 time; |
| 54 | u32 ticks; |
| 55 | u32 count; |
| 56 | u32 bm; |
| 57 | } threshold; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
| 60 | struct acpi_processor_cx { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 61 | u8 valid; |
| 62 | u8 type; |
| 63 | u32 address; |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 64 | u8 space_id; |
| 65 | u8 index; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 66 | u32 latency; |
| 67 | u32 latency_ticks; |
| 68 | u32 power; |
| 69 | u32 usage; |
Dominik Brodowski | a3c6598 | 2006-06-24 19:37:00 -0400 | [diff] [blame] | 70 | u64 time; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | struct acpi_processor_cx_policy promotion; |
| 72 | struct acpi_processor_cx_policy demotion; |
| 73 | }; |
| 74 | |
| 75 | struct acpi_processor_power { |
| 76 | struct acpi_processor_cx *state; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 77 | unsigned long bm_check_timestamp; |
| 78 | u32 default_state; |
| 79 | u32 bm_activity; |
| 80 | int count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; |
Thomas Gleixner | 169a0ab | 2007-02-16 01:27:55 -0800 | [diff] [blame] | 82 | int timer_broadcast_on_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | }; |
| 84 | |
| 85 | /* Performance Management */ |
| 86 | |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 87 | struct acpi_psd_package { |
| 88 | acpi_integer num_entries; |
| 89 | acpi_integer revision; |
| 90 | acpi_integer domain; |
| 91 | acpi_integer coord_type; |
| 92 | acpi_integer num_processors; |
| 93 | } __attribute__ ((packed)); |
| 94 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | struct acpi_pct_register { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 96 | u8 descriptor; |
| 97 | u16 length; |
| 98 | u8 space_id; |
| 99 | u8 bit_width; |
| 100 | u8 bit_offset; |
| 101 | u8 reserved; |
| 102 | u64 address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | } __attribute__ ((packed)); |
| 104 | |
| 105 | struct acpi_processor_px { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | acpi_integer core_frequency; /* megahertz */ |
| 107 | acpi_integer power; /* milliWatts */ |
| 108 | acpi_integer transition_latency; /* microseconds */ |
| 109 | acpi_integer bus_master_latency; /* microseconds */ |
| 110 | acpi_integer control; /* control value */ |
| 111 | acpi_integer status; /* success indicator */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | }; |
| 113 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | struct acpi_processor_performance { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 115 | unsigned int state; |
| 116 | unsigned int platform_limit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | struct acpi_pct_register control_register; |
| 118 | struct acpi_pct_register status_register; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 119 | unsigned int state_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | struct acpi_processor_px *states; |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 121 | struct acpi_psd_package domain_info; |
| 122 | cpumask_t shared_cpu_map; |
| 123 | unsigned int shared_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | }; |
| 125 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | /* Throttling Control */ |
| 127 | |
| 128 | struct acpi_processor_tx { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 129 | u16 power; |
| 130 | u16 performance; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | struct acpi_processor_throttling { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 134 | int state; |
| 135 | u32 address; |
| 136 | u8 duty_offset; |
| 137 | u8 duty_width; |
| 138 | int state_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; |
| 140 | }; |
| 141 | |
| 142 | /* Limit Interface */ |
| 143 | |
| 144 | struct acpi_processor_lx { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 145 | int px; /* performace state */ |
| 146 | int tx; /* throttle level */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
| 149 | struct acpi_processor_limit { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 150 | struct acpi_processor_lx state; /* current limit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | struct acpi_processor_lx thermal; /* thermal limit */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 152 | struct acpi_processor_lx user; /* user limit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | }; |
| 154 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | struct acpi_processor_flags { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | u8 power:1; |
| 157 | u8 performance:1; |
| 158 | u8 throttling:1; |
| 159 | u8 limit:1; |
| 160 | u8 bm_control:1; |
| 161 | u8 bm_check:1; |
| 162 | u8 has_cst:1; |
| 163 | u8 power_setup_done:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | }; |
| 165 | |
| 166 | struct acpi_processor { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 167 | acpi_handle handle; |
| 168 | u32 acpi_id; |
| 169 | u32 id; |
| 170 | u32 pblk; |
| 171 | int performance_platform_limit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | struct acpi_processor_flags flags; |
| 173 | struct acpi_processor_power power; |
| 174 | struct acpi_processor_performance *performance; |
| 175 | struct acpi_processor_throttling throttling; |
| 176 | struct acpi_processor_limit limit; |
Venkatesh Pallipadi | 05131ec | 2005-10-23 16:31:00 -0400 | [diff] [blame] | 177 | |
| 178 | /* the _PDC objects for this processor, if any */ |
| 179 | struct acpi_object_list *pdc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | }; |
| 181 | |
| 182 | struct acpi_processor_errata { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 183 | u8 smp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | struct { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 185 | u8 throttle:1; |
| 186 | u8 fdma:1; |
| 187 | u8 reserved:6; |
| 188 | u32 bmisx; |
| 189 | } piix4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 192 | extern int acpi_processor_preregister_performance(struct |
| 193 | acpi_processor_performance |
| 194 | **performance); |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 195 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 196 | extern int acpi_processor_register_performance(struct acpi_processor_performance |
| 197 | *performance, unsigned int cpu); |
| 198 | extern void acpi_processor_unregister_performance(struct |
| 199 | acpi_processor_performance |
| 200 | *performance, |
| 201 | unsigned int cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | |
| 203 | /* note: this locks both the calling module and the processor module |
| 204 | if a _PPC object exists, rmmod is disallowed then */ |
| 205 | int acpi_processor_notify_smm(struct module *calling_module); |
| 206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | /* for communication between multiple parts of the processor kernel module */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 208 | extern struct acpi_processor *processors[NR_CPUS]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | extern struct acpi_processor_errata errata; |
| 210 | |
Venkatesh Pallipadi | 05131ec | 2005-10-23 16:31:00 -0400 | [diff] [blame] | 211 | void arch_acpi_processor_init_pdc(struct acpi_processor *pr); |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 212 | |
Venkatesh Pallipadi | 05131ec | 2005-10-23 16:31:00 -0400 | [diff] [blame] | 213 | #ifdef ARCH_HAS_POWER_INIT |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 214 | void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 215 | unsigned int cpu); |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 216 | int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 217 | struct acpi_processor_cx *cx, |
| 218 | struct acpi_power_register *reg); |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 219 | void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate); |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 220 | #else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 221 | static inline void acpi_processor_power_init_bm_check(struct |
| 222 | acpi_processor_flags |
| 223 | *flags, unsigned int cpu) |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 224 | { |
| 225 | flags->bm_check = 1; |
| 226 | return; |
| 227 | } |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 228 | static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 229 | struct acpi_processor_cx *cx, |
| 230 | struct acpi_power_register |
| 231 | *reg) |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 232 | { |
| 233 | return -1; |
| 234 | } |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 235 | static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx |
| 236 | *cstate) |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 237 | { |
| 238 | return; |
| 239 | } |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 240 | #endif |
| 241 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | /* in processor_perflib.c */ |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | #ifdef CONFIG_CPU_FREQ |
| 245 | void acpi_processor_ppc_init(void); |
| 246 | void acpi_processor_ppc_exit(void); |
| 247 | int acpi_processor_ppc_has_changed(struct acpi_processor *pr); |
| 248 | #else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 249 | static inline void acpi_processor_ppc_init(void) |
| 250 | { |
| 251 | return; |
| 252 | } |
| 253 | static inline void acpi_processor_ppc_exit(void) |
| 254 | { |
| 255 | return; |
| 256 | } |
| 257 | static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr) |
| 258 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 259 | static unsigned int printout = 1; |
| 260 | if (printout) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 261 | printk(KERN_WARNING |
| 262 | "Warning: Processor Platform Limit event detected, but not handled.\n"); |
| 263 | printk(KERN_WARNING |
| 264 | "Consider compiling CPUfreq support into your kernel.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 265 | printout = 0; |
| 266 | } |
| 267 | return 0; |
| 268 | } |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 269 | #endif /* CONFIG_CPU_FREQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | |
| 271 | /* in processor_throttling.c */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 272 | int acpi_processor_get_throttling_info(struct acpi_processor *pr); |
| 273 | int acpi_processor_set_throttling(struct acpi_processor *pr, int state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | extern struct file_operations acpi_processor_throttling_fops; |
| 275 | |
| 276 | /* in processor_idle.c */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 277 | int acpi_processor_power_init(struct acpi_processor *pr, |
| 278 | struct acpi_device *device); |
| 279 | int acpi_processor_cst_has_changed(struct acpi_processor *pr); |
| 280 | int acpi_processor_power_exit(struct acpi_processor *pr, |
| 281 | struct acpi_device *device); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 282 | |
| 283 | /* in processor_thermal.c */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 284 | int acpi_processor_get_limit_info(struct acpi_processor *pr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | extern struct file_operations acpi_processor_limit_fops; |
| 286 | |
| 287 | #ifdef CONFIG_CPU_FREQ |
| 288 | void acpi_thermal_cpufreq_init(void); |
| 289 | void acpi_thermal_cpufreq_exit(void); |
| 290 | #else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 291 | static inline void acpi_thermal_cpufreq_init(void) |
| 292 | { |
| 293 | return; |
| 294 | } |
| 295 | static inline void acpi_thermal_cpufreq_exit(void) |
| 296 | { |
| 297 | return; |
| 298 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | #endif |
| 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | #endif |