Lines Matching full:tz

57 #define ACPI_THERMAL_TRIPS_EXCEPTION(tz, str) \  argument
59 acpi_handle_info(tz->device->handle, \
127 static int acpi_thermal_get_temperature(struct acpi_thermal *tz) in acpi_thermal_get_temperature() argument
132 if (!tz) in acpi_thermal_get_temperature()
135 tz->last_temp_dk = tz->temp_dk; in acpi_thermal_get_temperature()
137 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
141 tz->temp_dk = tmp; in acpi_thermal_get_temperature()
143 acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n", in acpi_thermal_get_temperature()
144 tz->temp_dk); in acpi_thermal_get_temperature()
149 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
154 if (!tz) in acpi_thermal_get_polling_frequency()
157 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
161 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
162 acpi_handle_debug(tz->device->handle, "Polling frequency is %lu dS\n", in acpi_thermal_get_polling_frequency()
163 tz->polling_frequency); in acpi_thermal_get_polling_frequency()
168 static int acpi_thermal_temp(struct acpi_thermal *tz, int temp_deci_k) in acpi_thermal_temp() argument
174 tz->kelvin_offset); in acpi_thermal_temp()
182 static int active_trip_index(struct acpi_thermal *tz, in active_trip_index() argument
188 return active - tz->trips.active; in active_trip_index()
191 static long get_passive_temp(struct acpi_thermal *tz) in get_passive_temp() argument
195 if (acpi_passive_trip_temp(tz->device, &temp)) in get_passive_temp()
201 static long get_active_temp(struct acpi_thermal *tz, int index) in get_active_temp() argument
205 if (acpi_active_trip_temp(tz->device, index, &temp)) in get_active_temp()
221 static void acpi_thermal_update_trip(struct acpi_thermal *tz, in acpi_thermal_update_trip() argument
230 acpi_trip->temp_dk = get_passive_temp(tz); in acpi_thermal_update_trip()
232 int index = active_trip_index(tz, acpi_trip); in acpi_thermal_update_trip()
234 acpi_trip->temp_dk = get_active_temp(tz, index); in acpi_thermal_update_trip()
238 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); in acpi_thermal_update_trip()
241 static bool update_trip_devices(struct acpi_thermal *tz, in update_trip_devices() argument
254 if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) { in update_trip_devices()
255 acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method); in update_trip_devices()
265 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "device"); in update_trip_devices()
271 static void acpi_thermal_update_trip_devices(struct acpi_thermal *tz, in acpi_thermal_update_trip_devices() argument
276 ACPI_THERMAL_TRIP_PASSIVE : active_trip_index(tz, acpi_trip); in acpi_thermal_update_trip_devices()
278 if (update_trip_devices(tz, acpi_trip, index, true)) in acpi_thermal_update_trip_devices()
282 ACPI_THERMAL_TRIPS_EXCEPTION(tz, "state"); in acpi_thermal_update_trip_devices()
286 struct acpi_thermal *tz; member
294 struct acpi_thermal *tz = atd->tz; in acpi_thermal_adjust_trip() local
301 acpi_thermal_update_trip(tz, trip); in acpi_thermal_adjust_trip()
303 acpi_thermal_update_trip_devices(tz, trip); in acpi_thermal_adjust_trip()
306 temp = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_adjust_trip()
310 thermal_zone_set_trip_temp(tz->thermal_zone, trip, temp); in acpi_thermal_adjust_trip()
315 static void acpi_queue_thermal_check(struct acpi_thermal *tz) in acpi_queue_thermal_check() argument
317 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
318 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
321 static void acpi_thermal_trips_update(struct acpi_thermal *tz, u32 event) in acpi_thermal_trips_update() argument
323 struct adjust_trip_data atd = { .tz = tz, .event = event }; in acpi_thermal_trips_update()
324 struct acpi_device *adev = tz->device; in acpi_thermal_trips_update()
333 thermal_zone_for_each_trip(tz->thermal_zone, in acpi_thermal_trips_update()
335 acpi_queue_thermal_check(tz); in acpi_thermal_trips_update()
340 static int acpi_thermal_get_critical_trip(struct acpi_thermal *tz) in acpi_thermal_get_critical_trip() argument
349 acpi_handle_debug(tz->device->handle, "Critical threshold disabled\n"); in acpi_thermal_get_critical_trip()
353 if (acpi_critical_trip_temp(tz->device, &temp)) in acpi_thermal_get_critical_trip()
366 acpi_handle_debug(tz->device->handle, "Critical threshold [%d]\n", temp); in acpi_thermal_get_critical_trip()
370 static int acpi_thermal_get_hot_trip(struct acpi_thermal *tz) in acpi_thermal_get_hot_trip() argument
374 if (acpi_hot_trip_temp(tz->device, &temp) || temp == THERMAL_TEMP_INVALID) { in acpi_thermal_get_hot_trip()
375 acpi_handle_debug(tz->device->handle, "No hot threshold\n"); in acpi_thermal_get_hot_trip()
379 acpi_handle_debug(tz->device->handle, "Hot threshold [%d]\n", temp); in acpi_thermal_get_hot_trip()
383 static bool passive_trip_params_init(struct acpi_thermal *tz) in passive_trip_params_init() argument
388 status = acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp); in passive_trip_params_init()
392 tz->trips.passive.tc1 = tmp; in passive_trip_params_init()
394 status = acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp); in passive_trip_params_init()
398 tz->trips.passive.tc2 = tmp; in passive_trip_params_init()
400 status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp); in passive_trip_params_init()
402 tz->trips.passive.delay = tmp; in passive_trip_params_init()
406 status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp); in passive_trip_params_init()
410 tz->trips.passive.delay = tmp * 100; in passive_trip_params_init()
415 static bool acpi_thermal_init_trip(struct acpi_thermal *tz, int index) in acpi_thermal_init_trip() argument
421 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_init_trip()
426 if (!passive_trip_params_init(tz)) in acpi_thermal_init_trip()
430 get_passive_temp(tz); in acpi_thermal_init_trip()
432 acpi_trip = &tz->trips.active[index].trip; in acpi_thermal_init_trip()
437 temp = get_active_temp(tz, index); in acpi_thermal_init_trip()
443 if (!update_trip_devices(tz, acpi_trip, index, false)) in acpi_thermal_init_trip()
454 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
459 if (acpi_thermal_init_trip(tz, ACPI_THERMAL_TRIP_PASSIVE)) in acpi_thermal_get_trip_points()
463 if (acpi_thermal_init_trip(tz, i)) in acpi_thermal_get_trip_points()
471 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()
638 static int acpi_thermal_zone_sysfs_add(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_add() argument
640 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_add()
643 ret = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_zone_sysfs_add()
649 &tz->device->dev.kobj, "device"); in acpi_thermal_zone_sysfs_add()
651 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_add()
656 static void acpi_thermal_zone_sysfs_remove(struct acpi_thermal *tz) in acpi_thermal_zone_sysfs_remove() argument
658 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_remove()
660 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_remove()
664 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz, in acpi_thermal_register_thermal_zone() argument
670 tz->thermal_zone = thermal_zone_device_register_with_trips("acpitz", in acpi_thermal_register_thermal_zone()
671 tz->trip_table, in acpi_thermal_register_thermal_zone()
673 0, tz, in acpi_thermal_register_thermal_zone()
677 tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
678 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
679 return PTR_ERR(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
681 result = acpi_thermal_zone_sysfs_add(tz); in acpi_thermal_register_thermal_zone()
685 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
689 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
690 thermal_zone_device_id(tz->thermal_zone)); in acpi_thermal_register_thermal_zone()
695 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_register_thermal_zone()
697 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
702 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
704 thermal_zone_device_disable(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
705 acpi_thermal_zone_sysfs_remove(tz); in acpi_thermal_unregister_thermal_zone()
706 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
707 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
718 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
720 if (!tz) in acpi_thermal_notify()
725 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
729 acpi_thermal_trips_update(tz, event); in acpi_thermal_notify()
750 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
752 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
780 static void acpi_thermal_guess_offset(struct acpi_thermal *tz, long crit_temp) in acpi_thermal_guess_offset() argument
783 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
785 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
790 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
801 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
804 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
806 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
808 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
810 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
813 static void acpi_thermal_free_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_free_thermal_zone() argument
817 acpi_handle_list_free(&tz->trips.passive.trip.devices); in acpi_thermal_free_thermal_zone()
819 acpi_handle_list_free(&tz->trips.active[i].trip.devices); in acpi_thermal_free_thermal_zone()
821 kfree(tz); in acpi_thermal_free_thermal_zone()
828 struct acpi_thermal *tz; in acpi_thermal_add() local
838 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
839 if (!tz) in acpi_thermal_add()
842 tz->device = device; in acpi_thermal_add()
843 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
846 device->driver_data = tz; in acpi_thermal_add()
848 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_add()
851 trip_count = acpi_thermal_get_trip_points(tz); in acpi_thermal_add()
853 crit_temp = acpi_thermal_get_critical_trip(tz); in acpi_thermal_add()
857 hot_temp = acpi_thermal_get_hot_trip(tz); in acpi_thermal_add()
868 result = acpi_thermal_get_temperature(tz); in acpi_thermal_add()
873 acpi_execute_simple_method(tz->device->handle, "_SCP", in acpi_thermal_add()
878 tz->polling_frequency = tzp; in acpi_thermal_add()
880 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_add()
882 acpi_thermal_guess_offset(tz, crit_temp); in acpi_thermal_add()
890 tz->trip_table = trip; in acpi_thermal_add()
894 trip->temperature = acpi_thermal_temp(tz, crit_temp); in acpi_thermal_add()
900 trip->temperature = acpi_thermal_temp(tz, hot_temp); in acpi_thermal_add()
904 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_add()
906 passive_delay = tz->trips.passive.delay; in acpi_thermal_add()
909 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
915 acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_add()
921 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
926 result = acpi_thermal_register_thermal_zone(tz, trip_count, passive_delay); in acpi_thermal_add()
930 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
931 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
932 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
935 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temp_dk)); in acpi_thermal_add()
946 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_add()
948 kfree(tz->trip_table); in acpi_thermal_add()
950 acpi_thermal_free_thermal_zone(tz); in acpi_thermal_add()
957 struct acpi_thermal *tz; in acpi_thermal_remove() local
962 tz = acpi_driver_data(device); in acpi_thermal_remove()
968 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
969 kfree(tz->trip_table); in acpi_thermal_remove()
970 acpi_thermal_free_thermal_zone(tz); in acpi_thermal_remove()
983 struct acpi_thermal *tz; in acpi_thermal_resume() local
989 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
990 if (!tz) in acpi_thermal_resume()
994 struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_resume()
1005 acpi_queue_thermal_check(tz); in acpi_thermal_resume()