Lines Matching +full:sar +full:- +full:threshold
1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved.
17 root_handle = ACPI_HANDLE(ab->dev); in ath12k_acpi_dsm_get_data()
20 return -EOPNOTSUPP; in ath12k_acpi_dsm_get_data()
23 obj = acpi_evaluate_dsm(root_handle, ab->hw_params->acpi_guid, 0, func, in ath12k_acpi_dsm_get_data()
28 return -ENOENT; in ath12k_acpi_dsm_get_data()
31 if (obj->type == ACPI_TYPE_INTEGER) { in ath12k_acpi_dsm_get_data()
32 ab->acpi.func_bit = obj->integer.value; in ath12k_acpi_dsm_get_data()
33 } else if (obj->type == ACPI_TYPE_BUFFER) { in ath12k_acpi_dsm_get_data()
36 if (obj->buffer.length != ATH12K_ACPI_DSM_TAS_CFG_SIZE) { in ath12k_acpi_dsm_get_data()
38 obj->buffer.length); in ath12k_acpi_dsm_get_data()
39 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
43 memcpy(&ab->acpi.tas_cfg, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
44 obj->buffer.length); in ath12k_acpi_dsm_get_data()
48 if (obj->buffer.length != ATH12K_ACPI_DSM_TAS_DATA_SIZE) { in ath12k_acpi_dsm_get_data()
50 obj->buffer.length); in ath12k_acpi_dsm_get_data()
51 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
55 memcpy(&ab->acpi.tas_sar_power_table, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
56 obj->buffer.length); in ath12k_acpi_dsm_get_data()
60 if (obj->buffer.length != ATH12K_ACPI_DSM_BIOS_SAR_DATA_SIZE) { in ath12k_acpi_dsm_get_data()
61 ath12k_warn(ab, "invalid ACPI BIOS SAR data size: %d\n", in ath12k_acpi_dsm_get_data()
62 obj->buffer.length); in ath12k_acpi_dsm_get_data()
63 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
67 memcpy(&ab->acpi.bios_sar_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
68 obj->buffer.length); in ath12k_acpi_dsm_get_data()
72 if (obj->buffer.length != ATH12K_ACPI_DSM_GEO_OFFSET_DATA_SIZE) { in ath12k_acpi_dsm_get_data()
74 obj->buffer.length); in ath12k_acpi_dsm_get_data()
75 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
79 memcpy(&ab->acpi.geo_offset_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
80 obj->buffer.length); in ath12k_acpi_dsm_get_data()
84 if (obj->buffer.length != ATH12K_ACPI_DSM_CCA_DATA_SIZE) { in ath12k_acpi_dsm_get_data()
86 obj->buffer.length); in ath12k_acpi_dsm_get_data()
87 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
91 memcpy(&ab->acpi.cca_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
92 obj->buffer.length); in ath12k_acpi_dsm_get_data()
96 if (obj->buffer.length != ATH12K_ACPI_DSM_BAND_EDGE_DATA_SIZE) { in ath12k_acpi_dsm_get_data()
98 obj->buffer.length); in ath12k_acpi_dsm_get_data()
99 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
103 memcpy(&ab->acpi.band_edge_power, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
104 obj->buffer.length); in ath12k_acpi_dsm_get_data()
110 obj->type); in ath12k_acpi_dsm_get_data()
111 ret = -EINVAL; in ath12k_acpi_dsm_get_data()
124 const u8 *tas_sar_power_table = ab->acpi.tas_sar_power_table; in ath12k_acpi_set_power_limit()
130 return -EINVAL; in ath12k_acpi_set_power_limit()
148 if (ab->acpi.bios_sar_data[0] != ATH12K_ACPI_POWER_LIMIT_VERSION || in ath12k_acpi_set_bios_sar_power()
149 ab->acpi.bios_sar_data[1] != ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG) { in ath12k_acpi_set_bios_sar_power()
150 ath12k_warn(ab, "invalid latest ACPI BIOS SAR data\n"); in ath12k_acpi_set_bios_sar_power()
151 return -EINVAL; in ath12k_acpi_set_bios_sar_power()
154 ret = ath12k_wmi_set_bios_sar_cmd(ab, ab->acpi.bios_sar_data); in ath12k_acpi_set_bios_sar_power()
156 ath12k_warn(ab, "failed to set ACPI BIOS SAR table: %d\n", ret); in ath12k_acpi_set_bios_sar_power()
173 if (!ab->acpi.acpi_tas_enable) { in ath12k_acpi_dsm_notify()
190 if (!ab->acpi.acpi_bios_sar_enable) in ath12k_acpi_dsm_notify()
195 ath12k_warn(ab, "failed to update BIOS SAR: %d\n", ret); in ath12k_acpi_dsm_notify()
201 ath12k_warn(ab, "failed to set BIOS SAR power limit: %d\n", ret); in ath12k_acpi_dsm_notify()
210 ret = ath12k_wmi_set_bios_sar_cmd(ab, ab->acpi.bios_sar_data); in ath12k_acpi_set_bios_sar_params()
212 ath12k_warn(ab, "failed to set ACPI BIOS SAR table: %d\n", ret); in ath12k_acpi_set_bios_sar_params()
216 ret = ath12k_wmi_set_bios_geo_cmd(ab, ab->acpi.geo_offset_data); in ath12k_acpi_set_bios_sar_params()
230 ab->acpi.tas_cfg, in ath12k_acpi_set_tas_params()
239 ab->acpi.tas_sar_power_table, in ath12k_acpi_set_tas_params()
256 if (!ab->hw_params->acpi_guid) in ath12k_acpi_start()
260 ab->acpi.acpi_tas_enable = false; in ath12k_acpi_start()
268 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_CFG)) { in ath12k_acpi_start()
276 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_DATA)) { in ath12k_acpi_start()
283 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_CFG) && in ath12k_acpi_start()
284 ab->acpi.tas_sar_power_table[0] == ATH12K_ACPI_TAS_DATA_VERSION && in ath12k_acpi_start()
285 ab->acpi.tas_sar_power_table[1] == ATH12K_ACPI_TAS_DATA_ENABLE) in ath12k_acpi_start()
286 ab->acpi.acpi_tas_enable = true; in ath12k_acpi_start()
289 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_BIOS_SAR)) { in ath12k_acpi_start()
292 ath12k_warn(ab, "failed to get ACPI bios sar data: %d\n", ret); in ath12k_acpi_start()
297 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_GEO_OFFSET)) { in ath12k_acpi_start()
304 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_BIOS_SAR) && in ath12k_acpi_start()
305 ab->acpi.bios_sar_data[0] == ATH12K_ACPI_POWER_LIMIT_VERSION && in ath12k_acpi_start()
306 ab->acpi.bios_sar_data[1] == ATH12K_ACPI_POWER_LIMIT_ENABLE_FLAG && in ath12k_acpi_start()
307 !ab->acpi.acpi_tas_enable) in ath12k_acpi_start()
308 ab->acpi.acpi_bios_sar_enable = true; in ath12k_acpi_start()
311 if (ab->acpi.acpi_tas_enable) { in ath12k_acpi_start()
319 if (ab->acpi.acpi_bios_sar_enable) { in ath12k_acpi_start()
325 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_CCA)) { in ath12k_acpi_start()
328 ath12k_warn(ab, "failed to get ACPI DSM CCA threshold configuration: %d\n", in ath12k_acpi_start()
333 if (ab->acpi.cca_data[0] == ATH12K_ACPI_CCA_THR_VERSION && in ath12k_acpi_start()
334 ab->acpi.cca_data[ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET] == in ath12k_acpi_start()
336 buf = ab->acpi.cca_data + ATH12K_ACPI_CCA_THR_OFFSET_DATA_OFFSET; in ath12k_acpi_start()
342 ath12k_warn(ab, "failed to set ACPI DSM CCA threshold: %d\n", in ath12k_acpi_start()
349 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, in ath12k_acpi_start()
358 if (ab->acpi.band_edge_power[0] == ATH12K_ACPI_BAND_EDGE_VERSION && in ath12k_acpi_start()
359 ab->acpi.band_edge_power[1] == ATH12K_ACPI_BAND_EDGE_ENABLE_FLAG) { in ath12k_acpi_start()
362 ab->acpi.band_edge_power, in ath12k_acpi_start()
363 sizeof(ab->acpi.band_edge_power)); in ath12k_acpi_start()
373 status = acpi_install_notify_handler(ACPI_HANDLE(ab->dev), in ath12k_acpi_start()
378 return -EIO; in ath12k_acpi_start()
381 ab->acpi.started = true; in ath12k_acpi_start()
388 if (!ab->acpi.started) in ath12k_acpi_stop()
391 acpi_remove_notify_handler(ACPI_HANDLE(ab->dev), in ath12k_acpi_stop()
395 memset(&ab->acpi, 0, sizeof(ab->acpi)); in ath12k_acpi_stop()