Lines Matching +full:no +full:- +full:temp +full:- +full:support

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * acpi_thermal.c - ACPI Thermal Zone Driver ($Revision: 41 $)
12 * 2. Enhance passive cooling (CPU) states/limit interface to support
48 #define ACPI_THERMAL_TRIP_PASSIVE (-1)
55 * when re-evaluating the AML code.
57 * We need to re-bind the cooling devices of a thermal zone when this occurs.
61 acpi_handle_info(tz->device->handle, \
63 "Please report to linux-acpi@vger.kernel.org\n", str); \
80 MODULE_PARM_DESC(off, "Set to disable ACPI thermal support.");
124 /* --------------------------------------------------------------------------
126 -------------------------------------------------------------------------- */
134 return -EINVAL; in acpi_thermal_get_temperature()
136 tz->last_temp_dk = tz->temp_dk; in acpi_thermal_get_temperature()
138 status = acpi_evaluate_integer(tz->device->handle, "_TMP", NULL, &tmp); in acpi_thermal_get_temperature()
140 return -ENODEV; in acpi_thermal_get_temperature()
142 tz->temp_dk = tmp; in acpi_thermal_get_temperature()
144 acpi_handle_debug(tz->device->handle, "Temperature is %lu dK\n", in acpi_thermal_get_temperature()
145 tz->temp_dk); in acpi_thermal_get_temperature()
156 return -EINVAL; in acpi_thermal_get_polling_frequency()
158 status = acpi_evaluate_integer(tz->device->handle, "_TZP", NULL, &tmp); in acpi_thermal_get_polling_frequency()
160 return -ENODEV; in acpi_thermal_get_polling_frequency()
162 tz->polling_frequency = tmp; in acpi_thermal_get_polling_frequency()
163 acpi_handle_debug(tz->device->handle, "Polling frequency is %lu dS\n", in acpi_thermal_get_polling_frequency()
164 tz->polling_frequency); in acpi_thermal_get_polling_frequency()
171 int temp; in acpi_thermal_temp() local
176 temp = deci_kelvin_to_millicelsius_with_offset(temp_deci_k, in acpi_thermal_temp()
177 tz->kelvin_offset); in acpi_thermal_temp()
178 if (temp <= 0) in acpi_thermal_temp()
181 return temp; in acpi_thermal_temp()
186 return acpi_trip->temp_dk != THERMAL_TEMP_INVALID; in acpi_thermal_trip_valid()
195 return active - tz->trips.active; in active_trip_index()
200 int temp; in get_passive_temp() local
202 if (acpi_passive_trip_temp(tz->device, &temp)) in get_passive_temp()
205 return temp; in get_passive_temp()
210 int temp; in get_active_temp() local
212 if (acpi_active_trip_temp(tz->device, index, &temp)) in get_active_temp()
216 * If an override has been provided, apply it so there are no active in get_active_temp()
222 if (temp > override) in get_active_temp()
225 return temp; in get_active_temp()
231 struct acpi_thermal_trip *acpi_trip = trip->priv; in acpi_thermal_update_trip()
233 if (trip->type == THERMAL_TRIP_PASSIVE) { in acpi_thermal_update_trip()
237 acpi_trip->temp_dk = get_passive_temp(tz); in acpi_thermal_update_trip()
241 acpi_trip->temp_dk = get_active_temp(tz, index); in acpi_thermal_update_trip()
261 if (!acpi_evaluate_reference(tz->device->handle, method, NULL, &devices)) { in update_trip_devices()
262 acpi_handle_info(tz->device->handle, "%s evaluation failure\n", method); in update_trip_devices()
266 if (acpi_handle_list_equal(&acpi_trip->devices, &devices)) { in update_trip_devices()
274 acpi_handle_list_replace(&acpi_trip->devices, &devices); in update_trip_devices()
281 struct acpi_thermal_trip *acpi_trip = trip->priv; in acpi_thermal_update_trip_devices()
282 int index = trip->type == THERMAL_TRIP_PASSIVE ? in acpi_thermal_update_trip_devices()
288 acpi_trip->temp_dk = THERMAL_TEMP_INVALID; in acpi_thermal_update_trip_devices()
299 struct acpi_thermal_trip *acpi_trip = trip->priv; in acpi_thermal_adjust_trip()
301 struct acpi_thermal *tz = atd->tz; in acpi_thermal_adjust_trip()
302 int temp; in acpi_thermal_adjust_trip() local
307 if (atd->event == ACPI_THERMAL_NOTIFY_THRESHOLDS) in acpi_thermal_adjust_trip()
313 temp = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_adjust_trip()
315 temp = THERMAL_TEMP_INVALID; in acpi_thermal_adjust_trip()
317 thermal_zone_set_trip_temp(tz->thermal_zone, trip, temp); in acpi_thermal_adjust_trip()
324 if (!work_pending(&tz->thermal_check_work)) in acpi_queue_thermal_check()
325 queue_work(acpi_thermal_pm_queue, &tz->thermal_check_work); in acpi_queue_thermal_check()
331 struct acpi_device *adev = tz->device; in acpi_thermal_trips_update()
340 thermal_zone_for_each_trip(tz->thermal_zone, in acpi_thermal_trips_update()
343 acpi_bus_generate_netlink_event(adev->pnp.device_class, in acpi_thermal_trips_update()
344 dev_name(&adev->dev), event, 0); in acpi_thermal_trips_update()
349 int temp; in acpi_thermal_get_critical_trip() local
352 temp = celsius_to_deci_kelvin(crt); in acpi_thermal_get_critical_trip()
355 if (crt == -1) { in acpi_thermal_get_critical_trip()
356 acpi_handle_debug(tz->device->handle, "Critical threshold disabled\n"); in acpi_thermal_get_critical_trip()
360 if (acpi_critical_trip_temp(tz->device, &temp)) in acpi_thermal_get_critical_trip()
363 if (temp <= 2732) { in acpi_thermal_get_critical_trip()
368 pr_info(FW_BUG "Invalid critical threshold (%d)\n", temp); in acpi_thermal_get_critical_trip()
373 acpi_handle_debug(tz->device->handle, "Critical threshold [%d]\n", temp); in acpi_thermal_get_critical_trip()
374 return temp; in acpi_thermal_get_critical_trip()
379 int temp; in acpi_thermal_get_hot_trip() local
381 if (acpi_hot_trip_temp(tz->device, &temp) || temp == THERMAL_TEMP_INVALID) { in acpi_thermal_get_hot_trip()
382 acpi_handle_debug(tz->device->handle, "No hot threshold\n"); in acpi_thermal_get_hot_trip()
386 acpi_handle_debug(tz->device->handle, "Hot threshold [%d]\n", temp); in acpi_thermal_get_hot_trip()
387 return temp; in acpi_thermal_get_hot_trip()
395 status = acpi_evaluate_integer(tz->device->handle, "_TC1", NULL, &tmp); in passive_trip_params_init()
399 tz->trips.passive.tc1 = tmp; in passive_trip_params_init()
401 status = acpi_evaluate_integer(tz->device->handle, "_TC2", NULL, &tmp); in passive_trip_params_init()
405 tz->trips.passive.tc2 = tmp; in passive_trip_params_init()
407 status = acpi_evaluate_integer(tz->device->handle, "_TFP", NULL, &tmp); in passive_trip_params_init()
409 tz->trips.passive.delay = tmp; in passive_trip_params_init()
413 status = acpi_evaluate_integer(tz->device->handle, "_TSP", NULL, &tmp); in passive_trip_params_init()
417 tz->trips.passive.delay = tmp * 100; in passive_trip_params_init()
425 long temp; in acpi_thermal_init_trip() local
428 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_init_trip()
430 if (psv == -1) in acpi_thermal_init_trip()
436 temp = psv > 0 ? celsius_to_deci_kelvin(psv) : in acpi_thermal_init_trip()
439 acpi_trip = &tz->trips.active[index].trip; in acpi_thermal_init_trip()
441 if (act == -1) in acpi_thermal_init_trip()
444 temp = get_active_temp(tz, index); in acpi_thermal_init_trip()
447 if (temp == THERMAL_TEMP_INVALID) in acpi_thermal_init_trip()
453 acpi_trip->temp_dk = temp; in acpi_thermal_init_trip()
457 acpi_trip->temp_dk = THERMAL_TEMP_INVALID; in acpi_thermal_init_trip()
473 tz->trips.active[i].trip.temp_dk = THERMAL_TEMP_INVALID; in acpi_thermal_get_trip_points()
476 /* sys I/F for generic thermal sysfs support */
478 static int thermal_get_temp(struct thermal_zone_device *thermal, int *temp) in thermal_get_temp() argument
484 return -EINVAL; in thermal_get_temp()
490 *temp = deci_kelvin_to_millicelsius_with_offset(tz->temp_dk, in thermal_get_temp()
491 tz->kelvin_offset); in thermal_get_temp()
504 return -EINVAL; in thermal_get_trend()
506 acpi_trip = trip->priv; in thermal_get_trend()
508 return -EINVAL; in thermal_get_trend()
510 switch (trip->type) { in thermal_get_trend()
512 t = tz->trips.passive.tc1 * (tz->temp_dk - in thermal_get_trend()
513 tz->last_temp_dk) + in thermal_get_trend()
514 tz->trips.passive.tc2 * (tz->temp_dk - in thermal_get_trend()
515 acpi_trip->temp_dk); in thermal_get_trend()
526 t = acpi_thermal_temp(tz, tz->temp_dk); in thermal_get_trend()
527 if (t <= trip->temperature) in thermal_get_trend()
538 return -EINVAL; in thermal_get_trend()
545 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_hot()
546 dev_name(&tz->device->dev), in acpi_thermal_zone_device_hot()
554 acpi_bus_generate_netlink_event(tz->device->pnp.device_class, in acpi_thermal_zone_device_critical()
555 dev_name(&tz->device->dev), in acpi_thermal_zone_device_critical()
566 struct acpi_thermal_trip *acpi_trip = trip->priv; in acpi_thermal_should_bind_cdev()
567 struct acpi_device *cdev_adev = cdev->devdata; in acpi_thermal_should_bind_cdev()
574 for (i = 0; i < acpi_trip->devices.count; i++) { in acpi_thermal_should_bind_cdev()
575 acpi_handle handle = acpi_trip->devices.handles[i]; in acpi_thermal_should_bind_cdev()
594 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_add()
597 ret = sysfs_create_link(&tz->device->dev.kobj, in acpi_thermal_zone_sysfs_add()
598 &tzdev->kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_add()
602 ret = sysfs_create_link(&tzdev->kobj, in acpi_thermal_zone_sysfs_add()
603 &tz->device->dev.kobj, "device"); in acpi_thermal_zone_sysfs_add()
605 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_add()
612 struct device *tzdev = thermal_zone_device(tz->thermal_zone); in acpi_thermal_zone_sysfs_remove()
614 sysfs_remove_link(&tz->device->dev.kobj, "thermal_zone"); in acpi_thermal_zone_sysfs_remove()
615 sysfs_remove_link(&tzdev->kobj, "device"); in acpi_thermal_zone_sysfs_remove()
626 tz->thermal_zone = thermal_zone_device_register_with_trips( in acpi_thermal_register_thermal_zone()
629 tz->polling_frequency * 100); in acpi_thermal_register_thermal_zone()
631 tz->thermal_zone = thermal_tripless_zone_device_register( in acpi_thermal_register_thermal_zone()
634 if (IS_ERR(tz->thermal_zone)) in acpi_thermal_register_thermal_zone()
635 return PTR_ERR(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
641 result = thermal_zone_device_enable(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
645 dev_info(&tz->device->dev, "registered as thermal_zone%d\n", in acpi_thermal_register_thermal_zone()
646 thermal_zone_device_id(tz->thermal_zone)); in acpi_thermal_register_thermal_zone()
653 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_register_thermal_zone()
660 thermal_zone_device_disable(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
662 thermal_zone_device_unregister(tz->thermal_zone); in acpi_thermal_unregister_thermal_zone()
663 tz->thermal_zone = NULL; in acpi_thermal_unregister_thermal_zone()
667 /* --------------------------------------------------------------------------
669 -------------------------------------------------------------------------- */
688 acpi_handle_debug(device->handle, "Unsupported event [0x%x]\n", in acpi_thermal_notify()
697 * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
708 acpi_handle handle = tz->device->handle; in acpi_thermal_aml_dependency_fix()
739 tz->kelvin_offset = 273100; in acpi_thermal_guess_offset()
741 tz->kelvin_offset = 273200; in acpi_thermal_guess_offset()
757 if (!refcount_dec_not_one(&tz->thermal_check_count)) in acpi_thermal_check_fn()
760 mutex_lock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
762 thermal_zone_device_update(tz->thermal_zone, THERMAL_EVENT_UNSPECIFIED); in acpi_thermal_check_fn()
764 refcount_inc(&tz->thermal_check_count); in acpi_thermal_check_fn()
766 mutex_unlock(&tz->thermal_check_lock); in acpi_thermal_check_fn()
773 acpi_handle_list_free(&tz->trips.passive.trip.devices); in acpi_thermal_free_thermal_zone()
775 acpi_handle_list_free(&tz->trips.active[i].trip.devices); in acpi_thermal_free_thermal_zone()
792 return -EINVAL; in acpi_thermal_add()
796 return -ENOMEM; in acpi_thermal_add()
798 tz->device = device; in acpi_thermal_add()
799 strscpy(tz->name, device->pnp.bus_id); in acpi_thermal_add()
802 device->driver_data = tz; in acpi_thermal_add()
818 acpi_execute_simple_method(tz->device->handle, "_SCP", in acpi_thermal_add()
823 tz->polling_frequency = tzp; in acpi_thermal_add()
832 trip->type = THERMAL_TRIP_CRITICAL; in acpi_thermal_add()
833 trip->temperature = acpi_thermal_temp(tz, crit_temp); in acpi_thermal_add()
838 trip->type = THERMAL_TRIP_HOT; in acpi_thermal_add()
839 trip->temperature = acpi_thermal_temp(tz, hot_temp); in acpi_thermal_add()
843 acpi_trip = &tz->trips.passive.trip; in acpi_thermal_add()
845 passive_delay = tz->trips.passive.delay; in acpi_thermal_add()
847 trip->type = THERMAL_TRIP_PASSIVE; in acpi_thermal_add()
848 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
849 trip->priv = acpi_trip; in acpi_thermal_add()
854 acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_add()
859 trip->type = THERMAL_TRIP_ACTIVE; in acpi_thermal_add()
860 trip->temperature = acpi_thermal_temp(tz, acpi_trip->temp_dk); in acpi_thermal_add()
861 trip->priv = acpi_trip; in acpi_thermal_add()
866 pr_warn(FW_BUG "No valid trip points!\n"); in acpi_thermal_add()
869 trip - trip_table, in acpi_thermal_add()
874 refcount_set(&tz->thermal_check_count, 3); in acpi_thermal_add()
875 mutex_init(&tz->thermal_check_lock); in acpi_thermal_add()
876 INIT_WORK(&tz->thermal_check_work, acpi_thermal_check_fn); in acpi_thermal_add()
879 acpi_device_bid(device), deci_kelvin_to_celsius(tz->temp_dk)); in acpi_thermal_add()
928 return -EINVAL; in acpi_thermal_resume()
932 return -EINVAL; in acpi_thermal_resume()
935 struct acpi_thermal_trip *acpi_trip = &tz->trips.active[i].trip; in acpi_thermal_resume()
940 for (j = 0; j < acpi_trip->devices.count; j++) { in acpi_thermal_resume()
941 acpi_bus_update_power(acpi_trip->devices.handles[j], in acpi_thermal_resume()
977 d->ident); in thermal_act()
978 act = -1; in thermal_act()
986 d->ident); in thermal_nocrt()
987 crt = -1; in thermal_nocrt()
995 d->ident); in thermal_tzp()
1005 d->ident); in thermal_psv()
1006 psv = -1; in thermal_psv()
1018 .ident = "AOpen i915GMm-HFS",
1021 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1026 .ident = "AOpen i915GMm-HFS",
1029 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1034 .ident = "AOpen i915GMm-HFS",
1037 DMI_MATCH(DMI_BOARD_NAME, "i915GMm-HFS"),
1042 .ident = "Gigabyte GA-7ZX",
1059 return -ENODEV; in acpi_thermal_init()
1065 return -ENODEV; in acpi_thermal_init()
1070 return -ENODEV; in acpi_thermal_init()