processor.h 6.3 KB

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