processor.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #ifndef __ACPI_PROCESSOR_H
  2. #define __ACPI_PROCESSOR_H
  3. #include <linux/kernel.h>
  4. #include <asm/acpi.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. #define ACPI_PDC_REVISION_ID 0x1
  13. /* Power Management */
  14. struct acpi_processor_cx;
  15. struct acpi_power_register {
  16. u8 descriptor;
  17. u16 length;
  18. u8 space_id;
  19. u8 bit_width;
  20. u8 bit_offset;
  21. u8 reserved;
  22. u64 address;
  23. } __attribute__ ((packed));
  24. struct acpi_processor_cx_policy {
  25. u32 count;
  26. struct acpi_processor_cx *state;
  27. struct {
  28. u32 time;
  29. u32 ticks;
  30. u32 count;
  31. u32 bm;
  32. } threshold;
  33. };
  34. struct acpi_processor_cx {
  35. u8 valid;
  36. u8 type;
  37. u32 address;
  38. u32 latency;
  39. u32 latency_ticks;
  40. u32 power;
  41. u32 usage;
  42. struct acpi_processor_cx_policy promotion;
  43. struct acpi_processor_cx_policy demotion;
  44. };
  45. struct acpi_processor_power {
  46. struct acpi_processor_cx *state;
  47. unsigned long bm_check_timestamp;
  48. u32 default_state;
  49. u32 bm_activity;
  50. int count;
  51. struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
  52. };
  53. /* Performance Management */
  54. struct acpi_pct_register {
  55. u8 descriptor;
  56. u16 length;
  57. u8 space_id;
  58. u8 bit_width;
  59. u8 bit_offset;
  60. u8 reserved;
  61. u64 address;
  62. } __attribute__ ((packed));
  63. struct acpi_processor_px {
  64. acpi_integer core_frequency; /* megahertz */
  65. acpi_integer power; /* milliWatts */
  66. acpi_integer transition_latency; /* microseconds */
  67. acpi_integer bus_master_latency; /* microseconds */
  68. acpi_integer control; /* control value */
  69. acpi_integer status; /* success indicator */
  70. };
  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. };
  79. /* Throttling Control */
  80. struct acpi_processor_tx {
  81. u16 power;
  82. u16 performance;
  83. };
  84. struct acpi_processor_throttling {
  85. int state;
  86. u32 address;
  87. u8 duty_offset;
  88. u8 duty_width;
  89. int state_count;
  90. struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
  91. };
  92. /* Limit Interface */
  93. struct acpi_processor_lx {
  94. int px; /* performace state */
  95. int tx; /* throttle level */
  96. };
  97. struct acpi_processor_limit {
  98. struct acpi_processor_lx state; /* current limit */
  99. struct acpi_processor_lx thermal; /* thermal limit */
  100. struct acpi_processor_lx user; /* user limit */
  101. };
  102. struct acpi_processor_flags {
  103. u8 power:1;
  104. u8 performance:1;
  105. u8 throttling:1;
  106. u8 limit:1;
  107. u8 bm_control:1;
  108. u8 bm_check:1;
  109. u8 has_cst:1;
  110. u8 power_setup_done:1;
  111. };
  112. struct acpi_processor {
  113. acpi_handle handle;
  114. u32 acpi_id;
  115. u32 id;
  116. u32 pblk;
  117. int performance_platform_limit;
  118. struct acpi_processor_flags flags;
  119. struct acpi_processor_power power;
  120. struct acpi_processor_performance *performance;
  121. struct acpi_processor_throttling throttling;
  122. struct acpi_processor_limit limit;
  123. /* the _PDC objects for this processor, if any */
  124. struct acpi_object_list *pdc;
  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(struct acpi_processor_performance
  136. *performance, unsigned int cpu);
  137. extern void acpi_processor_unregister_performance(struct
  138. acpi_processor_performance
  139. *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. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  148. #ifdef ARCH_HAS_POWER_INIT
  149. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  150. unsigned int cpu);
  151. #else
  152. static inline void acpi_processor_power_init_bm_check(struct
  153. acpi_processor_flags
  154. *flags, unsigned int cpu)
  155. {
  156. flags->bm_check = 1;
  157. return;
  158. }
  159. #endif
  160. /* in processor_perflib.c */
  161. #ifdef CONFIG_CPU_FREQ
  162. void acpi_processor_ppc_init(void);
  163. void acpi_processor_ppc_exit(void);
  164. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  165. #else
  166. static inline void acpi_processor_ppc_init(void)
  167. {
  168. return;
  169. }
  170. static inline void acpi_processor_ppc_exit(void)
  171. {
  172. return;
  173. }
  174. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  175. {
  176. static unsigned int printout = 1;
  177. if (printout) {
  178. printk(KERN_WARNING
  179. "Warning: Processor Platform Limit event detected, but not handled.\n");
  180. printk(KERN_WARNING
  181. "Consider compiling CPUfreq support into your kernel.\n");
  182. printout = 0;
  183. }
  184. return 0;
  185. }
  186. #endif /* CONFIG_CPU_FREQ */
  187. /* in processor_throttling.c */
  188. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  189. int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  190. extern struct file_operations acpi_processor_throttling_fops;
  191. /* in processor_idle.c */
  192. int acpi_processor_power_init(struct acpi_processor *pr,
  193. struct acpi_device *device);
  194. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  195. int acpi_processor_power_exit(struct acpi_processor *pr,
  196. struct acpi_device *device);
  197. /* in processor_thermal.c */
  198. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  199. extern struct file_operations acpi_processor_limit_fops;
  200. #ifdef CONFIG_CPU_FREQ
  201. void acpi_thermal_cpufreq_init(void);
  202. void acpi_thermal_cpufreq_exit(void);
  203. #else
  204. static inline void acpi_thermal_cpufreq_init(void)
  205. {
  206. return;
  207. }
  208. static inline void acpi_thermal_cpufreq_exit(void)
  209. {
  210. return;
  211. }
  212. #endif
  213. #endif