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