processor.h 8.9 KB

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