processor.h 8.5 KB

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