processor.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. #ifndef __ACPI_PROCESSOR_H
  2. #define __ACPI_PROCESSOR_H
  3. #include <linux/kernel.h>
  4. #include <linux/cpu.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. #define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
  15. #define ACPI_PSD_REV0_ENTRIES 5
  16. /*
  17. * Types of coordination defined in ACPI 3.0. Same macros can be used across
  18. * P, C and T states
  19. */
  20. #define DOMAIN_COORD_TYPE_SW_ALL 0xfc
  21. #define DOMAIN_COORD_TYPE_SW_ANY 0xfd
  22. #define DOMAIN_COORD_TYPE_HW_ALL 0xfe
  23. #define ACPI_CSTATE_SYSTEMIO (0)
  24. #define ACPI_CSTATE_FFH (1)
  25. /* Power Management */
  26. struct acpi_processor_cx;
  27. struct acpi_power_register {
  28. u8 descriptor;
  29. u16 length;
  30. u8 space_id;
  31. u8 bit_width;
  32. u8 bit_offset;
  33. u8 reserved;
  34. u64 address;
  35. } __attribute__ ((packed));
  36. struct acpi_processor_cx_policy {
  37. u32 count;
  38. struct acpi_processor_cx *state;
  39. struct {
  40. u32 time;
  41. u32 ticks;
  42. u32 count;
  43. u32 bm;
  44. } threshold;
  45. };
  46. struct acpi_processor_cx {
  47. u8 valid;
  48. u8 type;
  49. u32 address;
  50. u8 space_id;
  51. u8 index;
  52. u32 latency;
  53. u32 latency_ticks;
  54. u32 power;
  55. u32 usage;
  56. u64 time;
  57. struct acpi_processor_cx_policy promotion;
  58. struct acpi_processor_cx_policy demotion;
  59. };
  60. struct acpi_processor_power {
  61. struct acpi_processor_cx *state;
  62. unsigned long bm_check_timestamp;
  63. u32 default_state;
  64. u32 bm_activity;
  65. int count;
  66. struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
  67. int timer_broadcast_on_state;
  68. };
  69. /* Performance Management */
  70. struct acpi_psd_package {
  71. acpi_integer num_entries;
  72. acpi_integer revision;
  73. acpi_integer domain;
  74. acpi_integer coord_type;
  75. acpi_integer num_processors;
  76. } __attribute__ ((packed));
  77. struct acpi_pct_register {
  78. u8 descriptor;
  79. u16 length;
  80. u8 space_id;
  81. u8 bit_width;
  82. u8 bit_offset;
  83. u8 reserved;
  84. u64 address;
  85. } __attribute__ ((packed));
  86. struct acpi_processor_px {
  87. acpi_integer core_frequency; /* megahertz */
  88. acpi_integer power; /* milliWatts */
  89. acpi_integer transition_latency; /* microseconds */
  90. acpi_integer bus_master_latency; /* microseconds */
  91. acpi_integer control; /* control value */
  92. acpi_integer status; /* success indicator */
  93. };
  94. struct acpi_processor_performance {
  95. unsigned int state;
  96. unsigned int platform_limit;
  97. struct acpi_pct_register control_register;
  98. struct acpi_pct_register status_register;
  99. unsigned int state_count;
  100. struct acpi_processor_px *states;
  101. struct acpi_psd_package domain_info;
  102. cpumask_t shared_cpu_map;
  103. unsigned int shared_type;
  104. };
  105. /* Throttling Control */
  106. struct acpi_processor_tx {
  107. u16 power;
  108. u16 performance;
  109. };
  110. struct acpi_processor_throttling {
  111. int state;
  112. u32 address;
  113. u8 duty_offset;
  114. u8 duty_width;
  115. int state_count;
  116. struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
  117. };
  118. /* Limit Interface */
  119. struct acpi_processor_lx {
  120. int px; /* performace state */
  121. int tx; /* throttle level */
  122. };
  123. struct acpi_processor_limit {
  124. struct acpi_processor_lx state; /* current limit */
  125. struct acpi_processor_lx thermal; /* thermal limit */
  126. struct acpi_processor_lx user; /* user limit */
  127. };
  128. struct acpi_processor_flags {
  129. u8 power:1;
  130. u8 performance:1;
  131. u8 throttling:1;
  132. u8 limit:1;
  133. u8 bm_control:1;
  134. u8 bm_check:1;
  135. u8 has_cst:1;
  136. u8 power_setup_done:1;
  137. };
  138. struct acpi_processor {
  139. acpi_handle handle;
  140. u32 acpi_id;
  141. u32 id;
  142. u32 pblk;
  143. int performance_platform_limit;
  144. struct acpi_processor_flags flags;
  145. struct acpi_processor_power power;
  146. struct acpi_processor_performance *performance;
  147. struct acpi_processor_throttling throttling;
  148. struct acpi_processor_limit limit;
  149. /* the _PDC objects for this processor, if any */
  150. struct acpi_object_list *pdc;
  151. };
  152. struct acpi_processor_errata {
  153. u8 smp;
  154. struct {
  155. u8 throttle:1;
  156. u8 fdma:1;
  157. u8 reserved:6;
  158. u32 bmisx;
  159. } piix4;
  160. };
  161. extern int acpi_processor_preregister_performance(
  162. struct acpi_processor_performance **performance);
  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. /* note: this locks both the calling module and the processor module
  170. if a _PPC object exists, rmmod is disallowed then */
  171. int acpi_processor_notify_smm(struct module *calling_module);
  172. /* for communication between multiple parts of the processor kernel module */
  173. extern struct acpi_processor *processors[NR_CPUS];
  174. extern struct acpi_processor_errata errata;
  175. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  176. #ifdef ARCH_HAS_POWER_INIT
  177. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  178. unsigned int cpu);
  179. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  180. struct acpi_processor_cx *cx, struct acpi_power_register *reg);
  181. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  182. #else
  183. static inline void acpi_processor_power_init_bm_check(struct
  184. acpi_processor_flags
  185. *flags, unsigned int cpu)
  186. {
  187. flags->bm_check = 1;
  188. return;
  189. }
  190. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  191. struct acpi_processor_cx *cx, struct acpi_power_register *reg)
  192. {
  193. return -1;
  194. }
  195. static inline void acpi_processor_ffh_cstate_enter(
  196. struct acpi_processor_cx *cstate)
  197. {
  198. return;
  199. }
  200. #endif
  201. /* in processor_perflib.c */
  202. #ifdef CONFIG_CPU_FREQ
  203. void acpi_processor_ppc_init(void);
  204. void acpi_processor_ppc_exit(void);
  205. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  206. #else
  207. static inline void acpi_processor_ppc_init(void)
  208. {
  209. return;
  210. }
  211. static inline void acpi_processor_ppc_exit(void)
  212. {
  213. return;
  214. }
  215. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  216. {
  217. static unsigned int printout = 1;
  218. if (printout) {
  219. printk(KERN_WARNING
  220. "Warning: Processor Platform Limit event detected, but not handled.\n");
  221. printk(KERN_WARNING
  222. "Consider compiling CPUfreq support into your kernel.\n");
  223. printout = 0;
  224. }
  225. return 0;
  226. }
  227. #endif /* CONFIG_CPU_FREQ */
  228. /* in processor_throttling.c */
  229. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  230. int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  231. extern struct file_operations acpi_processor_throttling_fops;
  232. /* in processor_idle.c */
  233. int acpi_processor_power_init(struct acpi_processor *pr,
  234. struct acpi_device *device);
  235. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  236. int acpi_processor_power_exit(struct acpi_processor *pr,
  237. struct acpi_device *device);
  238. /* in processor_thermal.c */
  239. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  240. extern struct file_operations acpi_processor_limit_fops;
  241. #ifdef CONFIG_CPU_FREQ
  242. void acpi_thermal_cpufreq_init(void);
  243. void acpi_thermal_cpufreq_exit(void);
  244. #else
  245. static inline void acpi_thermal_cpufreq_init(void)
  246. {
  247. return;
  248. }
  249. static inline void acpi_thermal_cpufreq_exit(void)
  250. {
  251. return;
  252. }
  253. #endif
  254. #endif