processor.h 6.4 KB

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