Lines Matching refs:tz

65 #define ACPI_THERMAL_TRIPS_EXCEPTION(flags, tz, str) \  argument
68 acpi_handle_info(tz->device->handle, \
141 static int acpi_thermal_get_temperature(struct acpi_thermal *tz) in acpi_thermal_get_temperature() argument
146 if (!tz) in acpi_thermal_get_temperature()
149 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
151 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
155 tz->temperature = tmp; in acpi_thermal_get_temperature()
157 acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n", in acpi_thermal_get_temperature()
158 tz->temperature); in acpi_thermal_get_temperature()
163 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
168 if (!tz) in acpi_thermal_get_polling_frequency()
171 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
175 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
176 acpi_handle_debug(tz->device->handle, "Polling frequency is %lu dS\n", in acpi_thermal_get_polling_frequency()
177 tz->polling_frequency); in acpi_thermal_get_polling_frequency()
182 static int acpi_thermal_temp(struct acpi_thermal *tz, int temp_deci_k) in acpi_thermal_temp() argument
188 tz->kelvin_offset); in acpi_thermal_temp()
191 static void __acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in __acpi_thermal_trips_update() argument
201 status = acpi_evaluate_integer(tz->device->handle, "_CRT", NULL, &tmp); in __acpi_thermal_trips_update()
202 tz->trips.critical.temperature = tmp; in __acpi_thermal_trips_update()
210 tz->trips.critical.valid = false; in __acpi_thermal_trips_update()
211 acpi_handle_debug(tz->device->handle, in __acpi_thermal_trips_update()
215 tz->trips.critical.valid = false; in __acpi_thermal_trips_update()
217 tz->trips.critical.valid = true; in __acpi_thermal_trips_update()
218 acpi_handle_debug(tz->device->handle, in __acpi_thermal_trips_update()
220 tz->trips.critical.temperature); in __acpi_thermal_trips_update()
222 if (tz->trips.critical.valid) { in __acpi_thermal_trips_update()
224 tz->trips.critical.valid = false; in __acpi_thermal_trips_update()
231 if (crt_k > tz->trips.critical.temperature) in __acpi_thermal_trips_update()
234 tz->trips.critical.temperature = crt_k; in __acpi_thermal_trips_update()
241 status = acpi_evaluate_integer(tz->device->handle, "_HOT", NULL, &tmp); in __acpi_thermal_trips_update()
243 tz->trips.hot.valid = false; in __acpi_thermal_trips_update()
244 acpi_handle_debug(tz->device->handle, in __acpi_thermal_trips_update()
247 tz->trips.hot.temperature = tmp; in __acpi_thermal_trips_update()
248 tz->trips.hot.valid = true; in __acpi_thermal_trips_update()
249 acpi_handle_debug(tz->device->handle, in __acpi_thermal_trips_update()
251 tz->trips.hot.temperature); in __acpi_thermal_trips_update()
256 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.trip.valid) || in __acpi_thermal_trips_update()
258 valid = tz->trips.passive.trip.valid; in __acpi_thermal_trips_update()
265 status = acpi_evaluate_integer(tz->device->handle, in __acpi_thermal_trips_update()
270 tz->trips.passive.trip.valid = false; in __acpi_thermal_trips_update()
272 tz->trips.passive.trip.temperature = tmp; in __acpi_thermal_trips_update()
273 tz->trips.passive.trip.valid = true; in __acpi_thermal_trips_update()
275 status = acpi_evaluate_integer(tz->device->handle, in __acpi_thermal_trips_update()
278 tz->trips.passive.trip.valid = false; in __acpi_thermal_trips_update()
280 tz->trips.passive.tc1 = tmp; in __acpi_thermal_trips_update()
282 status = acpi_evaluate_integer(tz->device->handle, in __acpi_thermal_trips_update()
285 tz->trips.passive.trip.valid = false; in __acpi_thermal_trips_update()
287 tz->trips.passive.tc2 = tmp; in __acpi_thermal_trips_update()
289 status = acpi_evaluate_integer(tz->device->handle, in __acpi_thermal_trips_update()
292 tz->trips.passive.trip.valid = false; in __acpi_thermal_trips_update()
294 tz->trips.passive.tsp = tmp; in __acpi_thermal_trips_update()
298 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.trip.valid) { in __acpi_thermal_trips_update()
300 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in __acpi_thermal_trips_update()
303 acpi_handle_info(tz->device->handle, in __acpi_thermal_trips_update()
305 tz->trips.passive.trip.valid = false; in __acpi_thermal_trips_update()
307 tz->trips.passive.trip.valid = true; in __acpi_thermal_trips_update()
310 if (memcmp(&tz->trips.passive.devices, &devices, in __acpi_thermal_trips_update()
312 memcpy(&tz->trips.passive.devices, &devices, in __acpi_thermal_trips_update()
314 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in __acpi_thermal_trips_update()
318 if (valid != tz->trips.passive.trip.valid) in __acpi_thermal_trips_update()
319 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); in __acpi_thermal_trips_update()
325 valid = tz->trips.active[i].trip.valid; in __acpi_thermal_trips_update()
331 tz->trips.active[i].trip.valid)) { in __acpi_thermal_trips_update()
332 status = acpi_evaluate_integer(tz->device->handle, in __acpi_thermal_trips_update()
335 tz->trips.active[i].trip.valid = false; in __acpi_thermal_trips_update()
343 tz->trips.active[0].trip.temperature = in __acpi_thermal_trips_update()
350 tz->trips.active[i-1].trip.temperature = in __acpi_thermal_trips_update()
352 tz->trips.active[i-2].trip.temperature, in __acpi_thermal_trips_update()
357 tz->trips.active[i].trip.temperature = tmp; in __acpi_thermal_trips_update()
358 tz->trips.active[i].trip.valid = true; in __acpi_thermal_trips_update()
363 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].trip.valid) { in __acpi_thermal_trips_update()
365 status = acpi_evaluate_reference(tz->device->handle, in __acpi_thermal_trips_update()
368 acpi_handle_info(tz->device->handle, in __acpi_thermal_trips_update()
370 tz->trips.active[i].trip.valid = false; in __acpi_thermal_trips_update()
372 tz->trips.active[i].trip.valid = true; in __acpi_thermal_trips_update()
375 if (memcmp(&tz->trips.active[i].devices, &devices, in __acpi_thermal_trips_update()
377 memcpy(&tz->trips.active[i].devices, &devices, in __acpi_thermal_trips_update()
379 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in __acpi_thermal_trips_update()
383 if (valid != tz->trips.active[i].trip.valid) in __acpi_thermal_trips_update()
384 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "state"); in __acpi_thermal_trips_update()
386 if (!tz->trips.active[i].trip.valid) in __acpi_thermal_trips_update()
392 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in __acpi_thermal_trips_update()
395 memcmp(&tz->devices, &devices, sizeof(devices))) { in __acpi_thermal_trips_update()
396 tz->devices = devices; in __acpi_thermal_trips_update()
397 ACPI_THERMAL_TRIPS_EXCEPTION(flag, tz, "device"); in __acpi_thermal_trips_update()
405 struct acpi_thermal *tz = data; in acpi_thermal_adjust_trip() local
411 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); in acpi_thermal_adjust_trip()
421 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_adjust_thermal_zone() local
425 __acpi_thermal_trips_update(tz, flag); in acpi_thermal_adjust_thermal_zone()
427 for_each_thermal_trip(tz->thermal_zone, acpi_thermal_adjust_trip, tz); in acpi_thermal_adjust_thermal_zone()
430 static void acpi_queue_thermal_check(struct acpi_thermal *tz) in acpi_queue_thermal_check() argument
432 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
433 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
436 static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) in acpi_thermal_trips_update() argument
438 struct acpi_device *adev = tz->device; in acpi_thermal_trips_update()
447 thermal_zone_device_exec(tz->thermal_zone, in acpi_thermal_trips_update()
449 acpi_queue_thermal_check(tz); in acpi_thermal_trips_update()
454 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
459 __acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
461 valid = tz->trips.critical.valid | in acpi_thermal_get_trip_points()
462 tz->trips.hot.valid | in acpi_thermal_get_trip_points()
463 tz->trips.passive.trip.valid; in acpi_thermal_get_trip_points()
466 valid = valid || tz->trips.active[i].trip.valid; in acpi_thermal_get_trip_points()
479 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in thermal_get_temp() local
482 if (!tz) in thermal_get_temp()
485 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
489 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, in thermal_get_temp()
490 tz->kelvin_offset); in thermal_get_temp()
498 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in thermal_get_trend() local
502 if (!tz || !trip) in thermal_get_trend()
511 t = tz->trips.passive.tc1 * (tz->temperature - in thermal_get_trend()
512 tz->last_temperature) + in thermal_get_trend()
513 tz->trips.passive.tc2 * (tz->temperature - in thermal_get_trend()
525 t = acpi_thermal_temp(tz, tz->temperature); in thermal_get_trend()
542 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_zone_device_hot() local
544 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_hot()
545 dev_name(&tz->device->dev), in acpi_thermal_zone_device_hot()
551 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_zone_device_critical() local
553 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_critical()
554 dev_name(&tz->device->dev), in acpi_thermal_zone_device_critical()
565 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_cooling_device_cb() local
573 if (tz->trips.critical.valid) in acpi_thermal_cooling_device_cb()
576 if (tz->trips.hot.valid) in acpi_thermal_cooling_device_cb()
579 if (tz->trips.passive.trip.valid) { in acpi_thermal_cooling_device_cb()
581 for (i = 0; i < tz->trips.passive.devices.count; i++) { in acpi_thermal_cooling_device_cb()
582 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
604 if (!tz->trips.active[i].trip.valid) in acpi_thermal_cooling_device_cb()
608 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_cooling_device_cb()
609 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
656 static int acpi_thermal_zone_sysfs_add(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_add() argument
658 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_add()
661 ret = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_zone_sysfs_add()
667 &tz->device->dev.kobj, "device"); in acpi_thermal_zone_sysfs_add()
669 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_add()
674 static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_remove() argument
676 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_remove()
678 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_remove()
682 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
691 if (tz->trips.critical.valid) in acpi_thermal_register_thermal_zone()
694 if (tz->trips.hot.valid) in acpi_thermal_register_thermal_zone()
697 if (tz->trips.passive.trip.valid) { in acpi_thermal_register_thermal_zone()
699 passive_delay = tz->trips.passive.tsp * 100; in acpi_thermal_register_thermal_zone()
702 for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE && tz->trips.active[i].trip.valid; i++) in acpi_thermal_register_thermal_zone()
709 tz->trip_table = trip; in acpi_thermal_register_thermal_zone()
711 if (tz->trips.critical.valid) { in acpi_thermal_register_thermal_zone()
713 trip->temperature = acpi_thermal_temp(tz, tz->trips.critical.temperature); in acpi_thermal_register_thermal_zone()
717 if (tz->trips.hot.valid) { in acpi_thermal_register_thermal_zone()
719 trip->temperature = acpi_thermal_temp(tz, tz->trips.hot.temperature); in acpi_thermal_register_thermal_zone()
723 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_register_thermal_zone()
726 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); in acpi_thermal_register_thermal_zone()
732 acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_register_thermal_zone()
738 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temperature); in acpi_thermal_register_thermal_zone()
743 tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz", in acpi_thermal_register_thermal_zone()
744 tz->trip_table, in acpi_thermal_register_thermal_zone()
746 0, tz, in acpi_thermal_register_thermal_zone()
750 tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
751 if (IS_ERR(tz->thermal_zone)) { in acpi_thermal_register_thermal_zone()
752 result = PTR_ERR(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
756 result = acpi_thermal_zone_sysfs_add(tz); in acpi_thermal_register_thermal_zone()
760 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
764 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
765 thermal_zone_device_id(tz->thermal_zone)); in acpi_thermal_register_thermal_zone()
770 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_register_thermal_zone()
772 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
774 kfree(tz->trip_table); in acpi_thermal_register_thermal_zone()
779 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
781 thermal_zone_device_disable(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
782 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_unregister_thermal_zone()
783 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
784 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
795 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
797 if (!tz) in acpi_thermal_notify()
802 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
806 acpi_thermal_trips_update(tz, event); in acpi_thermal_notify()
827 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
829 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
847 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
851 if (!tz) in acpi_thermal_get_info()
854 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
857 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
862 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
867 acpi_execute_simple_method(tz->device->handle, "_SCP", in acpi_thermal_get_info()
872 tz->polling_frequency = tzp; in acpi_thermal_get_info()
874 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
889 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
891 if (tz->trips.critical.valid && in acpi_thermal_guess_offset()
892 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
893 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
895 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
900 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
911 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
914 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
916 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
918 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
920 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
925 struct acpi_thermal *tz; in acpi_thermal_add() local
931 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
932 if (!tz) in acpi_thermal_add()
935 tz->device = device; in acpi_thermal_add()
936 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
939 device->driver_data = tz; in acpi_thermal_add()
941 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
945 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
947 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
951 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
952 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
953 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
956 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); in acpi_thermal_add()
967 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_add()
969 kfree(tz); in acpi_thermal_add()
976 struct acpi_thermal *tz; in acpi_thermal_remove() local
981 tz = acpi_driver_data(device); in acpi_thermal_remove()
987 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
988 kfree(tz->trip_table); in acpi_thermal_remove()
989 kfree(tz); in acpi_thermal_remove()
1002 struct acpi_thermal *tz; in acpi_thermal_resume() local
1008 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1009 if (!tz) in acpi_thermal_resume()
1013 if (!tz->trips.active[i].trip.valid) in acpi_thermal_resume()
1016 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1017 acpi_bus_update_power(tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1022 acpi_queue_thermal_check(tz); in acpi_thermal_resume()