Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wifi: mt76: mt792x: extend MTCL of APCI to version3 for EHT control

This patch introduces version 3 of the MTCL table, which provides
regulatory information for WiFi 7. It also configured by the platform
vender like the version 1 and 2.

Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Link: https://patch.msgid.link/20250304113649.867387-5-mingyen.hsieh@mediatek.com
Signed-off-by: Felix Fietkau <nbd@nbd.name>

authored by

Ming Yen Hsieh and committed by
Felix Fietkau
7cebc230 b4ea6fdf

+120 -27
+3 -3
drivers/net/wireless/mediatek/mt76/mt792x.h
··· 508 508 int mt792x_init_acpi_sar(struct mt792x_dev *dev); 509 509 int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default); 510 510 u8 mt792x_acpi_get_flags(struct mt792x_phy *phy); 511 - u8 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2); 511 + u32 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2); 512 512 #else 513 513 static inline int mt792x_init_acpi_sar(struct mt792x_dev *dev) 514 514 { ··· 526 526 return 0; 527 527 } 528 528 529 - static inline u8 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2) 529 + static inline u32 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2) 530 530 { 531 - return 0xf; 531 + return MT792X_ACPI_MTCL_INVALID; 532 532 } 533 533 #endif 534 534
+100 -23
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.c
··· 4 4 #include <linux/acpi.h> 5 5 #include "mt792x.h" 6 6 7 + static const char * const cc_list_all[] = { 8 + "00", "EU", "AR", "AU", "AZ", "BY", "BO", "BR", 9 + "CA", "CL", "CN", "ID", "JP", "MY", "MX", "ME", 10 + "MA", "NZ", "NG", "PH", "RU", "RS", "SG", "KR", 11 + "TW", "TH", "UA", "GB", "US", "VN", "KH", "PY", 12 + }; 13 + 14 + static const char * const cc_list_eu[] = { 15 + "AD", "AT", "BE", "BG", "CY", "CZ", "HR", "DK", 16 + "EE", "FI", "FR", "DE", "GR", "HU", "IS", "IE", 17 + "IT", "LV", "LI", "LT", "LU", "MC", "MT", "NL", 18 + "NO", "PL", "PT", "RO", "SK", "SI", "ES", "SE", 19 + "CH", 20 + }; 21 + 22 + static const char * const cc_list_be[] = { 23 + "AR", "BR", "BY", "CL", "IQ", "MX", "OM", "RU", 24 + "RW", "VN", "KR", "UA", "", "", "", "", 25 + "EU", "AT", "CN", "CA", "TW", "NZ", "PH", "UK", 26 + "US", 27 + }; 28 + 7 29 static int 8 30 mt792x_acpi_read(struct mt792x_dev *dev, u8 *method, u8 **tbl, u32 *len) 9 31 { ··· 88 66 } 89 67 90 68 /* MTCL : Country List Table for 6G band */ 69 + /* MTCL : Country List Table for 6G band and 11BE */ 91 70 static int 92 71 mt792x_asar_acpi_read_mtcl(struct mt792x_dev *dev, u8 **table, u8 *version) 93 72 { 94 - int ret; 73 + int len, ret; 95 74 96 - *version = ((ret = mt792x_acpi_read(dev, MT792x_ACPI_MTCL, table, NULL)) < 0) 97 - ? 1 : 2; 75 + ret = mt792x_acpi_read(dev, MT792x_ACPI_MTCL, table, &len); 76 + if (ret) 77 + return ret; 78 + 79 + if (len == sizeof(struct mt792x_asar_cl)) 80 + *version = ((struct mt792x_asar_cl *)*table)->version; 81 + else if (len == sizeof(struct mt792x_asar_cl_v3)) 82 + *version = ((struct mt792x_asar_cl_v3 *)*table)->version; 83 + else 84 + return -EINVAL; 98 85 99 86 return ret; 100 87 } ··· 382 351 } 383 352 EXPORT_SYMBOL_GPL(mt792x_acpi_get_flags); 384 353 385 - static u8 354 + static u32 355 + mt792x_acpi_get_mtcl_map_v3(int row, int column, struct mt792x_asar_cl_v3 *cl) 356 + { 357 + u32 config = 0; 358 + u8 mode_be = 0; 359 + 360 + mode_be = (cl->mode_be > 0x02) ? 0 : cl->mode_be; 361 + 362 + if (cl->version > 2 && cl->clbe[row] & BIT(column)) 363 + config |= (mode_be & 0x3) << 4; 364 + 365 + return config; 366 + } 367 + 368 + static u32 386 369 mt792x_acpi_get_mtcl_map(int row, int column, struct mt792x_asar_cl *cl) 387 370 { 388 - u8 config = 0; 371 + u32 config = 0; 389 372 u8 mode_6g, mode_5g9; 390 373 391 374 mode_6g = (cl->mode_6g > 0x02) ? 0 : cl->mode_6g; ··· 413 368 return config; 414 369 } 415 370 416 - u8 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2) 371 + static u32 372 + mt792x_acpi_parse_mtcl_tbl_v3(struct mt792x_phy *phy, char *alpha2) 417 373 { 418 - static const char * const cc_list_all[] = { 419 - "00", "EU", "AR", "AU", "AZ", "BY", "BO", "BR", 420 - "CA", "CL", "CN", "ID", "JP", "MY", "MX", "ME", 421 - "MA", "NZ", "NG", "PH", "RU", "RS", "SG", "KR", 422 - "TW", "TH", "UA", "GB", "US", "VN", "KH", "PY", 423 - }; 424 - static const char * const cc_list_eu[] = { 425 - "AT", "BE", "BG", "CY", "CZ", "HR", "DK", "EE", 426 - "FI", "FR", "DE", "GR", "HU", "IS", "IE", "IT", 427 - "LV", "LI", "LT", "LU", "MT", "NL", "NO", "PL", 428 - "PT", "RO", "SK", "SI", "ES", "SE", "CH", 429 - }; 430 374 struct mt792x_acpi_sar *sar = phy->acpisar; 431 - struct mt792x_asar_cl *cl; 375 + struct mt792x_asar_cl_v3 *cl = sar->countrylist_v3; 432 376 int col, row, i; 433 377 434 - if (!sar) 435 - return 0xf; 378 + if (sar->ver != 3) 379 + goto out; 436 380 437 - cl = sar->countrylist; 438 381 if (!cl) 439 - return 0xc; 382 + return MT792X_ACPI_MTCL_INVALID; 383 + 384 + for (i = 0; i < ARRAY_SIZE(cc_list_be); i++) { 385 + col = 7 - i % 8; 386 + row = i / 8; 387 + if (!memcmp(cc_list_be[i], alpha2, 2)) 388 + return mt792x_acpi_get_mtcl_map_v3(row, col, cl); 389 + } 390 + for (i = 0; i < ARRAY_SIZE(cc_list_eu); i++) { 391 + if (!memcmp(cc_list_eu[i], alpha2, 2)) 392 + return mt792x_acpi_get_mtcl_map_v3(3, 7, cl); 393 + } 394 + 395 + out: 396 + /* Depends on driver */ 397 + return 0x20; 398 + } 399 + 400 + static u32 401 + mt792x_acpi_parse_mtcl_tbl(struct mt792x_phy *phy, char *alpha2) 402 + { 403 + struct mt792x_acpi_sar *sar = phy->acpisar; 404 + struct mt792x_asar_cl *cl = sar->countrylist; 405 + int col, row, i; 406 + 407 + if (!cl) 408 + return MT792X_ACPI_MTCL_INVALID; 440 409 441 410 for (i = 0; i < ARRAY_SIZE(cc_list_all); i++) { 442 411 col = 7 - i % 8; ··· 464 405 return mt792x_acpi_get_mtcl_map(0, 6, cl); 465 406 466 407 return mt792x_acpi_get_mtcl_map(0, 7, cl); 408 + } 409 + 410 + u32 mt792x_acpi_get_mtcl_conf(struct mt792x_phy *phy, char *alpha2) 411 + { 412 + struct mt792x_acpi_sar *sar = phy->acpisar; 413 + u32 config = 0; 414 + 415 + if (!sar) 416 + return MT792X_ACPI_MTCL_INVALID; 417 + 418 + config = mt792x_acpi_parse_mtcl_tbl_v3(phy, alpha2); 419 + 420 + if (config == MT792X_ACPI_MTCL_INVALID) 421 + return MT792X_ACPI_MTCL_INVALID; 422 + 423 + config |= mt792x_acpi_parse_mtcl_tbl(phy, alpha2); 424 + 425 + return config; 467 426 } 468 427 EXPORT_SYMBOL_GPL(mt792x_acpi_get_mtcl_conf);
+17 -1
drivers/net/wireless/mediatek/mt76/mt792x_acpi_sar.h
··· 15 15 #define MT792x_ACPI_MTGS "MTGS" 16 16 #define MT792x_ACPI_MTFG "MTFG" 17 17 18 + #define MT792X_ACPI_MTCL_INVALID 0xffffffff 19 + 18 20 struct mt792x_asar_dyn_limit { 19 21 u8 idx; 20 22 u8 frp[5]; ··· 74 72 DECLARE_FLEX_ARRAY(struct mt792x_asar_geo_limit_v2, tbl); 75 73 } __packed; 76 74 75 + struct mt792x_asar_cl_v3 { 76 + u8 names[4]; 77 + u8 version; 78 + u8 mode_6g; 79 + u8 cl6g[6]; 80 + u8 mode_5g9; 81 + u8 cl5g9[6]; 82 + u8 mode_be; 83 + u8 clbe[6]; 84 + } __packed; 85 + 77 86 struct mt792x_asar_cl { 78 87 u8 names[4]; 79 88 u8 version; ··· 113 100 struct mt792x_asar_geo *geo; 114 101 struct mt792x_asar_geo_v2 *geo_v2; 115 102 }; 116 - struct mt792x_asar_cl *countrylist; 103 + union { 104 + struct mt792x_asar_cl *countrylist; 105 + struct mt792x_asar_cl_v3 *countrylist_v3; 106 + }; 117 107 struct mt792x_asar_fg *fg; 118 108 }; 119 109