processor.h 6.4 KB

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