Lines Matching refs:tz

185 static int acpi_thermal_get_temperature(struct acpi_thermal *tz)  in acpi_thermal_get_temperature()  argument
190 if (!tz) in acpi_thermal_get_temperature()
193 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
195 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
199 tz->temperature = tmp; in acpi_thermal_get_temperature()
201 tz->temperature)); in acpi_thermal_get_temperature()
206 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
211 if (!tz) in acpi_thermal_get_polling_frequency()
214 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
218 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
220 tz->polling_frequency)); in acpi_thermal_get_polling_frequency()
225 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) in acpi_thermal_set_cooling_mode() argument
227 if (!tz) in acpi_thermal_set_cooling_mode()
230 if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
265 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in acpi_thermal_trips_update() argument
275 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
277 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
285 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
291 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
293 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
296 tz->trips.critical.temperature)); in acpi_thermal_trips_update()
298 if (tz->trips.critical.flags.valid == 1) { in acpi_thermal_trips_update()
300 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
307 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
310 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
317 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
320 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
324 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
325 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
328 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
333 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
335 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
342 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
347 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
349 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
350 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
353 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
356 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
358 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
360 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
363 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
365 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
367 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
370 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
372 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
376 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
378 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
382 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
385 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
387 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
389 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
395 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
402 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
408 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
409 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
412 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
418 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
425 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
426 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
428 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
432 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
433 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
438 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
440 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
445 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
448 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
450 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
452 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
458 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
461 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
467 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
470 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
471 tz->devices = devices; in acpi_thermal_trips_update()
479 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
481 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
486 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
487 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
488 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
491 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
504 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
507 if (!tz) in thermal_get_temp()
510 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
514 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, in thermal_get_temp()
515 tz->kelvin_offset); in thermal_get_temp()
522 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
525 if (!tz || trip < 0) in thermal_get_trip_type()
528 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
536 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
544 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
553 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
567 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
570 if (!tz || trip < 0) in thermal_get_trip_temp()
573 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
576 tz->trips.critical.temperature, in thermal_get_trip_temp()
577 tz->kelvin_offset); in thermal_get_trip_temp()
583 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
586 tz->trips.hot.temperature, in thermal_get_trip_temp()
587 tz->kelvin_offset); in thermal_get_trip_temp()
593 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
596 tz->trips.passive.temperature, in thermal_get_trip_temp()
597 tz->kelvin_offset); in thermal_get_trip_temp()
604 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
607 tz->trips.active[i].temperature, in thermal_get_trip_temp()
608 tz->kelvin_offset); in thermal_get_trip_temp()
620 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
622 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
624 tz->trips.critical.temperature, in thermal_get_crit_temp()
625 tz->kelvin_offset); in thermal_get_crit_temp()
634 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
644 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
661 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
662 + (tz->trips.passive.tc2 in thermal_get_trend()
663 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
679 struct acpi_thermal *tz = thermal->devdata; in thermal_notify() local
688 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
689 dev_name(&tz->device->dev), type, 1); in thermal_notify()
702 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
711 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
714 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
717 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
719 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
721 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
741 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
745 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
747 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
764 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
765 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
812 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
819 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
822 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
825 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
829 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
831 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
832 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
833 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
835 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
836 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
838 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
839 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
841 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
842 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
845 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
846 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
850 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
851 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
855 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
856 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
862 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
866 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
867 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
872 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_register_thermal_zone()
874 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_register_thermal_zone()
876 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
878 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
883 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
885 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
886 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
887 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
888 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
889 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
897 static void acpi_queue_thermal_check(struct acpi_thermal *tz) in acpi_queue_thermal_check() argument
899 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
900 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
905 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
908 if (!tz) in acpi_thermal_notify()
913 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
916 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
917 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
922 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
923 acpi_queue_thermal_check(tz); in acpi_thermal_notify()
946 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
948 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
966 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
971 if (!tz) in acpi_thermal_get_info()
974 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
977 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
982 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
987 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); in acpi_thermal_get_info()
989 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
993 tz->polling_frequency = tzp; in acpi_thermal_get_info()
995 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
1010 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
1012 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
1013 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
1014 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
1016 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
1021 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
1032 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
1035 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
1037 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
1039 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
1041 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
1047 struct acpi_thermal *tz = NULL; in acpi_thermal_add() local
1053 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1054 if (!tz) in acpi_thermal_add()
1057 tz->device = device; in acpi_thermal_add()
1058 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1061 device->driver_data = tz; in acpi_thermal_add()
1063 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1067 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1069 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1073 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
1074 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
1075 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1078 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); in acpi_thermal_add()
1082 kfree(tz); in acpi_thermal_add()
1089 struct acpi_thermal *tz = NULL; in acpi_thermal_remove() local
1095 tz = acpi_driver_data(device); in acpi_thermal_remove()
1097 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1098 kfree(tz); in acpi_thermal_remove()
1112 struct acpi_thermal *tz; in acpi_thermal_resume() local
1118 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1119 if (!tz) in acpi_thermal_resume()
1123 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1125 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1127 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1128 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1130 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1133 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1137 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1140 acpi_queue_thermal_check(tz); in acpi_thermal_resume()