xref: /aosp_15_r20/external/coreboot/src/include/sar.h (revision b9411a12aaaa7e1e6a6fb7c5e057f44ee179a49c)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #ifndef _SAR_H_
3 #define _SAR_H_
4 
5 #include <fw_config.h>
6 #include <stdint.h>
7 
8 #define MAX_ANT_GAINS_REVISION	2
9 #define MAX_DENYLIST_ENTRY	16
10 #define MAX_DSAR_SET_COUNT	3
11 #define MAX_GEO_OFFSET_REVISION	3
12 #define MAX_PROFILE_COUNT	7
13 #define MAX_SAR_REVISION	2
14 #define BSAR_REVISION		1
15 #define WBEM_REVISION		0
16 #define REVISION_SIZE		1
17 #define SAR_REV0_CHAINS_COUNT	2
18 #define SAR_REV0_SUBBANDS_COUNT	5
19 #define SAR_FILE_REVISION	1
20 #define SAR_STR_PREFIX		"$SAR"
21 #define SAR_STR_PREFIX_SIZE	4
22 
23 struct geo_profile {
24 	uint8_t revision;
25 	uint8_t chains_count;
26 	uint8_t bands_count;
27 	uint8_t wgds_table[];
28 } __packed;
29 
30 struct sar_profile {
31 	uint8_t revision;
32 	uint8_t dsar_set_count;
33 	uint8_t chains_count;
34 	uint8_t subbands_count;
35 	uint8_t sar_table[];
36 } __packed;
37 
38 struct gain_profile {
39 	uint8_t revision;
40 	uint8_t mode;
41 	uint8_t chains_count;
42 	uint8_t bands_count;
43 	uint8_t ppag_table[];
44 } __packed;
45 
46 struct avg_profile {
47 	uint8_t revision;
48 	uint8_t tas_selection;
49 	uint8_t tas_list_size;
50 	uint16_t deny_list_entry[MAX_DENYLIST_ENTRY];
51 } __packed;
52 
53 struct dsm_profile {
54 	uint32_t supported_functions;
55 	uint32_t disable_active_sdr_channels;
56 	uint32_t support_indonesia_5g_band;
57 	uint32_t support_ultra_high_band;
58 	uint32_t regulatory_configurations;
59 	uint32_t uart_configurations;
60 	uint32_t enablement_11ax;
61 	uint32_t unii_4;
62 	uint32_t enablement_11be;
63 	uint32_t energy_detection_threshold;
64 	uint32_t rfi_mitigation;
65 };
66 
67 struct bsar_profile {
68 	uint8_t revision;
69 	uint8_t increased_power_mode_limitation;
70 	uint8_t sar_lb_power_restriction;
71 	uint8_t br_modulation;
72 	uint8_t edr2_modulation;
73 	uint8_t edr3_modulation;
74 	uint8_t le_modulation;
75 	uint8_t le2_mhz_modulation;
76 	uint8_t le_lr_modulation;
77 } __packed;
78 
79 struct wbem_profile {
80 	uint8_t revision;
81 	uint32_t bandwidth_320mhz_country_enablement;
82 } __packed;
83 
84 struct sar_header {
85 	char marker[SAR_STR_PREFIX_SIZE];
86 	uint8_t version;
87 	uint16_t offsets[];
88 } __packed;
89 
90 /* Wifi SAR limit table structure */
91 union wifi_sar_limits {
92 	struct {
93 		struct sar_profile *sar;
94 		struct geo_profile *wgds;
95 		struct gain_profile *ppag;
96 		struct avg_profile *wtas;
97 		struct dsm_profile *dsm;
98 		struct bsar_profile *bsar;
99 		struct wbem_profile *wbem;
100 	};
101 	void *profile[MAX_PROFILE_COUNT];
102 };
103 
104 /*
105  * Retrieve the wifi ACPI configuration data from CBFS and decode it
106  * sar_limits:	Pointer to wifi_sar_limits where the resulted data is stored
107  *
108  * Returns: 0 on success, -1 on errors (The .hex file doesn't exist, or the decode failed)
109  */
110 int get_wifi_sar_limits(union wifi_sar_limits *sar_limits);
111 
112 #define WIFI_SAR_CBFS_DEFAULT_FILENAME	"wifi_sar_defaults.hex"
113 
114 const char *get_wifi_sar_cbfs_filename(void);
115 
116 char *get_wifi_sar_fw_config_filename(const struct fw_config_field *field);
117 
118 #endif /* _SAR_H_ */
119