blob: beccb377cd73b56474f280e35e46b2e33699e5ba [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
5#include <stdint.h>
6
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +05307#define MAX_ANT_GAINS_REVISION 2
Sugnan Prabhu Scc507702021-08-31 07:19:30 +05308#define MAX_DENYLIST_ENTRY 16
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +05309#define MAX_DSAR_SET_COUNT 3
10#define MAX_GEO_OFFSET_REVISION 3
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053011#define MAX_PROFILE_COUNT 5
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053012#define MAX_SAR_REVISION 2
13#define REVISION_SIZE 1
14#define SAR_REV0_CHAINS_COUNT 2
15#define SAR_REV0_SUBBANDS_COUNT 5
16#define SAR_FILE_REVISION 1
17#define SAR_STR_PREFIX "$SAR"
18#define SAR_STR_PREFIX_SIZE 4
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070019
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053020struct geo_profile {
21 uint8_t revision;
22 uint8_t chains_count;
23 uint8_t bands_count;
24 uint8_t wgds_table[0];
25} __packed;
26
27struct sar_profile {
28 uint8_t revision;
29 uint8_t dsar_set_count;
30 uint8_t chains_count;
31 uint8_t subbands_count;
32 uint8_t sar_table[0];
33} __packed;
34
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053035struct gain_profile {
36 uint8_t revision;
37 uint8_t mode;
38 uint8_t chains_count;
39 uint8_t bands_count;
40 uint8_t ppag_table[0];
41} __packed;
42
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053043struct avg_profile {
44 uint8_t revision;
45 uint8_t tas_selection;
46 uint8_t tas_list_size;
Sugnan Prabhu S627c8442021-09-06 15:05:56 +053047 uint16_t deny_list_entry[MAX_DENYLIST_ENTRY];
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053048} __packed;
49
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053050struct dsm_profile {
51 uint32_t supported_functions;
52 uint32_t disable_active_sdr_channels;
53 uint32_t support_indonesia_5g_band;
54 uint32_t support_ultra_high_band;
55 uint32_t regulatory_configurations;
56 uint32_t uart_configurations;
57 uint32_t enablement_11ax;
58 uint32_t unii_4;
59};
60
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053061struct sar_header {
62 char marker[SAR_STR_PREFIX_SIZE];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070063 uint8_t version;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053064 uint16_t offsets[0];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070065} __packed;
Robbie Zhanged840022016-12-23 11:43:07 -080066
67/* Wifi SAR limit table structure */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053068union wifi_sar_limits {
69 struct {
70 struct sar_profile *sar;
71 struct geo_profile *wgds;
Sugnan Prabhu Sd1fc8322021-08-31 07:11:35 +053072 struct gain_profile *ppag;
Sugnan Prabhu Scc507702021-08-31 07:19:30 +053073 struct avg_profile *wtas;
Sugnan Prabhu Sd70f4812021-08-25 17:36:44 +053074 struct dsm_profile *dsm;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053075 };
76 void *profile[MAX_PROFILE_COUNT];
77};
Robbie Zhanged840022016-12-23 11:43:07 -080078
79/*
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053080 * Retrieve the wifi ACPI configuration data from CBFS and decode it
Robbie Zhanged840022016-12-23 11:43:07 -080081 * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored
82 *
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053083 * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
Robbie Zhanged840022016-12-23 11:43:07 -080084 */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053085int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
Robbie Zhanged840022016-12-23 11:43:07 -080086
Furquan Shaikh7fe5d3d2021-03-13 22:54:16 -080087#define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"
88
Justin TerAvestc650d6c2018-12-14 11:05:03 -070089const char *get_wifi_sar_cbfs_filename(void);
90
Robbie Zhanged840022016-12-23 11:43:07 -080091#endif /* _SAR_H_ */