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