Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpigen.h> |
| 4 | #include <acpi/acpigen_dptf.h> |
Elyes HAOUAS | 441e191 | 2020-07-27 09:37:08 +0200 | [diff] [blame] | 5 | #include <stdbool.h> |
| 6 | #include <stdint.h> |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 7 | |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 8 | /* Defaults */ |
Tim Wawrzynczak | 46f6fcf | 2020-05-29 14:29:53 -0600 | [diff] [blame] | 9 | #define DEFAULT_RAW_UNIT "ma" |
| 10 | |
Tim Wawrzynczak | 03465f4 | 2020-06-03 16:27:30 -0600 | [diff] [blame] | 11 | /* DPTF-specific UUIDs */ |
| 12 | #define DPTF_PASSIVE_POLICY_1_0_UUID "42A441D6-AE6A-462B-A84B-4A8CE79027D3" |
| 13 | #define DPTF_CRITICAL_POLICY_UUID "97C68AE7-15FA-499c-B8C9-5DA81D606E0A" |
| 14 | #define DPTF_ACTIVE_POLICY_UUID "3A95C389-E4B8-4629-A526-C52C88626BAE" |
| 15 | |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 16 | enum { |
| 17 | ART_REVISION = 0, |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 18 | DEFAULT_PRIORITY = 100, |
Tim Wawrzynczak | 2ad8ffe | 2020-05-29 14:39:02 -0600 | [diff] [blame] | 19 | DEFAULT_TRIP_POINT = 0xFFFFFFFFull, |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 20 | DEFAULT_WEIGHT = 100, |
| 21 | DPTF_MAX_ART_THRESHOLDS = 10, |
Tim Wawrzynczak | a9d3e65 | 2020-07-27 13:51:04 -0600 | [diff] [blame] | 22 | FPS_REVISION = 0, |
Tim Wawrzynczak | bb5c255 | 2020-05-29 14:46:19 -0600 | [diff] [blame] | 23 | PPCC_REVISION = 2, |
| 24 | RAPL_PL1_INDEX = 0, |
| 25 | RAPL_PL2_INDEX = 1, |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | /* Convert degrees C to 1/10 degree Kelvin for ACPI */ |
| 29 | static int to_acpi_temp(int deg_c) |
| 30 | { |
| 31 | return deg_c * 10 + 2732; |
| 32 | } |
| 33 | |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 34 | /* Converts ms to 1/10th second for ACPI */ |
| 35 | static int to_acpi_time(int ms) |
| 36 | { |
| 37 | return ms / 100; |
| 38 | } |
| 39 | |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 40 | /* Writes out a 0-argument non-Serialized Method that returns an Integer */ |
| 41 | static void write_simple_return_method(const char *name, int value) |
| 42 | { |
| 43 | acpigen_write_method(name, 0); |
| 44 | acpigen_write_return_integer(value); |
| 45 | acpigen_pop_len(); /* Method */ |
| 46 | } |
| 47 | |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 48 | /* Writes out 'count' ZEROs in a row */ |
| 49 | static void write_zeros(int count) |
| 50 | { |
| 51 | for (; count; --count) |
| 52 | acpigen_write_integer(0); |
| 53 | } |
| 54 | |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 55 | /* Return the assigned namestring of any participant */ |
| 56 | static const char *namestring_of(enum dptf_participant participant) |
| 57 | { |
| 58 | switch (participant) { |
| 59 | case DPTF_CPU: |
| 60 | return "TCPU"; |
| 61 | case DPTF_CHARGER: |
| 62 | return "TCHG"; |
| 63 | case DPTF_FAN: |
| 64 | return "TFN1"; |
| 65 | case DPTF_TEMP_SENSOR_0: |
| 66 | return "TSR0"; |
| 67 | case DPTF_TEMP_SENSOR_1: |
| 68 | return "TSR1"; |
| 69 | case DPTF_TEMP_SENSOR_2: |
| 70 | return "TSR2"; |
| 71 | case DPTF_TEMP_SENSOR_3: |
| 72 | return "TSR3"; |
Sumeet Pawnikar | e2e0a6b | 2021-09-24 18:39:50 +0530 | [diff] [blame] | 73 | case DPTF_TPCH: |
| 74 | return "TPCH"; |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 75 | default: |
| 76 | return ""; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | /* Helper to get Scope for participants underneath \_SB.DPTF */ |
| 81 | static const char *scope_of(enum dptf_participant participant) |
| 82 | { |
| 83 | static char scope[16]; |
| 84 | |
| 85 | if (participant == DPTF_CPU) |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 86 | snprintf(scope, sizeof(scope), TCPU_SCOPE ".%s", namestring_of(participant)); |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 87 | else |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 88 | snprintf(scope, sizeof(scope), DPTF_DEVICE_PATH ".%s", |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 89 | namestring_of(participant)); |
| 90 | |
| 91 | return scope; |
| 92 | } |
| 93 | |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 94 | /* |
| 95 | * Most of the DPTF participants are underneath the \_SB.DPTF scope, so we can just get away |
| 96 | * with using the simple namestring for references, but the TCPU has a different scope, so |
| 97 | * either an absolute or relative path must be used instead. |
| 98 | */ |
| 99 | static const char *path_of(enum dptf_participant participant) |
| 100 | { |
| 101 | if (participant == DPTF_CPU) |
| 102 | return scope_of(participant); |
| 103 | else |
| 104 | return namestring_of(participant); |
| 105 | } |
| 106 | |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 107 | /* Write out scope of a participant */ |
| 108 | void dptf_write_scope(enum dptf_participant participant) |
| 109 | { |
| 110 | acpigen_write_scope(scope_of(participant)); |
| 111 | } |
| 112 | |
| 113 | /* |
| 114 | * This table describes active cooling relationships between the system's fan and the |
| 115 | * temperature sensors that it can have an effect on. As ever-increasing temperature thresholds |
| 116 | * are crossed (_AC9.._AC0, low to high), the corresponding fan percentages listed in this table |
| 117 | * are used to increase the speed of the fan in order to speed up cooling. |
| 118 | */ |
| 119 | static void write_active_relationship_table(const struct dptf_active_policy *policies, |
| 120 | int max_count) |
| 121 | { |
| 122 | char *pkg_count; |
| 123 | int i, j; |
| 124 | |
| 125 | /* Nothing to do */ |
| 126 | if (!max_count || policies[0].target == DPTF_NONE) |
| 127 | return; |
| 128 | |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 129 | acpigen_write_scope(DPTF_DEVICE_PATH); |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 130 | acpigen_write_method("_ART", 0); |
| 131 | |
| 132 | /* Return this package */ |
| 133 | acpigen_emit_byte(RETURN_OP); |
| 134 | |
| 135 | /* Keep track of items added to the package */ |
| 136 | pkg_count = acpigen_write_package(1); /* The '1' here is for the revision */ |
| 137 | acpigen_write_integer(ART_REVISION); |
| 138 | |
| 139 | for (i = 0; i < max_count; ++i) { |
| 140 | /* |
| 141 | * These have to be filled out from AC0 down to AC9, filling in only as many |
| 142 | * as are used. As soon as one isn't filled in, we're done. |
| 143 | */ |
| 144 | if (policies[i].target == DPTF_NONE) |
| 145 | break; |
| 146 | |
| 147 | (*pkg_count)++; |
| 148 | |
| 149 | /* Source, Target, Percent, Fan % for each of _AC0 ... _AC9 */ |
| 150 | acpigen_write_package(13); |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 151 | acpigen_emit_namestring(path_of(DPTF_FAN)); |
| 152 | acpigen_emit_namestring(path_of(policies[i].target)); |
Tim Wawrzynczak | c41f7f1 | 2020-05-29 13:56:37 -0600 | [diff] [blame] | 153 | acpigen_write_integer(DEFAULT_IF_0(policies[i].weight, DEFAULT_WEIGHT)); |
| 154 | |
| 155 | /* Write out fan %; corresponds with target's _ACx methods */ |
| 156 | for (j = 0; j < DPTF_MAX_ART_THRESHOLDS; ++j) |
| 157 | acpigen_write_integer(policies[i].thresholds[j].fan_pct); |
| 158 | |
| 159 | acpigen_pop_len(); /* inner Package */ |
| 160 | } |
| 161 | |
| 162 | acpigen_pop_len(); /* outer Package */ |
| 163 | acpigen_pop_len(); /* Method _ART */ |
| 164 | acpigen_pop_len(); /* Scope */ |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * _AC9 through _AC0 represent temperature thresholds, in increasing order, defined from _AC0 |
| 169 | * down, that, when reached, DPTF will activate TFN1 in order to actively cool the temperature |
| 170 | * sensor(s). As increasing thresholds are reached, the fan is spun faster. |
| 171 | */ |
| 172 | static void write_active_cooling_methods(const struct dptf_active_policy *policies, |
| 173 | int max_count) |
| 174 | { |
| 175 | char name[5]; |
| 176 | int i, j; |
| 177 | |
| 178 | /* Nothing to do */ |
| 179 | if (!max_count || policies[0].target == DPTF_NONE) |
| 180 | return; |
| 181 | |
| 182 | for (i = 0; i < max_count; ++i) { |
| 183 | if (policies[i].target == DPTF_NONE) |
| 184 | break; |
| 185 | |
| 186 | dptf_write_scope(policies[i].target); |
| 187 | |
| 188 | /* Write out as many of _AC0 through _AC9 that are applicable */ |
| 189 | for (j = 0; j < DPTF_MAX_ACX; ++j) { |
| 190 | if (!policies[i].thresholds[j].temp) |
| 191 | break; |
| 192 | |
| 193 | snprintf(name, sizeof(name), "_AC%1X", j); |
| 194 | write_simple_return_method(name, to_acpi_temp( |
| 195 | policies[i].thresholds[j].temp)); |
| 196 | } |
| 197 | |
| 198 | acpigen_pop_len(); /* Scope */ |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | void dptf_write_active_policies(const struct dptf_active_policy *policies, int max_count) |
| 203 | { |
| 204 | write_active_relationship_table(policies, max_count); |
| 205 | write_active_cooling_methods(policies, max_count); |
| 206 | } |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 207 | |
| 208 | /* |
| 209 | * This writes out the Thermal Relationship Table, which describes the thermal relationships |
| 210 | * between participants in a thermal zone. This information is used to passively cool (i.e., |
| 211 | * throttle) the Source (source of heat), in order to indirectly cool the Target (temperature |
| 212 | * sensor). |
| 213 | */ |
| 214 | static void write_thermal_relationship_table(const struct dptf_passive_policy *policies, |
| 215 | int max_count) |
| 216 | { |
| 217 | char *pkg_count; |
| 218 | int i; |
| 219 | |
| 220 | /* Nothing to do */ |
| 221 | if (!max_count || policies[0].source == DPTF_NONE) |
| 222 | return; |
| 223 | |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 224 | acpigen_write_scope(DPTF_DEVICE_PATH); |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 225 | |
| 226 | /* |
| 227 | * A _TRT Revision (TRTR) of 1 means that the 'Priority' field is an arbitrary priority |
| 228 | * value to be used for this specific relationship. The priority value determines the |
| 229 | * order in which various sources are used in a passive thermal action for a given |
| 230 | * target. |
| 231 | */ |
| 232 | acpigen_write_name_integer("TRTR", 1); |
| 233 | |
| 234 | /* Thermal Relationship Table */ |
| 235 | acpigen_write_method("_TRT", 0); |
| 236 | |
| 237 | /* Return this package */ |
| 238 | acpigen_emit_byte(RETURN_OP); |
| 239 | pkg_count = acpigen_write_package(0); |
| 240 | |
| 241 | for (i = 0; i < max_count; ++i) { |
| 242 | /* Stop writing the table once an entry is empty */ |
| 243 | if (policies[i].source == DPTF_NONE) |
| 244 | break; |
| 245 | |
| 246 | /* Keep track of outer package item count */ |
| 247 | (*pkg_count)++; |
| 248 | |
| 249 | acpigen_write_package(8); |
| 250 | |
| 251 | /* Source, Target, Priority, Sampling Period */ |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 252 | acpigen_emit_namestring(path_of(policies[i].source)); |
| 253 | acpigen_emit_namestring(path_of(policies[i].target)); |
Tim Wawrzynczak | 7eb1136 | 2020-05-29 14:10:53 -0600 | [diff] [blame] | 254 | acpigen_write_integer(DEFAULT_IF_0(policies[i].priority, DEFAULT_PRIORITY)); |
| 255 | acpigen_write_integer(to_acpi_time(policies[i].period)); |
| 256 | |
| 257 | /* Reserved */ |
| 258 | write_zeros(4); |
| 259 | |
| 260 | acpigen_pop_len(); /* Package */ |
| 261 | } |
| 262 | |
| 263 | acpigen_pop_len(); /* Package */ |
| 264 | acpigen_pop_len(); /* Method */ |
| 265 | acpigen_pop_len(); /* Scope */ |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | * When a temperature sensor measures above its the temperature returned in its _PSV Method, |
| 270 | * DPTF will begin throttling Sources in order to indirectly cool the sensor. |
| 271 | */ |
| 272 | static void write_all_PSV(const struct dptf_passive_policy *policies, int max_count) |
| 273 | { |
| 274 | int i; |
| 275 | |
| 276 | for (i = 0; i < max_count; ++i) { |
| 277 | if (policies[i].source == DPTF_NONE) |
| 278 | break; |
| 279 | |
| 280 | dptf_write_scope(policies[i].target); |
| 281 | write_simple_return_method("_PSV", to_acpi_temp(policies[i].temp)); |
| 282 | acpigen_pop_len(); /* Scope */ |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | void dptf_write_passive_policies(const struct dptf_passive_policy *policies, int max_count) |
| 287 | { |
| 288 | write_thermal_relationship_table(policies, max_count); |
| 289 | write_all_PSV(policies, max_count); |
| 290 | } |
Tim Wawrzynczak | 3a9cde9 | 2020-05-29 14:19:15 -0600 | [diff] [blame] | 291 | |
| 292 | void dptf_write_critical_policies(const struct dptf_critical_policy *policies, int max_count) |
| 293 | { |
| 294 | int i; |
| 295 | |
| 296 | for (i = 0; i < max_count; ++i) { |
| 297 | if (policies[i].source == DPTF_NONE) |
| 298 | break; |
| 299 | |
| 300 | dptf_write_scope(policies[i].source); |
| 301 | |
| 302 | /* Choose _CRT or _HOT */ |
| 303 | write_simple_return_method(policies[i].type == DPTF_CRITICAL_SHUTDOWN ? |
| 304 | "_CRT" : "_HOT", to_acpi_temp(policies[i].temp)); |
| 305 | |
| 306 | acpigen_pop_len(); /* Scope */ |
| 307 | } |
| 308 | } |
Tim Wawrzynczak | 46f6fcf | 2020-05-29 14:29:53 -0600 | [diff] [blame] | 309 | |
| 310 | void dptf_write_charger_perf(const struct dptf_charger_perf *states, int max_count) |
| 311 | { |
| 312 | char *pkg_count; |
| 313 | int i; |
| 314 | |
| 315 | if (!max_count || !states[0].control) |
| 316 | return; |
| 317 | |
| 318 | dptf_write_scope(DPTF_CHARGER); |
| 319 | |
| 320 | /* PPSS - Participant Performance Supported States */ |
| 321 | acpigen_write_method("PPSS", 0); |
| 322 | acpigen_emit_byte(RETURN_OP); |
| 323 | |
| 324 | pkg_count = acpigen_write_package(0); |
| 325 | for (i = 0; i < max_count; ++i) { |
| 326 | if (!states[i].control) |
| 327 | break; |
| 328 | |
| 329 | (*pkg_count)++; |
| 330 | |
| 331 | /* |
| 332 | * 0, 0, 0, 0, # Reserved |
| 333 | * Control, Raw Performance, Raw Unit, 0 # Reserved |
| 334 | */ |
| 335 | acpigen_write_package(8); |
| 336 | write_zeros(4); |
| 337 | acpigen_write_integer(states[i].control); |
| 338 | acpigen_write_integer(states[i].raw_perf); |
| 339 | acpigen_write_string(DEFAULT_RAW_UNIT); |
| 340 | acpigen_write_integer(0); |
| 341 | acpigen_pop_len(); /* inner Package */ |
| 342 | } |
| 343 | |
| 344 | acpigen_pop_len(); /* outer Package */ |
| 345 | acpigen_pop_len(); /* Method PPSS */ |
| 346 | acpigen_pop_len(); /* Scope */ |
| 347 | } |
Tim Wawrzynczak | 2ad8ffe | 2020-05-29 14:39:02 -0600 | [diff] [blame] | 348 | |
| 349 | void dptf_write_fan_perf(const struct dptf_fan_perf *states, int max_count) |
| 350 | { |
| 351 | char *pkg_count; |
| 352 | int i; |
| 353 | |
| 354 | if (!max_count || !states[0].percent) |
| 355 | return; |
| 356 | |
| 357 | dptf_write_scope(DPTF_FAN); |
| 358 | |
| 359 | /* _FPS - Fan Performance States */ |
| 360 | acpigen_write_name("_FPS"); |
Tim Wawrzynczak | a9d3e65 | 2020-07-27 13:51:04 -0600 | [diff] [blame] | 361 | pkg_count = acpigen_write_package(1); /* 1 for Revision */ |
| 362 | acpigen_write_integer(FPS_REVISION); /* revision */ |
Tim Wawrzynczak | 2ad8ffe | 2020-05-29 14:39:02 -0600 | [diff] [blame] | 363 | |
| 364 | for (i = 0; i < max_count; ++i) { |
| 365 | /* |
| 366 | * Some _FPS tables do include a last entry where Percent is 0, but Power is |
| 367 | * called out, so this table is finished when both are zero. |
| 368 | */ |
| 369 | if (!states[i].percent && !states[i].power) |
| 370 | break; |
| 371 | |
| 372 | (*pkg_count)++; |
| 373 | acpigen_write_package(5); |
| 374 | acpigen_write_integer(states[i].percent); |
| 375 | acpigen_write_integer(DEFAULT_TRIP_POINT); |
| 376 | acpigen_write_integer(states[i].speed); |
| 377 | acpigen_write_integer(states[i].noise_level); |
| 378 | acpigen_write_integer(states[i].power); |
| 379 | acpigen_pop_len(); /* inner Package */ |
| 380 | } |
| 381 | |
| 382 | acpigen_pop_len(); /* Package */ |
| 383 | acpigen_pop_len(); /* Scope */ |
| 384 | } |
Tim Wawrzynczak | bb5c255 | 2020-05-29 14:46:19 -0600 | [diff] [blame] | 385 | |
| 386 | void dptf_write_power_limits(const struct dptf_power_limits *limits) |
| 387 | { |
| 388 | char *pkg_count; |
| 389 | |
| 390 | /* Nothing to do */ |
| 391 | if (!limits->pl1.min_power && !limits->pl2.min_power) |
| 392 | return; |
| 393 | |
| 394 | dptf_write_scope(DPTF_CPU); |
| 395 | acpigen_write_method("PPCC", 0); |
| 396 | |
| 397 | pkg_count = acpigen_write_package(1); /* 1 for the Revision */ |
| 398 | acpigen_write_integer(PPCC_REVISION); /* revision */ |
| 399 | |
| 400 | if (limits->pl1.min_power) { |
| 401 | (*pkg_count)++; |
| 402 | acpigen_write_package(6); |
| 403 | acpigen_write_integer(RAPL_PL1_INDEX); |
| 404 | acpigen_write_integer(limits->pl1.min_power); |
| 405 | acpigen_write_integer(limits->pl1.max_power); |
| 406 | acpigen_write_integer(limits->pl1.time_window_min); |
| 407 | acpigen_write_integer(limits->pl1.time_window_max); |
| 408 | acpigen_write_integer(limits->pl1.granularity); |
| 409 | acpigen_pop_len(); /* inner Package */ |
| 410 | } |
| 411 | |
| 412 | if (limits->pl2.min_power) { |
| 413 | (*pkg_count)++; |
| 414 | acpigen_write_package(6); |
| 415 | acpigen_write_integer(RAPL_PL2_INDEX); |
| 416 | acpigen_write_integer(limits->pl2.min_power); |
| 417 | acpigen_write_integer(limits->pl2.max_power); |
| 418 | acpigen_write_integer(limits->pl2.time_window_min); |
| 419 | acpigen_write_integer(limits->pl2.time_window_max); |
| 420 | acpigen_write_integer(limits->pl2.granularity); |
| 421 | acpigen_pop_len(); /* inner Package */ |
| 422 | } |
| 423 | |
| 424 | acpigen_pop_len(); /* outer Package */ |
| 425 | acpigen_pop_len(); /* Method */ |
| 426 | acpigen_pop_len(); /* Scope */ |
| 427 | } |
Tim Wawrzynczak | e4d8ebc | 2020-05-29 14:58:16 -0600 | [diff] [blame] | 428 | |
| 429 | void dptf_write_STR(const char *str) |
| 430 | { |
| 431 | if (!str) |
| 432 | return; |
| 433 | |
| 434 | acpigen_write_name_string("_STR", str); |
| 435 | } |
| 436 | |
| 437 | void dptf_write_fan_options(bool fine_grained, int step_size, bool low_speed_notify) |
| 438 | { |
| 439 | acpigen_write_name("_FIF"); |
| 440 | acpigen_write_package(4); |
| 441 | |
| 442 | acpigen_write_integer(0); /* Revision */ |
| 443 | acpigen_write_integer(fine_grained); |
| 444 | acpigen_write_integer(step_size); |
| 445 | acpigen_write_integer(low_speed_notify); |
| 446 | acpigen_pop_len(); /* Package */ |
| 447 | } |
| 448 | |
| 449 | void dptf_write_tsr_hysteresis(uint8_t hysteresis) |
| 450 | { |
| 451 | if (!hysteresis) |
| 452 | return; |
| 453 | |
| 454 | acpigen_write_name_integer("GTSH", hysteresis); |
| 455 | } |
Tim Wawrzynczak | 03465f4 | 2020-06-03 16:27:30 -0600 | [diff] [blame] | 456 | |
| 457 | void dptf_write_enabled_policies(const struct dptf_active_policy *active_policies, |
| 458 | int active_count, |
| 459 | const struct dptf_passive_policy *passive_policies, |
| 460 | int passive_count, |
| 461 | const struct dptf_critical_policy *critical_policies, |
| 462 | int critical_count) |
| 463 | { |
| 464 | bool is_active_used; |
| 465 | bool is_passive_used; |
| 466 | bool is_critical_used; |
| 467 | int pkg_count; |
| 468 | |
| 469 | is_active_used = (active_count && active_policies[0].target != DPTF_NONE); |
| 470 | is_passive_used = (passive_count && passive_policies[0].target != DPTF_NONE); |
| 471 | is_critical_used = (critical_count && critical_policies[0].source != DPTF_NONE); |
| 472 | pkg_count = is_active_used + is_passive_used + is_critical_used; |
| 473 | |
| 474 | if (!pkg_count) |
| 475 | return; |
| 476 | |
Tim Wawrzynczak | 5212ece6 | 2020-07-16 11:54:04 -0600 | [diff] [blame] | 477 | acpigen_write_scope(DPTF_DEVICE_PATH); |
Tim Wawrzynczak | 03465f4 | 2020-06-03 16:27:30 -0600 | [diff] [blame] | 478 | acpigen_write_name("IDSP"); |
| 479 | acpigen_write_package(pkg_count); |
| 480 | |
| 481 | if (is_active_used) |
| 482 | acpigen_write_uuid(DPTF_ACTIVE_POLICY_UUID); |
| 483 | |
| 484 | if (is_passive_used) |
| 485 | acpigen_write_uuid(DPTF_PASSIVE_POLICY_1_0_UUID); |
| 486 | |
| 487 | if (is_critical_used) |
| 488 | acpigen_write_uuid(DPTF_CRITICAL_POLICY_UUID); |
| 489 | |
| 490 | acpigen_pop_len(); /* Package */ |
| 491 | acpigen_pop_len(); /* Scope */ |
| 492 | } |