Lines Matching refs:tz
201 static int acpi_thermal_get_temperature(struct acpi_thermal *tz) in acpi_thermal_get_temperature() argument
206 if (!tz) in acpi_thermal_get_temperature()
209 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
211 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
215 tz->temperature = tmp; in acpi_thermal_get_temperature()
217 tz->temperature)); in acpi_thermal_get_temperature()
222 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
227 if (!tz) in acpi_thermal_get_polling_frequency()
230 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
234 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
236 tz->polling_frequency)); in acpi_thermal_get_polling_frequency()
241 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) in acpi_thermal_set_cooling_mode() argument
243 if (!tz) in acpi_thermal_set_cooling_mode()
246 if (!acpi_has_method(tz->device->handle, "_SCP")) { in acpi_thermal_set_cooling_mode()
249 } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
285 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in acpi_thermal_trips_update() argument
295 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
297 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
305 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
311 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
313 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
316 tz->trips.critical.temperature)); in acpi_thermal_trips_update()
318 if (tz->trips.critical.flags.valid == 1) { in acpi_thermal_trips_update()
320 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
326 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
329 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
336 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
339 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
343 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
344 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
347 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
352 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
354 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
361 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
366 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
368 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
369 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
372 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
375 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
377 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
379 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
382 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
384 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
386 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
389 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
391 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
395 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
397 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
401 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
404 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
406 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
408 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
414 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
421 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
427 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
428 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
431 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
437 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
444 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
445 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
447 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
451 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
452 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
457 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
459 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
464 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
467 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
469 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
471 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
477 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
480 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
485 && acpi_has_method(tz->device->handle, "_TZD")) { in acpi_thermal_trips_update()
487 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
490 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
491 tz->devices = devices; in acpi_thermal_trips_update()
499 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
501 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
506 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
507 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
508 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
511 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
522 struct acpi_thermal *tz = data; in acpi_thermal_check() local
524 if (!tz->tz_enabled) in acpi_thermal_check()
527 thermal_zone_device_update(tz->thermal_zone); in acpi_thermal_check()
535 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
538 if (!tz) in thermal_get_temp()
541 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
545 *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature, in thermal_get_temp()
546 tz->kelvin_offset); in thermal_get_temp()
553 struct acpi_thermal *tz = thermal->devdata; in thermal_get_mode() local
555 if (!tz) in thermal_get_mode()
558 *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : in thermal_get_mode()
567 struct acpi_thermal *tz = thermal->devdata; in thermal_set_mode() local
570 if (!tz) in thermal_set_mode()
584 if (enable != tz->tz_enabled) { in thermal_set_mode()
585 tz->tz_enabled = enable; in thermal_set_mode()
588 tz->tz_enabled ? "Enable" : "Disable")); in thermal_set_mode()
589 acpi_thermal_check(tz); in thermal_set_mode()
597 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
600 if (!tz || trip < 0) in thermal_get_trip_type()
603 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
611 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
619 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
628 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
642 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
645 if (!tz || trip < 0) in thermal_get_trip_temp()
648 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
651 tz->trips.critical.temperature, in thermal_get_trip_temp()
652 tz->kelvin_offset); in thermal_get_trip_temp()
658 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
661 tz->trips.hot.temperature, in thermal_get_trip_temp()
662 tz->kelvin_offset); in thermal_get_trip_temp()
668 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
671 tz->trips.passive.temperature, in thermal_get_trip_temp()
672 tz->kelvin_offset); in thermal_get_trip_temp()
679 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
682 tz->trips.active[i].temperature, in thermal_get_trip_temp()
683 tz->kelvin_offset); in thermal_get_trip_temp()
694 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
696 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
698 tz->trips.critical.temperature, in thermal_get_crit_temp()
699 tz->kelvin_offset); in thermal_get_crit_temp()
708 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
718 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
735 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
736 + (tz->trips.passive.tc2 in thermal_get_trend()
737 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
753 struct acpi_thermal *tz = thermal->devdata; in thermal_notify() local
762 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
763 dev_name(&tz->device->dev), type, 1); in thermal_notify()
776 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
785 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
788 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
791 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
793 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
795 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
814 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
818 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
820 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
836 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
837 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
885 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
892 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
895 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
898 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
902 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
904 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
905 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
906 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
908 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
909 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
911 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
912 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
914 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
915 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
918 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
919 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
923 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
924 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
928 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
929 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
933 tz->tz_enabled = 1; in acpi_thermal_register_thermal_zone()
935 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
936 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
940 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
942 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
943 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
944 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
945 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
946 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
956 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
959 if (!tz) in acpi_thermal_notify()
964 acpi_thermal_check(tz); in acpi_thermal_notify()
967 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
968 acpi_thermal_check(tz); in acpi_thermal_notify()
973 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
974 acpi_thermal_check(tz); in acpi_thermal_notify()
997 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
999 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
1017 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
1022 if (!tz) in acpi_thermal_get_info()
1025 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
1028 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
1033 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
1038 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); in acpi_thermal_get_info()
1040 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
1044 tz->polling_frequency = tzp; in acpi_thermal_get_info()
1046 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
1061 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
1063 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
1064 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
1065 tz->kelvin_offset = 2731; in acpi_thermal_guess_offset()
1067 tz->kelvin_offset = 2732; in acpi_thermal_guess_offset()
1072 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
1074 acpi_thermal_check(tz); in acpi_thermal_check_fn()
1080 struct acpi_thermal *tz = NULL; in acpi_thermal_add() local
1086 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1087 if (!tz) in acpi_thermal_add()
1090 tz->device = device; in acpi_thermal_add()
1091 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1094 device->driver_data = tz; in acpi_thermal_add()
1096 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1100 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1102 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1106 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1109 acpi_device_bid(device), KELVIN_TO_CELSIUS(tz->temperature)); in acpi_thermal_add()
1113 kfree(tz); in acpi_thermal_add()
1120 struct acpi_thermal *tz = NULL; in acpi_thermal_remove() local
1126 tz = acpi_driver_data(device); in acpi_thermal_remove()
1128 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1129 kfree(tz); in acpi_thermal_remove()
1143 struct acpi_thermal *tz; in acpi_thermal_resume() local
1149 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1150 if (!tz) in acpi_thermal_resume()
1154 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1156 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1158 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1159 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1161 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1164 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1168 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1171 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_thermal_resume()