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