processor.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. #ifndef __ACPI_PROCESSOR_H
  2. #define __ACPI_PROCESSOR_H
  3. #include <linux/kernel.h>
  4. #include <linux/cpu.h>
  5. #include <linux/thermal.h>
  6. #include <asm/acpi.h>
  7. #define ACPI_PROCESSOR_CLASS "processor"
  8. #define ACPI_PROCESSOR_DEVICE_NAME "Processor"
  9. #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007"
  10. #define ACPI_PROCESSOR_BUSY_METRIC 10
  11. #define ACPI_PROCESSOR_MAX_POWER 8
  12. #define ACPI_PROCESSOR_MAX_C2_LATENCY 100
  13. #define ACPI_PROCESSOR_MAX_C3_LATENCY 1000
  14. #define ACPI_PROCESSOR_MAX_THROTTLING 16
  15. #define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */
  16. #define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4
  17. #define ACPI_PDC_REVISION_ID 0x1
  18. #define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
  19. #define ACPI_PSD_REV0_ENTRIES 5
  20. #define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
  21. #define ACPI_TSD_REV0_ENTRIES 5
  22. /*
  23. * Types of coordination defined in ACPI 3.0. Same macros can be used across
  24. * P, C and T states
  25. */
  26. #define DOMAIN_COORD_TYPE_SW_ALL 0xfc
  27. #define DOMAIN_COORD_TYPE_SW_ANY 0xfd
  28. #define DOMAIN_COORD_TYPE_HW_ALL 0xfe
  29. #define ACPI_CSTATE_SYSTEMIO 0
  30. #define ACPI_CSTATE_FFH 1
  31. #define ACPI_CSTATE_HALT 2
  32. #define ACPI_CX_DESC_LEN 32
  33. /* Power Management */
  34. struct acpi_processor_cx;
  35. struct acpi_power_register {
  36. u8 descriptor;
  37. u16 length;
  38. u8 space_id;
  39. u8 bit_width;
  40. u8 bit_offset;
  41. u8 access_size;
  42. u64 address;
  43. } __attribute__ ((packed));
  44. struct acpi_processor_cx {
  45. u8 valid;
  46. u8 type;
  47. u32 address;
  48. u8 entry_method;
  49. u8 index;
  50. u32 latency;
  51. u8 bm_sts_skip;
  52. char desc[ACPI_CX_DESC_LEN];
  53. };
  54. struct acpi_processor_power {
  55. struct acpi_processor_cx *state;
  56. unsigned long bm_check_timestamp;
  57. u32 default_state;
  58. int count;
  59. struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER];
  60. int timer_broadcast_on_state;
  61. };
  62. /* Performance Management */
  63. struct acpi_psd_package {
  64. u64 num_entries;
  65. u64 revision;
  66. u64 domain;
  67. u64 coord_type;
  68. u64 num_processors;
  69. } __attribute__ ((packed));
  70. struct acpi_pct_register {
  71. u8 descriptor;
  72. u16 length;
  73. u8 space_id;
  74. u8 bit_width;
  75. u8 bit_offset;
  76. u8 reserved;
  77. u64 address;
  78. } __attribute__ ((packed));
  79. struct acpi_processor_px {
  80. u64 core_frequency; /* megahertz */
  81. u64 power; /* milliWatts */
  82. u64 transition_latency; /* microseconds */
  83. u64 bus_master_latency; /* microseconds */
  84. u64 control; /* control value */
  85. u64 status; /* success indicator */
  86. };
  87. struct acpi_processor_performance {
  88. unsigned int state;
  89. unsigned int platform_limit;
  90. struct acpi_pct_register control_register;
  91. struct acpi_pct_register status_register;
  92. unsigned int state_count;
  93. struct acpi_processor_px *states;
  94. struct acpi_psd_package domain_info;
  95. cpumask_var_t shared_cpu_map;
  96. unsigned int shared_type;
  97. };
  98. /* Throttling Control */
  99. struct acpi_tsd_package {
  100. u64 num_entries;
  101. u64 revision;
  102. u64 domain;
  103. u64 coord_type;
  104. u64 num_processors;
  105. } __attribute__ ((packed));
  106. struct acpi_ptc_register {
  107. u8 descriptor;
  108. u16 length;
  109. u8 space_id;
  110. u8 bit_width;
  111. u8 bit_offset;
  112. u8 reserved;
  113. u64 address;
  114. } __attribute__ ((packed));
  115. struct acpi_processor_tx_tss {
  116. u64 freqpercentage; /* */
  117. u64 power; /* milliWatts */
  118. u64 transition_latency; /* microseconds */
  119. u64 control; /* control value */
  120. u64 status; /* success indicator */
  121. };
  122. struct acpi_processor_tx {
  123. u16 power;
  124. u16 performance;
  125. };
  126. struct acpi_processor;
  127. struct acpi_processor_throttling {
  128. unsigned int state;
  129. unsigned int platform_limit;
  130. struct acpi_pct_register control_register;
  131. struct acpi_pct_register status_register;
  132. unsigned int state_count;
  133. struct acpi_processor_tx_tss *states_tss;
  134. struct acpi_tsd_package domain_info;
  135. cpumask_var_t shared_cpu_map;
  136. int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
  137. int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
  138. int state, bool force);
  139. u32 address;
  140. u8 duty_offset;
  141. u8 duty_width;
  142. u8 tsd_valid_flag;
  143. unsigned int shared_type;
  144. struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
  145. };
  146. /* Limit Interface */
  147. struct acpi_processor_lx {
  148. int px; /* performance state */
  149. int tx; /* throttle level */
  150. };
  151. struct acpi_processor_limit {
  152. struct acpi_processor_lx state; /* current limit */
  153. struct acpi_processor_lx thermal; /* thermal limit */
  154. struct acpi_processor_lx user; /* user limit */
  155. };
  156. struct acpi_processor_flags {
  157. u8 power:1;
  158. u8 performance:1;
  159. u8 throttling:1;
  160. u8 limit:1;
  161. u8 bm_control:1;
  162. u8 bm_check:1;
  163. u8 has_cst:1;
  164. u8 power_setup_done:1;
  165. u8 bm_rld_set:1;
  166. u8 need_hotplug_init:1;
  167. };
  168. struct acpi_processor {
  169. acpi_handle handle;
  170. u32 acpi_id;
  171. u32 id;
  172. u32 pblk;
  173. int performance_platform_limit;
  174. int throttling_platform_limit;
  175. /* 0 - states 0..n-th state available */
  176. struct acpi_processor_flags flags;
  177. struct acpi_processor_power power;
  178. struct acpi_processor_performance *performance;
  179. struct acpi_processor_throttling throttling;
  180. struct acpi_processor_limit limit;
  181. struct thermal_cooling_device *cdev;
  182. struct device *dev; /* Processor device. */
  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 void acpi_processor_load_module(struct acpi_processor *pr);
  194. extern int acpi_processor_preregister_performance(struct
  195. acpi_processor_performance
  196. __percpu *performance);
  197. extern int acpi_processor_register_performance(struct acpi_processor_performance
  198. *performance, unsigned int cpu);
  199. extern void acpi_processor_unregister_performance(struct
  200. acpi_processor_performance
  201. *performance,
  202. unsigned int cpu);
  203. /* note: this locks both the calling module and the processor module
  204. if a _PPC object exists, rmmod is disallowed then */
  205. int acpi_processor_notify_smm(struct module *calling_module);
  206. /* parsing the _P* objects. */
  207. extern int acpi_processor_get_performance_info(struct acpi_processor *pr);
  208. /* for communication between multiple parts of the processor kernel module */
  209. DECLARE_PER_CPU(struct acpi_processor *, processors);
  210. extern struct acpi_processor_errata errata;
  211. #ifdef ARCH_HAS_POWER_INIT
  212. void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
  213. unsigned int cpu);
  214. int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  215. struct acpi_processor_cx *cx,
  216. struct acpi_power_register *reg);
  217. void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate);
  218. #else
  219. static inline void acpi_processor_power_init_bm_check(struct
  220. acpi_processor_flags
  221. *flags, unsigned int cpu)
  222. {
  223. flags->bm_check = 1;
  224. return;
  225. }
  226. static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu,
  227. struct acpi_processor_cx *cx,
  228. struct acpi_power_register
  229. *reg)
  230. {
  231. return -1;
  232. }
  233. static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx
  234. *cstate)
  235. {
  236. return;
  237. }
  238. #endif
  239. /* in processor_perflib.c */
  240. #ifdef CONFIG_CPU_FREQ
  241. void acpi_processor_ppc_init(void);
  242. void acpi_processor_ppc_exit(void);
  243. int acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag);
  244. extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit);
  245. #else
  246. static inline void acpi_processor_ppc_init(void)
  247. {
  248. return;
  249. }
  250. static inline void acpi_processor_ppc_exit(void)
  251. {
  252. return;
  253. }
  254. static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr,
  255. int event_flag)
  256. {
  257. static unsigned int printout = 1;
  258. if (printout) {
  259. printk(KERN_WARNING
  260. "Warning: Processor Platform Limit event detected, but not handled.\n");
  261. printk(KERN_WARNING
  262. "Consider compiling CPUfreq support into your kernel.\n");
  263. printout = 0;
  264. }
  265. return 0;
  266. }
  267. static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit)
  268. {
  269. return -ENODEV;
  270. }
  271. #endif /* CONFIG_CPU_FREQ */
  272. /* in processor_core.c */
  273. void acpi_processor_set_pdc(acpi_handle handle);
  274. int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id);
  275. /* in processor_throttling.c */
  276. int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
  277. int acpi_processor_get_throttling_info(struct acpi_processor *pr);
  278. extern int acpi_processor_set_throttling(struct acpi_processor *pr,
  279. int state, bool force);
  280. /*
  281. * Reevaluate whether the T-state is invalid after one cpu is
  282. * onlined/offlined. In such case the flags.throttling will be updated.
  283. */
  284. extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr,
  285. unsigned long action);
  286. extern const struct file_operations acpi_processor_throttling_fops;
  287. extern void acpi_processor_throttling_init(void);
  288. /* in processor_idle.c */
  289. int acpi_processor_power_init(struct acpi_processor *pr);
  290. int acpi_processor_power_exit(struct acpi_processor *pr);
  291. int acpi_processor_cst_has_changed(struct acpi_processor *pr);
  292. int acpi_processor_hotplug(struct acpi_processor *pr);
  293. extern struct cpuidle_driver acpi_idle_driver;
  294. #ifdef CONFIG_PM_SLEEP
  295. void acpi_processor_syscore_init(void);
  296. void acpi_processor_syscore_exit(void);
  297. #else
  298. static inline void acpi_processor_syscore_init(void) {}
  299. static inline void acpi_processor_syscore_exit(void) {}
  300. #endif
  301. /* in processor_thermal.c */
  302. int acpi_processor_get_limit_info(struct acpi_processor *pr);
  303. extern const struct thermal_cooling_device_ops processor_cooling_ops;
  304. #ifdef CONFIG_CPU_FREQ
  305. void acpi_thermal_cpufreq_init(void);
  306. void acpi_thermal_cpufreq_exit(void);
  307. #else
  308. static inline void acpi_thermal_cpufreq_init(void)
  309. {
  310. return;
  311. }
  312. static inline void acpi_thermal_cpufreq_exit(void)
  313. {
  314. return;
  315. }
  316. #endif
  317. #endif