Lines Matching full:tz
59 #define ACPI_THERMAL_TRIPS_EXCEPTION(tz, str) \ argument
61 acpi_handle_info(tz->device->handle, \
128 static int acpi_thermal_get_temperature(struct acpi_thermal *tz) in acpi_thermal_get_temperature() argument
133 if (!tz) in acpi_thermal_get_temperature()
136 tz->last_temp_dk = tz->temp_dk; in acpi_thermal_get_temperature()
138 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
142 tz->temp_dk = tmp; in acpi_thermal_get_temperature()
144 acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n", in acpi_thermal_get_temperature()
145 tz->temp_dk); in acpi_thermal_get_temperature()
150 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
155 if (!tz) in acpi_thermal_get_polling_frequency()
158 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
162 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
163 acpi_handle_debug(tz->device->handle, "Polling frequency is %lu dS\n", in acpi_thermal_get_polling_frequency()
164 tz->polling_frequency); in acpi_thermal_get_polling_frequency()
169 static int acpi_thermal_temp(struct acpi_thermal *tz, int temp_deci_k) in acpi_thermal_temp() argument
177 tz->kelvin_offset); in acpi_thermal_temp()
189 static int active_trip_index(struct acpi_thermal *tz, in active_trip_index() argument
195 return active - tz->trips.active; in active_trip_index()
198 static long get_passive_temp(struct acpi_thermal *tz) in get_passive_temp() argument
202 if (acpi_passive_trip_temp(tz->device, &temp)) in get_passive_temp()
208 static long get_active_temp(struct acpi_thermal *tz, int index) in get_active_temp() argument
212 if (acpi_active_trip_temp(tz->device, index, &temp)) in get_active_temp()
228 static void acpi_thermal_update_trip(struct acpi_thermal *tz, in acpi_thermal_update_trip() argument
237 acpi_trip->temp_dk = get_passive_temp(tz); in acpi_thermal_update_trip()
239 int index = active_trip_index(tz, acpi_trip); in acpi_thermal_update_trip()
241 acpi_trip->temp_dk = get_active_temp(tz, index); in acpi_thermal_update_trip()
245 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); in acpi_thermal_update_trip()
248 static bool update_trip_devices(struct acpi_thermal *tz, in update_trip_devices() argument
261 if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) { in update_trip_devices()
262 acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method); in update_trip_devices()
272 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "device"); in update_trip_devices()
278 static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, in acpi_thermal_update_trip_devices() argument
283 ACPI_THERMAL_TRIP_PASSIVE : active_trip_index(tz, acpi_trip); in acpi_thermal_update_trip_devices()
285 if (update_trip_devices(tz, acpi_trip, index, true)) in acpi_thermal_update_trip_devices()
289 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); in acpi_thermal_update_trip_devices()
293 struct acpi_thermal *tz; member
301 struct acpi_thermal *tz = atd->tz; in acpi_thermal_adjust_trip() local
308 acpi_thermal_update_trip(tz, trip); in acpi_thermal_adjust_trip()
310 acpi_thermal_update_trip_devices(tz, trip); in acpi_thermal_adjust_trip()
313 temp = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_adjust_trip()
317 thermal_zone_set_trip_temp(tz->thermal_zone, trip, temp); in acpi_thermal_adjust_trip()
322 static void acpi_queue_thermal_check(struct acpi_thermal *tz) in acpi_queue_thermal_check() argument
324 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
325 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
328 static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) in acpi_thermal_trips_update() argument
330 struct adjust_trip_data atd = { .tz = tz, .event = event }; in acpi_thermal_trips_update()
331 struct acpi_device *adev = tz->device; in acpi_thermal_trips_update()
340 thermal_zone_for_each_trip(tz->thermal_zone, in acpi_thermal_trips_update()
342 acpi_queue_thermal_check(tz); in acpi_thermal_trips_update()
347 static int acpi_thermal_get_critical_trip(struct acpi_thermal *tz) in acpi_thermal_get_critical_trip() argument
356 acpi_handle_debug(tz->device->handle, "Critical threshold disabled\n"); in acpi_thermal_get_critical_trip()
360 if (acpi_critical_trip_temp(tz->device, &temp)) in acpi_thermal_get_critical_trip()
373 acpi_handle_debug(tz->device->handle, "Critical threshold [%d]\n", temp); in acpi_thermal_get_critical_trip()
377 static int acpi_thermal_get_hot_trip(struct acpi_thermal *tz) in acpi_thermal_get_hot_trip() argument
381 if (acpi_hot_trip_temp(tz->device, &temp) || temp == THERMAL_TEMP_INVALID) { in acpi_thermal_get_hot_trip()
382 acpi_handle_debug(tz->device->handle, "No hot threshold\n"); in acpi_thermal_get_hot_trip()
386 acpi_handle_debug(tz->device->handle, "Hot threshold [%d]\n", temp); in acpi_thermal_get_hot_trip()
390 static bool passive_trip_params_init(struct acpi_thermal *tz) in passive_trip_params_init() argument
395 status = acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp); in passive_trip_params_init()
399 tz->trips.passive.tc1 = tmp; in passive_trip_params_init()
401 status = acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp); in passive_trip_params_init()
405 tz->trips.passive.tc2 = tmp; in passive_trip_params_init()
407 status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp); in passive_trip_params_init()
409 tz->trips.passive.delay = tmp; in passive_trip_params_init()
413 status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp); in passive_trip_params_init()
417 tz->trips.passive.delay = tmp * 100; in passive_trip_params_init()
422 static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index) in acpi_thermal_init_trip() argument
428 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_init_trip()
433 if (!passive_trip_params_init(tz)) in acpi_thermal_init_trip()
437 get_passive_temp(tz); in acpi_thermal_init_trip()
439 acpi_trip = &tz->trips.active[index].trip; in acpi_thermal_init_trip()
444 temp = get_active_temp(tz, index); in acpi_thermal_init_trip()
450 if (!update_trip_devices(tz, acpi_trip, index, false)) in acpi_thermal_init_trip()
461 static void acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
465 acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE); in acpi_thermal_get_trip_points()
468 if (!acpi_thermal_init_trip(tz, i)) in acpi_thermal_get_trip_points()
473 tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID; in acpi_thermal_get_trip_points()
480 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in thermal_get_temp() local
483 if (!tz) in thermal_get_temp()
486 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
490 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temp_dk, in thermal_get_temp()
491 tz->kelvin_offset); in thermal_get_temp()
499 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in thermal_get_trend() local
503 if (!tz || !trip) in thermal_get_trend()
512 t = tz->trips.passive.tc1 * (tz->temp_dk - in thermal_get_trend()
513 tz->last_temp_dk) + in thermal_get_trend()
514 tz->trips.passive.tc2 * (tz->temp_dk - in thermal_get_trend()
526 t = acpi_thermal_temp(tz, tz->temp_dk); in thermal_get_trend()
543 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_zone_device_hot() local
545 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_hot()
546 dev_name(&tz->device->dev), in acpi_thermal_zone_device_hot()
552 struct acpi_thermal *tz = thermal_zone_device_priv(thermal); in acpi_thermal_zone_device_critical() local
554 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_critical()
555 dev_name(&tz->device->dev), in acpi_thermal_zone_device_critical()
592 static int acpi_thermal_zone_sysfs_add(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_add() argument
594 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_add()
597 ret = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_zone_sysfs_add()
603 &tz->device->dev.kobj, "device"); in acpi_thermal_zone_sysfs_add()
605 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_add()
610 static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_remove() argument
612 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_remove()
614 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_remove()
618 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz, in acpi_thermal_register_thermal_zone() argument
626 tz->thermal_zone = thermal_zone_device_register_with_trips( in acpi_thermal_register_thermal_zone()
627 "acpitz", trip_table, trip_count, tz, in acpi_thermal_register_thermal_zone()
629 tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
631 tz->thermal_zone = thermal_tripless_zone_device_register( in acpi_thermal_register_thermal_zone()
632 "acpitz", tz, &acpi_thermal_zone_ops, NULL); in acpi_thermal_register_thermal_zone()
634 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
635 return PTR_ERR(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
637 result = acpi_thermal_zone_sysfs_add(tz); in acpi_thermal_register_thermal_zone()
641 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
645 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
646 thermal_zone_device_id(tz->thermal_zone)); in acpi_thermal_register_thermal_zone()
651 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_register_thermal_zone()
653 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
658 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
660 thermal_zone_device_disable(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
661 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_unregister_thermal_zone()
662 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
663 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
674 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
676 if (!tz) in acpi_thermal_notify()
681 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
685 acpi_thermal_trips_update(tz, event); in acpi_thermal_notify()
706 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
708 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
736 static void acpi_thermal_guess_offset(struct acpi_thermal *tz, long crit_temp) in acpi_thermal_guess_offset() argument
739 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
741 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
746 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
757 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
760 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
762 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
764 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
766 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
769 static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_free_thermal_zone() argument
773 acpi_handle_list_free(&tz->trips.passive.trip.devices); in acpi_thermal_free_thermal_zone()
775 acpi_handle_list_free(&tz->trips.active[i].trip.devices); in acpi_thermal_free_thermal_zone()
777 kfree(tz); in acpi_thermal_free_thermal_zone()
785 struct acpi_thermal *tz; in acpi_thermal_add() local
794 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
795 if (!tz) in acpi_thermal_add()
798 tz->device = device; in acpi_thermal_add()
799 strscpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
802 device->driver_data = tz; in acpi_thermal_add()
804 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_add()
807 acpi_thermal_get_trip_points(tz); in acpi_thermal_add()
809 crit_temp = acpi_thermal_get_critical_trip(tz); in acpi_thermal_add()
810 hot_temp = acpi_thermal_get_hot_trip(tz); in acpi_thermal_add()
813 result = acpi_thermal_get_temperature(tz); in acpi_thermal_add()
818 acpi_execute_simple_method(tz->device->handle, "_SCP", in acpi_thermal_add()
823 tz->polling_frequency = tzp; in acpi_thermal_add()
825 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_add()
827 acpi_thermal_guess_offset(tz, crit_temp); in acpi_thermal_add()
833 trip->temperature = acpi_thermal_temp(tz, crit_temp); in acpi_thermal_add()
839 trip->temperature = acpi_thermal_temp(tz, hot_temp); in acpi_thermal_add()
843 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_add()
845 passive_delay = tz->trips.passive.delay; in acpi_thermal_add()
848 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
854 acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_add()
860 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
868 result = acpi_thermal_register_thermal_zone(tz, trip_table, in acpi_thermal_add()
874 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
875 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
876 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
879 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temp_dk)); in acpi_thermal_add()
890 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_add()
892 acpi_thermal_free_thermal_zone(tz); in acpi_thermal_add()
899 struct acpi_thermal *tz; in acpi_thermal_remove() local
904 tz = acpi_driver_data(device); in acpi_thermal_remove()
910 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
911 acpi_thermal_free_thermal_zone(tz); in acpi_thermal_remove()
924 struct acpi_thermal *tz; in acpi_thermal_resume() local
930 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
931 if (!tz) in acpi_thermal_resume()
935 struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_resume()
946 acpi_queue_thermal_check(tz); in acpi_thermal_resume()