blob: c201cea2f4a691a7a5b4330a2c6434bd03176931 [file] [log] [blame]
Angel Pons32859fc2020-04-02 23:48:27 +02001/* SPDX-License-Identifier: GPL-2.0-only */
Robbie Zhanged840022016-12-23 11:43:07 -08002#ifndef _SAR_H_
3#define _SAR_H_
4
Eric Lai8cb2f182022-12-19 09:14:39 +08005#include <fw_config.h>
Robbie Zhanged840022016-12-23 11:43:07 -08006#include <stdint.h>
7
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +05308#define MAX_ANT_GAINS_REVISION 2
Sugnan Prabhu Scc507702021-08-31 07:19:30 +05309#define MAX_DENYLIST_ENTRY 16
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053010#define MAX_DSAR_SET_COUNT 3
11#define MAX_GEO_OFFSET_REVISION 3
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053012#define MAX_PROFILE_COUNT 5
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053013#define MAX_SAR_REVISION 2
14#define REVISION_SIZE 1
15#define SAR_REV0_CHAINS_COUNT 2
16#define SAR_REV0_SUBBANDS_COUNT 5
17#define SAR_FILE_REVISION 1
18#define SAR_STR_PREFIX "$SAR"
19#define SAR_STR_PREFIX_SIZE 4
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070020
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053021struct geo_profile {
22 uint8_t revision;
23 uint8_t chains_count;
24 uint8_t bands_count;
Elyes Haouas8843b6f2023-07-27 19:07:58 +020025 uint8_t wgds_table[];
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053026} __packed;
27
28struct sar_profile {
29 uint8_t revision;
30 uint8_t dsar_set_count;
31 uint8_t chains_count;
32 uint8_t subbands_count;
Elyes Haouas8843b6f2023-07-27 19:07:58 +020033 uint8_t sar_table[];
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053034} __packed;
35
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053036struct gain_profile {
37 uint8_t revision;
38 uint8_t mode;
39 uint8_t chains_count;
40 uint8_t bands_count;
Elyes Haouas8843b6f2023-07-27 19:07:58 +020041 uint8_t ppag_table[];
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053042} __packed;
43
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053044struct avg_profile {
45 uint8_t revision;
46 uint8_t tas_selection;
47 uint8_t tas_list_size;
Sugnan Prabhu S627c8442021-09-06 15:05:56 +053048 uint16_t deny_list_entry[MAX_DENYLIST_ENTRY];
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053049} __packed;
50
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053051struct dsm_profile {
52 uint32_t supported_functions;
53 uint32_t disable_active_sdr_channels;
54 uint32_t support_indonesia_5g_band;
55 uint32_t support_ultra_high_band;
56 uint32_t regulatory_configurations;
57 uint32_t uart_configurations;
58 uint32_t enablement_11ax;
59 uint32_t unii_4;
Ravi Sarawadi511222c2024-05-06 09:58:52 -070060 uint32_t enablement_11be;
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053061};
62
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053063struct sar_header {
64 char marker[SAR_STR_PREFIX_SIZE];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070065 uint8_t version;
Elyes Haouas8843b6f2023-07-27 19:07:58 +020066 uint16_t offsets[];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070067} __packed;
Robbie Zhanged840022016-12-23 11:43:07 -080068
69/* Wifi SAR limit table structure */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053070union wifi_sar_limits {
71 struct {
72 struct sar_profile *sar;
73 struct geo_profile *wgds;
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053074 struct gain_profile *ppag;
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053075 struct avg_profile *wtas;
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053076 struct dsm_profile *dsm;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053077 };
78 void *profile[MAX_PROFILE_COUNT];
79};
Robbie Zhanged840022016-12-23 11:43:07 -080080
81/*
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053082 * Retrieve the wifi ACPI configuration data from CBFS and decode it
Robbie Zhanged840022016-12-23 11:43:07 -080083 * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored
84 *
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053085 * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
Robbie Zhanged840022016-12-23 11:43:07 -080086 */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053087int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
Robbie Zhanged840022016-12-23 11:43:07 -080088
Furquan Shaikh7fe5d3d2021-03-13 22:54:16 -080089#define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"
90
Justin TerAvestc650d6c2018-12-14 11:05:03 -070091const char *get_wifi_sar_cbfs_filename(void);
92
Eric Lai8cb2f182022-12-19 09:14:39 +080093char *get_wifi_sar_fw_config_filename(const struct fw_config_field *field);
94
Robbie Zhanged840022016-12-23 11:43:07 -080095#endif /* _SAR_H_ */