Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <acpi/acpi_device.h> |
| 4 | #include <acpi/acpigen.h> |
Tim Wawrzynczak | d40a4c2 | 2021-02-25 13:14:49 -0700 | [diff] [blame] | 5 | #include <acpi/acpigen_pci.h> |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 6 | #include <console/console.h> |
| 7 | #include <device/pci_ids.h> |
| 8 | #include <sar.h> |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 9 | #include <stdlib.h> |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 10 | #include <wrdd.h> |
| 11 | |
| 12 | #include "chip.h" |
| 13 | #include "wifi_private.h" |
| 14 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 15 | /* WIFI Domain type */ |
| 16 | #define DOMAIN_TYPE_WIFI 0x7 |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 17 | |
| 18 | /* |
| 19 | * WIFI ACPI NAME = "WF" + hex value of last 8 bits of dev_path_encode + '\0' |
| 20 | * The above representation returns unique and consistent name every time |
| 21 | * generate_wifi_acpi_name is invoked. The last 8 bits of dev_path_encode is |
| 22 | * chosen since it contains the bus address of the device. |
| 23 | */ |
| 24 | #define WIFI_ACPI_NAME_MAX_LEN 5 |
| 25 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 26 | __weak int get_wifi_sar_limits(union wifi_sar_limits *sar_limits) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 27 | { |
| 28 | return -1; |
| 29 | } |
| 30 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 31 | static const uint8_t *sar_fetch_set(const struct sar_profile *sar, size_t set_num) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 32 | { |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 33 | const uint8_t *sar_table = &sar->sar_table[0]; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 34 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 35 | return sar_table + (sar->chains_count * sar->subbands_count * set_num); |
| 36 | } |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 37 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 38 | static const uint8_t *wgds_fetch_set(struct geo_profile *wgds, size_t set_num) |
| 39 | { |
| 40 | const uint8_t *wgds_table = &wgds->wgds_table[0]; |
| 41 | |
| 42 | return wgds_table + (wgds->bands_count * set_num); |
| 43 | } |
| 44 | |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 45 | static const uint8_t *ppag_fetch_set(struct gain_profile *ppag, size_t set_num) |
| 46 | { |
| 47 | const uint8_t *ppag_table = &ppag->ppag_table[0]; |
| 48 | |
| 49 | return ppag_table + (ppag->bands_count * set_num); |
| 50 | } |
| 51 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 52 | static void sar_emit_wrds(const struct sar_profile *sar) |
| 53 | { |
| 54 | int i; |
| 55 | size_t package_size, table_size; |
| 56 | const uint8_t *set; |
| 57 | |
| 58 | if (sar == NULL) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 59 | return; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * Name ("WRDS", Package () { |
| 63 | * Revision, |
| 64 | * Package () { |
| 65 | * Domain Type, // 0x7:WiFi |
| 66 | * WiFi SAR BIOS, // BIOS SAR Enable/disable |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 67 | * SAR Table Set // Set#1 of SAR Table |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 68 | * } |
| 69 | * }) |
| 70 | */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 71 | if (sar->revision > MAX_SAR_REVISION) { |
| 72 | printk(BIOS_ERR, "ERROR: Invalid SAR table revision: %d\n", sar->revision); |
| 73 | return; |
| 74 | } |
| 75 | |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 76 | acpigen_write_name("WRDS"); |
| 77 | acpigen_write_package(2); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 78 | acpigen_write_dword(sar->revision); |
| 79 | |
| 80 | table_size = sar->chains_count * sar->subbands_count; |
| 81 | /* Emit 'Domain Type' + 'WiFi SAR Enable' + Set#1 */ |
| 82 | package_size = 1 + 1 + table_size; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 83 | acpigen_write_package(package_size); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 84 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
| 85 | acpigen_write_dword(1); |
| 86 | |
| 87 | set = sar_fetch_set(sar, 0); |
| 88 | for (i = 0; i < table_size; i++) |
| 89 | acpigen_write_byte(set[i]); |
| 90 | |
| 91 | acpigen_write_package_end(); |
| 92 | acpigen_write_package_end(); |
| 93 | } |
| 94 | |
| 95 | static void sar_emit_ewrd(const struct sar_profile *sar) |
| 96 | { |
| 97 | int i; |
| 98 | size_t package_size, set_num, table_size; |
| 99 | const uint8_t *set; |
| 100 | |
| 101 | if (sar == NULL) |
| 102 | return; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 103 | |
| 104 | /* |
| 105 | * Name ("EWRD", Package () { |
| 106 | * Revision, |
| 107 | * Package () { |
| 108 | * Domain Type, // 0x7:WiFi |
| 109 | * Dynamic SAR Enable, // Dynamic SAR Enable/disable |
| 110 | * Extended SAR sets, // Number of optional SAR table sets |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 111 | * SAR Table Set, // Set#2 of SAR Table |
| 112 | * SAR Table Set, // Set#3 of SAR Table |
| 113 | * SAR Table Set // Set#4 of SAR Table |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 114 | * } |
| 115 | * }) |
| 116 | */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 117 | if (sar->revision > MAX_SAR_REVISION) { |
| 118 | printk(BIOS_ERR, "ERROR: Invalid SAR table revision: %d\n", sar->revision); |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | if (sar->dsar_set_count == 0) { |
| 123 | printk(BIOS_WARNING, "WARNING: DSAR set count is 0\n"); |
| 124 | return; |
| 125 | } |
| 126 | |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 127 | acpigen_write_name("EWRD"); |
| 128 | acpigen_write_package(2); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 129 | acpigen_write_dword(sar->revision); |
| 130 | |
| 131 | table_size = sar->chains_count * sar->subbands_count; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 132 | /* |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 133 | * Emit 'Domain Type' + 'Dynamic SAR Enable' + 'Extended SAR sets count' |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 134 | * + number of bytes for Set#2 & 3 & 4 |
| 135 | */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 136 | package_size = 1 + 1 + 1 + table_size * sar->dsar_set_count; |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 137 | acpigen_write_package(package_size); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 138 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
| 139 | acpigen_write_dword(1); |
| 140 | acpigen_write_dword(sar->dsar_set_count); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 141 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 142 | for (set_num = 1; set_num <= sar->dsar_set_count; set_num++) { |
| 143 | set = sar_fetch_set(sar, set_num); |
| 144 | for (i = 0; i < table_size; i++) |
| 145 | acpigen_write_byte(set[i]); |
| 146 | } |
| 147 | |
| 148 | /* wifi driver always expects 3 DSAR sets */ |
| 149 | for (i = 0; i < (table_size * (MAX_DSAR_SET_COUNT - sar->dsar_set_count)); i++) |
| 150 | acpigen_write_byte(0); |
| 151 | |
| 152 | acpigen_write_package_end(); |
| 153 | acpigen_write_package_end(); |
| 154 | } |
| 155 | |
| 156 | static void sar_emit_wgds(struct geo_profile *wgds) |
| 157 | { |
| 158 | int i; |
| 159 | size_t package_size, set_num; |
| 160 | const uint8_t *set; |
| 161 | |
| 162 | if (wgds == NULL) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 163 | return; |
| 164 | |
| 165 | /* |
| 166 | * Name ("WGDS", Package() { |
| 167 | * Revision, |
| 168 | * Package() { |
| 169 | * DomainType, // 0x7:WiFi |
| 170 | * WgdsWiFiSarDeltaGroup1PowerMax1, // Group 1 FCC 2400 Max |
| 171 | * WgdsWiFiSarDeltaGroup1PowerChainA1, // Group 1 FCC 2400 A Offset |
| 172 | * WgdsWiFiSarDeltaGroup1PowerChainB1, // Group 1 FCC 2400 B Offset |
| 173 | * WgdsWiFiSarDeltaGroup1PowerMax2, // Group 1 FCC 5200 Max |
| 174 | * WgdsWiFiSarDeltaGroup1PowerChainA2, // Group 1 FCC 5200 A Offset |
| 175 | * WgdsWiFiSarDeltaGroup1PowerChainB2, // Group 1 FCC 5200 B Offset |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 176 | * WgdsWiFiSarDeltaGroup1PowerMax3, // Group 1 FCC 6000-7000 Max |
| 177 | * WgdsWiFiSarDeltaGroup1PowerChainA3, // Group 1 FCC 6000-7000 A Offset |
| 178 | * WgdsWiFiSarDeltaGroup1PowerChainB3, // Group 1 FCC 6000-7000 B Offset |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 179 | * WgdsWiFiSarDeltaGroup2PowerMax1, // Group 2 EC Jap 2400 Max |
| 180 | * WgdsWiFiSarDeltaGroup2PowerChainA1, // Group 2 EC Jap 2400 A Offset |
| 181 | * WgdsWiFiSarDeltaGroup2PowerChainB1, // Group 2 EC Jap 2400 B Offset |
| 182 | * WgdsWiFiSarDeltaGroup2PowerMax2, // Group 2 EC Jap 5200 Max |
| 183 | * WgdsWiFiSarDeltaGroup2PowerChainA2, // Group 2 EC Jap 5200 A Offset |
| 184 | * WgdsWiFiSarDeltaGroup2PowerChainB2, // Group 2 EC Jap 5200 B Offset |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 185 | * WgdsWiFiSarDeltaGroup2PowerMax3, // Group 2 EC Jap 6000-7000 Max |
| 186 | * WgdsWiFiSarDeltaGroup2PowerChainA3, // Group 2 EC Jap 6000-7000 A Offset |
| 187 | * WgdsWiFiSarDeltaGroup2PowerChainB3, // Group 2 EC Jap 6000-7000 B Offset |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 188 | * WgdsWiFiSarDeltaGroup3PowerMax1, // Group 3 ROW 2400 Max |
| 189 | * WgdsWiFiSarDeltaGroup3PowerChainA1, // Group 3 ROW 2400 A Offset |
| 190 | * WgdsWiFiSarDeltaGroup3PowerChainB1, // Group 3 ROW 2400 B Offset |
| 191 | * WgdsWiFiSarDeltaGroup3PowerMax2, // Group 3 ROW 5200 Max |
| 192 | * WgdsWiFiSarDeltaGroup3PowerChainA2, // Group 3 ROW 5200 A Offset |
| 193 | * WgdsWiFiSarDeltaGroup3PowerChainB2, // Group 3 ROW 5200 B Offset |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 194 | * WgdsWiFiSarDeltaGroup3PowerMax3, // Group 3 ROW 6000-7000 Max |
| 195 | * WgdsWiFiSarDeltaGroup3PowerChainA3, // Group 3 ROW 6000-7000 A Offset |
| 196 | * WgdsWiFiSarDeltaGroup3PowerChainB3, // Group 3 ROW 6000-7000 B Offset |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 197 | * } |
| 198 | * }) |
| 199 | */ |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 200 | if (wgds->revision > MAX_GEO_OFFSET_REVISION) { |
| 201 | printk(BIOS_ERR, "ERROR: Invalid WGDS revision: %d\n", wgds->revision); |
| 202 | return; |
| 203 | } |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 204 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 205 | package_size = 1 + wgds->chains_count * wgds->bands_count; |
| 206 | |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 207 | acpigen_write_name("WGDS"); |
| 208 | acpigen_write_package(2); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 209 | acpigen_write_dword(wgds->revision); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 210 | /* Emit 'Domain Type' + |
| 211 | * Group specific delta of power (6 bytes * NUM_WGDS_SAR_GROUPS) |
| 212 | */ |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 213 | acpigen_write_package(package_size); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 214 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
| 215 | |
| 216 | for (set_num = 0; set_num < wgds->chains_count; set_num++) { |
| 217 | set = wgds_fetch_set(wgds, set_num); |
| 218 | for (i = 0; i < wgds->bands_count; i++) |
| 219 | acpigen_write_byte(set[i]); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 220 | } |
| 221 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 222 | acpigen_write_package_end(); |
| 223 | acpigen_write_package_end(); |
| 224 | } |
| 225 | |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 226 | static void sar_emit_ppag(struct gain_profile *ppag) |
| 227 | { |
| 228 | int i; |
| 229 | size_t package_size, set_num; |
| 230 | const uint8_t *set; |
| 231 | |
| 232 | if (ppag == NULL) |
| 233 | return; |
| 234 | |
| 235 | /* |
| 236 | * Name ("PPAG", Package () { |
| 237 | * Revision, |
| 238 | * Package () { |
| 239 | * Domain Type, // 0x7:WiFi |
| 240 | * PPAG Mode, // Defines the mode of ANT_gain control to be used |
| 241 | * ANT_gain Table Chain A // Defines the ANT_gain in dBi for chain A |
| 242 | * ANT_gain Table Chain B // Defines the ANT_gain in dBi for chain B |
| 243 | * } |
| 244 | * }) |
| 245 | */ |
| 246 | if (ppag->revision > MAX_ANT_GAINS_REVISION) { |
| 247 | printk(BIOS_ERR, "Invalid PPAG revision: %d\n", ppag->revision); |
| 248 | return; |
| 249 | } |
| 250 | |
| 251 | package_size = 1 + 1 + ppag->chains_count * ppag->bands_count; |
| 252 | |
| 253 | acpigen_write_name("PPAG"); |
| 254 | acpigen_write_package(2); |
| 255 | acpigen_write_dword(ppag->revision); |
| 256 | acpigen_write_package(package_size); |
| 257 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
| 258 | acpigen_write_dword(ppag->mode); |
| 259 | |
| 260 | for (set_num = 0; set_num < ppag->chains_count; set_num++) { |
| 261 | set = ppag_fetch_set(ppag, set_num); |
| 262 | for (i = 0; i < ppag->bands_count; i++) |
| 263 | acpigen_write_byte(set[i]); |
| 264 | } |
| 265 | |
| 266 | acpigen_write_package_end(); |
| 267 | acpigen_write_package_end(); |
| 268 | } |
| 269 | |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame^] | 270 | static void sar_emit_wtas(struct avg_profile *wtas) |
| 271 | { |
| 272 | int i; |
| 273 | size_t package_size; |
| 274 | |
| 275 | if (wtas == NULL) |
| 276 | return; |
| 277 | |
| 278 | /* |
| 279 | * Name (WTAS, Package() { |
| 280 | * { |
| 281 | * Revision, |
| 282 | * Package() |
| 283 | * { |
| 284 | * DomainType, // 0x7:WiFi |
| 285 | * WifiTASSelection, // Enable/Disable the TAS feature |
| 286 | * WifiTASListEntries, // No. of blocked countries not approved by OEM to |
| 287 | * BlockedListEntry1, support this feature |
| 288 | * BlockedListEntry2, |
| 289 | * BlockedListEntry3, |
| 290 | * BlockedListEntry4, |
| 291 | * BlockedListEntry5, |
| 292 | * BlockedListEntry6, |
| 293 | * BlockedListEntry7, |
| 294 | * BlockedListEntry8, |
| 295 | * BlockedListEntry9, |
| 296 | * BlockedListEntry10, |
| 297 | * BlockedListEntry11, |
| 298 | * BlockedListEntry12, |
| 299 | * BlockedListEntry13, |
| 300 | * BlockedListEntry14, |
| 301 | * BlockedListEntry15, |
| 302 | * BlockedListEntry16, |
| 303 | * } |
| 304 | * }) |
| 305 | */ |
| 306 | package_size = 1 + 1 + 1 + MAX_DENYLIST_ENTRY; |
| 307 | |
| 308 | acpigen_write_name("WTAS"); |
| 309 | acpigen_write_package(2); |
| 310 | acpigen_write_dword(wtas->revision); |
| 311 | acpigen_write_package(package_size); |
| 312 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
| 313 | acpigen_write_dword(wtas->tas_selection); |
| 314 | acpigen_write_dword(wtas->tas_list_size); |
| 315 | for (i = 0; i < MAX_DENYLIST_ENTRY; i++) |
| 316 | acpigen_write_byte(wtas->deny_list_entry[i]); |
| 317 | |
| 318 | acpigen_write_package_end(); |
| 319 | acpigen_write_package_end(); |
| 320 | } |
| 321 | |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 322 | static void emit_sar_acpi_structures(const struct device *dev) |
| 323 | { |
| 324 | union wifi_sar_limits sar_limits; |
| 325 | |
| 326 | /* |
| 327 | * If device type is PCI, ensure that the device has Intel vendor ID. CBFS SAR and SAR |
| 328 | * ACPI tables are currently used only by Intel WiFi devices. |
| 329 | */ |
| 330 | if (dev->path.type == DEVICE_PATH_PCI && dev->vendor != PCI_VENDOR_ID_INTEL) |
| 331 | return; |
| 332 | |
| 333 | /* Retrieve the sar limits data */ |
| 334 | if (get_wifi_sar_limits(&sar_limits) < 0) { |
| 335 | printk(BIOS_ERR, "ERROR: failed getting SAR limits!\n"); |
| 336 | return; |
| 337 | } |
| 338 | |
| 339 | sar_emit_wrds(sar_limits.sar); |
| 340 | sar_emit_ewrd(sar_limits.sar); |
| 341 | sar_emit_wgds(sar_limits.wgds); |
Sugnan Prabhu S | d1fc832 | 2021-08-31 07:11:35 +0530 | [diff] [blame] | 342 | sar_emit_ppag(sar_limits.ppag); |
Sugnan Prabhu S | cc50770 | 2021-08-31 07:19:30 +0530 | [diff] [blame^] | 343 | sar_emit_wtas(sar_limits.wtas); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 344 | |
| 345 | free(sar_limits.sar); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 346 | } |
| 347 | |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 348 | static void wifi_ssdt_write_device(const struct device *dev, const char *path) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 349 | { |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 350 | /* Device */ |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 351 | acpigen_write_device(path); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 352 | acpi_device_write_uid(dev); |
| 353 | |
| 354 | if (dev->chip_ops) |
| 355 | acpigen_write_name_string("_DDN", dev->chip_ops->name); |
| 356 | |
| 357 | /* Address */ |
| 358 | acpigen_write_ADR_pci_device(dev); |
| 359 | |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 360 | acpigen_pop_len(); /* Device */ |
| 361 | } |
| 362 | |
| 363 | static void wifi_ssdt_write_properties(const struct device *dev, const char *scope) |
| 364 | { |
| 365 | const struct drivers_wifi_generic_config *config = dev->chip_info; |
| 366 | |
| 367 | /* Scope */ |
| 368 | acpigen_write_scope(scope); |
| 369 | |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 370 | /* Wake capabilities */ |
| 371 | if (config) |
| 372 | acpigen_write_PRW(config->wake, ACPI_S3); |
| 373 | |
| 374 | /* Fill regulatory domain structure */ |
| 375 | if (CONFIG(HAVE_REGULATORY_DOMAIN)) { |
| 376 | /* |
| 377 | * Name ("WRDD", Package () { |
| 378 | * WRDD_REVISION, // Revision |
| 379 | * Package () { |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 380 | * DOMAIN_TYPE_WIFI, // Domain Type, 7:WiFi |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 381 | * wifi_regulatory_domain() // Country Identifier |
| 382 | * } |
| 383 | * }) |
| 384 | */ |
| 385 | acpigen_write_name("WRDD"); |
| 386 | acpigen_write_package(2); |
| 387 | acpigen_write_integer(WRDD_REVISION); |
| 388 | acpigen_write_package(2); |
Sugnan Prabhu S | fcb4f2d | 2021-07-30 20:12:22 +0530 | [diff] [blame] | 389 | acpigen_write_dword(DOMAIN_TYPE_WIFI); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 390 | acpigen_write_dword(wifi_regulatory_domain()); |
| 391 | acpigen_pop_len(); |
| 392 | acpigen_pop_len(); |
| 393 | } |
| 394 | |
| 395 | /* Fill Wifi sar related ACPI structures */ |
| 396 | if (CONFIG(USE_SAR)) |
| 397 | emit_sar_acpi_structures(dev); |
| 398 | |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 399 | acpigen_pop_len(); /* Scope */ |
| 400 | |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 401 | printk(BIOS_INFO, "%s: %s %s\n", scope, dev->chip_ops ? dev->chip_ops->name : "", |
| 402 | dev_path(dev)); |
| 403 | } |
| 404 | |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 405 | void wifi_pcie_fill_ssdt(const struct device *dev) |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 406 | { |
| 407 | const char *path; |
| 408 | |
Furquan Shaikh | 6017abb | 2020-10-27 17:41:09 -0700 | [diff] [blame] | 409 | path = acpi_device_path(dev); |
| 410 | if (!path) |
| 411 | return; |
| 412 | |
| 413 | wifi_ssdt_write_device(dev, path); |
| 414 | wifi_ssdt_write_properties(dev, path); |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 417 | const char *wifi_pcie_acpi_name(const struct device *dev) |
Furquan Shaikh | 2736c82 | 2020-10-27 19:46:11 -0700 | [diff] [blame] | 418 | { |
| 419 | static char wifi_acpi_name[WIFI_ACPI_NAME_MAX_LEN]; |
| 420 | |
| 421 | /* ACPI 6.3, ASL 20.2.2: (Name Objects Encoding). */ |
| 422 | snprintf(wifi_acpi_name, sizeof(wifi_acpi_name), "WF%02X", |
| 423 | (dev_path_encode(dev) & 0xff)); |
| 424 | return wifi_acpi_name; |
| 425 | } |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 426 | |
| 427 | void wifi_cnvi_fill_ssdt(const struct device *dev) |
| 428 | { |
| 429 | const char *path; |
| 430 | |
Furquan Shaikh | d436750 | 2020-10-27 18:00:46 -0700 | [diff] [blame] | 431 | path = acpi_device_path(dev->bus->dev); |
| 432 | if (!path) |
| 433 | return; |
| 434 | |
| 435 | wifi_ssdt_write_properties(dev, path); |
| 436 | } |