processor.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  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(struct
  162. acpi_processor_performance
  163. **performance);
  164. extern int acpi_processor_register_performance(struct acpi_processor_performance
  165. *performance, unsigned int cpu);
  166. extern void acpi_processor_unregister_performance(struct
  167. acpi_processor_performance
  168. *performance,
  169. unsigned int cpu);
  170. /* note: this locks both the calling module and the processor module
  171. if a _PPC object exists, rmmod is disallowed then */
  172. int acpi_processor_notify_smm(struct module *calling_module);
  173. /* for communication between multiple parts of the processor kernel module */
  174. extern struct acpi_processor *processors[NR_CPUS];
  175. extern struct acpi_processor_errata errata;
  176. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  177. #ifdef ARCH_HAS_POWER_INIT
  178. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  179. unsigned int cpu);
  180. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  181. struct acpi_processor_cx *cx,
  182. struct acpi_power_register *reg);
  183. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  184. #else
  185. static inline void acpi_processor_power_init_bm_check(struct
  186. acpi_processor_flags
  187. *flags, unsigned int cpu)
  188. {
  189. flags->bm_check = 1;
  190. return;
  191. }
  192. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  193. struct acpi_processor_cx *cx,
  194. struct acpi_power_register
  195. *reg)
  196. {
  197. return -1;
  198. }
  199. static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
  200. *cstate)
  201. {
  202. return;
  203. }
  204. #endif
  205. /* in processor_perflib.c */
  206. #ifdef CONFIG_CPU_FREQ
  207. void acpi_processor_ppc_init(void);
  208. void acpi_processor_ppc_exit(void);
  209. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  210. #else
  211. static inline void acpi_processor_ppc_init(void)
  212. {
  213. return;
  214. }
  215. static inline void acpi_processor_ppc_exit(void)
  216. {
  217. return;
  218. }
  219. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  220. {
  221. static unsigned int printout = 1;
  222. if (printout) {
  223. printk(KERN_WARNING
  224. "Warning: Processor Platform Limit event detected, but not handled.\n");
  225. printk(KERN_WARNING
  226. "Consider compiling CPUfreq support into your kernel.\n");
  227. printout = 0;
  228. }
  229. return 0;
  230. }
  231. #endif /* CONFIG_CPU_FREQ */
  232. /* in processor_throttling.c */
  233. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  234. int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  235. extern struct file_operations acpi_processor_throttling_fops;
  236. /* in processor_idle.c */
  237. int acpi_processor_power_init(struct acpi_processor *pr,
  238. struct acpi_device *device);
  239. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  240. int acpi_processor_power_exit(struct acpi_processor *pr,
  241. struct acpi_device *device);
  242. /* in processor_thermal.c */
  243. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  244. extern struct file_operations acpi_processor_limit_fops;
  245. #ifdef CONFIG_CPU_FREQ
  246. void acpi_thermal_cpufreq_init(void);
  247. void acpi_thermal_cpufreq_exit(void);
  248. #else
  249. static inline void acpi_thermal_cpufreq_init(void)
  250. {
  251. return;
  252. }
  253. static inline void acpi_thermal_cpufreq_exit(void)
  254. {
  255. return;
  256. }
  257. #endif
  258. #endif