Lines Matching refs:tz

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