processor.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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,
  147. int state);
  148. u32 address;
  149. u8 duty_offset;
  150. u8 duty_width;
  151. struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
  152. };
  153. /* Limit Interface */
  154. struct acpi_processor_lx {
  155. int px; /* performace state */
  156. int tx; /* throttle level */
  157. };
  158. struct acpi_processor_limit {
  159. struct acpi_processor_lx state; /* current limit */
  160. struct acpi_processor_lx thermal; /* thermal limit */
  161. struct acpi_processor_lx user; /* user limit */
  162. };
  163. struct acpi_processor_flags {
  164. u8 power:1;
  165. u8 performance:1;
  166. u8 throttling:1;
  167. u8 limit:1;
  168. u8 bm_control:1;
  169. u8 bm_check:1;
  170. u8 has_cst:1;
  171. u8 power_setup_done:1;
  172. };
  173. struct acpi_processor {
  174. acpi_handle handle;
  175. u32 acpi_id;
  176. u32 id;
  177. u32 pblk;
  178. int performance_platform_limit;
  179. int throttling_platform_limit;
  180. /* 0 - states 0..n-th state available */
  181. struct acpi_processor_flags flags;
  182. struct acpi_processor_power power;
  183. struct acpi_processor_performance *performance;
  184. struct acpi_processor_throttling throttling;
  185. struct acpi_processor_limit limit;
  186. /* the _PDC objects for this processor, if any */
  187. struct acpi_object_list *pdc;
  188. };
  189. struct acpi_processor_errata {
  190. u8 smp;
  191. struct {
  192. u8 throttle:1;
  193. u8 fdma:1;
  194. u8 reserved:6;
  195. u32 bmisx;
  196. } piix4;
  197. };
  198. extern int acpi_processor_preregister_performance(struct
  199. acpi_processor_performance
  200. *performance);
  201. extern int acpi_processor_register_performance(struct acpi_processor_performance
  202. *performance, unsigned int cpu);
  203. extern void acpi_processor_unregister_performance(struct
  204. acpi_processor_performance
  205. *performance,
  206. unsigned int cpu);
  207. /* note: this locks both the calling module and the processor module
  208. if a _PPC object exists, rmmod is disallowed then */
  209. int acpi_processor_notify_smm(struct module *calling_module);
  210. /* for communication between multiple parts of the processor kernel module */
  211. extern struct acpi_processor *processors[NR_CPUS];
  212. extern struct acpi_processor_errata errata;
  213. void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
  214. #ifdef ARCH_HAS_POWER_INIT
  215. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  216. unsigned int cpu);
  217. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  218. struct acpi_processor_cx *cx,
  219. struct acpi_power_register *reg);
  220. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  221. #else
  222. static inline void acpi_processor_power_init_bm_check(struct
  223. acpi_processor_flags
  224. *flags, unsigned int cpu)
  225. {
  226. flags->bm_check = 1;
  227. return;
  228. }
  229. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  230. struct acpi_processor_cx *cx,
  231. struct acpi_power_register
  232. *reg)
  233. {
  234. return -1;
  235. }
  236. static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
  237. *cstate)
  238. {
  239. return;
  240. }
  241. #endif
  242. /* in processor_perflib.c */
  243. #ifdef CONFIG_CPU_FREQ
  244. void acpi_processor_ppc_init(void);
  245. void acpi_processor_ppc_exit(void);
  246. int acpi_processor_ppc_has_changed(struct acpi_processor *pr);
  247. #else
  248. static inline void acpi_processor_ppc_init(void)
  249. {
  250. return;
  251. }
  252. static inline void acpi_processor_ppc_exit(void)
  253. {
  254. return;
  255. }
  256. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
  257. {
  258. static unsigned int printout = 1;
  259. if (printout) {
  260. printk(KERN_WARNING
  261. "Warning: Processor Platform Limit event detected, but not handled.\n");
  262. printk(KERN_WARNING
  263. "Consider compiling CPUfreq support into your kernel.\n");
  264. printout = 0;
  265. }
  266. return 0;
  267. }
  268. #endif /* CONFIG_CPU_FREQ */
  269. /* in processor_throttling.c */
  270. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  271. extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
  272. extern struct file_operations acpi_processor_throttling_fops;
  273. /* in processor_idle.c */
  274. int acpi_processor_power_init(struct acpi_processor *pr,
  275. struct acpi_device *device);
  276. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  277. int acpi_processor_power_exit(struct acpi_processor *pr,
  278. struct acpi_device *device);
  279. int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
  280. int acpi_processor_resume(struct acpi_device * device);
  281. /* in processor_thermal.c */
  282. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  283. extern struct file_operations acpi_processor_limit_fops;
  284. #ifdef CONFIG_CPU_FREQ
  285. void acpi_thermal_cpufreq_init(void);
  286. void acpi_thermal_cpufreq_exit(void);
  287. #else
  288. static inline void acpi_thermal_cpufreq_init(void)
  289. {
  290. return;
  291. }
  292. static inline void acpi_thermal_cpufreq_exit(void)
  293. {
  294. return;
  295. }
  296. #endif
  297. #endif