1 #ifndef __ACPI_PROCESSOR_H 2 #define __ACPI_PROCESSOR_H 3 4 #include <linux/kernel.h> 5 6 #include <asm/acpi.h> 7 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 18 #define ACPI_PDC_REVISION_ID 0x1 19 20 /* Power Management */ 21 22 struct acpi_processor_cx; 23 24 struct acpi_power_register { 25 u8 descriptor; 26 u16 length; 27 u8 space_id; 28 u8 bit_width; 29 u8 bit_offset; 30 u8 reserved; 31 u64 address; 32 } __attribute__ ((packed)); 33 34 struct acpi_processor_cx_policy { 35 u32 count; 36 struct acpi_processor_cx *state; 37 struct { 38 u32 time; 39 u32 ticks; 40 u32 count; 41 u32 bm; 42 } threshold; 43 }; 44 45 struct acpi_processor_cx { 46 u8 valid; 47 u8 type; 48 u32 address; 49 u32 latency; 50 u32 latency_ticks; 51 u32 power; 52 u32 usage; 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; 59 unsigned long bm_check_timestamp; 60 u32 default_state; 61 u32 bm_activity; 62 int count; 63 struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; 64 }; 65 66 /* Performance Management */ 67 68 struct acpi_pct_register { 69 u8 descriptor; 70 u16 length; 71 u8 space_id; 72 u8 bit_width; 73 u8 bit_offset; 74 u8 reserved; 75 u64 address; 76 } __attribute__ ((packed)); 77 78 struct acpi_processor_px { 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 */ 85 }; 86 87 struct acpi_processor_performance { 88 unsigned int state; 89 unsigned int platform_limit; 90 struct acpi_pct_register control_register; 91 struct acpi_pct_register status_register; 92 unsigned int state_count; 93 struct acpi_processor_px *states; 94 95 }; 96 97 /* Throttling Control */ 98 99 struct acpi_processor_tx { 100 u16 power; 101 u16 performance; 102 }; 103 104 struct acpi_processor_throttling { 105 int state; 106 u32 address; 107 u8 duty_offset; 108 u8 duty_width; 109 int state_count; 110 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; 111 }; 112 113 /* Limit Interface */ 114 115 struct acpi_processor_lx { 116 int px; /* performace state */ 117 int tx; /* throttle level */ 118 }; 119 120 struct acpi_processor_limit { 121 struct acpi_processor_lx state; /* current limit */ 122 struct acpi_processor_lx thermal; /* thermal limit */ 123 struct acpi_processor_lx user; /* user limit */ 124 }; 125 126 struct acpi_processor_flags { 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; 135 }; 136 137 struct acpi_processor { 138 acpi_handle handle; 139 u32 acpi_id; 140 u32 id; 141 u32 pblk; 142 int performance_platform_limit; 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; 148 149 /* the _PDC objects for this processor, if any */ 150 struct acpi_object_list *pdc; 151 }; 152 153 struct acpi_processor_errata { 154 u8 smp; 155 struct { 156 u8 throttle:1; 157 u8 fdma:1; 158 u8 reserved:6; 159 u32 bmisx; 160 } piix4; 161 }; 162 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); 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 174 /* for communication between multiple parts of the processor kernel module */ 175 extern struct acpi_processor *processors[NR_CPUS]; 176 extern struct acpi_processor_errata errata; 177 178 void arch_acpi_processor_init_pdc(struct acpi_processor *pr); 179 180 #ifdef ARCH_HAS_POWER_INIT 181 void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, 182 unsigned int cpu); 183 #else 184 static inline void acpi_processor_power_init_bm_check(struct 185 acpi_processor_flags 186 *flags, unsigned int cpu) 187 { 188 flags->bm_check = 1; 189 return; 190 } 191 #endif 192 193 /* in processor_perflib.c */ 194 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 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 { 210 static unsigned int printout = 1; 211 if (printout) { 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"); 216 printout = 0; 217 } 218 return 0; 219 } 220 #endif /* CONFIG_CPU_FREQ */ 221 222 /* in processor_throttling.c */ 223 int acpi_processor_get_throttling_info(struct acpi_processor *pr); 224 int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 225 extern struct file_operations acpi_processor_throttling_fops; 226 227 /* in processor_idle.c */ 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); 233 234 /* in processor_thermal.c */ 235 int acpi_processor_get_limit_info(struct acpi_processor *pr); 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 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 } 250 #endif 251 252 #endif 253