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