Lines Matching defs:tz

196 static int acpi_thermal_get_temperature(struct acpi_thermal *tz)
201 if (!tz)
204 tz->last_temperature = tz->temperature;
206 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp);
210 tz->temperature = tmp;
212 tz->temperature));
217 static int acpi_thermal_get_polling_frequency(struct acpi_thermal *tz)
222 if (!tz)
225 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp);
229 tz->polling_frequency = tmp;
231 tz->polling_frequency));
236 static int acpi_thermal_set_cooling_mode(struct acpi_thermal *tz, int mode)
244 if (!tz)
247 status = acpi_get_handle(tz->device->handle, "_SCP", &handle);
290 static int acpi_thermal_trips_update(struct acpi_thermal *tz, int flag)
300 status = acpi_evaluate_integer(tz->device->handle,
302 tz->trips.critical.temperature = tmp;
310 tz->trips.critical.flags.valid = 0;
316 tz->trips.critical.flags.valid = 0;
318 tz->trips.critical.flags.valid = 1;
321 tz->trips.critical.temperature));
323 if (tz->trips.critical.flags.valid == 1) {
325 tz->trips.critical.flags.valid = 0;
331 if (crt_k > tz->trips.critical.temperature)
334 tz->trips.critical.temperature = crt_k;
341 status = acpi_evaluate_integer(tz->device->handle,
344 tz->trips.hot.flags.valid = 0;
348 tz->trips.hot.temperature = tmp;
349 tz->trips.hot.flags.valid = 1;
352 tz->trips.critical.temperature));
357 if (((flag & ACPI_TRIPS_PASSIVE) && tz->trips.passive.flags.valid) ||
359 valid = tz->trips.passive.flags.valid;
366 status = acpi_evaluate_integer(tz->device->handle,
371 tz->trips.passive.flags.valid = 0;
373 tz->trips.passive.temperature = tmp;
374 tz->trips.passive.flags.valid = 1;
377 tz->device->handle, "_TC1",
380 tz->trips.passive.flags.valid = 0;
382 tz->trips.passive.tc1 = tmp;
384 tz->device->handle, "_TC2",
387 tz->trips.passive.flags.valid = 0;
389 tz->trips.passive.tc2 = tmp;
391 tz->device->handle, "_TSP",
394 tz->trips.passive.flags.valid = 0;
396 tz->trips.passive.tsp = tmp;
400 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.passive.flags.valid) {
402 status = acpi_evaluate_reference(tz->device->handle, "_PSL",
407 tz->trips.passive.flags.valid = 0;
410 tz->trips.passive.flags.valid = 1;
412 if (memcmp(&tz->trips.passive.devices, &devices,
414 memcpy(&tz->trips.passive.devices, &devices,
420 if (valid != tz->trips.passive.flags.valid)
427 valid = tz->trips.active[i].flags.valid;
433 tz->trips.active[i].flags.valid)) {
434 status = acpi_evaluate_integer(tz->device->handle,
437 tz->trips.active[i].flags.valid = 0;
443 tz->trips.active[0].temperature =
450 tz->trips.active[i - 1].temperature =
451 (tz->trips.active[i - 2].temperature <
453 tz->trips.active[i - 2].temperature :
457 tz->trips.active[i].temperature = tmp;
458 tz->trips.active[i].flags.valid = 1;
463 if ((flag & ACPI_TRIPS_DEVICES) && tz->trips.active[i].flags.valid ) {
465 status = acpi_evaluate_reference(tz->device->handle,
470 tz->trips.active[i].flags.valid = 0;
473 tz->trips.active[i].flags.valid = 1;
475 if (memcmp(&tz->trips.active[i].devices, &devices,
477 memcpy(&tz->trips.active[i].devices, &devices,
483 if (valid != tz->trips.active[i].flags.valid)
486 if (!tz->trips.active[i].flags.valid)
492 status = acpi_evaluate_reference(tz->device->handle, "_TZD",
494 if (memcmp(&tz->devices, &devices,
496 memcpy(&tz->devices, &devices,
505 static int acpi_thermal_get_trip_points(struct acpi_thermal *tz)
507 int i, valid, ret = acpi_thermal_trips_update(tz, ACPI_TRIPS_INIT);
512 valid = tz->trips.critical.flags.valid |
513 tz->trips.hot.flags.valid |
514 tz->trips.passive.flags.valid;
517 valid |= tz->trips.active[i].flags.valid;
528 struct acpi_thermal *tz = data;
530 thermal_zone_device_update(tz->thermal_zone);
539 struct acpi_thermal *tz = thermal->devdata;
542 if (!tz)
545 result = acpi_thermal_get_temperature(tz);
549 *temp = KELVIN_TO_MILLICELSIUS(tz->temperature, tz->kelvin_offset);
558 struct acpi_thermal *tz = thermal->devdata;
560 if (!tz)
563 *mode = tz->tz_enabled ? THERMAL_DEVICE_ENABLED :
572 struct acpi_thermal *tz = thermal->devdata;
575 if (!tz)
588 if (enable != tz->tz_enabled) {
589 tz->tz_enabled = enable;
592 tz->tz_enabled ? enabled : disabled));
593 acpi_thermal_check(tz);
601 struct acpi_thermal *tz = thermal->devdata;
604 if (!tz || trip < 0)
607 if (tz->trips.critical.flags.valid) {
615 if (tz->trips.hot.flags.valid) {
623 if (tz->trips.passive.flags.valid) {
632 tz->trips.active[i].flags.valid; i++) {
646 struct acpi_thermal *tz = thermal->devdata;
649 if (!tz || trip < 0)
652 if (tz->trips.critical.flags.valid) {
655 tz->trips.critical.temperature,
656 tz->kelvin_offset);
662 if (tz->trips.hot.flags.valid) {
665 tz->trips.hot.temperature,
666 tz->kelvin_offset);
672 if (tz->trips.passive.flags.valid) {
675 tz->trips.passive.temperature,
676 tz->kelvin_offset);
683 tz->trips.active[i].flags.valid; i++) {
686 tz->trips.active[i].temperature,
687 tz->kelvin_offset);
698 struct acpi_thermal *tz = thermal->devdata;
700 if (tz->trips.critical.flags.valid) {
702 tz->trips.critical.temperature,
703 tz->kelvin_offset);
713 struct acpi_thermal *tz = thermal->devdata;
722 acpi_bus_generate_proc_event(tz->device, type, 1);
723 acpi_bus_generate_netlink_event(tz->device->pnp.device_class,
724 dev_name(&tz->device->dev), type, 1);
739 struct acpi_thermal *tz = thermal->devdata;
748 if (tz->trips.critical.flags.valid)
751 if (tz->trips.hot.flags.valid)
754 if (tz->trips.passive.flags.valid) {
756 for (i = 0; i < tz->trips.passive.devices.count;
758 handle = tz->trips.passive.devices.handles[i];
769 if (!tz->trips.active[i].flags.valid)
773 j < tz->trips.active[i].devices.count;
775 handle = tz->trips.active[i].devices.handles[j];
785 for (i = 0; i < tz->devices.count; i++) {
786 handle = tz->devices.handles[i];
827 static int acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
834 if (tz->trips.critical.flags.valid)
837 if (tz->trips.hot.flags.valid)
840 if (tz->trips.passive.flags.valid)
844 tz->trips.active[i].flags.valid; i++, trips++);
846 if (tz->trips.passive.flags.valid)
847 tz->thermal_zone =
848 thermal_zone_device_register("acpitz", trips, tz,
850 tz->trips.passive.tc1,
851 tz->trips.passive.tc2,
852 tz->trips.passive.tsp*100,
853 tz->polling_frequency*100);
855 tz->thermal_zone =
856 thermal_zone_device_register("acpitz", trips, tz,
859 tz->polling_frequency*100);
860 if (IS_ERR(tz->thermal_zone))
863 result = sysfs_create_link(&tz->device->dev.kobj,
864 &tz->thermal_zone->device.kobj, "thermal_zone");
868 result = sysfs_create_link(&tz->thermal_zone->device.kobj,
869 &tz->device->dev.kobj, "device");
873 status = acpi_attach_data(tz->device->handle,
875 tz->thermal_zone);
882 tz->tz_enabled = 1;
884 dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
885 tz->thermal_zone->id);
889 static void acpi_thermal_unregister_thermal_zone(struct acpi_thermal *tz)
891 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone");
892 sysfs_remove_link(&tz->thermal_zone->device.kobj, "device");
893 thermal_zone_device_unregister(tz->thermal_zone);
894 tz->thermal_zone = NULL;
895 acpi_detach_data(tz->device->handle, acpi_bus_private_data_handler);
905 struct acpi_thermal *tz = acpi_driver_data(device);
908 if (!tz)
913 acpi_thermal_check(tz);
916 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_THRESHOLDS);
917 acpi_thermal_check(tz);
923 acpi_thermal_trips_update(tz, ACPI_TRIPS_REFRESH_DEVICES);
924 acpi_thermal_check(tz);
936 static int acpi_thermal_get_info(struct acpi_thermal *tz)
941 if (!tz)
945 result = acpi_thermal_get_trip_points(tz);
950 result = acpi_thermal_get_temperature(tz);
955 result = acpi_thermal_set_cooling_mode(tz, ACPI_THERMAL_MODE_ACTIVE);
957 tz->flags.cooling_mode = 1;
961 tz->polling_frequency = tzp;
963 acpi_thermal_get_polling_frequency(tz);
978 static void acpi_thermal_guess_offset(struct acpi_thermal *tz)
980 if (tz->trips.critical.flags.valid &&
981 (tz->trips.critical.temperature % 5) == 1)
982 tz->kelvin_offset = 2731;
984 tz->kelvin_offset = 2732;
990 struct acpi_thermal *tz = NULL;
996 tz = kzalloc(sizeof(struct acpi_thermal), GFP_KERNEL);
997 if (!tz)
1000 tz->device = device;
1001 strcpy(tz->name, device->pnp.bus_id);
1004 device->driver_data = tz;
1005 mutex_init(&tz->lock);
1008 result = acpi_thermal_get_info(tz);
1012 acpi_thermal_guess_offset(tz);
1014 result = acpi_thermal_register_thermal_zone(tz);
1020 KELVIN_TO_CELSIUS(tz->temperature));
1024 kfree(tz);
1031 struct acpi_thermal *tz = NULL;
1036 tz = acpi_driver_data(device);
1038 acpi_thermal_unregister_thermal_zone(tz);
1039 mutex_destroy(&tz->lock);
1040 kfree(tz);
1046 struct acpi_thermal *tz = NULL;
1053 tz = acpi_driver_data(device);
1056 if (!(&tz->trips.active[i]))
1058 if (!tz->trips.active[i].flags.valid)
1060 tz->trips.active[i].flags.enabled = 1;
1061 for (j = 0; j < tz->trips.active[i].devices.count; j++) {
1063 tz->trips.active[i].devices.handles[j],
1066 tz->trips.active[i].flags.enabled = 0;
1070 tz->state.active |= tz->trips.active[i].flags.enabled;
1073 acpi_thermal_check(tz);