Lines Matching refs:ar

28 	struct ath10k *ar = cdev->devdata;  in ath10k_thermal_get_cur_throttle_state()  local
30 mutex_lock(&ar->conf_mutex); in ath10k_thermal_get_cur_throttle_state()
31 *state = ar->thermal.throttle_state; in ath10k_thermal_get_cur_throttle_state()
32 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_get_cur_throttle_state()
41 struct ath10k *ar = cdev->devdata; in ath10k_thermal_set_cur_throttle_state() local
44 ath10k_warn(ar, "throttle state %ld is exceeding the limit %d\n", in ath10k_thermal_set_cur_throttle_state()
48 mutex_lock(&ar->conf_mutex); in ath10k_thermal_set_cur_throttle_state()
49 ar->thermal.throttle_state = throttle_state; in ath10k_thermal_set_cur_throttle_state()
50 ath10k_thermal_set_throttling(ar); in ath10k_thermal_set_cur_throttle_state()
51 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_set_cur_throttle_state()
65 struct ath10k *ar = dev_get_drvdata(dev); in ath10k_thermal_show_temp() local
69 mutex_lock(&ar->conf_mutex); in ath10k_thermal_show_temp()
72 if (ar->state != ATH10K_STATE_ON) { in ath10k_thermal_show_temp()
77 reinit_completion(&ar->thermal.wmi_sync); in ath10k_thermal_show_temp()
78 ret = ath10k_wmi_pdev_get_temperature(ar); in ath10k_thermal_show_temp()
80 ath10k_warn(ar, "failed to read temperature %d\n", ret); in ath10k_thermal_show_temp()
84 if (test_bit(ATH10K_FLAG_CRASH_FLUSH, &ar->dev_flags)) { in ath10k_thermal_show_temp()
89 time_left = wait_for_completion_timeout(&ar->thermal.wmi_sync, in ath10k_thermal_show_temp()
92 ath10k_warn(ar, "failed to synchronize thermal read\n"); in ath10k_thermal_show_temp()
97 spin_lock_bh(&ar->data_lock); in ath10k_thermal_show_temp()
98 temperature = ar->thermal.temperature; in ath10k_thermal_show_temp()
99 spin_unlock_bh(&ar->data_lock); in ath10k_thermal_show_temp()
104 mutex_unlock(&ar->conf_mutex); in ath10k_thermal_show_temp()
108 void ath10k_thermal_event_temperature(struct ath10k *ar, int temperature) in ath10k_thermal_event_temperature() argument
110 spin_lock_bh(&ar->data_lock); in ath10k_thermal_event_temperature()
111 ar->thermal.temperature = temperature; in ath10k_thermal_event_temperature()
112 spin_unlock_bh(&ar->data_lock); in ath10k_thermal_event_temperature()
113 complete(&ar->thermal.wmi_sync); in ath10k_thermal_event_temperature()
125 void ath10k_thermal_set_throttling(struct ath10k *ar) in ath10k_thermal_set_throttling() argument
130 lockdep_assert_held(&ar->conf_mutex); in ath10k_thermal_set_throttling()
132 if (!test_bit(WMI_SERVICE_THERM_THROT, ar->wmi.svc_map)) in ath10k_thermal_set_throttling()
135 if (!ar->wmi.ops->gen_pdev_set_quiet_mode) in ath10k_thermal_set_throttling()
138 if (ar->state != ATH10K_STATE_ON) in ath10k_thermal_set_throttling()
141 period = ar->thermal.quiet_period; in ath10k_thermal_set_throttling()
142 duration = (period * ar->thermal.throttle_state) / 100; in ath10k_thermal_set_throttling()
145 ret = ath10k_wmi_pdev_set_quiet_mode(ar, period, duration, in ath10k_thermal_set_throttling()
149 ath10k_warn(ar, "failed to set quiet mode period %u duarion %u enabled %u ret %d\n", in ath10k_thermal_set_throttling()
154 int ath10k_thermal_register(struct ath10k *ar) in ath10k_thermal_register() argument
160 if (!test_bit(WMI_SERVICE_THERM_THROT, ar->wmi.svc_map)) in ath10k_thermal_register()
163 cdev = thermal_cooling_device_register("ath10k_thermal", ar, in ath10k_thermal_register()
167 ath10k_err(ar, "failed to setup thermal device result: %ld\n", in ath10k_thermal_register()
172 ret = sysfs_create_link(&ar->dev->kobj, &cdev->device.kobj, in ath10k_thermal_register()
175 ath10k_err(ar, "failed to create cooling device symlink\n"); in ath10k_thermal_register()
179 ar->thermal.cdev = cdev; in ath10k_thermal_register()
180 ar->thermal.quiet_period = ATH10K_QUIET_PERIOD_DEFAULT; in ath10k_thermal_register()
185 if (!(ar->wmi.ops->gen_pdev_get_temperature)) in ath10k_thermal_register()
194 hwmon_dev = devm_hwmon_device_register_with_groups(ar->dev, in ath10k_thermal_register()
195 "ath10k_hwmon", ar, in ath10k_thermal_register()
198 ath10k_err(ar, "failed to register hwmon device: %ld\n", in ath10k_thermal_register()
206 sysfs_remove_link(&ar->dev->kobj, "cooling_device"); in ath10k_thermal_register()
212 void ath10k_thermal_unregister(struct ath10k *ar) in ath10k_thermal_unregister() argument
214 if (!test_bit(WMI_SERVICE_THERM_THROT, ar->wmi.svc_map)) in ath10k_thermal_unregister()
217 sysfs_remove_link(&ar->dev->kobj, "cooling_device"); in ath10k_thermal_unregister()
218 thermal_cooling_device_unregister(ar->thermal.cdev); in ath10k_thermal_unregister()