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