processor.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. };
  54. /* Performance Management */
  55. struct acpi_pct_register {
  56. u8 descriptor;
  57. u16 length;
  58. u8 space_id;
  59. u8 bit_width;
  60. u8 bit_offset;
  61. u8 reserved;
  62. u64 address;
  63. } __attribute__ ((packed));
  64. struct acpi_processor_px {
  65. acpi_integer core_frequency; /* megahertz */
  66. acpi_integer power; /* milliWatts */
  67. acpi_integer transition_latency; /* microseconds */
  68. acpi_integer bus_master_latency; /* microseconds */
  69. acpi_integer control; /* control value */
  70. acpi_integer status; /* success indicator */
  71. };
  72. struct acpi_processor_performance {
  73. unsigned int state;
  74. unsigned int platform_limit;
  75. struct acpi_pct_register control_register;
  76. struct acpi_pct_register status_register;
  77. unsigned int state_count;
  78. struct acpi_processor_px *states;
  79. };
  80. /* Throttling Control */
  81. struct acpi_processor_tx {
  82. u16 power;
  83. u16 performance;
  84. };
  85. struct acpi_processor_throttling {
  86. int state;
  87. u32 address;
  88. u8 duty_offset;
  89. u8 duty_width;
  90. int state_count;
  91. struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
  92. };
  93. /* Limit Interface */
  94. struct acpi_processor_lx {
  95. int px; /* performace state */
  96. int tx; /* throttle level */
  97. };
  98. struct acpi_processor_limit {
  99. struct acpi_processor_lx state; /* current limit */
  100. struct acpi_processor_lx thermal; /* thermal limit */
  101. struct acpi_processor_lx user; /* user limit */
  102. };
  103. struct acpi_processor_flags {
  104. u8 power:1;
  105. u8 performance:1;
  106. u8 throttling:1;
  107. u8 limit:1;
  108. u8 bm_control:1;
  109. u8 bm_check:1;
  110. u8 has_cst:1;
  111. u8 power_setup_done:1;
  112. };
  113. struct acpi_processor {
  114. acpi_handle handle;
  115. u32 acpi_id;
  116. u32 id;
  117. u32 pblk;
  118. int performance_platform_limit;
  119. struct acpi_processor_flags flags;
  120. struct acpi_processor_power power;
  121. struct acpi_processor_performance *performance;
  122. struct acpi_processor_throttling throttling;
  123. struct acpi_processor_limit limit;
  124. /* the _PDC objects for this processor, if any */
  125. struct acpi_object_list *pdc;
  126. };
  127. struct acpi_processor_errata {
  128. u8 smp;
  129. struct {
  130. u8 throttle:1;
  131. u8 fdma:1;
  132. u8 reserved:6;
  133. u32 bmisx;
  134. } piix4;
  135. };
  136. extern int acpi_processor_register_performance(struct acpi_processor_performance
  137. *performance, unsigned int cpu);
  138. extern void acpi_processor_unregister_performance(struct
  139. acpi_processor_performance
  140. *performance,
  141. unsigned int cpu);
  142. /* note: this locks both the calling module and the processor module
  143. if a _PPC object exists, rmmod is disallowed then */
  144. int acpi_processor_notify_smm(struct module *calling_module);
  145. /* for communication between multiple parts of the processor kernel module */
  146. extern struct acpi_processor *processors[NR_CPUS];
  147. extern struct acpi_processor_errata errata;
  148. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  149. #ifdef ARCH_HAS_POWER_INIT
  150. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  151. unsigned int cpu);
  152. #else
  153. static inline void acpi_processor_power_init_bm_check(struct
  154. acpi_processor_flags
  155. *flags, unsigned int cpu)
  156. {
  157. flags->bm_check = 1;
  158. return;
  159. }
  160. #endif
  161. /* in processor_perflib.c */
  162. #ifdef CONFIG_CPU_FREQ
  163. void acpi_processor_ppc_init(void);
  164. void acpi_processor_ppc_exit(void);
  165. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  166. #else
  167. static inline void acpi_processor_ppc_init(void)
  168. {
  169. return;
  170. }
  171. static inline void acpi_processor_ppc_exit(void)
  172. {
  173. return;
  174. }
  175. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  176. {
  177. static unsigned int printout = 1;
  178. if (printout) {
  179. printk(KERN_WARNING
  180. "Warning: Processor Platform Limit event detected, but not handled.\n");
  181. printk(KERN_WARNING
  182. "Consider compiling CPUfreq support into your kernel.\n");
  183. printout = 0;
  184. }
  185. return 0;
  186. }
  187. #endif /* CONFIG_CPU_FREQ */
  188. /* in processor_throttling.c */
  189. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  190. int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  191. ssize_t acpi_processor_write_throttling(struct file *file,
  192. const char __user * buffer,
  193. size_t count, loff_t * data);
  194. extern struct file_operations acpi_processor_throttling_fops;
  195. /* in processor_idle.c */
  196. int acpi_processor_power_init(struct acpi_processor *pr,
  197. struct acpi_device *device);
  198. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  199. int acpi_processor_power_exit(struct acpi_processor *pr,
  200. struct acpi_device *device);
  201. /* in processor_thermal.c */
  202. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  203. ssize_t acpi_processor_write_limit(struct file *file,
  204. const char __user * buffer,
  205. size_t count, loff_t * data);
  206. extern struct file_operations acpi_processor_limit_fops;
  207. #ifdef CONFIG_CPU_FREQ
  208. void acpi_thermal_cpufreq_init(void);
  209. void acpi_thermal_cpufreq_exit(void);
  210. #else
  211. static inline void acpi_thermal_cpufreq_init(void)
  212. {
  213. return;
  214. }
  215. static inline void acpi_thermal_cpufreq_exit(void)
  216. {
  217. return;
  218. }
  219. #endif
  220. #endif