processor.h 7.0 KB

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