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()
304 if (crt_k > tz->trips.critical.temperature) in acpi_thermal_trips_update()
307 tz->trips.critical.temperature = crt_k; in acpi_thermal_trips_update()
314 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
317 tz->trips.hot.flags.valid = 0; in acpi_thermal_trips_update()
321 tz->trips.hot.temperature = tmp; in acpi_thermal_trips_update()
322 tz->trips.hot.flags.valid = 1; in acpi_thermal_trips_update()
325 tz->trips.hot.temperature)); in acpi_thermal_trips_update()
330 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) || in acpi_thermal_trips_update()
332 valid = tz->trips.passive.flags.valid; in acpi_thermal_trips_update()
339 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
344 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
346 tz->trips.passive.temperature = tmp; in acpi_thermal_trips_update()
347 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
350 tz->device->handle, "_TC1", in acpi_thermal_trips_update()
353 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
355 tz->trips.passive.tc1 = tmp; in acpi_thermal_trips_update()
357 tz->device->handle, "_TC2", in acpi_thermal_trips_update()
360 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
362 tz->trips.passive.tc2 = tmp; in acpi_thermal_trips_update()
364 tz->device->handle, "_TSP", in acpi_thermal_trips_update()
367 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
369 tz->trips.passive.tsp = tmp; in acpi_thermal_trips_update()
373 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) { in acpi_thermal_trips_update()
375 status = acpi_evaluate_reference(tz->device->handle, "_PSL", in acpi_thermal_trips_update()
379 tz->trips.passive.flags.valid = 0; in acpi_thermal_trips_update()
382 tz->trips.passive.flags.valid = 1; in acpi_thermal_trips_update()
384 if (memcmp(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
386 memcpy(&tz->trips.passive.devices, &devices, in acpi_thermal_trips_update()
392 if (valid != tz->trips.passive.flags.valid) in acpi_thermal_trips_update()
399 valid = tz->trips.active[i].flags.valid; in acpi_thermal_trips_update()
405 tz->trips.active[i].flags.valid)) { in acpi_thermal_trips_update()
406 status = acpi_evaluate_integer(tz->device->handle, in acpi_thermal_trips_update()
409 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
415 tz->trips.active[0].temperature = in acpi_thermal_trips_update()
422 tz->trips.active[i - 1].temperature = in acpi_thermal_trips_update()
423 (tz->trips.active[i - 2].temperature < in acpi_thermal_trips_update()
425 tz->trips.active[i - 2].temperature : in acpi_thermal_trips_update()
429 tz->trips.active[i].temperature = tmp; in acpi_thermal_trips_update()
430 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
435 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) { in acpi_thermal_trips_update()
437 status = acpi_evaluate_reference(tz->device->handle, in acpi_thermal_trips_update()
442 tz->trips.active[i].flags.valid = 0; in acpi_thermal_trips_update()
445 tz->trips.active[i].flags.valid = 1; in acpi_thermal_trips_update()
447 if (memcmp(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
449 memcpy(&tz->trips.active[i].devices, &devices, in acpi_thermal_trips_update()
455 if (valid != tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
458 if (!tz->trips.active[i].flags.valid) in acpi_thermal_trips_update()
464 status = acpi_evaluate_reference(tz->device->handle, "_TZD", in acpi_thermal_trips_update()
467 && memcmp(&tz->devices, &devices, sizeof(devices))) { in acpi_thermal_trips_update()
468 tz->devices = devices; in acpi_thermal_trips_update()
476 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz) in acpi_thermal_get_trip_points() argument
478 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT); in acpi_thermal_get_trip_points()
483 valid = tz->trips.critical.flags.valid | in acpi_thermal_get_trip_points()
484 tz->trips.hot.flags.valid | in acpi_thermal_get_trip_points()
485 tz->trips.passive.flags.valid; in acpi_thermal_get_trip_points()
488 valid |= tz->trips.active[i].flags.valid; in acpi_thermal_get_trip_points()
499 struct acpi_thermal *tz = data; in acpi_thermal_check() local
501 if (!tz->tz_enabled) in acpi_thermal_check()
504 thermal_zone_device_update(tz->thermal_zone, in acpi_thermal_check()
512 struct acpi_thermal *tz = thermal->devdata; in thermal_get_temp() local
515 if (!tz) in thermal_get_temp()
518 result = acpi_thermal_get_temperature(tz); in thermal_get_temp()
522 *temp = DECI_KELVIN_TO_MILLICELSIUS_WITH_OFFSET(tz->temperature, in thermal_get_temp()
523 tz->kelvin_offset); in thermal_get_temp()
530 struct acpi_thermal *tz = thermal->devdata; in thermal_get_mode() local
532 if (!tz) in thermal_get_mode()
535 *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED : in thermal_get_mode()
544 struct acpi_thermal *tz = thermal->devdata; in thermal_set_mode() local
547 if (!tz) in thermal_set_mode()
561 if (enable != tz->tz_enabled) { in thermal_set_mode()
562 tz->tz_enabled = enable; in thermal_set_mode()
565 tz->tz_enabled ? "Enable" : "Disable")); in thermal_set_mode()
566 acpi_thermal_check(tz); in thermal_set_mode()
574 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_type() local
577 if (!tz || trip < 0) in thermal_get_trip_type()
580 if (tz->trips.critical.flags.valid) { in thermal_get_trip_type()
588 if (tz->trips.hot.flags.valid) { in thermal_get_trip_type()
596 if (tz->trips.passive.flags.valid) { in thermal_get_trip_type()
605 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_type()
619 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trip_temp() local
622 if (!tz || trip < 0) in thermal_get_trip_temp()
625 if (tz->trips.critical.flags.valid) { in thermal_get_trip_temp()
628 tz->trips.critical.temperature, in thermal_get_trip_temp()
629 tz->kelvin_offset); in thermal_get_trip_temp()
635 if (tz->trips.hot.flags.valid) { in thermal_get_trip_temp()
638 tz->trips.hot.temperature, in thermal_get_trip_temp()
639 tz->kelvin_offset); in thermal_get_trip_temp()
645 if (tz->trips.passive.flags.valid) { in thermal_get_trip_temp()
648 tz->trips.passive.temperature, in thermal_get_trip_temp()
649 tz->kelvin_offset); in thermal_get_trip_temp()
656 tz->trips.active[i].flags.valid; i++) { in thermal_get_trip_temp()
659 tz->trips.active[i].temperature, in thermal_get_trip_temp()
660 tz->kelvin_offset); in thermal_get_trip_temp()
672 struct acpi_thermal *tz = thermal->devdata; in thermal_get_crit_temp() local
674 if (tz->trips.critical.flags.valid) { in thermal_get_crit_temp()
676 tz->trips.critical.temperature, in thermal_get_crit_temp()
677 tz->kelvin_offset); in thermal_get_crit_temp()
686 struct acpi_thermal *tz = thermal->devdata; in thermal_get_trend() local
696 tz->temperature, tz->kelvin_offset); in thermal_get_trend()
713 i = (tz->trips.passive.tc1 * (tz->temperature - tz->last_temperature)) in thermal_get_trend()
714 + (tz->trips.passive.tc2 in thermal_get_trend()
715 * (tz->temperature - tz->trips.passive.temperature)); in thermal_get_trend()
731 struct acpi_thermal *tz = thermal->devdata; in thermal_notify() local
740 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in thermal_notify()
741 dev_name(&tz->device->dev), type, 1); in thermal_notify()
754 struct acpi_thermal *tz = thermal->devdata; in acpi_thermal_cooling_device_cb() local
763 if (tz->trips.critical.flags.valid) in acpi_thermal_cooling_device_cb()
766 if (tz->trips.hot.flags.valid) in acpi_thermal_cooling_device_cb()
769 if (tz->trips.passive.flags.valid) { in acpi_thermal_cooling_device_cb()
771 for (i = 0; i < tz->trips.passive.devices.count; in acpi_thermal_cooling_device_cb()
773 handle = tz->trips.passive.devices.handles[i]; in acpi_thermal_cooling_device_cb()
793 if (!tz->trips.active[i].flags.valid) in acpi_thermal_cooling_device_cb()
797 j < tz->trips.active[i].devices.count; in acpi_thermal_cooling_device_cb()
799 handle = tz->trips.active[i].devices.handles[j]; in acpi_thermal_cooling_device_cb()
816 for (i = 0; i < tz->devices.count; i++) { in acpi_thermal_cooling_device_cb()
817 handle = tz->devices.handles[i]; in acpi_thermal_cooling_device_cb()
866 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_register_thermal_zone() argument
873 if (tz->trips.critical.flags.valid) in acpi_thermal_register_thermal_zone()
876 if (tz->trips.hot.flags.valid) in acpi_thermal_register_thermal_zone()
879 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
883 tz->trips.active[i].flags.valid; i++, trips++); in acpi_thermal_register_thermal_zone()
885 if (tz->trips.passive.flags.valid) in acpi_thermal_register_thermal_zone()
886 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
887 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
889 tz->trips.passive.tsp*100, in acpi_thermal_register_thermal_zone()
890 tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
892 tz->thermal_zone = in acpi_thermal_register_thermal_zone()
893 thermal_zone_device_register("acpitz", trips, 0, tz, in acpi_thermal_register_thermal_zone()
895 0, tz->polling_frequency*100); in acpi_thermal_register_thermal_zone()
896 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
899 result = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_register_thermal_zone()
900 &tz->thermal_zone->device.kobj, "thermal_zone"); in acpi_thermal_register_thermal_zone()
904 result = sysfs_create_link(&tz->thermal_zone->device.kobj, in acpi_thermal_register_thermal_zone()
905 &tz->device->dev.kobj, "device"); in acpi_thermal_register_thermal_zone()
909 status = acpi_bus_attach_private_data(tz->device->handle, in acpi_thermal_register_thermal_zone()
910 tz->thermal_zone); in acpi_thermal_register_thermal_zone()
914 tz->tz_enabled = 1; in acpi_thermal_register_thermal_zone()
916 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
917 tz->thermal_zone->id); in acpi_thermal_register_thermal_zone()
921 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz) in acpi_thermal_unregister_thermal_zone() argument
923 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_unregister_thermal_zone()
924 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device"); in acpi_thermal_unregister_thermal_zone()
925 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
926 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
927 acpi_bus_detach_private_data(tz->device->handle); in acpi_thermal_unregister_thermal_zone()
937 struct acpi_thermal *tz = acpi_driver_data(device); in acpi_thermal_notify() local
940 if (!tz) in acpi_thermal_notify()
945 acpi_thermal_check(tz); in acpi_thermal_notify()
948 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS); in acpi_thermal_notify()
949 acpi_thermal_check(tz); in acpi_thermal_notify()
954 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES); in acpi_thermal_notify()
955 acpi_thermal_check(tz); in acpi_thermal_notify()
978 static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz) in acpi_thermal_aml_dependency_fix() argument
980 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
998 static int acpi_thermal_get_info(struct acpi_thermal *tz) in acpi_thermal_get_info() argument
1003 if (!tz) in acpi_thermal_get_info()
1006 acpi_thermal_aml_dependency_fix(tz); in acpi_thermal_get_info()
1009 result = acpi_thermal_get_trip_points(tz); in acpi_thermal_get_info()
1014 result = acpi_thermal_get_temperature(tz); in acpi_thermal_get_info()
1019 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE); in acpi_thermal_get_info()
1021 tz->flags.cooling_mode = 1; in acpi_thermal_get_info()
1025 tz->polling_frequency = tzp; in acpi_thermal_get_info()
1027 acpi_thermal_get_polling_frequency(tz); in acpi_thermal_get_info()
1042 static void acpi_thermal_guess_offset(struct acpi_thermal *tz) in acpi_thermal_guess_offset() argument
1044 if (tz->trips.critical.flags.valid && in acpi_thermal_guess_offset()
1045 (tz->trips.critical.temperature % 5) == 1) in acpi_thermal_guess_offset()
1046 tz->kelvin_offset = 2731; in acpi_thermal_guess_offset()
1048 tz->kelvin_offset = 2732; in acpi_thermal_guess_offset()
1053 struct acpi_thermal *tz = container_of(work, struct acpi_thermal, in acpi_thermal_check_fn() local
1055 acpi_thermal_check(tz); in acpi_thermal_check_fn()
1061 struct acpi_thermal *tz = NULL; in acpi_thermal_add() local
1067 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL); in acpi_thermal_add()
1068 if (!tz) in acpi_thermal_add()
1071 tz->device = device; in acpi_thermal_add()
1072 strcpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
1075 device->driver_data = tz; in acpi_thermal_add()
1077 result = acpi_thermal_get_info(tz); in acpi_thermal_add()
1081 acpi_thermal_guess_offset(tz); in acpi_thermal_add()
1083 result = acpi_thermal_register_thermal_zone(tz); in acpi_thermal_add()
1087 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
1090 acpi_device_bid(device), DECI_KELVIN_TO_CELSIUS(tz->temperature)); in acpi_thermal_add()
1094 kfree(tz); in acpi_thermal_add()
1101 struct acpi_thermal *tz = NULL; in acpi_thermal_remove() local
1107 tz = acpi_driver_data(device); in acpi_thermal_remove()
1109 acpi_thermal_unregister_thermal_zone(tz); in acpi_thermal_remove()
1110 kfree(tz); in acpi_thermal_remove()
1124 struct acpi_thermal *tz; in acpi_thermal_resume() local
1130 tz = acpi_driver_data(to_acpi_device(dev)); in acpi_thermal_resume()
1131 if (!tz) in acpi_thermal_resume()
1135 if (!(&tz->trips.active[i])) in acpi_thermal_resume()
1137 if (!tz->trips.active[i].flags.valid) in acpi_thermal_resume()
1139 tz->trips.active[i].flags.enabled = 1; in acpi_thermal_resume()
1140 for (j = 0; j < tz->trips.active[i].devices.count; j++) { in acpi_thermal_resume()
1142 tz->trips.active[i].devices.handles[j], in acpi_thermal_resume()
1145 tz->trips.active[i].flags.enabled = 0; in acpi_thermal_resume()
1149 tz->state.active |= tz->trips.active[i].flags.enabled; in acpi_thermal_resume()
1152 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_thermal_resume()