|
43 | 43 | #define ACPI_THERMAL_MAX_ACTIVE 10 |
44 | 44 | #define ACPI_THERMAL_MAX_LIMIT_STR_LEN 65 |
45 | 45 |
|
46 | | -#define ACPI_TRIPS_CRITICAL BIT(0) |
47 | | -#define ACPI_TRIPS_HOT BIT(1) |
48 | | -#define ACPI_TRIPS_PASSIVE BIT(2) |
49 | | -#define ACPI_TRIPS_ACTIVE BIT(3) |
50 | | -#define ACPI_TRIPS_DEVICES BIT(4) |
| 46 | +#define ACPI_TRIPS_PASSIVE BIT(0) |
| 47 | +#define ACPI_TRIPS_ACTIVE BIT(1) |
| 48 | +#define ACPI_TRIPS_DEVICES BIT(2) |
51 | 49 |
|
52 | 50 | #define ACPI_TRIPS_THRESHOLDS (ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE) |
53 | 51 |
|
54 | | -#define ACPI_TRIPS_INIT (ACPI_TRIPS_CRITICAL | ACPI_TRIPS_HOT | \ |
55 | | - ACPI_TRIPS_PASSIVE | ACPI_TRIPS_ACTIVE | \ |
56 | | - ACPI_TRIPS_DEVICES) |
| 52 | +#define ACPI_TRIPS_INIT (ACPI_TRIPS_THRESHOLDS | ACPI_TRIPS_DEVICES) |
57 | 53 |
|
58 | 54 | /* |
59 | 55 | * This exception is thrown out in two cases: |
@@ -196,62 +192,6 @@ static void __acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) |
196 | 192 | bool valid = false; |
197 | 193 | int i; |
198 | 194 |
|
199 | | - /* Critical Shutdown */ |
200 | | - if (flag & ACPI_TRIPS_CRITICAL) { |
201 | | - status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp); |
202 | | - tz->trips.critical.temperature = tmp; |
203 | | - /* |
204 | | - * Treat freezing temperatures as invalid as well; some |
205 | | - * BIOSes return really low values and cause reboots at startup. |
206 | | - * Below zero (Celsius) values clearly aren't right for sure.. |
207 | | - * ... so lets discard those as invalid. |
208 | | - */ |
209 | | - if (ACPI_FAILURE(status)) { |
210 | | - tz->trips.critical.valid = false; |
211 | | - acpi_handle_debug(tz->device->handle, |
212 | | - "No critical threshold\n"); |
213 | | - } else if (tmp <= 2732) { |
214 | | - pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp); |
215 | | - tz->trips.critical.valid = false; |
216 | | - } else { |
217 | | - tz->trips.critical.valid = true; |
218 | | - acpi_handle_debug(tz->device->handle, |
219 | | - "Found critical threshold [%lu]\n", |
220 | | - tz->trips.critical.temperature); |
221 | | - } |
222 | | - if (tz->trips.critical.valid) { |
223 | | - if (crt == -1) { |
224 | | - tz->trips.critical.valid = false; |
225 | | - } else if (crt > 0) { |
226 | | - unsigned long crt_k = celsius_to_deci_kelvin(crt); |
227 | | - |
228 | | - /* |
229 | | - * Allow override critical threshold |
230 | | - */ |
231 | | - if (crt_k > tz->trips.critical.temperature) |
232 | | - pr_info("Critical threshold %d C\n", crt); |
233 | | - |
234 | | - tz->trips.critical.temperature = crt_k; |
235 | | - } |
236 | | - } |
237 | | - } |
238 | | - |
239 | | - /* Critical Sleep (optional) */ |
240 | | - if (flag & ACPI_TRIPS_HOT) { |
241 | | - status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); |
242 | | - if (ACPI_FAILURE(status)) { |
243 | | - tz->trips.hot.valid = false; |
244 | | - acpi_handle_debug(tz->device->handle, |
245 | | - "No hot threshold\n"); |
246 | | - } else { |
247 | | - tz->trips.hot.temperature = tmp; |
248 | | - tz->trips.hot.valid = true; |
249 | | - acpi_handle_debug(tz->device->handle, |
250 | | - "Found hot threshold [%lu]\n", |
251 | | - tz->trips.hot.temperature); |
252 | | - } |
253 | | - } |
254 | | - |
255 | 195 | /* Passive (optional) */ |
256 | 196 | if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.trip.valid) || |
257 | 197 | flag == ACPI_TRIPS_INIT) { |
@@ -451,11 +391,73 @@ static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) |
451 | 391 | dev_name(&adev->dev), event, 0); |
452 | 392 | } |
453 | 393 |
|
| 394 | +static void acpi_thermal_get_critical_trip(struct acpi_thermal *tz) |
| 395 | +{ |
| 396 | + unsigned long long tmp; |
| 397 | + acpi_status status; |
| 398 | + |
| 399 | + if (crt > 0) { |
| 400 | + tmp = celsius_to_deci_kelvin(crt); |
| 401 | + goto set; |
| 402 | + } |
| 403 | + if (crt == -1) { |
| 404 | + acpi_handle_debug(tz->device->handle, "Critical threshold disabled\n"); |
| 405 | + goto fail; |
| 406 | + } |
| 407 | + |
| 408 | + status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp); |
| 409 | + if (ACPI_FAILURE(status)) { |
| 410 | + acpi_handle_debug(tz->device->handle, "No critical threshold\n"); |
| 411 | + goto fail; |
| 412 | + } |
| 413 | + if (tmp <= 2732) { |
| 414 | + /* |
| 415 | + * Below zero (Celsius) values clearly aren't right for sure, |
| 416 | + * so discard them as invalid. |
| 417 | + */ |
| 418 | + pr_info(FW_BUG "Invalid critical threshold (%llu)\n", tmp); |
| 419 | + goto fail; |
| 420 | + } |
| 421 | + |
| 422 | +set: |
| 423 | + tz->trips.critical.valid = true; |
| 424 | + tz->trips.critical.temperature = tmp; |
| 425 | + acpi_handle_debug(tz->device->handle, "Critical threshold [%lu]\n", |
| 426 | + tz->trips.critical.temperature); |
| 427 | + return; |
| 428 | + |
| 429 | +fail: |
| 430 | + tz->trips.critical.valid = false; |
| 431 | + tz->trips.critical.temperature = THERMAL_TEMP_INVALID; |
| 432 | +} |
| 433 | + |
| 434 | +static void acpi_thermal_get_hot_trip(struct acpi_thermal *tz) |
| 435 | +{ |
| 436 | + unsigned long long tmp; |
| 437 | + acpi_status status; |
| 438 | + |
| 439 | + status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); |
| 440 | + if (ACPI_FAILURE(status)) { |
| 441 | + tz->trips.hot.valid = false; |
| 442 | + tz->trips.hot.temperature = THERMAL_TEMP_INVALID; |
| 443 | + acpi_handle_debug(tz->device->handle, "No hot threshold\n"); |
| 444 | + return; |
| 445 | + } |
| 446 | + |
| 447 | + tz->trips.hot.valid = true; |
| 448 | + tz->trips.hot.temperature = tmp; |
| 449 | + acpi_handle_debug(tz->device->handle, "Hot threshold [%lu]\n", |
| 450 | + tz->trips.hot.temperature); |
| 451 | +} |
| 452 | + |
454 | 453 | static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) |
455 | 454 | { |
456 | 455 | bool valid; |
457 | 456 | int i; |
458 | 457 |
|
| 458 | + acpi_thermal_get_critical_trip(tz); |
| 459 | + acpi_thermal_get_hot_trip(tz); |
| 460 | + /* Passive and active trip points (optional). */ |
459 | 461 | __acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); |
460 | 462 |
|
461 | 463 | valid = tz->trips.critical.valid | |
|
0 commit comments