Lines Matching refs:tz
182 static int acpi_thermal_get_temperature(struct acpi_thermal *tz) in acpi_thermal_get_temperature() argument
187 if (!tz) in acpi_thermal_get_temperature()
190 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
192 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
196 tz->temperature = tmp; in acpi_thermal_get_temperature()
198 acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n", in acpi_thermal_get_temperature()
199 tz->temperature); in acpi_thermal_get_temperature()
204 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
209 if (!tz) in acpi_thermal_get_polling_frequency()
212 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
216 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
217 acpi_handle_debug(tz->device->handle, "Polling frequency is %lu dS\n", in acpi_thermal_get_polling_frequency()
218 tz->polling_frequency); in acpi_thermal_get_polling_frequency()
223 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) in acpi_thermal_set_cooling_mode() argument
225 if (!tz) in acpi_thermal_set_cooling_mode()
228 if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
255 #define ACPI_THERMAL_TRIPS_EXCEPTION(flags, tz, str) \ argument
258 acpi_handle_info(tz->device->handle, \
263 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in acpi_thermal_trips_update() argument
273 status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp); in acpi_thermal_trips_update()
274 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
282 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
283 acpi_handle_debug(tz->device->handle, in acpi_thermal_trips_update()
287 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
289 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
290 acpi_handle_debug(tz->device->handle, in acpi_thermal_trips_update()
292 tz->trips.critical.temperature); in acpi_thermal_trips_update()
294 if (tz->trips.critical.flags.valid) { in acpi_thermal_trips_update()
296 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
303 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
306 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
313 status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); in acpi_thermal_trips_update()
315 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
316 acpi_handle_debug(tz->device->handle, in acpi_thermal_trips_update()
319 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
320 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
321 acpi_handle_debug(tz->device->handle, in acpi_thermal_trips_update()
323 tz->trips.hot.temperature); in acpi_thermal_trips_update()
328 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
330 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
337 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
342 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
344 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
345 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
347 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
350 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
352 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
354 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
357 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
359 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
361 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
364 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
366 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
370 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
372 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
375 acpi_handle_info(tz->device->handle, in acpi_thermal_trips_update()
377 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
379 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
382 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
384 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
386 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in acpi_thermal_trips_update()
390 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
391 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); in acpi_thermal_trips_update()
397 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
403 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
404 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
407 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
415 tz->trips.active[0].temperature = celsius_to_deci_kelvin(act); in acpi_thermal_trips_update()
421 tz->trips.active[i-1].temperature = in acpi_thermal_trips_update()
422 (tz->trips.active[i-2].temperature < in acpi_thermal_trips_update()
424 tz->trips.active[i-2].temperature : in acpi_thermal_trips_update()
429 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
430 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
435 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid) { in acpi_thermal_trips_update()
437 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
440 acpi_handle_info(tz->device->handle, in acpi_thermal_trips_update()
442 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
444 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
447 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
449 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
451 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in acpi_thermal_trips_update()
455 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
456 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); in acpi_thermal_trips_update()
458 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
464 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
467 memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
468 tz->devices = devices; in acpi_thermal_trips_update()
469 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in acpi_thermal_trips_update()
476 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
478 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
483 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
484 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
485 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
488 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
501 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
504 if (!tz) in thermal_get_temp()
507 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
511 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, in thermal_get_temp()
512 tz->kelvin_offset); in thermal_get_temp()
519 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
522 if (!tz || trip < 0) in thermal_get_trip_type()
525 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
533 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
541 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
549 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
563 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
566 if (!tz || trip < 0) in thermal_get_trip_temp()
569 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
572 tz->trips.critical.temperature, in thermal_get_trip_temp()
573 tz->kelvin_offset); in thermal_get_trip_temp()
579 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
582 tz->trips.hot.temperature, in thermal_get_trip_temp()
583 tz->kelvin_offset); in thermal_get_trip_temp()
589 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
592 tz->trips.passive.temperature, in thermal_get_trip_temp()
593 tz->kelvin_offset); in thermal_get_trip_temp()
600 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
603 tz->trips.active[i].temperature, in thermal_get_trip_temp()
604 tz->kelvin_offset); in thermal_get_trip_temp()
616 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
618 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
620 tz->trips.critical.temperature, in thermal_get_crit_temp()
621 tz->kelvin_offset); in thermal_get_crit_temp()
631 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
641 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
658 i = tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature) + in thermal_get_trend()
659 tz->trips.passive.tc2 * (tz->temperature - tz->trips.passive.temperature); in thermal_get_trend()
673 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_zone_device_hot() local
675 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_hot()
676 dev_name(&tz->device->dev), in acpi_thermal_zone_device_hot()
682 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_zone_device_critical() local
684 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_critical()
685 dev_name(&tz->device->dev), in acpi_thermal_zone_device_critical()
696 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
704 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
707 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
710 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
712 for (i = 0; i < tz->trips.passive.devices.count; i++) { in acpi_thermal_cooling_device_cb()
713 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
735 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
739 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_cooling_device_cb()
740 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
790 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
797 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
800 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
803 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
806 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].flags.valid; in acpi_thermal_register_thermal_zone()
809 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
810 tz->thermal_zone = thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
812 tz->trips.passive.tsp * 100, in acpi_thermal_register_thermal_zone()
813 tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
815 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
816 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
818 0, tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
820 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
823 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
824 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
828 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
829 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
833 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
834 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
840 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
844 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
845 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
850 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_register_thermal_zone()
852 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_register_thermal_zone()
854 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
856 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
861 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
863 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
864 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
865 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
866 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
867 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
875 static void acpi_queue_thermal_check(struct acpi_thermal *tz) in acpi_queue_thermal_check() argument
877 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
878 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
883 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
885 if (!tz) in acpi_thermal_notify()
890 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
893 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
894 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
899 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
900 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
923 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
925 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
943 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
947 if (!tz) in acpi_thermal_get_info()
950 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
953 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
958 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
963 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); in acpi_thermal_get_info()
965 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
969 tz->polling_frequency = tzp; in acpi_thermal_get_info()
971 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
986 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
988 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
989 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
990 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
992 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
997 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
1008 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
1011 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
1013 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
1015 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
1017 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
1022 struct acpi_thermal *tz; in acpi_thermal_add() local
1028 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1029 if (!tz) in acpi_thermal_add()
1032 tz->device = device; in acpi_thermal_add()
1033 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1036 device->driver_data = tz; in acpi_thermal_add()
1038 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1042 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1044 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1048 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
1049 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
1050 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1053 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); in acpi_thermal_add()
1057 kfree(tz); in acpi_thermal_add()
1064 struct acpi_thermal *tz; in acpi_thermal_remove() local
1070 tz = acpi_driver_data(device); in acpi_thermal_remove()
1072 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1073 kfree(tz); in acpi_thermal_remove()
1086 struct acpi_thermal *tz; in acpi_thermal_resume() local
1092 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1093 if (!tz) in acpi_thermal_resume()
1097 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1100 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1101 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1103 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1106 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1110 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1113 acpi_queue_thermal_check(tz); in acpi_thermal_resume()