Lines Matching +full:cooling +full:- +full:device
1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
3 * Copyright (C) 2012-2014, 2019-2022, 2024 Intel Corporation
4 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
5 * Copyright (C) 2015-2016 Intel Deutschland GmbH
17 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
18 u32 duration = tt->params.ct_kill_duration;
20 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
27 tt->throttle = false;
28 tt->dynamic_smps = false;
35 if (!mvm->temperature_test)
36 schedule_delayed_work(&tt->ct_kill_exit,
42 if (!test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
52 if (mvm->temperature_test)
55 if (mvm->temperature == temp)
58 mvm->temperature = temp;
74 return -EINVAL;
77 notif_v1 = (void *)pkt->data;
79 temp = le32_to_cpu(notif_v1->temp);
85 IWL_DEBUG_TEMP(mvm, "DTS_MEASUREMENT_NOTIFICATION - %d\n", temp);
116 if (test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status))
132 notif_v2 = (void *)pkt->data;
133 ths_crossed = le32_to_cpu(notif_v2->threshold_idx);
148 if (mvm->tz_device.tzone) {
149 struct iwl_mvm_thermal_device *tz_dev = &mvm->tz_device;
151 thermal_zone_device_update(tz_dev->tzone,
162 notif = (struct ct_kill_notif *)pkt->data;
164 notif->temperature);
165 if (iwl_fw_lookup_notif_ver(mvm->fw, PHY_OPS_GROUP,
169 notif->dts, notif->scheme);
194 if (fw_has_capa(&mvm->fw->ucode_capa,
214 "Sending temperature measurement command - %s response\n",
226 resp = (void *)cmd.resp_pkt->data;
227 *temp = le32_to_cpu(resp->temp);
250 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw,
256 lockdep_assert_held(&mvm->mutex);
258 iwl_init_notification_wait(&mvm->notif_wait, &wait_temp_notif,
264 iwl_remove_notification(&mvm->notif_wait, &wait_temp_notif);
268 ret = iwl_wait_notification(&mvm->notif_wait, &wait_temp_notif,
293 duration = tt->params.ct_kill_duration;
295 flush_work(&mvm->roc_done_wk);
297 mutex_lock(&mvm->mutex);
311 if (temp <= tt->params.ct_kill_exit) {
312 mutex_unlock(&mvm->mutex);
318 mutex_unlock(&mvm->mutex);
319 schedule_delayed_work(&mvm->thermal_throttle.ct_kill_exit,
329 lockdep_assert_held(&mvm->mutex);
331 if (mvm->thermal_throttle.dynamic_smps)
336 if (vif->type != NL80211_IFTYPE_STATION)
347 for (i = 0; i < mvm->fw->ucode_capa.num_stations; i++) {
352 if (enable == mvmsta->tt_tx_protection)
361 mvmsta->tt_tx_protection = enable;
374 backoff = max(backoff, mvm->thermal_throttle.min_backoff);
379 mvm->thermal_throttle.tx_backoff = backoff;
387 struct iwl_tt_params *params = &mvm->thermal_throttle.params;
388 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
389 s32 temperature = mvm->temperature;
394 IWL_DEBUG_TEMP(mvm, "NIC temperature: %d\n", mvm->temperature);
396 if (params->support_ct_kill && temperature >= params->ct_kill_entry) {
401 if (params->support_ct_kill &&
402 temperature <= params->ct_kill_exit) {
407 if (params->support_dynamic_smps) {
408 if (!tt->dynamic_smps &&
409 temperature >= params->dynamic_smps_entry) {
411 tt->dynamic_smps = true;
413 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
416 } else if (tt->dynamic_smps &&
417 temperature <= params->dynamic_smps_exit) {
419 tt->dynamic_smps = false;
421 mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
426 if (params->support_tx_protection) {
427 if (temperature >= params->tx_protection_entry) {
430 } else if (temperature <= params->tx_protection_exit) {
435 if (params->support_tx_backoff) {
436 tx_backoff = tt->min_backoff;
438 if (temperature < params->tx_backoff[i].temperature)
440 tx_backoff = max(tt->min_backoff,
441 params->tx_backoff[i].backoff);
443 if (tx_backoff != tt->min_backoff)
445 if (tt->tx_backoff != tx_backoff)
449 if (!tt->throttle && throttle_enable) {
452 tt->throttle = true;
453 } else if (tt->throttle && !tt->dynamic_smps &&
454 tt->tx_backoff == tt->min_backoff &&
455 temperature <= params->tx_protection_exit) {
458 tt->throttle = false;
486 2400, /* cooling state 0 */
487 2000, /* cooling state 1 */
488 1800, /* cooling state 2 */
489 1600, /* cooling state 3 */
490 1400, /* cooling state 4 */
491 1200, /* cooling state 5 */
492 1000, /* cooling state 6 */
493 900, /* cooling state 7 */
494 800, /* cooling state 8 */
495 700, /* cooling state 9 */
496 650, /* cooling state 10 */
497 600, /* cooling state 11 */
498 550, /* cooling state 12 */
499 500, /* cooling state 13 */
500 450, /* cooling state 14 */
501 400, /* cooling state 15 */
502 350, /* cooling state 16 */
503 300, /* cooling state 17 */
504 250, /* cooling state 18 */
505 200, /* cooling state 19 */
506 150, /* cooling state 20 */
519 lockdep_assert_held(&mvm->mutex);
534 mvm->cooling_dev.cur_state = state;
557 return ((s16)le16_to_cpu(*(__le16 *)a) -
570 if (trip->temperature == THERMAL_TEMP_INVALID)
573 twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000));
585 lockdep_assert_held(&mvm->mutex);
587 if (!mvm->tz_device.tzone)
597 for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd);
616 static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
619 struct iwl_mvm *mvm = thermal_zone_device_priv(device);
626 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
643 static int iwl_mvm_tzone_set_trip_temp(struct thermal_zone_device *device,
646 struct iwl_mvm *mvm = thermal_zone_device_priv(device);
651 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
652 return -EIO;
655 return -EINVAL;
672 mvm->tz_device.tzone = NULL;
685 mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID;
686 mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE;
687 mvm->tz_device.trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP;
689 mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name,
690 mvm->tz_device.trips,
694 if (IS_ERR(mvm->tz_device.tzone)) {
697 PTR_ERR(mvm->tz_device.tzone));
698 mvm->tz_device.tzone = NULL;
702 ret = thermal_zone_device_enable(mvm->tz_device.tzone);
705 thermal_zone_device_unregister(mvm->tz_device.tzone);
712 *state = ARRAY_SIZE(iwl_mvm_cdev_budgets) - 1;
720 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
722 *state = mvm->cooling_dev.cur_state;
730 struct iwl_mvm *mvm = (struct iwl_mvm *)(cdev->devdata);
735 mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR)
736 return -EIO;
739 return -EINVAL;
760 mvm->cooling_dev.cdev =
765 if (IS_ERR(mvm->cooling_dev.cdev)) {
767 "Failed to register to cooling device (err = %ld)\n",
768 PTR_ERR(mvm->cooling_dev.cdev));
769 mvm->cooling_dev.cdev = NULL;
776 if (!iwl_mvm_is_tt_in_fw(mvm) || !mvm->tz_device.tzone)
779 IWL_DEBUG_TEMP(mvm, "Thermal zone device unregister\n");
780 if (mvm->tz_device.tzone) {
781 thermal_zone_device_unregister(mvm->tz_device.tzone);
782 mvm->tz_device.tzone = NULL;
788 if (!iwl_mvm_is_ctdp_supported(mvm) || !mvm->cooling_dev.cdev)
791 IWL_DEBUG_TEMP(mvm, "Cooling device unregister\n");
792 if (mvm->cooling_dev.cdev) {
793 thermal_cooling_device_unregister(mvm->cooling_dev.cdev);
794 mvm->cooling_dev.cdev = NULL;
801 struct iwl_mvm_tt_mgmt *tt = &mvm->thermal_throttle;
805 if (mvm->cfg->thermal_params)
806 tt->params = *mvm->cfg->thermal_params;
808 tt->params = iwl_mvm_default_tt_params;
810 tt->throttle = false;
811 tt->dynamic_smps = false;
812 tt->min_backoff = min_backoff;
813 INIT_DELAYED_WORK(&tt->ct_kill_exit, check_exit_ctkill);
819 mvm->init_status |= IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE;
824 if (!(mvm->init_status & IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE))
827 cancel_delayed_work_sync(&mvm->thermal_throttle.ct_kill_exit);
834 mvm->init_status &= ~IWL_MVM_INIT_STATUS_THERMAL_INIT_COMPLETE;