Lines Matching refs:ar
39 struct ath10k *ar = cdev->devdata; in ath10k_thermal_get_cur_throttle_state() local
41 mutex_lock(&ar->conf_mutex); in ath10k_thermal_get_cur_throttle_state()
42 *state = ar->thermal.throttle_state; in ath10k_thermal_get_cur_throttle_state()
43 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_get_cur_throttle_state()
52 struct ath10k *ar = cdev->devdata; in ath10k_thermal_set_cur_throttle_state() local
55 ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n", in ath10k_thermal_set_cur_throttle_state()
59 mutex_lock(&ar->conf_mutex); in ath10k_thermal_set_cur_throttle_state()
60 ar->thermal.throttle_state = throttle_state; in ath10k_thermal_set_cur_throttle_state()
61 ath10k_thermal_set_throttling(ar); in ath10k_thermal_set_cur_throttle_state()
62 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_set_cur_throttle_state()
76 struct ath10k *ar = dev_get_drvdata(dev); in ath10k_thermal_show_temp() local
80 mutex_lock(&ar->conf_mutex); in ath10k_thermal_show_temp()
83 if (ar->state != ATH10K_STATE_ON) { in ath10k_thermal_show_temp()
88 reinit_completion(&ar->thermal.wmi_sync); in ath10k_thermal_show_temp()
89 ret = ath10k_wmi_pdev_get_temperature(ar); in ath10k_thermal_show_temp()
91 ath10k_warn(ar, "failed to read temperature %d\n", ret); in ath10k_thermal_show_temp()
95 if (test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags)) { in ath10k_thermal_show_temp()
100 time_left = wait_for_completion_timeout(&ar->thermal.wmi_sync, in ath10k_thermal_show_temp()
103 ath10k_warn(ar, "failed to synchronize thermal read\n"); in ath10k_thermal_show_temp()
108 spin_lock_bh(&ar->data_lock); in ath10k_thermal_show_temp()
109 temperature = ar->thermal.temperature; in ath10k_thermal_show_temp()
110 spin_unlock_bh(&ar->data_lock); in ath10k_thermal_show_temp()
115 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_show_temp()
119 void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature) in ath10k_thermal_event_temperature() argument
121 spin_lock_bh(&ar->data_lock); in ath10k_thermal_event_temperature()
122 ar->thermal.temperature = temperature; in ath10k_thermal_event_temperature()
123 spin_unlock_bh(&ar->data_lock); in ath10k_thermal_event_temperature()
124 complete(&ar->thermal.wmi_sync); in ath10k_thermal_event_temperature()
136 void ath10k_thermal_set_throttling(struct ath10k *ar) in ath10k_thermal_set_throttling() argument
141 lockdep_assert_held(&ar->conf_mutex); in ath10k_thermal_set_throttling()
143 if (!ar->wmi.ops->gen_pdev_set_quiet_mode) in ath10k_thermal_set_throttling()
146 if (ar->state != ATH10K_STATE_ON) in ath10k_thermal_set_throttling()
149 period = ar->thermal.quiet_period; in ath10k_thermal_set_throttling()
150 duration = (period * ar->thermal.throttle_state) / 100; in ath10k_thermal_set_throttling()
153 ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration, in ath10k_thermal_set_throttling()
157 ath10k_warn(ar, "failed to set quiet mode period %u duarion %u enabled %u ret %d\n", in ath10k_thermal_set_throttling()
162 int ath10k_thermal_register(struct ath10k *ar) in ath10k_thermal_register() argument
168 cdev = thermal_cooling_device_register("ath10k_thermal", ar, in ath10k_thermal_register()
172 ath10k_err(ar, "failed to setup thermal device result: %ld\n", in ath10k_thermal_register()
177 ret = sysfs_create_link(&ar->dev->kobj, &cdev->device.kobj, in ath10k_thermal_register()
180 ath10k_err(ar, "failed to create cooling device symlink\n"); in ath10k_thermal_register()
184 ar->thermal.cdev = cdev; in ath10k_thermal_register()
185 ar->thermal.quiet_period = ATH10K_QUIET_PERIOD_DEFAULT; in ath10k_thermal_register()
190 if (ar->wmi.op_version != ATH10K_FW_WMI_OP_VERSION_10_2_4) in ath10k_thermal_register()
198 hwmon_dev = devm_hwmon_device_register_with_groups(ar->dev, in ath10k_thermal_register()
199 "ath10k_hwmon", ar, in ath10k_thermal_register()
202 ath10k_err(ar, "failed to register hwmon device: %ld\n", in ath10k_thermal_register()
210 sysfs_remove_link(&ar->dev->kobj, "cooling_device"); in ath10k_thermal_register()
216 void ath10k_thermal_unregister(struct ath10k *ar) in ath10k_thermal_unregister() argument
218 sysfs_remove_link(&ar->dev->kobj, "cooling_device"); in ath10k_thermal_unregister()
219 thermal_cooling_device_unregister(ar->thermal.cdev); in ath10k_thermal_unregister()