Lines Matching +full:- +full:- +full:valid +full:- +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $)
120 u8 valid:1; member
179 /* --------------------------------------------------------------------------
181 -------------------------------------------------------------------------- */
189 return -EINVAL; in acpi_thermal_get_temperature()
191 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
193 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
195 return -ENODEV; in acpi_thermal_get_temperature()
197 tz->temperature = tmp; in acpi_thermal_get_temperature()
199 tz->temperature)); in acpi_thermal_get_temperature()
210 return -EINVAL; in acpi_thermal_get_polling_frequency()
212 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
214 return -ENODEV; in acpi_thermal_get_polling_frequency()
216 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
218 tz->polling_frequency)); in acpi_thermal_get_polling_frequency()
226 return -EINVAL; in acpi_thermal_set_cooling_mode()
228 if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
230 return -ENODEV; in acpi_thermal_set_cooling_mode()
250 * 1.An invalid trip point becomes invalid or a valid trip point becomes invalid
251 * when re-evaluating the AML code.
253 * We need to re-bind the cooling devices of a thermal zone when this occurs.
260 "Please send acpidump to linux-acpi@vger.kernel.org", str)); \
268 int valid = 0; in acpi_thermal_trips_update() local
273 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
275 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
283 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
289 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
291 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
294 tz->trips.critical.temperature)); in acpi_thermal_trips_update()
296 if (tz->trips.critical.flags.valid == 1) { in acpi_thermal_trips_update()
297 if (crt == -1) { in acpi_thermal_trips_update()
298 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
305 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
308 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
315 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
318 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
322 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
323 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
326 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
331 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
333 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
334 if (psv == -1) { in acpi_thermal_trips_update()
340 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
345 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
347 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
348 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
351 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
354 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
356 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
358 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
361 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
363 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
365 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
368 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
370 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
374 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
376 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
380 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
383 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
385 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
387 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
393 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
400 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
402 if (act == -1) in acpi_thermal_trips_update()
406 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
407 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
410 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
416 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
423 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
424 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
426 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
430 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
431 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
436 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
438 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
443 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
446 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
448 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
450 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
456 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
459 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
465 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
468 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
469 tz->devices = devices; in acpi_thermal_trips_update()
479 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points() local
484 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
485 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
486 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
489 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
491 if (!valid) { in acpi_thermal_get_trip_points()
492 pr_warn(FW_BUG "No valid trip found\n"); in acpi_thermal_get_trip_points()
493 return -ENODEV; in acpi_thermal_get_trip_points()
502 thermal_zone_device_update(tz->thermal_zone, in acpi_thermal_check()
510 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp()
514 return -EINVAL; in thermal_get_temp()
520 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, in thermal_get_temp()
521 tz->kelvin_offset); in thermal_get_temp()
528 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type()
532 return -EINVAL; in thermal_get_trip_type()
534 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
539 trip--; in thermal_get_trip_type()
542 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
547 trip--; in thermal_get_trip_type()
550 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
555 trip--; in thermal_get_trip_type()
559 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
564 trip--; in thermal_get_trip_type()
567 return -EINVAL; in thermal_get_trip_type()
573 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp()
577 return -EINVAL; in thermal_get_trip_temp()
579 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
582 tz->trips.critical.temperature, in thermal_get_trip_temp()
583 tz->kelvin_offset); in thermal_get_trip_temp()
586 trip--; in thermal_get_trip_temp()
589 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
592 tz->trips.hot.temperature, in thermal_get_trip_temp()
593 tz->kelvin_offset); in thermal_get_trip_temp()
596 trip--; in thermal_get_trip_temp()
599 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
602 tz->trips.passive.temperature, in thermal_get_trip_temp()
603 tz->kelvin_offset); in thermal_get_trip_temp()
606 trip--; in thermal_get_trip_temp()
610 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
613 tz->trips.active[i].temperature, in thermal_get_trip_temp()
614 tz->kelvin_offset); in thermal_get_trip_temp()
617 trip--; in thermal_get_trip_temp()
620 return -EINVAL; in thermal_get_trip_temp()
626 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp()
628 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
630 tz->trips.critical.temperature, in thermal_get_crit_temp()
631 tz->kelvin_offset); in thermal_get_crit_temp()
634 return -EINVAL; in thermal_get_crit_temp()
640 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend()
645 return -EINVAL; in thermal_get_trend()
650 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
652 return -EINVAL; in thermal_get_trend()
659 return -EINVAL; in thermal_get_trend()
664 * tz->temperature has already been updated by generic thermal layer, in thermal_get_trend()
667 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
668 + (tz->trips.passive.tc2 in thermal_get_trend()
669 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
685 struct acpi_thermal *tz = thermal->devdata; in thermal_notify()
694 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
695 dev_name(&tz->device->dev), type, 1); in thermal_notify()
707 struct acpi_device *device = cdev->devdata; in acpi_thermal_cooling_device_cb()
708 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb()
714 int trip = -1; in acpi_thermal_cooling_device_cb()
717 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
720 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
723 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
725 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
727 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
747 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
751 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
753 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
770 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
771 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
825 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
828 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
831 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
835 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
837 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
838 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
841 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
842 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
844 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
847 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
848 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
849 return -ENODEV; in acpi_thermal_register_thermal_zone()
851 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
852 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
856 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
857 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
861 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
862 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
864 result = -ENODEV; in acpi_thermal_register_thermal_zone()
868 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
872 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
873 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
878 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_register_thermal_zone()
880 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_register_thermal_zone()
882 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
884 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
891 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
892 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
893 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
894 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
895 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
899 /* --------------------------------------------------------------------------
901 -------------------------------------------------------------------------- */
918 acpi_bus_generate_netlink_event(device->pnp.device_class, in acpi_thermal_notify()
919 dev_name(&device->dev), event, 0); in acpi_thermal_notify()
924 acpi_bus_generate_netlink_event(device->pnp.device_class, in acpi_thermal_notify()
925 dev_name(&device->dev), event, 0); in acpi_thermal_notify()
937 * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
948 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
972 return -EINVAL; in acpi_thermal_get_info()
989 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
993 tz->polling_frequency = tzp; in acpi_thermal_get_info()
1012 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
1013 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
1014 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
1016 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
1033 return -EINVAL; in acpi_thermal_add()
1037 return -ENOMEM; in acpi_thermal_add()
1039 tz->device = device; in acpi_thermal_add()
1040 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1043 device->driver_data = tz; in acpi_thermal_add()
1055 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1058 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); in acpi_thermal_add()
1072 return -EINVAL; in acpi_thermal_remove()
1096 return -EINVAL; in acpi_thermal_resume()
1100 return -EINVAL; in acpi_thermal_resume()
1103 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1105 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1107 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1108 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1110 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1113 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1117 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1120 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_thermal_resume()
1130 "disabling all active thermal trip points\n", d->ident); in thermal_act()
1131 act = -1; in thermal_act()
1138 "disabling all critical thermal trip point actions.\n", d->ident); in thermal_nocrt()
1146 "enabling thermal zone polling\n", d->ident); in thermal_tzp()
1155 "disabling all passive thermal trip points\n", d->ident); in thermal_psv()
1156 psv = -1; in thermal_psv()
1168 .ident = "AOpen i915GMm-HFS",
1171 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1176 .ident = "AOpen i915GMm-HFS",
1179 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1184 .ident = "AOpen i915GMm-HFS",
1187 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1192 .ident = "Gigabyte GA-7ZX",
1209 return -ENODEV; in acpi_thermal_init()
1215 return -ENODEV; in acpi_thermal_init()
1220 return -ENODEV; in acpi_thermal_init()