processor.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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. u64 num_entries;
  79. u64 revision;
  80. u64 domain;
  81. u64 coord_type;
  82. u64 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. u64 core_frequency; /* megahertz */
  95. u64 power; /* milliWatts */
  96. u64 transition_latency; /* microseconds */
  97. u64 bus_master_latency; /* microseconds */
  98. u64 control; /* control value */
  99. u64 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. u64 num_entries;
  115. u64 revision;
  116. u64 domain;
  117. u64 coord_type;
  118. u64 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. u64 freqpercentage; /* */
  131. u64 power; /* milliWatts */
  132. u64 transition_latency; /* microseconds */
  133. u64 control; /* control value */
  134. u64 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, bool force);
  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. };
  196. struct acpi_processor_errata {
  197. u8 smp;
  198. struct {
  199. u8 throttle:1;
  200. u8 fdma:1;
  201. u8 reserved:6;
  202. u32 bmisx;
  203. } piix4;
  204. };
  205. extern int acpi_processor_preregister_performance(struct
  206. acpi_processor_performance
  207. __percpu *performance);
  208. extern int acpi_processor_register_performance(struct acpi_processor_performance
  209. *performance, unsigned int cpu);
  210. extern void acpi_processor_unregister_performance(struct
  211. acpi_processor_performance
  212. *performance,
  213. unsigned int cpu);
  214. /* note: this locks both the calling module and the processor module
  215. if a _PPC object exists, rmmod is disallowed then */
  216. int acpi_processor_notify_smm(struct module *calling_module);
  217. /* for communication between multiple parts of the processor kernel module */
  218. DECLARE_PER_CPU(struct acpi_processor *, processors);
  219. extern struct acpi_processor_errata errata;
  220. #ifdef ARCH_HAS_POWER_INIT
  221. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  222. unsigned int cpu);
  223. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  224. struct acpi_processor_cx *cx,
  225. struct acpi_power_register *reg);
  226. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  227. #else
  228. static inline void acpi_processor_power_init_bm_check(struct
  229. acpi_processor_flags
  230. *flags, unsigned int cpu)
  231. {
  232. flags->bm_check = 1;
  233. return;
  234. }
  235. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  236. struct acpi_processor_cx *cx,
  237. struct acpi_power_register
  238. *reg)
  239. {
  240. return -1;
  241. }
  242. static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
  243. *cstate)
  244. {
  245. return;
  246. }
  247. #endif
  248. /* in processor_perflib.c */
  249. #ifdef CONFIG_CPU_FREQ
  250. void acpi_processor_ppc_init(void);
  251. void acpi_processor_ppc_exit(void);
  252. int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag);
  253. extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit);
  254. #else
  255. static inline void acpi_processor_ppc_init(void)
  256. {
  257. return;
  258. }
  259. static inline void acpi_processor_ppc_exit(void)
  260. {
  261. return;
  262. }
  263. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
  264. int event_flag)
  265. {
  266. static unsigned int printout = 1;
  267. if (printout) {
  268. printk(KERN_WARNING
  269. "Warning: Processor Platform Limit event detected, but not handled.\n");
  270. printk(KERN_WARNING
  271. "Consider compiling CPUfreq support into your kernel.\n");
  272. printout = 0;
  273. }
  274. return 0;
  275. }
  276. static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
  277. {
  278. return -ENODEV;
  279. }
  280. #endif /* CONFIG_CPU_FREQ */
  281. /* in processor_core.c */
  282. void acpi_processor_set_pdc(acpi_handle handle);
  283. #ifdef CONFIG_SMP
  284. int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
  285. #else
  286. static inline int acpi_get_cpuid(acpi_handle handle, int type, u32 acpi_id)
  287. {
  288. return -1;
  289. }
  290. #endif
  291. /* in processor_throttling.c */
  292. int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
  293. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  294. extern int acpi_processor_set_throttling(struct acpi_processor *pr,
  295. int state, bool force);
  296. extern const struct file_operations acpi_processor_throttling_fops;
  297. extern void acpi_processor_throttling_init(void);
  298. /* in processor_idle.c */
  299. int acpi_processor_power_init(struct acpi_processor *pr,
  300. struct acpi_device *device);
  301. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  302. int acpi_processor_power_exit(struct acpi_processor *pr,
  303. struct acpi_device *device);
  304. int acpi_processor_suspend(struct acpi_device * device, pm_message_t state);
  305. int acpi_processor_resume(struct acpi_device * device);
  306. extern struct cpuidle_driver acpi_idle_driver;
  307. /* in processor_thermal.c */
  308. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  309. extern const struct file_operations acpi_processor_limit_fops;
  310. extern struct thermal_cooling_device_ops processor_cooling_ops;
  311. #ifdef CONFIG_CPU_FREQ
  312. void acpi_thermal_cpufreq_init(void);
  313. void acpi_thermal_cpufreq_exit(void);
  314. #else
  315. static inline void acpi_thermal_cpufreq_init(void)
  316. {
  317. return;
  318. }
  319. static inline void acpi_thermal_cpufreq_exit(void)
  320. {
  321. return;
  322. }
  323. #endif
  324. #endif