Lines Matching full:ab
11 static int ath12k_acpi_dsm_get_data(struct ath12k_base *ab, int func) in ath12k_acpi_dsm_get_data() argument
17 root_handle = ACPI_HANDLE(ab->dev); in ath12k_acpi_dsm_get_data()
19 ath12k_dbg(ab, ATH12K_DBG_BOOT, "invalid acpi handler\n"); 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()
27 ath12k_dbg(ab, ATH12K_DBG_BOOT, "acpi_evaluate_dsm() failed\n"); in ath12k_acpi_dsm_get_data()
32 ab->acpi.func_bit = obj->integer.value; in ath12k_acpi_dsm_get_data()
37 ath12k_warn(ab, "invalid ACPI DSM TAS config size: %d\n", in ath12k_acpi_dsm_get_data()
43 memcpy(&ab->acpi.tas_cfg, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
49 ath12k_warn(ab, "invalid ACPI DSM TAS data size: %d\n", in ath12k_acpi_dsm_get_data()
55 memcpy(&ab->acpi.tas_sar_power_table, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
61 ath12k_warn(ab, "invalid ACPI BIOS SAR data size: %d\n", in ath12k_acpi_dsm_get_data()
67 memcpy(&ab->acpi.bios_sar_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
73 ath12k_warn(ab, "invalid ACPI GEO OFFSET data size: %d\n", in ath12k_acpi_dsm_get_data()
79 memcpy(&ab->acpi.geo_offset_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
85 ath12k_warn(ab, "invalid ACPI DSM CCA data size: %d\n", in ath12k_acpi_dsm_get_data()
91 memcpy(&ab->acpi.cca_data, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
97 ath12k_warn(ab, "invalid ACPI DSM band edge data size: %d\n", in ath12k_acpi_dsm_get_data()
103 memcpy(&ab->acpi.band_edge_power, obj->buffer.pointer, in ath12k_acpi_dsm_get_data()
109 ath12k_warn(ab, "ACPI DSM method returned an unsupported object type: %d\n", in ath12k_acpi_dsm_get_data()
122 static int ath12k_acpi_set_power_limit(struct ath12k_base *ab) in ath12k_acpi_set_power_limit() argument
124 const u8 *tas_sar_power_table = ab->acpi.tas_sar_power_table; in ath12k_acpi_set_power_limit()
129 ath12k_warn(ab, "latest ACPI TAS data is invalid\n"); in ath12k_acpi_set_power_limit()
133 ret = ath12k_wmi_set_bios_cmd(ab, WMI_BIOS_PARAM_TAS_DATA_TYPE, in ath12k_acpi_set_power_limit()
137 ath12k_warn(ab, "failed to send ACPI TAS data table: %d\n", ret); in ath12k_acpi_set_power_limit()
144 static int ath12k_acpi_set_bios_sar_power(struct ath12k_base *ab) in ath12k_acpi_set_bios_sar_power() argument
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()
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()
166 struct ath12k_base *ab = data; in ath12k_acpi_dsm_notify() local
169 ath12k_warn(ab, "unknown acpi notify %u\n", event); in ath12k_acpi_dsm_notify()
173 if (!ab->acpi.acpi_tas_enable) { in ath12k_acpi_dsm_notify()
174 ath12k_dbg(ab, ATH12K_DBG_BOOT, "acpi_tas_enable is false\n"); in ath12k_acpi_dsm_notify()
178 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_TAS_DATA); in ath12k_acpi_dsm_notify()
180 ath12k_warn(ab, "failed to update ACPI TAS data table: %d\n", ret); in ath12k_acpi_dsm_notify()
184 ret = ath12k_acpi_set_power_limit(ab); in ath12k_acpi_dsm_notify()
186 ath12k_warn(ab, "failed to set ACPI TAS power limit data: %d", ret); in ath12k_acpi_dsm_notify()
190 if (!ab->acpi.acpi_bios_sar_enable) in ath12k_acpi_dsm_notify()
193 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_BIOS_SAR); in ath12k_acpi_dsm_notify()
195 ath12k_warn(ab, "failed to update BIOS SAR: %d\n", ret); in ath12k_acpi_dsm_notify()
199 ret = ath12k_acpi_set_bios_sar_power(ab); in ath12k_acpi_dsm_notify()
201 ath12k_warn(ab, "failed to set BIOS SAR power limit: %d\n", ret); in ath12k_acpi_dsm_notify()
206 static int ath12k_acpi_set_bios_sar_params(struct ath12k_base *ab) in ath12k_acpi_set_bios_sar_params() argument
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()
218 ath12k_warn(ab, "failed to set ACPI BIOS GEO table: %d\n", ret); in ath12k_acpi_set_bios_sar_params()
225 static int ath12k_acpi_set_tas_params(struct ath12k_base *ab) in ath12k_acpi_set_tas_params() argument
229 ret = ath12k_wmi_set_bios_cmd(ab, WMI_BIOS_PARAM_TAS_CONFIG_TYPE, in ath12k_acpi_set_tas_params()
230 ab->acpi.tas_cfg, in ath12k_acpi_set_tas_params()
233 ath12k_warn(ab, "failed to send ACPI TAS config table parameter: %d\n", in ath12k_acpi_set_tas_params()
238 ret = ath12k_wmi_set_bios_cmd(ab, WMI_BIOS_PARAM_TAS_DATA_TYPE, in ath12k_acpi_set_tas_params()
239 ab->acpi.tas_sar_power_table, in ath12k_acpi_set_tas_params()
242 ath12k_warn(ab, "failed to send ACPI TAS data table parameter: %d\n", in ath12k_acpi_set_tas_params()
250 int ath12k_acpi_start(struct ath12k_base *ab) in ath12k_acpi_start() argument
256 if (!ab->hw_params->acpi_guid) in ath12k_acpi_start()
260 ab->acpi.acpi_tas_enable = false; in ath12k_acpi_start()
262 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_SUPPORT_FUNCS); in ath12k_acpi_start()
264 ath12k_dbg(ab, ATH12K_DBG_BOOT, "failed to get ACPI DSM data: %d\n", ret); in ath12k_acpi_start()
268 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_CFG)) { in ath12k_acpi_start()
269 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_TAS_CFG); in ath12k_acpi_start()
271 ath12k_warn(ab, "failed to get ACPI TAS config table: %d\n", ret); in ath12k_acpi_start()
276 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_TAS_DATA)) { in ath12k_acpi_start()
277 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_TAS_DATA); in ath12k_acpi_start()
279 ath12k_warn(ab, "failed to get ACPI TAS data table: %d\n", ret); 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()
290 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_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()
298 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_GEO_OFFSET); in ath12k_acpi_start()
300 ath12k_warn(ab, "failed to get ACPI geo offset data: %d\n", ret); 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()
312 ret = ath12k_acpi_set_tas_params(ab); in ath12k_acpi_start()
314 ath12k_warn(ab, "failed to send ACPI parameters: %d\n", ret); in ath12k_acpi_start()
319 if (ab->acpi.acpi_bios_sar_enable) { in ath12k_acpi_start()
320 ret = ath12k_acpi_set_bios_sar_params(ab); in ath12k_acpi_start()
325 if (ATH12K_ACPI_FUNC_BIT_VALID(ab->acpi, ATH12K_ACPI_FUNC_BIT_CCA)) { in ath12k_acpi_start()
326 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_INDEX_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()
337 ret = ath12k_wmi_set_bios_cmd(ab, 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()
351 ret = ath12k_acpi_dsm_get_data(ab, ATH12K_ACPI_DSM_FUNC_INDEX_BAND_EDGE); in ath12k_acpi_start()
353 ath12k_warn(ab, "failed to get ACPI DSM band edge channel power: %d\n", 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()
360 ret = ath12k_wmi_set_bios_cmd(ab, 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()
365 ath12k_warn(ab, in ath12k_acpi_start()
373 status = acpi_install_notify_handler(ACPI_HANDLE(ab->dev), in ath12k_acpi_start()
375 ath12k_acpi_dsm_notify, ab); in ath12k_acpi_start()
377 ath12k_warn(ab, "failed to install DSM notify callback: %d\n", status); in ath12k_acpi_start()
381 ab->acpi.started = true; in ath12k_acpi_start()
386 void ath12k_acpi_stop(struct ath12k_base *ab) in ath12k_acpi_stop() argument
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()