blob: 625fd51648e39ffc39ddd7e59a6be3f6e5b9e33c [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 Sfcb4f2d2021-07-30 20:12:22 +05307#define MAX_DSAR_SET_COUNT 3
8#define MAX_GEO_OFFSET_REVISION 3
9#define MAX_PROFILE_COUNT 2
10#define MAX_SAR_REVISION 2
11#define REVISION_SIZE 1
12#define SAR_REV0_CHAINS_COUNT 2
13#define SAR_REV0_SUBBANDS_COUNT 5
14#define SAR_FILE_REVISION 1
15#define SAR_STR_PREFIX "$SAR"
16#define SAR_STR_PREFIX_SIZE 4
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070017
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053018struct geo_profile {
19 uint8_t revision;
20 uint8_t chains_count;
21 uint8_t bands_count;
22 uint8_t wgds_table[0];
23} __packed;
24
25struct sar_profile {
26 uint8_t revision;
27 uint8_t dsar_set_count;
28 uint8_t chains_count;
29 uint8_t subbands_count;
30 uint8_t sar_table[0];
31} __packed;
32
33struct sar_header {
34 char marker[SAR_STR_PREFIX_SIZE];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070035 uint8_t version;
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053036 uint16_t offsets[0];
Pratik Prajapati7fd1e4b2017-08-11 14:06:57 -070037} __packed;
Robbie Zhanged840022016-12-23 11:43:07 -080038
39/* Wifi SAR limit table structure */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053040union wifi_sar_limits {
41 struct {
42 struct sar_profile *sar;
43 struct geo_profile *wgds;
44 };
45 void *profile[MAX_PROFILE_COUNT];
46};
Robbie Zhanged840022016-12-23 11:43:07 -080047
48/*
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053049 * Retrieve the wifi ACPI configuration data from CBFS and decode it
Robbie Zhanged840022016-12-23 11:43:07 -080050 * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored
51 *
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053052 * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
Robbie Zhanged840022016-12-23 11:43:07 -080053 */
Sugnan Prabhu Sfcb4f2d2021-07-30 20:12:22 +053054int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
Robbie Zhanged840022016-12-23 11:43:07 -080055
Furquan Shaikh7fe5d3d2021-03-13 22:54:16 -080056#define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex"
57
Justin TerAvestc650d6c2018-12-14 11:05:03 -070058const char *get_wifi_sar_cbfs_filename(void);
59
Robbie Zhanged840022016-12-23 11:43:07 -080060#endif /* _SAR_H_ */