processor.h 8.8 KB

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