processor.h 5.7 KB

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