Angel Pons | 32859fc | 2020-04-02 23:48:27 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 2 | #ifndef _SAR_H_ |
| 3 | #define _SAR_H_ |
| 4 | |
Eric Lai | 8cb2f18 | 2022-12-19 09:14:39 +0800 | [diff] [blame] | 5 | #include <fw_config.h> |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 6 | #include <stdint.h> |
| 7 | |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 8 | #define MAX_ANT_GAINS_REVISION 2 |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame] | 9 | #define MAX_DENYLIST_ENTRY 16 |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 10 | #define MAX_DSAR_SET_COUNT 3 |
| 11 | #define MAX_GEO_OFFSET_REVISION 3 |
Sugnan Prabhu S | d70f481 | 2021-08-25 17:36:44 +0530 | [diff] [blame] | 12 | #define MAX_PROFILE_COUNT 5 |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 13 | #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 Prajapati | 7fd1e4b | 2017-08-11 14:06:57 -0700 | [diff] [blame] | 20 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 21 | struct geo_profile { |
| 22 | uint8_t revision; |
| 23 | uint8_t chains_count; |
| 24 | uint8_t bands_count; |
| 25 | uint8_t wgds_table[0]; |
| 26 | } __packed; |
| 27 | |
| 28 | struct sar_profile { |
| 29 | uint8_t revision; |
| 30 | uint8_t dsar_set_count; |
| 31 | uint8_t chains_count; |
| 32 | uint8_t subbands_count; |
| 33 | uint8_t sar_table[0]; |
| 34 | } __packed; |
| 35 | |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 36 | struct gain_profile { |
| 37 | uint8_t revision; |
| 38 | uint8_t mode; |
| 39 | uint8_t chains_count; |
| 40 | uint8_t bands_count; |
| 41 | uint8_t ppag_table[0]; |
| 42 | } __packed; |
| 43 | |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame] | 44 | struct avg_profile { |
| 45 | uint8_t revision; |
| 46 | uint8_t tas_selection; |
| 47 | uint8_t tas_list_size; |
Sugnan Prabhu S | 627c844 | 2021-09-06 15:05:56 +0530 | [diff] [blame] | 48 | uint16_t deny_list_entry[MAX_DENYLIST_ENTRY]; |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame] | 49 | } __packed; |
| 50 | |
Sugnan Prabhu S | d70f481 | 2021-08-25 17:36:44 +0530 | [diff] [blame] | 51 | struct 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; |
| 60 | }; |
| 61 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 62 | struct sar_header { |
| 63 | char marker[SAR_STR_PREFIX_SIZE]; |
Pratik Prajapati | 7fd1e4b | 2017-08-11 14:06:57 -0700 | [diff] [blame] | 64 | uint8_t version; |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 65 | uint16_t offsets[0]; |
Pratik Prajapati | 7fd1e4b | 2017-08-11 14:06:57 -0700 | [diff] [blame] | 66 | } __packed; |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 67 | |
| 68 | /* Wifi SAR limit table structure */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 69 | union wifi_sar_limits { |
| 70 | struct { |
| 71 | struct sar_profile *sar; |
| 72 | struct geo_profile *wgds; |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 73 | struct gain_profile *ppag; |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame] | 74 | struct avg_profile *wtas; |
Sugnan Prabhu S | d70f481 | 2021-08-25 17:36:44 +0530 | [diff] [blame] | 75 | struct dsm_profile *dsm; |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 76 | }; |
| 77 | void *profile[MAX_PROFILE_COUNT]; |
| 78 | }; |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 79 | |
| 80 | /* |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 81 | * Retrieve the wifi ACPI configuration data from CBFS and decode it |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 82 | * sar_limits: Pointer to wifi_sar_limits where the resulted data is stored |
| 83 | * |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 84 | * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed) |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 85 | */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 86 | int get_wifi_sar_limits(union wifi_sar_limits *sar_limits); |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 87 | |
Furquan Shaikh | 7fe5d3d | 2021-03-13 22:54:16 -0800 | [diff] [blame] | 88 | #define WIFI_SAR_CBFS_DEFAULT_FILENAME "wifi_sar_defaults.hex" |
| 89 | |
Justin TerAvest | c650d6c | 2018-12-14 11:05:03 -0700 | [diff] [blame] | 90 | const char *get_wifi_sar_cbfs_filename(void); |
| 91 | |
Eric Lai | 8cb2f18 | 2022-12-19 09:14:39 +0800 | [diff] [blame] | 92 | char *get_wifi_sar_fw_config_filename(const struct fw_config_field *field); |
| 93 | |
Robbie Zhang | ed84002 | 2016-12-23 11:43:07 -0800 | [diff] [blame] | 94 | #endif /* _SAR_H_ */ |