processor.h 8.2 KB

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