Lines Matching refs:tz

183 static int acpi_thermal_get_temperature(struct acpi_thermal *tz)  in acpi_thermal_get_temperature()  argument
188 if (!tz) in acpi_thermal_get_temperature()
191 tz->last_temperature = tz->temperature; in acpi_thermal_get_temperature()
193 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
197 tz->temperature = tmp; in acpi_thermal_get_temperature()
199 tz->temperature)); in acpi_thermal_get_temperature()
204 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz) in acpi_thermal_get_polling_frequency() argument
209 if (!tz) in acpi_thermal_get_polling_frequency()
212 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
216 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
218 tz->polling_frequency)); in acpi_thermal_get_polling_frequency()
223 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode) in acpi_thermal_set_cooling_mode() argument
225 if (!tz) in acpi_thermal_set_cooling_mode()
228 if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle, in acpi_thermal_set_cooling_mode()
263 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag) in acpi_thermal_trips_update() argument
273 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
275 tz->trips.critical.temperature = tmp; in acpi_thermal_trips_update()
283 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
289 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
291 tz->trips.critical.flags.valid = 1; in acpi_thermal_trips_update()
294 tz->trips.critical.temperature)); in acpi_thermal_trips_update()
296 if (tz->trips.critical.flags.valid == 1) { in acpi_thermal_trips_update()
298 tz->trips.critical.flags.valid = 0; in acpi_thermal_trips_update()
305 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
308 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
315 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
318 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
322 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
323 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
326 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
331 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
333 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
340 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
345 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
347 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
348 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
351 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
354 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
356 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
358 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
361 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
363 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
365 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
368 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
370 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
374 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
376 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
380 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
383 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
385 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
387 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
393 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
400 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
406 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
407 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
410 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
416 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
423 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
424 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
426 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
430 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
431 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
436 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
438 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
443 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
446 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
448 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
450 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
456 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
459 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
465 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
468 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
469 tz->devices = devices; in acpi_thermal_trips_update()
477 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
479 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
484 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
485 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
486 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
489 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
500 struct acpi_thermal *tz = data; in acpi_thermal_check() local
502 thermal_zone_device_update(tz->thermal_zone, in acpi_thermal_check()
510 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
513 if (!tz) in thermal_get_temp()
516 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
520 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temperature, in thermal_get_temp()
521 tz->kelvin_offset); in thermal_get_temp()
528 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
531 if (!tz || trip < 0) in thermal_get_trip_type()
534 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
542 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
550 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
559 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
573 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
576 if (!tz || trip < 0) in thermal_get_trip_temp()
579 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
582 tz->trips.critical.temperature, in thermal_get_trip_temp()
583 tz->kelvin_offset); in thermal_get_trip_temp()
589 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
592 tz->trips.hot.temperature, in thermal_get_trip_temp()
593 tz->kelvin_offset); in thermal_get_trip_temp()
599 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
602 tz->trips.passive.temperature, in thermal_get_trip_temp()
603 tz->kelvin_offset); in thermal_get_trip_temp()
610 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
613 tz->trips.active[i].temperature, in thermal_get_trip_temp()
614 tz->kelvin_offset); in thermal_get_trip_temp()
626 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
628 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
630 tz->trips.critical.temperature, in thermal_get_crit_temp()
631 tz->kelvin_offset); in thermal_get_crit_temp()
640 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
650 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
667 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
668 + (tz->trips.passive.tc2 in thermal_get_trend()
669 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
685 struct acpi_thermal *tz = thermal->devdata; in thermal_notify() local
694 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
695 dev_name(&tz->device->dev), type, 1); in thermal_notify()
708 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
717 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
720 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
723 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
725 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
727 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
747 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
751 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
753 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
770 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
771 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
818 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
825 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
828 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
831 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
835 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
837 if (tz->trips.passive.flags.valid) 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 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
842 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
844 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
845 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
847 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
848 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
851 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
852 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
856 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
857 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
861 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
862 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
868 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
872 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
873 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
878 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_register_thermal_zone()
880 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_register_thermal_zone()
882 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
884 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
889 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
891 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
892 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
893 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
894 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
895 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
905 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
908 if (!tz) in acpi_thermal_notify()
913 acpi_thermal_check(tz); in acpi_thermal_notify()
916 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
917 acpi_thermal_check(tz); in acpi_thermal_notify()
922 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
923 acpi_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
1023 acpi_thermal_check(tz); in acpi_thermal_check_fn()
1029 struct acpi_thermal *tz = NULL; in acpi_thermal_add() local
1035 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1036 if (!tz) in acpi_thermal_add()
1039 tz->device = device; in acpi_thermal_add()
1040 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1043 device->driver_data = tz; in acpi_thermal_add()
1045 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1049 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1051 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1055 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1058 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temperature)); in acpi_thermal_add()
1062 kfree(tz); in acpi_thermal_add()
1069 struct acpi_thermal *tz = NULL; in acpi_thermal_remove() local
1075 tz = acpi_driver_data(device); in acpi_thermal_remove()
1077 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1078 kfree(tz); in acpi_thermal_remove()
1092 struct acpi_thermal *tz; in acpi_thermal_resume() local
1098 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1099 if (!tz) in acpi_thermal_resume()
1103 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1105 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1107 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1108 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1110 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1113 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1117 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1120 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_thermal_resume()