Lines Matching refs:tz

197 static int acpi_thermal_get_temperature(struct acpi_thermal *tz)  in acpi_thermal_get_temperature()  argument
202 if (!tz) in acpi_thermal_get_temperature()
205 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
207 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
211 tz->temperature = tmp; in acpi_thermal_get_temperature()
213 tz->temperature)); in acpi_thermal_get_temperature()
218 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
223 if (!tz) in acpi_thermal_get_polling_frequency()
226 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
230 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
232 tz->polling_frequency)); in acpi_thermal_get_polling_frequency()
237 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) in acpi_thermal_set_cooling_mode() argument
239 if (!tz) in acpi_thermal_set_cooling_mode()
242 if (!acpi_has_method(tz->device->handle, "_SCP")) { in acpi_thermal_set_cooling_mode()
245 } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
281 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in acpi_thermal_trips_update() argument
291 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
293 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
301 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
307 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
309 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
312 tz->trips.critical.temperature)); in acpi_thermal_trips_update()
314 if (tz->trips.critical.flags.valid == 1) { in acpi_thermal_trips_update()
316 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
322 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
325 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
332 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
335 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
339 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
340 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
343 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
348 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
350 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
357 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
362 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
364 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
365 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
368 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
371 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
373 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
375 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
378 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
380 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
382 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
385 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
387 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
391 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
393 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
397 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
400 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
402 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
404 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
410 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
417 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
423 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
424 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
427 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
433 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
440 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
441 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
443 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
447 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
448 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
453 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
455 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
460 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
463 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
465 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
467 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
473 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
476 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
481 && acpi_has_method(tz->device->handle, "_TZD")) { in acpi_thermal_trips_update()
483 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
486 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
487 tz->devices = devices; in acpi_thermal_trips_update()
495 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
497 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
502 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
503 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
504 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
507 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
518 struct acpi_thermal *tz = data; in acpi_thermal_check() local
520 if (!tz->tz_enabled) in acpi_thermal_check()
523 thermal_zone_device_update(tz->thermal_zone); in acpi_thermal_check()
530 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
533 if (!tz) in thermal_get_temp()
536 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
540 *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature, in thermal_get_temp()
541 tz->kelvin_offset); in thermal_get_temp()
548 struct acpi_thermal *tz = thermal->devdata; in thermal_get_mode() local
550 if (!tz) in thermal_get_mode()
553 *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : in thermal_get_mode()
562 struct acpi_thermal *tz = thermal->devdata; in thermal_set_mode() local
565 if (!tz) in thermal_set_mode()
579 if (enable != tz->tz_enabled) { in thermal_set_mode()
580 tz->tz_enabled = enable; in thermal_set_mode()
583 tz->tz_enabled ? "Enable" : "Disable")); in thermal_set_mode()
584 acpi_thermal_check(tz); in thermal_set_mode()
592 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
595 if (!tz || trip < 0) in thermal_get_trip_type()
598 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
606 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
614 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
623 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
637 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
640 if (!tz || trip < 0) in thermal_get_trip_temp()
643 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
646 tz->trips.critical.temperature, in thermal_get_trip_temp()
647 tz->kelvin_offset); in thermal_get_trip_temp()
653 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
656 tz->trips.hot.temperature, in thermal_get_trip_temp()
657 tz->kelvin_offset); in thermal_get_trip_temp()
663 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
666 tz->trips.passive.temperature, in thermal_get_trip_temp()
667 tz->kelvin_offset); in thermal_get_trip_temp()
674 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
677 tz->trips.active[i].temperature, in thermal_get_trip_temp()
678 tz->kelvin_offset); in thermal_get_trip_temp()
690 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
692 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
694 tz->trips.critical.temperature, in thermal_get_crit_temp()
695 tz->kelvin_offset); in thermal_get_crit_temp()
704 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
714 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
731 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
732 + (tz->trips.passive.tc2 in thermal_get_trend()
733 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
749 struct acpi_thermal *tz = thermal->devdata; in thermal_notify() local
758 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
759 dev_name(&tz->device->dev), type, 1); in thermal_notify()
772 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
781 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
784 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
787 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
789 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
791 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
811 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
815 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
817 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
834 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
835 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
884 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
891 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
894 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
897 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
901 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
903 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
904 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
905 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
907 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
908 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
910 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
911 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
913 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
914 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
917 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
918 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
922 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
923 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
927 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
928 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
932 tz->tz_enabled = 1; in acpi_thermal_register_thermal_zone()
934 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
935 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
939 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
941 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
942 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
943 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
944 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
945 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
955 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
958 if (!tz) in acpi_thermal_notify()
963 acpi_thermal_check(tz); in acpi_thermal_notify()
966 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
967 acpi_thermal_check(tz); in acpi_thermal_notify()
972 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
973 acpi_thermal_check(tz); in acpi_thermal_notify()
996 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
998 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
1016 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
1021 if (!tz) in acpi_thermal_get_info()
1024 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
1027 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
1032 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
1037 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); in acpi_thermal_get_info()
1039 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
1043 tz->polling_frequency = tzp; in acpi_thermal_get_info()
1045 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
1060 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
1062 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
1063 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
1064 tz->kelvin_offset = 2731; in acpi_thermal_guess_offset()
1066 tz->kelvin_offset = 2732; in acpi_thermal_guess_offset()
1071 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
1073 acpi_thermal_check(tz); in acpi_thermal_check_fn()
1079 struct acpi_thermal *tz = NULL; in acpi_thermal_add() local
1085 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1086 if (!tz) in acpi_thermal_add()
1089 tz->device = device; in acpi_thermal_add()
1090 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1093 device->driver_data = tz; in acpi_thermal_add()
1095 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1099 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1101 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1105 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1108 acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature)); in acpi_thermal_add()
1112 kfree(tz); in acpi_thermal_add()
1119 struct acpi_thermal *tz = NULL; in acpi_thermal_remove() local
1125 tz = acpi_driver_data(device); in acpi_thermal_remove()
1127 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1128 kfree(tz); in acpi_thermal_remove()
1142 struct acpi_thermal *tz; in acpi_thermal_resume() local
1148 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1149 if (!tz) in acpi_thermal_resume()
1153 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1155 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1157 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1158 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1160 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1163 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1167 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1170 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_thermal_resume()