processor.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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 <linux/thermal.h>
  7. #include <asm/acpi.h>
  8. #define ACPI_PROCESSOR_BUSY_METRIC 10
  9. #define ACPI_PROCESSOR_MAX_POWER 8
  10. #define ACPI_PROCESSOR_MAX_C2_LATENCY 100
  11. #define ACPI_PROCESSOR_MAX_C3_LATENCY 1000
  12. #define ACPI_PROCESSOR_MAX_THROTTLING 16
  13. #define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */
  14. #define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4
  15. #define ACPI_PDC_REVISION_ID 0x1
  16. #define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
  17. #define ACPI_PSD_REV0_ENTRIES 5
  18. #define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
  19. #define ACPI_TSD_REV0_ENTRIES 5
  20. /*
  21. * Types of coordination defined in ACPI 3.0. Same macros can be used across
  22. * P, C and T states
  23. */
  24. #define DOMAIN_COORD_TYPE_SW_ALL 0xfc
  25. #define DOMAIN_COORD_TYPE_SW_ANY 0xfd
  26. #define DOMAIN_COORD_TYPE_HW_ALL 0xfe
  27. #define ACPI_CSTATE_SYSTEMIO (0)
  28. #define ACPI_CSTATE_FFH (1)
  29. /* Power Management */
  30. struct acpi_processor_cx;
  31. struct acpi_power_register {
  32. u8 descriptor;
  33. u16 length;
  34. u8 space_id;
  35. u8 bit_width;
  36. u8 bit_offset;
  37. u8 reserved;
  38. u64 address;
  39. } __attribute__ ((packed));
  40. struct acpi_processor_cx_policy {
  41. u32 count;
  42. struct acpi_processor_cx *state;
  43. struct {
  44. u32 time;
  45. u32 ticks;
  46. u32 count;
  47. u32 bm;
  48. } threshold;
  49. };
  50. struct acpi_processor_cx {
  51. u8 valid;
  52. u8 type;
  53. u32 address;
  54. u8 space_id;
  55. u8 index;
  56. u32 latency;
  57. u32 latency_ticks;
  58. u32 power;
  59. u32 usage;
  60. u64 time;
  61. struct acpi_processor_cx_policy promotion;
  62. struct acpi_processor_cx_policy demotion;
  63. };
  64. struct acpi_processor_power {
  65. struct cpuidle_device dev;
  66. struct acpi_processor_cx *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. struct thermal_cooling_device *cdev;
  191. /* the _PDC objects for this processor, if any */
  192. struct acpi_object_list *pdc;
  193. };
  194. struct acpi_processor_errata {
  195. u8 smp;
  196. struct {
  197. u8 throttle:1;
  198. u8 fdma:1;
  199. u8 reserved:6;
  200. u32 bmisx;
  201. } piix4;
  202. };
  203. extern int acpi_processor_preregister_performance(struct
  204. acpi_processor_performance
  205. *performance);
  206. extern int acpi_processor_register_performance(struct acpi_processor_performance
  207. *performance, unsigned int cpu);
  208. extern void acpi_processor_unregister_performance(struct
  209. acpi_processor_performance
  210. *performance,
  211. unsigned int cpu);
  212. /* note: this locks both the calling module and the processor module
  213. if a _PPC object exists, rmmod is disallowed then */
  214. int acpi_processor_notify_smm(struct module *calling_module);
  215. /* for communication between multiple parts of the processor kernel module */
  216. extern struct acpi_processor *processors[NR_CPUS];
  217. extern struct acpi_processor_errata errata;
  218. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  219. #ifdef ARCH_HAS_POWER_INIT
  220. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  221. unsigned int cpu);
  222. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  223. struct acpi_processor_cx *cx,
  224. struct acpi_power_register *reg);
  225. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  226. #else
  227. static inline void acpi_processor_power_init_bm_check(struct
  228. acpi_processor_flags
  229. *flags, unsigned int cpu)
  230. {
  231. flags->bm_check = 1;
  232. return;
  233. }
  234. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  235. struct acpi_processor_cx *cx,
  236. struct acpi_power_register
  237. *reg)
  238. {
  239. return -1;
  240. }
  241. static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
  242. *cstate)
  243. {
  244. return;
  245. }
  246. #endif
  247. /* in processor_perflib.c */
  248. #ifdef CONFIG_CPU_FREQ
  249. void acpi_processor_ppc_init(void);
  250. void acpi_processor_ppc_exit(void);
  251. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  252. #else
  253. static inline void acpi_processor_ppc_init(void)
  254. {
  255. return;
  256. }
  257. static inline void acpi_processor_ppc_exit(void)
  258. {
  259. return;
  260. }
  261. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  262. {
  263. static unsigned int printout = 1;
  264. if (printout) {
  265. printk(KERN_WARNING
  266. "Warning: Processor Platform Limit event detected, but not handled.\n");
  267. printk(KERN_WARNING
  268. "Consider compiling CPUfreq support into your kernel.\n");
  269. printout = 0;
  270. }
  271. return 0;
  272. }
  273. #endif /* CONFIG_CPU_FREQ */
  274. /* in processor_throttling.c */
  275. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  276. extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  277. extern struct file_operations acpi_processor_throttling_fops;
  278. /* in processor_idle.c */
  279. int acpi_processor_power_init(struct acpi_processor *pr,
  280. struct acpi_device *device);
  281. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  282. int acpi_processor_power_exit(struct acpi_processor *pr,
  283. struct acpi_device *device);
  284. int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
  285. int acpi_processor_resume(struct acpi_device * device);
  286. extern struct cpuidle_driver acpi_idle_driver;
  287. /* in processor_thermal.c */
  288. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  289. extern struct file_operations acpi_processor_limit_fops;
  290. extern struct thermal_cooling_device_ops processor_cooling_ops;
  291. #ifdef CONFIG_CPU_FREQ
  292. void acpi_thermal_cpufreq_init(void);
  293. void acpi_thermal_cpufreq_exit(void);
  294. #else
  295. static inline void acpi_thermal_cpufreq_init(void)
  296. {
  297. return;
  298. }
  299. static inline void acpi_thermal_cpufreq_exit(void)
  300. {
  301. return;
  302. }
  303. #endif
  304. #endif