Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | #ifndef __ACPI_PROCESSOR_H |
| 3 | #define __ACPI_PROCESSOR_H |
| 4 | |
| 5 | #include <linux/kernel.h> |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 6 | #include <linux/cpu.h> |
Viresh Kumar | d15ce41 | 2019-08-28 14:20:13 +0530 | [diff] [blame] | 7 | #include <linux/cpufreq.h> |
| 8 | #include <linux/pm_qos.h> |
Zhang Rui | d9460fd22 | 2008-01-17 15:51:23 +0800 | [diff] [blame] | 9 | #include <linux/thermal.h> |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 10 | #include <asm/acpi.h> |
| 11 | |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 12 | #define ACPI_PROCESSOR_CLASS "processor" |
| 13 | #define ACPI_PROCESSOR_DEVICE_NAME "Processor" |
| 14 | #define ACPI_PROCESSOR_DEVICE_HID "ACPI0007" |
Sudeep Holla | db62fda | 2016-02-17 11:54:19 +0000 | [diff] [blame] | 15 | #define ACPI_PROCESSOR_CONTAINER_HID "ACPI0010" |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 16 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #define ACPI_PROCESSOR_BUSY_METRIC 10 |
| 18 | |
| 19 | #define ACPI_PROCESSOR_MAX_POWER 8 |
| 20 | #define ACPI_PROCESSOR_MAX_C2_LATENCY 100 |
| 21 | #define ACPI_PROCESSOR_MAX_C3_LATENCY 1000 |
| 22 | |
| 23 | #define ACPI_PROCESSOR_MAX_THROTTLING 16 |
| 24 | #define ACPI_PROCESSOR_MAX_THROTTLE 250 /* 25% */ |
| 25 | #define ACPI_PROCESSOR_MAX_DUTY_WIDTH 4 |
| 26 | |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 27 | #define ACPI_PDC_REVISION_ID 0x1 |
| 28 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 29 | #define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 30 | #define ACPI_PSD_REV0_ENTRIES 5 |
| 31 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 32 | #define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ |
| 33 | #define ACPI_TSD_REV0_ENTRIES 5 |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 34 | /* |
| 35 | * Types of coordination defined in ACPI 3.0. Same macros can be used across |
| 36 | * P, C and T states |
| 37 | */ |
| 38 | #define DOMAIN_COORD_TYPE_SW_ALL 0xfc |
| 39 | #define DOMAIN_COORD_TYPE_SW_ANY 0xfd |
| 40 | #define DOMAIN_COORD_TYPE_HW_ALL 0xfe |
| 41 | |
Venkatesh Pallipadi | 4fcb2fc | 2008-02-11 17:46:31 -0800 | [diff] [blame] | 42 | #define ACPI_CSTATE_SYSTEMIO 0 |
| 43 | #define ACPI_CSTATE_FFH 1 |
| 44 | #define ACPI_CSTATE_HALT 2 |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 45 | #define ACPI_CSTATE_INTEGER 3 |
Venkatesh Pallipadi | 4fcb2fc | 2008-02-11 17:46:31 -0800 | [diff] [blame] | 46 | |
| 47 | #define ACPI_CX_DESC_LEN 32 |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | /* Power Management */ |
| 50 | |
| 51 | struct acpi_processor_cx; |
| 52 | |
| 53 | struct acpi_power_register { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 54 | u8 descriptor; |
| 55 | u16 length; |
| 56 | u8 space_id; |
| 57 | u8 bit_width; |
| 58 | u8 bit_offset; |
Len Brown | 718be4a | 2010-07-22 16:54:27 -0400 | [diff] [blame] | 59 | u8 access_size; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 60 | u64 address; |
Fabian Frederick | 92c4d2a | 2014-06-01 19:16:17 +0200 | [diff] [blame] | 61 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | struct acpi_processor_cx { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 64 | u8 valid; |
| 65 | u8 type; |
| 66 | u32 address; |
venkatesh.pallipadi@intel.com | bc71bec | 2008-01-31 17:35:04 -0800 | [diff] [blame] | 67 | u8 entry_method; |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 68 | u8 index; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 69 | u32 latency; |
Len Brown | 718be4a | 2010-07-22 16:54:27 -0400 | [diff] [blame] | 70 | u8 bm_sts_skip; |
Venkatesh Pallipadi | 4fcb2fc | 2008-02-11 17:46:31 -0800 | [diff] [blame] | 71 | char desc[ACPI_CX_DESC_LEN]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | }; |
| 73 | |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 74 | struct acpi_lpi_state { |
| 75 | u32 min_residency; |
| 76 | u32 wake_latency; /* worst case */ |
| 77 | u32 flags; |
| 78 | u32 arch_flags; |
| 79 | u32 res_cnt_freq; |
| 80 | u32 enable_parent_state; |
| 81 | u64 address; |
| 82 | u8 index; |
| 83 | u8 entry_method; |
| 84 | char desc[ACPI_CX_DESC_LEN]; |
| 85 | }; |
| 86 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | struct acpi_processor_power { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 88 | int count; |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 89 | union { |
| 90 | struct acpi_processor_cx states[ACPI_PROCESSOR_MAX_POWER]; |
| 91 | struct acpi_lpi_state lpi_states[ACPI_PROCESSOR_MAX_POWER]; |
| 92 | }; |
Thomas Gleixner | 169a0ab | 2007-02-16 01:27:55 -0800 | [diff] [blame] | 93 | int timer_broadcast_on_state; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | }; |
| 95 | |
| 96 | /* Performance Management */ |
| 97 | |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 98 | struct acpi_psd_package { |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 99 | u64 num_entries; |
| 100 | u64 revision; |
| 101 | u64 domain; |
| 102 | u64 coord_type; |
| 103 | u64 num_processors; |
Fabian Frederick | 92c4d2a | 2014-06-01 19:16:17 +0200 | [diff] [blame] | 104 | } __packed; |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | struct acpi_pct_register { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 107 | u8 descriptor; |
| 108 | u16 length; |
| 109 | u8 space_id; |
| 110 | u8 bit_width; |
| 111 | u8 bit_offset; |
| 112 | u8 reserved; |
| 113 | u64 address; |
Fabian Frederick | 92c4d2a | 2014-06-01 19:16:17 +0200 | [diff] [blame] | 114 | } __packed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
| 116 | struct acpi_processor_px { |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 117 | u64 core_frequency; /* megahertz */ |
| 118 | u64 power; /* milliWatts */ |
| 119 | u64 transition_latency; /* microseconds */ |
| 120 | u64 bus_master_latency; /* microseconds */ |
| 121 | u64 control; /* control value */ |
| 122 | u64 status; /* success indicator */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | }; |
| 124 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | struct acpi_processor_performance { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 126 | unsigned int state; |
| 127 | unsigned int platform_limit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | struct acpi_pct_register control_register; |
| 129 | struct acpi_pct_register status_register; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 130 | unsigned int state_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | struct acpi_processor_px *states; |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 132 | struct acpi_psd_package domain_info; |
Rusty Russell | 2fdf66b | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 133 | cpumask_var_t shared_cpu_map; |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 134 | unsigned int shared_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | /* Throttling Control */ |
| 138 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 139 | struct acpi_tsd_package { |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 140 | u64 num_entries; |
| 141 | u64 revision; |
| 142 | u64 domain; |
| 143 | u64 coord_type; |
| 144 | u64 num_processors; |
Fabian Frederick | 92c4d2a | 2014-06-01 19:16:17 +0200 | [diff] [blame] | 145 | } __packed; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 146 | |
| 147 | struct acpi_ptc_register { |
| 148 | u8 descriptor; |
| 149 | u16 length; |
| 150 | u8 space_id; |
| 151 | u8 bit_width; |
| 152 | u8 bit_offset; |
| 153 | u8 reserved; |
| 154 | u64 address; |
Fabian Frederick | 92c4d2a | 2014-06-01 19:16:17 +0200 | [diff] [blame] | 155 | } __packed; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 156 | |
| 157 | struct acpi_processor_tx_tss { |
Lin Ming | 439913f | 2010-01-28 10:53:19 +0800 | [diff] [blame] | 158 | u64 freqpercentage; /* */ |
| 159 | u64 power; /* milliWatts */ |
| 160 | u64 transition_latency; /* microseconds */ |
| 161 | u64 control; /* control value */ |
| 162 | u64 status; /* success indicator */ |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 163 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | struct acpi_processor_tx { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | u16 power; |
| 166 | u16 performance; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | }; |
| 168 | |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 169 | struct acpi_processor; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | struct acpi_processor_throttling { |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 171 | unsigned int state; |
| 172 | unsigned int platform_limit; |
| 173 | struct acpi_pct_register control_register; |
| 174 | struct acpi_pct_register status_register; |
| 175 | unsigned int state_count; |
| 176 | struct acpi_processor_tx_tss *states_tss; |
| 177 | struct acpi_tsd_package domain_info; |
Rusty Russell | 2fdf66b | 2008-12-31 18:08:47 -0800 | [diff] [blame] | 178 | cpumask_var_t shared_cpu_map; |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 179 | int (*acpi_processor_get_throttling) (struct acpi_processor * pr); |
| 180 | int (*acpi_processor_set_throttling) (struct acpi_processor * pr, |
Frans Pop | 2a90800 | 2009-08-26 14:29:29 -0700 | [diff] [blame] | 181 | int state, bool force); |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 182 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 183 | u32 address; |
| 184 | u8 duty_offset; |
| 185 | u8 duty_width; |
Zhao Yakui | 1180509 | 2008-01-28 13:53:42 +0800 | [diff] [blame] | 186 | u8 tsd_valid_flag; |
| 187 | unsigned int shared_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; |
| 189 | }; |
| 190 | |
| 191 | /* Limit Interface */ |
| 192 | |
| 193 | struct acpi_processor_lx { |
Joe Perches | aee07ba | 2008-02-03 17:07:16 +0200 | [diff] [blame] | 194 | int px; /* performance state */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 195 | int tx; /* throttle level */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | }; |
| 197 | |
| 198 | struct acpi_processor_limit { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 199 | struct acpi_processor_lx state; /* current limit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | struct acpi_processor_lx thermal; /* thermal limit */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 201 | struct acpi_processor_lx user; /* user limit */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | }; |
| 203 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | struct acpi_processor_flags { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 205 | u8 power:1; |
| 206 | u8 performance:1; |
| 207 | u8 throttling:1; |
| 208 | u8 limit:1; |
| 209 | u8 bm_control:1; |
| 210 | u8 bm_check:1; |
| 211 | u8 has_cst:1; |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 212 | u8 has_lpi:1; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | u8 power_setup_done:1; |
Len Brown | 4f86d3a | 2007-10-03 18:58:00 -0400 | [diff] [blame] | 214 | u8 bm_rld_set:1; |
Thomas Renninger | 99b7250 | 2012-01-19 18:18:43 +0100 | [diff] [blame] | 215 | u8 need_hotplug_init:1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | }; |
| 217 | |
| 218 | struct acpi_processor { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 219 | acpi_handle handle; |
| 220 | u32 acpi_id; |
Catalin Marinas | 828aef3 | 2015-03-24 14:02:46 +0000 | [diff] [blame] | 221 | phys_cpuid_t phys_id; /* CPU hardware ID such as APIC ID for x86 */ |
Hanjun Guo | af8f3f5 | 2015-01-04 18:55:02 +0800 | [diff] [blame] | 222 | u32 id; /* CPU logical ID allocated by OS */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 223 | u32 pblk; |
| 224 | int performance_platform_limit; |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 225 | int throttling_platform_limit; |
Len Brown | ff55a9c | 2007-06-02 00:15:25 -0400 | [diff] [blame] | 226 | /* 0 - states 0..n-th state available */ |
Luming Yu | 01854e6 | 2007-05-26 22:49:58 +0800 | [diff] [blame] | 227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | struct acpi_processor_flags flags; |
| 229 | struct acpi_processor_power power; |
| 230 | struct acpi_processor_performance *performance; |
| 231 | struct acpi_processor_throttling throttling; |
| 232 | struct acpi_processor_limit limit; |
Zhang Rui | d9460fd22 | 2008-01-17 15:51:23 +0800 | [diff] [blame] | 233 | struct thermal_cooling_device *cdev; |
Rafael J. Wysocki | ac212b6 | 2013-05-03 00:26:22 +0200 | [diff] [blame] | 234 | struct device *dev; /* Processor device. */ |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 235 | struct freq_qos_request perflib_req; |
| 236 | struct freq_qos_request thermal_req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | }; |
| 238 | |
| 239 | struct acpi_processor_errata { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 240 | u8 smp; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | struct { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 242 | u8 throttle:1; |
| 243 | u8 fdma:1; |
| 244 | u8 reserved:6; |
| 245 | u32 bmisx; |
| 246 | } piix4; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | }; |
| 248 | |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 249 | extern int acpi_processor_preregister_performance(struct |
| 250 | acpi_processor_performance |
Tejun Heo | a29d8b8 | 2010-02-02 14:39:15 +0900 | [diff] [blame] | 251 | __percpu *performance); |
Venkatesh Pallipadi | 3b2d994 | 2005-12-14 15:05:00 -0500 | [diff] [blame] | 252 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 253 | extern int acpi_processor_register_performance(struct acpi_processor_performance |
| 254 | *performance, unsigned int cpu); |
Rafael J. Wysocki | b2f8dc4 | 2015-07-22 22:11:16 +0200 | [diff] [blame] | 255 | extern void acpi_processor_unregister_performance(unsigned int cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Rafael J. Wysocki | d0ea59e | 2016-11-17 22:47:47 +0100 | [diff] [blame] | 257 | int acpi_processor_pstate_control(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /* note: this locks both the calling module and the processor module |
| 259 | if a _PPC object exists, rmmod is disallowed then */ |
| 260 | int acpi_processor_notify_smm(struct module *calling_module); |
Joao Martins | 4d0f1ce | 2018-03-15 14:22:05 +0000 | [diff] [blame] | 261 | int acpi_processor_get_psd(acpi_handle handle, |
| 262 | struct acpi_psd_package *pdomain); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Konrad Rzeszutek Wilk | c705c78 | 2013-03-05 13:42:54 -0500 | [diff] [blame] | 264 | /* parsing the _P* objects. */ |
| 265 | extern int acpi_processor_get_performance_info(struct acpi_processor *pr); |
| 266 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | /* for communication between multiple parts of the processor kernel module */ |
Mike Travis | 706546d | 2008-06-09 16:22:23 -0700 | [diff] [blame] | 268 | DECLARE_PER_CPU(struct acpi_processor *, processors); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | extern struct acpi_processor_errata errata; |
| 270 | |
Sudeep Holla | 35ae713 | 2016-07-19 18:52:53 +0100 | [diff] [blame] | 271 | #if defined(ARCH_HAS_POWER_INIT) && defined(CONFIG_ACPI_PROCESSOR_CSTATE) |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 272 | void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags, |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 273 | unsigned int cpu); |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 274 | int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 275 | struct acpi_processor_cx *cx, |
| 276 | struct acpi_power_register *reg); |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 277 | void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cstate); |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 278 | #else |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | static inline void acpi_processor_power_init_bm_check(struct |
| 280 | acpi_processor_flags |
| 281 | *flags, unsigned int cpu) |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 282 | { |
| 283 | flags->bm_check = 1; |
| 284 | return; |
| 285 | } |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 286 | static inline int acpi_processor_ffh_cstate_probe(unsigned int cpu, |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 287 | struct acpi_processor_cx *cx, |
| 288 | struct acpi_power_register |
| 289 | *reg) |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 290 | { |
| 291 | return -1; |
| 292 | } |
Len Brown | fd35094 | 2007-05-09 23:34:35 -0400 | [diff] [blame] | 293 | static inline void acpi_processor_ffh_cstate_enter(struct acpi_processor_cx |
| 294 | *cstate) |
Venkatesh Pallipadi | 991528d | 2006-09-25 16:28:13 -0700 | [diff] [blame] | 295 | { |
| 296 | return; |
| 297 | } |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 298 | #endif |
| 299 | |
Qian Cai | 696ac2e | 2020-04-03 10:03:45 -0400 | [diff] [blame] | 300 | static inline int call_on_cpu(int cpu, long (*fn)(void *), void *arg, |
| 301 | bool direct) |
| 302 | { |
| 303 | if (direct || (is_percpu_thread() && cpu == smp_processor_id())) |
| 304 | return fn(arg); |
| 305 | return work_on_cpu(cpu, fn, arg); |
| 306 | } |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | /* in processor_perflib.c */ |
Venkatesh Pallipadi | 02df8b9 | 2005-04-15 15:07:10 -0400 | [diff] [blame] | 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | #ifdef CONFIG_CPU_FREQ |
Viresh Kumar | d15ce41 | 2019-08-28 14:20:13 +0530 | [diff] [blame] | 311 | extern bool acpi_processor_cpufreq_init; |
| 312 | void acpi_processor_ignore_ppc_init(void); |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 313 | void acpi_processor_ppc_init(struct cpufreq_policy *policy); |
| 314 | void acpi_processor_ppc_exit(struct cpufreq_policy *policy); |
Rafael J. Wysocki | bca5f55 | 2016-11-18 13:57:54 +0100 | [diff] [blame] | 315 | void acpi_processor_ppc_has_changed(struct acpi_processor *pr, int event_flag); |
Thomas Renninger | e2f74f3 | 2009-11-19 12:31:01 +0100 | [diff] [blame] | 316 | extern int acpi_processor_get_bios_limit(int cpu, unsigned int *limit); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #else |
Viresh Kumar | d15ce41 | 2019-08-28 14:20:13 +0530 | [diff] [blame] | 318 | static inline void acpi_processor_ignore_ppc_init(void) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 319 | { |
| 320 | return; |
| 321 | } |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 322 | static inline void acpi_processor_ppc_init(struct cpufreq_policy *policy) |
Viresh Kumar | d15ce41 | 2019-08-28 14:20:13 +0530 | [diff] [blame] | 323 | { |
| 324 | return; |
| 325 | } |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 326 | static inline void acpi_processor_ppc_exit(struct cpufreq_policy *policy) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 327 | { |
| 328 | return; |
| 329 | } |
Brian Norris | a507a30 | 2018-06-19 10:02:01 -0700 | [diff] [blame] | 330 | static inline void acpi_processor_ppc_has_changed(struct acpi_processor *pr, |
Zhao Yakui | d81c45e1 | 2009-10-16 09:20:41 +0800 | [diff] [blame] | 331 | int event_flag) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 332 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | static unsigned int printout = 1; |
| 334 | if (printout) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | printk(KERN_WARNING |
| 336 | "Warning: Processor Platform Limit event detected, but not handled.\n"); |
| 337 | printk(KERN_WARNING |
| 338 | "Consider compiling CPUfreq support into your kernel.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | printout = 0; |
| 340 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | } |
Thomas Renninger | e2f74f3 | 2009-11-19 12:31:01 +0100 | [diff] [blame] | 342 | static inline int acpi_processor_get_bios_limit(int cpu, unsigned int *limit) |
| 343 | { |
| 344 | return -ENODEV; |
| 345 | } |
| 346 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 347 | #endif /* CONFIG_CPU_FREQ */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | |
Alex Chiang | 4d5d4cd | 2010-02-22 12:11:14 -0700 | [diff] [blame] | 349 | /* in processor_core.c */ |
Catalin Marinas | 828aef3 | 2015-03-24 14:02:46 +0000 | [diff] [blame] | 350 | phys_cpuid_t acpi_get_phys_id(acpi_handle, int type, u32 acpi_id); |
David Daney | fb7c2ba | 2016-05-24 15:35:43 -0700 | [diff] [blame] | 351 | phys_cpuid_t acpi_map_madt_entry(u32 acpi_id); |
Catalin Marinas | 828aef3 | 2015-03-24 14:02:46 +0000 | [diff] [blame] | 352 | int acpi_map_cpuid(phys_cpuid_t phys_id, u32 acpi_id); |
Alex Chiang | 2e9d5e4 | 2010-02-22 12:11:19 -0700 | [diff] [blame] | 353 | int acpi_get_cpuid(acpi_handle, int type, u32 acpi_id); |
Alex Chiang | 78f1699 | 2009-12-20 12:19:09 -0700 | [diff] [blame] | 354 | |
Ashwin Chaugule | 4f2f757 | 2015-09-09 16:27:07 -0400 | [diff] [blame] | 355 | #ifdef CONFIG_ACPI_CPPC_LIB |
| 356 | extern int acpi_cppc_processor_probe(struct acpi_processor *pr); |
| 357 | extern void acpi_cppc_processor_exit(struct acpi_processor *pr); |
| 358 | #else |
| 359 | static inline int acpi_cppc_processor_probe(struct acpi_processor *pr) |
| 360 | { |
| 361 | return 0; |
| 362 | } |
| 363 | static inline void acpi_cppc_processor_exit(struct acpi_processor *pr) |
| 364 | { |
| 365 | return; |
| 366 | } |
| 367 | #endif /* CONFIG_ACPI_CPPC_LIB */ |
| 368 | |
Hanjun Guo | 24119a8 | 2014-10-30 17:52:58 +0800 | [diff] [blame] | 369 | /* in processor_pdc.c */ |
| 370 | void acpi_processor_set_pdc(acpi_handle handle); |
| 371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | /* in processor_throttling.c */ |
Ashwin Chaugule | 239708a | 2015-08-05 09:40:25 -0400 | [diff] [blame] | 373 | #ifdef CONFIG_ACPI_CPU_FREQ_PSS |
Adrian Bunk | a66b34b | 2008-06-09 16:22:24 -0700 | [diff] [blame] | 374 | int acpi_processor_tstate_has_changed(struct acpi_processor *pr); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 375 | int acpi_processor_get_throttling_info(struct acpi_processor *pr); |
Frans Pop | 2a90800 | 2009-08-26 14:29:29 -0700 | [diff] [blame] | 376 | extern int acpi_processor_set_throttling(struct acpi_processor *pr, |
| 377 | int state, bool force); |
Zhao Yakui | 5a344a5 | 2011-01-10 16:35:45 +0800 | [diff] [blame] | 378 | /* |
| 379 | * Reevaluate whether the T-state is invalid after one cpu is |
| 380 | * onlined/offlined. In such case the flags.throttling will be updated. |
| 381 | */ |
| 382 | extern void acpi_processor_reevaluate_tstate(struct acpi_processor *pr, |
Sebastian Andrzej Siewior | 64f3bf2 | 2016-09-06 19:04:47 +0200 | [diff] [blame] | 383 | bool is_dead); |
Jan Engelhardt | 070d8eb | 2009-01-12 00:07:55 +0100 | [diff] [blame] | 384 | extern const struct file_operations acpi_processor_throttling_fops; |
Zhao Yakui | 1180509 | 2008-01-28 13:53:42 +0800 | [diff] [blame] | 385 | extern void acpi_processor_throttling_init(void); |
Ashwin Chaugule | 239708a | 2015-08-05 09:40:25 -0400 | [diff] [blame] | 386 | #else |
| 387 | static inline int acpi_processor_tstate_has_changed(struct acpi_processor *pr) |
| 388 | { |
| 389 | return 0; |
| 390 | } |
| 391 | |
| 392 | static inline int acpi_processor_get_throttling_info(struct acpi_processor *pr) |
| 393 | { |
| 394 | return -ENODEV; |
| 395 | } |
| 396 | |
| 397 | static inline int acpi_processor_set_throttling(struct acpi_processor *pr, |
| 398 | int state, bool force) |
| 399 | { |
| 400 | return -ENODEV; |
| 401 | } |
| 402 | |
| 403 | static inline void acpi_processor_reevaluate_tstate(struct acpi_processor *pr, |
Sebastian Andrzej Siewior | 64f3bf2 | 2016-09-06 19:04:47 +0200 | [diff] [blame] | 404 | bool is_dead) {} |
Ashwin Chaugule | 239708a | 2015-08-05 09:40:25 -0400 | [diff] [blame] | 405 | |
| 406 | static inline void acpi_processor_throttling_init(void) {} |
| 407 | #endif /* CONFIG_ACPI_CPU_FREQ_PSS */ |
| 408 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 409 | /* in processor_idle.c */ |
Ashwin Chaugule | 5f05586 | 2015-08-05 09:40:26 -0400 | [diff] [blame] | 410 | extern struct cpuidle_driver acpi_idle_driver; |
| 411 | #ifdef CONFIG_ACPI_PROCESSOR_IDLE |
Daniel Lezcano | 38a991b | 2012-09-15 22:42:54 +0200 | [diff] [blame] | 412 | int acpi_processor_power_init(struct acpi_processor *pr); |
| 413 | int acpi_processor_power_exit(struct acpi_processor *pr); |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 414 | int acpi_processor_power_state_has_changed(struct acpi_processor *pr); |
Deepthi Dharwar | 46bcfad | 2011-10-28 16:20:42 +0530 | [diff] [blame] | 415 | int acpi_processor_hotplug(struct acpi_processor *pr); |
Ashwin Chaugule | 5f05586 | 2015-08-05 09:40:26 -0400 | [diff] [blame] | 416 | #else |
| 417 | static inline int acpi_processor_power_init(struct acpi_processor *pr) |
| 418 | { |
| 419 | return -ENODEV; |
| 420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | |
Ashwin Chaugule | 5f05586 | 2015-08-05 09:40:26 -0400 | [diff] [blame] | 422 | static inline int acpi_processor_power_exit(struct acpi_processor *pr) |
| 423 | { |
| 424 | return -ENODEV; |
| 425 | } |
| 426 | |
Sudeep Holla | a36a7fe | 2016-07-21 17:18:07 +0100 | [diff] [blame] | 427 | static inline int acpi_processor_power_state_has_changed(struct acpi_processor *pr) |
Ashwin Chaugule | 5f05586 | 2015-08-05 09:40:26 -0400 | [diff] [blame] | 428 | { |
| 429 | return -ENODEV; |
| 430 | } |
| 431 | |
| 432 | static inline int acpi_processor_hotplug(struct acpi_processor *pr) |
| 433 | { |
| 434 | return -ENODEV; |
| 435 | } |
| 436 | #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ |
| 437 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | /* in processor_thermal.c */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 439 | int acpi_processor_get_limit_info(struct acpi_processor *pr); |
Vasiliy Kulikov | 9c8b04b | 2011-06-25 21:07:52 +0400 | [diff] [blame] | 440 | extern const struct thermal_cooling_device_ops processor_cooling_ops; |
Ashwin Chaugule | 239708a | 2015-08-05 09:40:25 -0400 | [diff] [blame] | 441 | #if defined(CONFIG_ACPI_CPU_FREQ_PSS) & defined(CONFIG_CPU_FREQ) |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 442 | void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy); |
| 443 | void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 444 | #else |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 445 | static inline void acpi_thermal_cpufreq_init(struct cpufreq_policy *policy) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 446 | { |
| 447 | return; |
| 448 | } |
Rafael J. Wysocki | 3000ce3 | 2019-10-16 12:47:06 +0200 | [diff] [blame] | 449 | static inline void acpi_thermal_cpufreq_exit(struct cpufreq_policy *policy) |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 450 | { |
| 451 | return; |
| 452 | } |
Ashwin Chaugule | 239708a | 2015-08-05 09:40:25 -0400 | [diff] [blame] | 453 | #endif /* CONFIG_ACPI_CPU_FREQ_PSS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | #endif |