1 // SPDX-License-Identifier: BSD-3-Clause-Clear 2 /* 3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved. 4 * Copyright (c) 2021-2024 Qualcomm Innovation Center, Inc. All rights reserved. 5 */ 6 7 #include <linux/elf.h> 8 9 #include "qmi.h" 10 #include "core.h" 11 #include "debug.h" 12 #include <linux/of.h> 13 #include <linux/firmware.h> 14 15 #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02 16 #define HOST_CSTATE_BIT 0x04 17 #define PLATFORM_CAP_PCIE_GLOBAL_RESET 0x08 18 #define ATH12K_QMI_MAX_CHUNK_SIZE 2097152 19 20 static const struct qmi_elem_info wlfw_host_mlo_chip_info_s_v01_ei[] = { 21 { 22 .data_type = QMI_UNSIGNED_1_BYTE, 23 .elem_len = 1, 24 .elem_size = sizeof(u8), 25 .array_type = NO_ARRAY, 26 .tlv_type = 0, 27 .offset = offsetof(struct wlfw_host_mlo_chip_info_s_v01, 28 chip_id), 29 }, 30 { 31 .data_type = QMI_UNSIGNED_1_BYTE, 32 .elem_len = 1, 33 .elem_size = sizeof(u8), 34 .array_type = NO_ARRAY, 35 .tlv_type = 0, 36 .offset = offsetof(struct wlfw_host_mlo_chip_info_s_v01, 37 num_local_links), 38 }, 39 { 40 .data_type = QMI_UNSIGNED_1_BYTE, 41 .elem_len = QMI_WLFW_MAX_NUM_MLO_LINKS_PER_CHIP_V01, 42 .elem_size = sizeof(u8), 43 .array_type = STATIC_ARRAY, 44 .tlv_type = 0, 45 .offset = offsetof(struct wlfw_host_mlo_chip_info_s_v01, 46 hw_link_id), 47 }, 48 { 49 .data_type = QMI_UNSIGNED_1_BYTE, 50 .elem_len = QMI_WLFW_MAX_NUM_MLO_LINKS_PER_CHIP_V01, 51 .elem_size = sizeof(u8), 52 .array_type = STATIC_ARRAY, 53 .tlv_type = 0, 54 .offset = offsetof(struct wlfw_host_mlo_chip_info_s_v01, 55 valid_mlo_link_id), 56 }, 57 { 58 .data_type = QMI_EOTI, 59 .array_type = NO_ARRAY, 60 .tlv_type = QMI_COMMON_TLV_TYPE, 61 }, 62 }; 63 64 static const struct qmi_elem_info qmi_wlanfw_host_cap_req_msg_v01_ei[] = { 65 { 66 .data_type = QMI_OPT_FLAG, 67 .elem_len = 1, 68 .elem_size = sizeof(u8), 69 .array_type = NO_ARRAY, 70 .tlv_type = 0x10, 71 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 72 num_clients_valid), 73 }, 74 { 75 .data_type = QMI_UNSIGNED_4_BYTE, 76 .elem_len = 1, 77 .elem_size = sizeof(u32), 78 .array_type = NO_ARRAY, 79 .tlv_type = 0x10, 80 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 81 num_clients), 82 }, 83 { 84 .data_type = QMI_OPT_FLAG, 85 .elem_len = 1, 86 .elem_size = sizeof(u8), 87 .array_type = NO_ARRAY, 88 .tlv_type = 0x11, 89 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 90 wake_msi_valid), 91 }, 92 { 93 .data_type = QMI_UNSIGNED_4_BYTE, 94 .elem_len = 1, 95 .elem_size = sizeof(u32), 96 .array_type = NO_ARRAY, 97 .tlv_type = 0x11, 98 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 99 wake_msi), 100 }, 101 { 102 .data_type = QMI_OPT_FLAG, 103 .elem_len = 1, 104 .elem_size = sizeof(u8), 105 .array_type = NO_ARRAY, 106 .tlv_type = 0x12, 107 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 108 gpios_valid), 109 }, 110 { 111 .data_type = QMI_DATA_LEN, 112 .elem_len = 1, 113 .elem_size = sizeof(u8), 114 .array_type = NO_ARRAY, 115 .tlv_type = 0x12, 116 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 117 gpios_len), 118 }, 119 { 120 .data_type = QMI_UNSIGNED_4_BYTE, 121 .elem_len = QMI_WLFW_MAX_NUM_GPIO_V01, 122 .elem_size = sizeof(u32), 123 .array_type = VAR_LEN_ARRAY, 124 .tlv_type = 0x12, 125 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 126 gpios), 127 }, 128 { 129 .data_type = QMI_OPT_FLAG, 130 .elem_len = 1, 131 .elem_size = sizeof(u8), 132 .array_type = NO_ARRAY, 133 .tlv_type = 0x13, 134 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 135 nm_modem_valid), 136 }, 137 { 138 .data_type = QMI_UNSIGNED_1_BYTE, 139 .elem_len = 1, 140 .elem_size = sizeof(u8), 141 .array_type = NO_ARRAY, 142 .tlv_type = 0x13, 143 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 144 nm_modem), 145 }, 146 { 147 .data_type = QMI_OPT_FLAG, 148 .elem_len = 1, 149 .elem_size = sizeof(u8), 150 .array_type = NO_ARRAY, 151 .tlv_type = 0x14, 152 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 153 bdf_support_valid), 154 }, 155 { 156 .data_type = QMI_UNSIGNED_1_BYTE, 157 .elem_len = 1, 158 .elem_size = sizeof(u8), 159 .array_type = NO_ARRAY, 160 .tlv_type = 0x14, 161 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 162 bdf_support), 163 }, 164 { 165 .data_type = QMI_OPT_FLAG, 166 .elem_len = 1, 167 .elem_size = sizeof(u8), 168 .array_type = NO_ARRAY, 169 .tlv_type = 0x15, 170 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 171 bdf_cache_support_valid), 172 }, 173 { 174 .data_type = QMI_UNSIGNED_1_BYTE, 175 .elem_len = 1, 176 .elem_size = sizeof(u8), 177 .array_type = NO_ARRAY, 178 .tlv_type = 0x15, 179 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 180 bdf_cache_support), 181 }, 182 { 183 .data_type = QMI_OPT_FLAG, 184 .elem_len = 1, 185 .elem_size = sizeof(u8), 186 .array_type = NO_ARRAY, 187 .tlv_type = 0x16, 188 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 189 m3_support_valid), 190 }, 191 { 192 .data_type = QMI_UNSIGNED_1_BYTE, 193 .elem_len = 1, 194 .elem_size = sizeof(u8), 195 .array_type = NO_ARRAY, 196 .tlv_type = 0x16, 197 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 198 m3_support), 199 }, 200 { 201 .data_type = QMI_OPT_FLAG, 202 .elem_len = 1, 203 .elem_size = sizeof(u8), 204 .array_type = NO_ARRAY, 205 .tlv_type = 0x17, 206 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 207 m3_cache_support_valid), 208 }, 209 { 210 .data_type = QMI_UNSIGNED_1_BYTE, 211 .elem_len = 1, 212 .elem_size = sizeof(u8), 213 .array_type = NO_ARRAY, 214 .tlv_type = 0x17, 215 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 216 m3_cache_support), 217 }, 218 { 219 .data_type = QMI_OPT_FLAG, 220 .elem_len = 1, 221 .elem_size = sizeof(u8), 222 .array_type = NO_ARRAY, 223 .tlv_type = 0x18, 224 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 225 cal_filesys_support_valid), 226 }, 227 { 228 .data_type = QMI_UNSIGNED_1_BYTE, 229 .elem_len = 1, 230 .elem_size = sizeof(u8), 231 .array_type = NO_ARRAY, 232 .tlv_type = 0x18, 233 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 234 cal_filesys_support), 235 }, 236 { 237 .data_type = QMI_OPT_FLAG, 238 .elem_len = 1, 239 .elem_size = sizeof(u8), 240 .array_type = NO_ARRAY, 241 .tlv_type = 0x19, 242 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 243 cal_cache_support_valid), 244 }, 245 { 246 .data_type = QMI_UNSIGNED_1_BYTE, 247 .elem_len = 1, 248 .elem_size = sizeof(u8), 249 .array_type = NO_ARRAY, 250 .tlv_type = 0x19, 251 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 252 cal_cache_support), 253 }, 254 { 255 .data_type = QMI_OPT_FLAG, 256 .elem_len = 1, 257 .elem_size = sizeof(u8), 258 .array_type = NO_ARRAY, 259 .tlv_type = 0x1A, 260 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 261 cal_done_valid), 262 }, 263 { 264 .data_type = QMI_UNSIGNED_1_BYTE, 265 .elem_len = 1, 266 .elem_size = sizeof(u8), 267 .array_type = NO_ARRAY, 268 .tlv_type = 0x1A, 269 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 270 cal_done), 271 }, 272 { 273 .data_type = QMI_OPT_FLAG, 274 .elem_len = 1, 275 .elem_size = sizeof(u8), 276 .array_type = NO_ARRAY, 277 .tlv_type = 0x1B, 278 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 279 mem_bucket_valid), 280 }, 281 { 282 .data_type = QMI_UNSIGNED_4_BYTE, 283 .elem_len = 1, 284 .elem_size = sizeof(u32), 285 .array_type = NO_ARRAY, 286 .tlv_type = 0x1B, 287 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 288 mem_bucket), 289 }, 290 { 291 .data_type = QMI_OPT_FLAG, 292 .elem_len = 1, 293 .elem_size = sizeof(u8), 294 .array_type = NO_ARRAY, 295 .tlv_type = 0x1C, 296 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 297 mem_cfg_mode_valid), 298 }, 299 { 300 .data_type = QMI_UNSIGNED_1_BYTE, 301 .elem_len = 1, 302 .elem_size = sizeof(u8), 303 .array_type = NO_ARRAY, 304 .tlv_type = 0x1C, 305 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 306 mem_cfg_mode), 307 }, 308 { 309 .data_type = QMI_OPT_FLAG, 310 .elem_len = 1, 311 .elem_size = sizeof(u8), 312 .array_type = NO_ARRAY, 313 .tlv_type = 0x1D, 314 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 315 cal_duration_valid), 316 }, 317 { 318 .data_type = QMI_UNSIGNED_2_BYTE, 319 .elem_len = 1, 320 .elem_size = sizeof(u16), 321 .array_type = NO_ARRAY, 322 .tlv_type = 0x1D, 323 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 324 cal_duraiton), 325 }, 326 { 327 .data_type = QMI_OPT_FLAG, 328 .elem_len = 1, 329 .elem_size = sizeof(u8), 330 .array_type = NO_ARRAY, 331 .tlv_type = 0x1E, 332 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 333 platform_name_valid), 334 }, 335 { 336 .data_type = QMI_STRING, 337 .elem_len = QMI_WLANFW_MAX_PLATFORM_NAME_LEN_V01 + 1, 338 .elem_size = sizeof(char), 339 .array_type = NO_ARRAY, 340 .tlv_type = 0x1E, 341 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 342 platform_name), 343 }, 344 { 345 .data_type = QMI_OPT_FLAG, 346 .elem_len = 1, 347 .elem_size = sizeof(u8), 348 .array_type = NO_ARRAY, 349 .tlv_type = 0x1F, 350 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 351 ddr_range_valid), 352 }, 353 { 354 .data_type = QMI_STRUCT, 355 .elem_len = QMI_WLANFW_MAX_HOST_DDR_RANGE_SIZE_V01, 356 .elem_size = sizeof(struct qmi_wlanfw_host_ddr_range), 357 .array_type = STATIC_ARRAY, 358 .tlv_type = 0x1F, 359 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 360 ddr_range), 361 }, 362 { 363 .data_type = QMI_OPT_FLAG, 364 .elem_len = 1, 365 .elem_size = sizeof(u8), 366 .array_type = NO_ARRAY, 367 .tlv_type = 0x20, 368 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 369 host_build_type_valid), 370 }, 371 { 372 .data_type = QMI_SIGNED_4_BYTE_ENUM, 373 .elem_len = 1, 374 .elem_size = sizeof(enum qmi_wlanfw_host_build_type), 375 .array_type = NO_ARRAY, 376 .tlv_type = 0x20, 377 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 378 host_build_type), 379 }, 380 { 381 .data_type = QMI_OPT_FLAG, 382 .elem_len = 1, 383 .elem_size = sizeof(u8), 384 .array_type = NO_ARRAY, 385 .tlv_type = 0x21, 386 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 387 mlo_capable_valid), 388 }, 389 { 390 .data_type = QMI_UNSIGNED_1_BYTE, 391 .elem_len = 1, 392 .elem_size = sizeof(u8), 393 .array_type = NO_ARRAY, 394 .tlv_type = 0x21, 395 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 396 mlo_capable), 397 }, 398 { 399 .data_type = QMI_OPT_FLAG, 400 .elem_len = 1, 401 .elem_size = sizeof(u8), 402 .array_type = NO_ARRAY, 403 .tlv_type = 0x22, 404 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 405 mlo_chip_id_valid), 406 }, 407 { 408 .data_type = QMI_UNSIGNED_2_BYTE, 409 .elem_len = 1, 410 .elem_size = sizeof(u16), 411 .array_type = NO_ARRAY, 412 .tlv_type = 0x22, 413 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 414 mlo_chip_id), 415 }, 416 { 417 .data_type = QMI_OPT_FLAG, 418 .elem_len = 1, 419 .elem_size = sizeof(u8), 420 .array_type = NO_ARRAY, 421 .tlv_type = 0x23, 422 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 423 mlo_group_id_valid), 424 }, 425 { 426 .data_type = QMI_UNSIGNED_1_BYTE, 427 .elem_len = 1, 428 .elem_size = sizeof(u8), 429 .array_type = NO_ARRAY, 430 .tlv_type = 0x23, 431 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 432 mlo_group_id), 433 }, 434 { 435 .data_type = QMI_OPT_FLAG, 436 .elem_len = 1, 437 .elem_size = sizeof(u8), 438 .array_type = NO_ARRAY, 439 .tlv_type = 0x24, 440 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 441 max_mlo_peer_valid), 442 }, 443 { 444 .data_type = QMI_UNSIGNED_2_BYTE, 445 .elem_len = 1, 446 .elem_size = sizeof(u16), 447 .array_type = NO_ARRAY, 448 .tlv_type = 0x24, 449 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 450 max_mlo_peer), 451 }, 452 { 453 .data_type = QMI_OPT_FLAG, 454 .elem_len = 1, 455 .elem_size = sizeof(u8), 456 .array_type = NO_ARRAY, 457 .tlv_type = 0x25, 458 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 459 mlo_num_chips_valid), 460 }, 461 { 462 .data_type = QMI_UNSIGNED_1_BYTE, 463 .elem_len = 1, 464 .elem_size = sizeof(u8), 465 .array_type = NO_ARRAY, 466 .tlv_type = 0x25, 467 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 468 mlo_num_chips), 469 }, 470 { 471 .data_type = QMI_OPT_FLAG, 472 .elem_len = 1, 473 .elem_size = sizeof(u8), 474 .array_type = NO_ARRAY, 475 .tlv_type = 0x26, 476 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 477 mlo_chip_info_valid), 478 }, 479 { 480 .data_type = QMI_STRUCT, 481 .elem_len = QMI_WLFW_MAX_NUM_MLO_CHIPS_V01, 482 .elem_size = sizeof(struct wlfw_host_mlo_chip_info_s_v01), 483 .array_type = STATIC_ARRAY, 484 .tlv_type = 0x26, 485 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 486 mlo_chip_info), 487 .ei_array = wlfw_host_mlo_chip_info_s_v01_ei, 488 }, 489 { 490 .data_type = QMI_OPT_FLAG, 491 .elem_len = 1, 492 .elem_size = sizeof(u8), 493 .array_type = NO_ARRAY, 494 .tlv_type = 0x27, 495 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 496 feature_list_valid), 497 }, 498 { 499 .data_type = QMI_UNSIGNED_8_BYTE, 500 .elem_len = 1, 501 .elem_size = sizeof(u64), 502 .array_type = NO_ARRAY, 503 .tlv_type = 0x27, 504 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01, 505 feature_list), 506 }, 507 { 508 .data_type = QMI_EOTI, 509 .array_type = NO_ARRAY, 510 .tlv_type = QMI_COMMON_TLV_TYPE, 511 }, 512 }; 513 514 static const struct qmi_elem_info qmi_wlanfw_host_cap_resp_msg_v01_ei[] = { 515 { 516 .data_type = QMI_STRUCT, 517 .elem_len = 1, 518 .elem_size = sizeof(struct qmi_response_type_v01), 519 .array_type = NO_ARRAY, 520 .tlv_type = 0x02, 521 .offset = offsetof(struct qmi_wlanfw_host_cap_resp_msg_v01, resp), 522 .ei_array = qmi_response_type_v01_ei, 523 }, 524 { 525 .data_type = QMI_EOTI, 526 .array_type = NO_ARRAY, 527 .tlv_type = QMI_COMMON_TLV_TYPE, 528 }, 529 }; 530 531 static const struct qmi_elem_info qmi_wlanfw_phy_cap_req_msg_v01_ei[] = { 532 { 533 .data_type = QMI_EOTI, 534 .array_type = NO_ARRAY, 535 .tlv_type = QMI_COMMON_TLV_TYPE, 536 }, 537 }; 538 539 static const struct qmi_elem_info qmi_wlanfw_phy_cap_resp_msg_v01_ei[] = { 540 { 541 .data_type = QMI_STRUCT, 542 .elem_len = 1, 543 .elem_size = sizeof(struct qmi_response_type_v01), 544 .array_type = NO_ARRAY, 545 .tlv_type = 0x02, 546 .offset = offsetof(struct qmi_wlanfw_phy_cap_resp_msg_v01, resp), 547 .ei_array = qmi_response_type_v01_ei, 548 }, 549 { 550 .data_type = QMI_OPT_FLAG, 551 .elem_len = 1, 552 .elem_size = sizeof(u8), 553 .array_type = NO_ARRAY, 554 .tlv_type = 0x10, 555 .offset = offsetof(struct qmi_wlanfw_phy_cap_resp_msg_v01, 556 num_phy_valid), 557 }, 558 { 559 .data_type = QMI_UNSIGNED_1_BYTE, 560 .elem_len = 1, 561 .elem_size = sizeof(u8), 562 .array_type = NO_ARRAY, 563 .tlv_type = 0x10, 564 .offset = offsetof(struct qmi_wlanfw_phy_cap_resp_msg_v01, 565 num_phy), 566 }, 567 { 568 .data_type = QMI_OPT_FLAG, 569 .elem_len = 1, 570 .elem_size = sizeof(u8), 571 .array_type = NO_ARRAY, 572 .tlv_type = 0x11, 573 .offset = offsetof(struct qmi_wlanfw_phy_cap_resp_msg_v01, 574 board_id_valid), 575 }, 576 { 577 .data_type = QMI_UNSIGNED_4_BYTE, 578 .elem_len = 1, 579 .elem_size = sizeof(u32), 580 .array_type = NO_ARRAY, 581 .tlv_type = 0x11, 582 .offset = offsetof(struct qmi_wlanfw_phy_cap_resp_msg_v01, 583 board_id), 584 }, 585 { 586 .data_type = QMI_EOTI, 587 .array_type = NO_ARRAY, 588 .tlv_type = QMI_COMMON_TLV_TYPE, 589 }, 590 }; 591 592 static const struct qmi_elem_info qmi_wlanfw_ind_register_req_msg_v01_ei[] = { 593 { 594 .data_type = QMI_OPT_FLAG, 595 .elem_len = 1, 596 .elem_size = sizeof(u8), 597 .array_type = NO_ARRAY, 598 .tlv_type = 0x10, 599 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 600 fw_ready_enable_valid), 601 }, 602 { 603 .data_type = QMI_UNSIGNED_1_BYTE, 604 .elem_len = 1, 605 .elem_size = sizeof(u8), 606 .array_type = NO_ARRAY, 607 .tlv_type = 0x10, 608 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 609 fw_ready_enable), 610 }, 611 { 612 .data_type = QMI_OPT_FLAG, 613 .elem_len = 1, 614 .elem_size = sizeof(u8), 615 .array_type = NO_ARRAY, 616 .tlv_type = 0x11, 617 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 618 initiate_cal_download_enable_valid), 619 }, 620 { 621 .data_type = QMI_UNSIGNED_1_BYTE, 622 .elem_len = 1, 623 .elem_size = sizeof(u8), 624 .array_type = NO_ARRAY, 625 .tlv_type = 0x11, 626 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 627 initiate_cal_download_enable), 628 }, 629 { 630 .data_type = QMI_OPT_FLAG, 631 .elem_len = 1, 632 .elem_size = sizeof(u8), 633 .array_type = NO_ARRAY, 634 .tlv_type = 0x12, 635 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 636 initiate_cal_update_enable_valid), 637 }, 638 { 639 .data_type = QMI_UNSIGNED_1_BYTE, 640 .elem_len = 1, 641 .elem_size = sizeof(u8), 642 .array_type = NO_ARRAY, 643 .tlv_type = 0x12, 644 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 645 initiate_cal_update_enable), 646 }, 647 { 648 .data_type = QMI_OPT_FLAG, 649 .elem_len = 1, 650 .elem_size = sizeof(u8), 651 .array_type = NO_ARRAY, 652 .tlv_type = 0x13, 653 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 654 msa_ready_enable_valid), 655 }, 656 { 657 .data_type = QMI_UNSIGNED_1_BYTE, 658 .elem_len = 1, 659 .elem_size = sizeof(u8), 660 .array_type = NO_ARRAY, 661 .tlv_type = 0x13, 662 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 663 msa_ready_enable), 664 }, 665 { 666 .data_type = QMI_OPT_FLAG, 667 .elem_len = 1, 668 .elem_size = sizeof(u8), 669 .array_type = NO_ARRAY, 670 .tlv_type = 0x14, 671 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 672 pin_connect_result_enable_valid), 673 }, 674 { 675 .data_type = QMI_UNSIGNED_1_BYTE, 676 .elem_len = 1, 677 .elem_size = sizeof(u8), 678 .array_type = NO_ARRAY, 679 .tlv_type = 0x14, 680 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 681 pin_connect_result_enable), 682 }, 683 { 684 .data_type = QMI_OPT_FLAG, 685 .elem_len = 1, 686 .elem_size = sizeof(u8), 687 .array_type = NO_ARRAY, 688 .tlv_type = 0x15, 689 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 690 client_id_valid), 691 }, 692 { 693 .data_type = QMI_UNSIGNED_4_BYTE, 694 .elem_len = 1, 695 .elem_size = sizeof(u32), 696 .array_type = NO_ARRAY, 697 .tlv_type = 0x15, 698 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 699 client_id), 700 }, 701 { 702 .data_type = QMI_OPT_FLAG, 703 .elem_len = 1, 704 .elem_size = sizeof(u8), 705 .array_type = NO_ARRAY, 706 .tlv_type = 0x16, 707 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 708 request_mem_enable_valid), 709 }, 710 { 711 .data_type = QMI_UNSIGNED_1_BYTE, 712 .elem_len = 1, 713 .elem_size = sizeof(u8), 714 .array_type = NO_ARRAY, 715 .tlv_type = 0x16, 716 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 717 request_mem_enable), 718 }, 719 { 720 .data_type = QMI_OPT_FLAG, 721 .elem_len = 1, 722 .elem_size = sizeof(u8), 723 .array_type = NO_ARRAY, 724 .tlv_type = 0x17, 725 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 726 fw_mem_ready_enable_valid), 727 }, 728 { 729 .data_type = QMI_UNSIGNED_1_BYTE, 730 .elem_len = 1, 731 .elem_size = sizeof(u8), 732 .array_type = NO_ARRAY, 733 .tlv_type = 0x17, 734 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 735 fw_mem_ready_enable), 736 }, 737 { 738 .data_type = QMI_OPT_FLAG, 739 .elem_len = 1, 740 .elem_size = sizeof(u8), 741 .array_type = NO_ARRAY, 742 .tlv_type = 0x18, 743 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 744 fw_init_done_enable_valid), 745 }, 746 { 747 .data_type = QMI_UNSIGNED_1_BYTE, 748 .elem_len = 1, 749 .elem_size = sizeof(u8), 750 .array_type = NO_ARRAY, 751 .tlv_type = 0x18, 752 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 753 fw_init_done_enable), 754 }, 755 756 { 757 .data_type = QMI_OPT_FLAG, 758 .elem_len = 1, 759 .elem_size = sizeof(u8), 760 .array_type = NO_ARRAY, 761 .tlv_type = 0x19, 762 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 763 rejuvenate_enable_valid), 764 }, 765 { 766 .data_type = QMI_UNSIGNED_1_BYTE, 767 .elem_len = 1, 768 .elem_size = sizeof(u8), 769 .array_type = NO_ARRAY, 770 .tlv_type = 0x19, 771 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 772 rejuvenate_enable), 773 }, 774 { 775 .data_type = QMI_OPT_FLAG, 776 .elem_len = 1, 777 .elem_size = sizeof(u8), 778 .array_type = NO_ARRAY, 779 .tlv_type = 0x1A, 780 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 781 xo_cal_enable_valid), 782 }, 783 { 784 .data_type = QMI_UNSIGNED_1_BYTE, 785 .elem_len = 1, 786 .elem_size = sizeof(u8), 787 .array_type = NO_ARRAY, 788 .tlv_type = 0x1A, 789 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 790 xo_cal_enable), 791 }, 792 { 793 .data_type = QMI_OPT_FLAG, 794 .elem_len = 1, 795 .elem_size = sizeof(u8), 796 .array_type = NO_ARRAY, 797 .tlv_type = 0x1B, 798 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 799 cal_done_enable_valid), 800 }, 801 { 802 .data_type = QMI_UNSIGNED_1_BYTE, 803 .elem_len = 1, 804 .elem_size = sizeof(u8), 805 .array_type = NO_ARRAY, 806 .tlv_type = 0x1B, 807 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01, 808 cal_done_enable), 809 }, 810 { 811 .data_type = QMI_EOTI, 812 .array_type = NO_ARRAY, 813 .tlv_type = QMI_COMMON_TLV_TYPE, 814 }, 815 }; 816 817 static const struct qmi_elem_info qmi_wlanfw_ind_register_resp_msg_v01_ei[] = { 818 { 819 .data_type = QMI_STRUCT, 820 .elem_len = 1, 821 .elem_size = sizeof(struct qmi_response_type_v01), 822 .array_type = NO_ARRAY, 823 .tlv_type = 0x02, 824 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01, 825 resp), 826 .ei_array = qmi_response_type_v01_ei, 827 }, 828 { 829 .data_type = QMI_OPT_FLAG, 830 .elem_len = 1, 831 .elem_size = sizeof(u8), 832 .array_type = NO_ARRAY, 833 .tlv_type = 0x10, 834 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01, 835 fw_status_valid), 836 }, 837 { 838 .data_type = QMI_UNSIGNED_8_BYTE, 839 .elem_len = 1, 840 .elem_size = sizeof(u64), 841 .array_type = NO_ARRAY, 842 .tlv_type = 0x10, 843 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01, 844 fw_status), 845 }, 846 { 847 .data_type = QMI_EOTI, 848 .array_type = NO_ARRAY, 849 .tlv_type = QMI_COMMON_TLV_TYPE, 850 }, 851 }; 852 853 static const struct qmi_elem_info qmi_wlanfw_mem_cfg_s_v01_ei[] = { 854 { 855 .data_type = QMI_UNSIGNED_8_BYTE, 856 .elem_len = 1, 857 .elem_size = sizeof(u64), 858 .array_type = NO_ARRAY, 859 .tlv_type = 0, 860 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, offset), 861 }, 862 { 863 .data_type = QMI_UNSIGNED_4_BYTE, 864 .elem_len = 1, 865 .elem_size = sizeof(u32), 866 .array_type = NO_ARRAY, 867 .tlv_type = 0, 868 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, size), 869 }, 870 { 871 .data_type = QMI_UNSIGNED_1_BYTE, 872 .elem_len = 1, 873 .elem_size = sizeof(u8), 874 .array_type = NO_ARRAY, 875 .tlv_type = 0, 876 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, secure_flag), 877 }, 878 { 879 .data_type = QMI_EOTI, 880 .array_type = NO_ARRAY, 881 .tlv_type = QMI_COMMON_TLV_TYPE, 882 }, 883 }; 884 885 static const struct qmi_elem_info qmi_wlanfw_mem_seg_s_v01_ei[] = { 886 { 887 .data_type = QMI_UNSIGNED_4_BYTE, 888 .elem_len = 1, 889 .elem_size = sizeof(u32), 890 .array_type = NO_ARRAY, 891 .tlv_type = 0, 892 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, 893 size), 894 }, 895 { 896 .data_type = QMI_SIGNED_4_BYTE_ENUM, 897 .elem_len = 1, 898 .elem_size = sizeof(enum qmi_wlanfw_mem_type_enum_v01), 899 .array_type = NO_ARRAY, 900 .tlv_type = 0, 901 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, type), 902 }, 903 { 904 .data_type = QMI_DATA_LEN, 905 .elem_len = 1, 906 .elem_size = sizeof(u8), 907 .array_type = NO_ARRAY, 908 .tlv_type = 0, 909 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, mem_cfg_len), 910 }, 911 { 912 .data_type = QMI_STRUCT, 913 .elem_len = QMI_WLANFW_MAX_NUM_MEM_CFG_V01, 914 .elem_size = sizeof(struct qmi_wlanfw_mem_cfg_s_v01), 915 .array_type = VAR_LEN_ARRAY, 916 .tlv_type = 0, 917 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, mem_cfg), 918 .ei_array = qmi_wlanfw_mem_cfg_s_v01_ei, 919 }, 920 { 921 .data_type = QMI_EOTI, 922 .array_type = NO_ARRAY, 923 .tlv_type = QMI_COMMON_TLV_TYPE, 924 }, 925 }; 926 927 static const struct qmi_elem_info qmi_wlanfw_request_mem_ind_msg_v01_ei[] = { 928 { 929 .data_type = QMI_DATA_LEN, 930 .elem_len = 1, 931 .elem_size = sizeof(u8), 932 .array_type = NO_ARRAY, 933 .tlv_type = 0x01, 934 .offset = offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01, 935 mem_seg_len), 936 }, 937 { 938 .data_type = QMI_STRUCT, 939 .elem_len = ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01, 940 .elem_size = sizeof(struct qmi_wlanfw_mem_seg_s_v01), 941 .array_type = VAR_LEN_ARRAY, 942 .tlv_type = 0x01, 943 .offset = offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01, 944 mem_seg), 945 .ei_array = qmi_wlanfw_mem_seg_s_v01_ei, 946 }, 947 { 948 .data_type = QMI_EOTI, 949 .array_type = NO_ARRAY, 950 .tlv_type = QMI_COMMON_TLV_TYPE, 951 }, 952 }; 953 954 static const struct qmi_elem_info qmi_wlanfw_mem_seg_resp_s_v01_ei[] = { 955 { 956 .data_type = QMI_UNSIGNED_8_BYTE, 957 .elem_len = 1, 958 .elem_size = sizeof(u64), 959 .array_type = NO_ARRAY, 960 .tlv_type = 0, 961 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, addr), 962 }, 963 { 964 .data_type = QMI_UNSIGNED_4_BYTE, 965 .elem_len = 1, 966 .elem_size = sizeof(u32), 967 .array_type = NO_ARRAY, 968 .tlv_type = 0, 969 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, size), 970 }, 971 { 972 .data_type = QMI_SIGNED_4_BYTE_ENUM, 973 .elem_len = 1, 974 .elem_size = sizeof(enum qmi_wlanfw_mem_type_enum_v01), 975 .array_type = NO_ARRAY, 976 .tlv_type = 0, 977 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, type), 978 }, 979 { 980 .data_type = QMI_UNSIGNED_1_BYTE, 981 .elem_len = 1, 982 .elem_size = sizeof(u8), 983 .array_type = NO_ARRAY, 984 .tlv_type = 0, 985 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, restore), 986 }, 987 { 988 .data_type = QMI_EOTI, 989 .array_type = NO_ARRAY, 990 .tlv_type = QMI_COMMON_TLV_TYPE, 991 }, 992 }; 993 994 static const struct qmi_elem_info qmi_wlanfw_respond_mem_req_msg_v01_ei[] = { 995 { 996 .data_type = QMI_DATA_LEN, 997 .elem_len = 1, 998 .elem_size = sizeof(u8), 999 .array_type = NO_ARRAY, 1000 .tlv_type = 0x01, 1001 .offset = offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01, 1002 mem_seg_len), 1003 }, 1004 { 1005 .data_type = QMI_STRUCT, 1006 .elem_len = ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01, 1007 .elem_size = sizeof(struct qmi_wlanfw_mem_seg_resp_s_v01), 1008 .array_type = VAR_LEN_ARRAY, 1009 .tlv_type = 0x01, 1010 .offset = offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01, 1011 mem_seg), 1012 .ei_array = qmi_wlanfw_mem_seg_resp_s_v01_ei, 1013 }, 1014 { 1015 .data_type = QMI_EOTI, 1016 .array_type = NO_ARRAY, 1017 .tlv_type = QMI_COMMON_TLV_TYPE, 1018 }, 1019 }; 1020 1021 static const struct qmi_elem_info qmi_wlanfw_respond_mem_resp_msg_v01_ei[] = { 1022 { 1023 .data_type = QMI_STRUCT, 1024 .elem_len = 1, 1025 .elem_size = sizeof(struct qmi_response_type_v01), 1026 .array_type = NO_ARRAY, 1027 .tlv_type = 0x02, 1028 .offset = offsetof(struct qmi_wlanfw_respond_mem_resp_msg_v01, 1029 resp), 1030 .ei_array = qmi_response_type_v01_ei, 1031 }, 1032 { 1033 .data_type = QMI_EOTI, 1034 .array_type = NO_ARRAY, 1035 .tlv_type = QMI_COMMON_TLV_TYPE, 1036 }, 1037 }; 1038 1039 static const struct qmi_elem_info qmi_wlanfw_cap_req_msg_v01_ei[] = { 1040 { 1041 .data_type = QMI_EOTI, 1042 .array_type = NO_ARRAY, 1043 .tlv_type = QMI_COMMON_TLV_TYPE, 1044 }, 1045 }; 1046 1047 static const struct qmi_elem_info qmi_wlanfw_rf_chip_info_s_v01_ei[] = { 1048 { 1049 .data_type = QMI_UNSIGNED_4_BYTE, 1050 .elem_len = 1, 1051 .elem_size = sizeof(u32), 1052 .array_type = NO_ARRAY, 1053 .tlv_type = 0, 1054 .offset = offsetof(struct qmi_wlanfw_rf_chip_info_s_v01, 1055 chip_id), 1056 }, 1057 { 1058 .data_type = QMI_UNSIGNED_4_BYTE, 1059 .elem_len = 1, 1060 .elem_size = sizeof(u32), 1061 .array_type = NO_ARRAY, 1062 .tlv_type = 0, 1063 .offset = offsetof(struct qmi_wlanfw_rf_chip_info_s_v01, 1064 chip_family), 1065 }, 1066 { 1067 .data_type = QMI_EOTI, 1068 .array_type = NO_ARRAY, 1069 .tlv_type = QMI_COMMON_TLV_TYPE, 1070 }, 1071 }; 1072 1073 static const struct qmi_elem_info qmi_wlanfw_rf_board_info_s_v01_ei[] = { 1074 { 1075 .data_type = QMI_UNSIGNED_4_BYTE, 1076 .elem_len = 1, 1077 .elem_size = sizeof(u32), 1078 .array_type = NO_ARRAY, 1079 .tlv_type = 0, 1080 .offset = offsetof(struct qmi_wlanfw_rf_board_info_s_v01, 1081 board_id), 1082 }, 1083 { 1084 .data_type = QMI_EOTI, 1085 .array_type = NO_ARRAY, 1086 .tlv_type = QMI_COMMON_TLV_TYPE, 1087 }, 1088 }; 1089 1090 static const struct qmi_elem_info qmi_wlanfw_soc_info_s_v01_ei[] = { 1091 { 1092 .data_type = QMI_UNSIGNED_4_BYTE, 1093 .elem_len = 1, 1094 .elem_size = sizeof(u32), 1095 .array_type = NO_ARRAY, 1096 .tlv_type = 0, 1097 .offset = offsetof(struct qmi_wlanfw_soc_info_s_v01, soc_id), 1098 }, 1099 { 1100 .data_type = QMI_EOTI, 1101 .array_type = NO_ARRAY, 1102 .tlv_type = QMI_COMMON_TLV_TYPE, 1103 }, 1104 }; 1105 1106 static const struct qmi_elem_info qmi_wlanfw_dev_mem_info_s_v01_ei[] = { 1107 { 1108 .data_type = QMI_UNSIGNED_8_BYTE, 1109 .elem_len = 1, 1110 .elem_size = sizeof(u64), 1111 .array_type = NO_ARRAY, 1112 .tlv_type = 0, 1113 .offset = offsetof(struct qmi_wlanfw_dev_mem_info_s_v01, 1114 start), 1115 }, 1116 { 1117 .data_type = QMI_UNSIGNED_8_BYTE, 1118 .elem_len = 1, 1119 .elem_size = sizeof(u64), 1120 .array_type = NO_ARRAY, 1121 .tlv_type = 0, 1122 .offset = offsetof(struct qmi_wlanfw_dev_mem_info_s_v01, 1123 size), 1124 }, 1125 { 1126 .data_type = QMI_EOTI, 1127 .array_type = NO_ARRAY, 1128 .tlv_type = QMI_COMMON_TLV_TYPE, 1129 }, 1130 }; 1131 1132 static const struct qmi_elem_info qmi_wlanfw_fw_version_info_s_v01_ei[] = { 1133 { 1134 .data_type = QMI_UNSIGNED_4_BYTE, 1135 .elem_len = 1, 1136 .elem_size = sizeof(u32), 1137 .array_type = NO_ARRAY, 1138 .tlv_type = 0, 1139 .offset = offsetof(struct qmi_wlanfw_fw_version_info_s_v01, 1140 fw_version), 1141 }, 1142 { 1143 .data_type = QMI_STRING, 1144 .elem_len = ATH12K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1, 1145 .elem_size = sizeof(char), 1146 .array_type = NO_ARRAY, 1147 .tlv_type = 0, 1148 .offset = offsetof(struct qmi_wlanfw_fw_version_info_s_v01, 1149 fw_build_timestamp), 1150 }, 1151 { 1152 .data_type = QMI_EOTI, 1153 .array_type = NO_ARRAY, 1154 .tlv_type = QMI_COMMON_TLV_TYPE, 1155 }, 1156 }; 1157 1158 static const struct qmi_elem_info qmi_wlanfw_cap_resp_msg_v01_ei[] = { 1159 { 1160 .data_type = QMI_STRUCT, 1161 .elem_len = 1, 1162 .elem_size = sizeof(struct qmi_response_type_v01), 1163 .array_type = NO_ARRAY, 1164 .tlv_type = 0x02, 1165 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, resp), 1166 .ei_array = qmi_response_type_v01_ei, 1167 }, 1168 { 1169 .data_type = QMI_OPT_FLAG, 1170 .elem_len = 1, 1171 .elem_size = sizeof(u8), 1172 .array_type = NO_ARRAY, 1173 .tlv_type = 0x10, 1174 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1175 chip_info_valid), 1176 }, 1177 { 1178 .data_type = QMI_STRUCT, 1179 .elem_len = 1, 1180 .elem_size = sizeof(struct qmi_wlanfw_rf_chip_info_s_v01), 1181 .array_type = NO_ARRAY, 1182 .tlv_type = 0x10, 1183 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1184 chip_info), 1185 .ei_array = qmi_wlanfw_rf_chip_info_s_v01_ei, 1186 }, 1187 { 1188 .data_type = QMI_OPT_FLAG, 1189 .elem_len = 1, 1190 .elem_size = sizeof(u8), 1191 .array_type = NO_ARRAY, 1192 .tlv_type = 0x11, 1193 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1194 board_info_valid), 1195 }, 1196 { 1197 .data_type = QMI_STRUCT, 1198 .elem_len = 1, 1199 .elem_size = sizeof(struct qmi_wlanfw_rf_board_info_s_v01), 1200 .array_type = NO_ARRAY, 1201 .tlv_type = 0x11, 1202 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1203 board_info), 1204 .ei_array = qmi_wlanfw_rf_board_info_s_v01_ei, 1205 }, 1206 { 1207 .data_type = QMI_OPT_FLAG, 1208 .elem_len = 1, 1209 .elem_size = sizeof(u8), 1210 .array_type = NO_ARRAY, 1211 .tlv_type = 0x12, 1212 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1213 soc_info_valid), 1214 }, 1215 { 1216 .data_type = QMI_STRUCT, 1217 .elem_len = 1, 1218 .elem_size = sizeof(struct qmi_wlanfw_soc_info_s_v01), 1219 .array_type = NO_ARRAY, 1220 .tlv_type = 0x12, 1221 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1222 soc_info), 1223 .ei_array = qmi_wlanfw_soc_info_s_v01_ei, 1224 }, 1225 { 1226 .data_type = QMI_OPT_FLAG, 1227 .elem_len = 1, 1228 .elem_size = sizeof(u8), 1229 .array_type = NO_ARRAY, 1230 .tlv_type = 0x13, 1231 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1232 fw_version_info_valid), 1233 }, 1234 { 1235 .data_type = QMI_STRUCT, 1236 .elem_len = 1, 1237 .elem_size = sizeof(struct qmi_wlanfw_fw_version_info_s_v01), 1238 .array_type = NO_ARRAY, 1239 .tlv_type = 0x13, 1240 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1241 fw_version_info), 1242 .ei_array = qmi_wlanfw_fw_version_info_s_v01_ei, 1243 }, 1244 { 1245 .data_type = QMI_OPT_FLAG, 1246 .elem_len = 1, 1247 .elem_size = sizeof(u8), 1248 .array_type = NO_ARRAY, 1249 .tlv_type = 0x14, 1250 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1251 fw_build_id_valid), 1252 }, 1253 { 1254 .data_type = QMI_STRING, 1255 .elem_len = ATH12K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1, 1256 .elem_size = sizeof(char), 1257 .array_type = NO_ARRAY, 1258 .tlv_type = 0x14, 1259 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1260 fw_build_id), 1261 }, 1262 { 1263 .data_type = QMI_OPT_FLAG, 1264 .elem_len = 1, 1265 .elem_size = sizeof(u8), 1266 .array_type = NO_ARRAY, 1267 .tlv_type = 0x15, 1268 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1269 num_macs_valid), 1270 }, 1271 { 1272 .data_type = QMI_UNSIGNED_1_BYTE, 1273 .elem_len = 1, 1274 .elem_size = sizeof(u8), 1275 .array_type = NO_ARRAY, 1276 .tlv_type = 0x15, 1277 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1278 num_macs), 1279 }, 1280 { 1281 .data_type = QMI_OPT_FLAG, 1282 .elem_len = 1, 1283 .elem_size = sizeof(u8), 1284 .array_type = NO_ARRAY, 1285 .tlv_type = 0x16, 1286 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1287 voltage_mv_valid), 1288 }, 1289 { 1290 .data_type = QMI_UNSIGNED_4_BYTE, 1291 .elem_len = 1, 1292 .elem_size = sizeof(u32), 1293 .array_type = NO_ARRAY, 1294 .tlv_type = 0x16, 1295 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1296 voltage_mv), 1297 }, 1298 { 1299 .data_type = QMI_OPT_FLAG, 1300 .elem_len = 1, 1301 .elem_size = sizeof(u8), 1302 .array_type = NO_ARRAY, 1303 .tlv_type = 0x17, 1304 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1305 time_freq_hz_valid), 1306 }, 1307 { 1308 .data_type = QMI_UNSIGNED_4_BYTE, 1309 .elem_len = 1, 1310 .elem_size = sizeof(u32), 1311 .array_type = NO_ARRAY, 1312 .tlv_type = 0x17, 1313 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1314 time_freq_hz), 1315 }, 1316 { 1317 .data_type = QMI_OPT_FLAG, 1318 .elem_len = 1, 1319 .elem_size = sizeof(u8), 1320 .array_type = NO_ARRAY, 1321 .tlv_type = 0x18, 1322 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1323 otp_version_valid), 1324 }, 1325 { 1326 .data_type = QMI_UNSIGNED_4_BYTE, 1327 .elem_len = 1, 1328 .elem_size = sizeof(u32), 1329 .array_type = NO_ARRAY, 1330 .tlv_type = 0x18, 1331 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1332 otp_version), 1333 }, 1334 { 1335 .data_type = QMI_OPT_FLAG, 1336 .elem_len = 1, 1337 .elem_size = sizeof(u8), 1338 .array_type = NO_ARRAY, 1339 .tlv_type = 0x19, 1340 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1341 eeprom_caldata_read_timeout_valid), 1342 }, 1343 { 1344 .data_type = QMI_UNSIGNED_4_BYTE, 1345 .elem_len = 1, 1346 .elem_size = sizeof(u32), 1347 .array_type = NO_ARRAY, 1348 .tlv_type = 0x19, 1349 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1350 eeprom_caldata_read_timeout), 1351 }, 1352 { 1353 .data_type = QMI_OPT_FLAG, 1354 .elem_len = 1, 1355 .elem_size = sizeof(u8), 1356 .array_type = NO_ARRAY, 1357 .tlv_type = 0x1A, 1358 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1359 fw_caps_valid), 1360 }, 1361 { 1362 .data_type = QMI_UNSIGNED_8_BYTE, 1363 .elem_len = 1, 1364 .elem_size = sizeof(u64), 1365 .array_type = NO_ARRAY, 1366 .tlv_type = 0x1A, 1367 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, fw_caps), 1368 }, 1369 { 1370 .data_type = QMI_OPT_FLAG, 1371 .elem_len = 1, 1372 .elem_size = sizeof(u8), 1373 .array_type = NO_ARRAY, 1374 .tlv_type = 0x1B, 1375 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1376 rd_card_chain_cap_valid), 1377 }, 1378 { 1379 .data_type = QMI_UNSIGNED_4_BYTE, 1380 .elem_len = 1, 1381 .elem_size = sizeof(u32), 1382 .array_type = NO_ARRAY, 1383 .tlv_type = 0x1B, 1384 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1385 rd_card_chain_cap), 1386 }, 1387 { 1388 .data_type = QMI_OPT_FLAG, 1389 .elem_len = 1, 1390 .elem_size = sizeof(u8), 1391 .array_type = NO_ARRAY, 1392 .tlv_type = 0x1C, 1393 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, 1394 dev_mem_info_valid), 1395 }, 1396 { 1397 .data_type = QMI_STRUCT, 1398 .elem_len = ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01, 1399 .elem_size = sizeof(struct qmi_wlanfw_dev_mem_info_s_v01), 1400 .array_type = STATIC_ARRAY, 1401 .tlv_type = 0x1C, 1402 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, dev_mem), 1403 .ei_array = qmi_wlanfw_dev_mem_info_s_v01_ei, 1404 }, 1405 { 1406 .data_type = QMI_EOTI, 1407 .array_type = NO_ARRAY, 1408 .tlv_type = QMI_COMMON_TLV_TYPE, 1409 }, 1410 }; 1411 1412 static const struct qmi_elem_info qmi_wlanfw_bdf_download_req_msg_v01_ei[] = { 1413 { 1414 .data_type = QMI_UNSIGNED_1_BYTE, 1415 .elem_len = 1, 1416 .elem_size = sizeof(u8), 1417 .array_type = NO_ARRAY, 1418 .tlv_type = 0x01, 1419 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1420 valid), 1421 }, 1422 { 1423 .data_type = QMI_OPT_FLAG, 1424 .elem_len = 1, 1425 .elem_size = sizeof(u8), 1426 .array_type = NO_ARRAY, 1427 .tlv_type = 0x10, 1428 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1429 file_id_valid), 1430 }, 1431 { 1432 .data_type = QMI_SIGNED_4_BYTE_ENUM, 1433 .elem_len = 1, 1434 .elem_size = sizeof(enum qmi_wlanfw_cal_temp_id_enum_v01), 1435 .array_type = NO_ARRAY, 1436 .tlv_type = 0x10, 1437 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1438 file_id), 1439 }, 1440 { 1441 .data_type = QMI_OPT_FLAG, 1442 .elem_len = 1, 1443 .elem_size = sizeof(u8), 1444 .array_type = NO_ARRAY, 1445 .tlv_type = 0x11, 1446 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1447 total_size_valid), 1448 }, 1449 { 1450 .data_type = QMI_UNSIGNED_4_BYTE, 1451 .elem_len = 1, 1452 .elem_size = sizeof(u32), 1453 .array_type = NO_ARRAY, 1454 .tlv_type = 0x11, 1455 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1456 total_size), 1457 }, 1458 { 1459 .data_type = QMI_OPT_FLAG, 1460 .elem_len = 1, 1461 .elem_size = sizeof(u8), 1462 .array_type = NO_ARRAY, 1463 .tlv_type = 0x12, 1464 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1465 seg_id_valid), 1466 }, 1467 { 1468 .data_type = QMI_UNSIGNED_4_BYTE, 1469 .elem_len = 1, 1470 .elem_size = sizeof(u32), 1471 .array_type = NO_ARRAY, 1472 .tlv_type = 0x12, 1473 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1474 seg_id), 1475 }, 1476 { 1477 .data_type = QMI_OPT_FLAG, 1478 .elem_len = 1, 1479 .elem_size = sizeof(u8), 1480 .array_type = NO_ARRAY, 1481 .tlv_type = 0x13, 1482 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1483 data_valid), 1484 }, 1485 { 1486 .data_type = QMI_DATA_LEN, 1487 .elem_len = 1, 1488 .elem_size = sizeof(u16), 1489 .array_type = NO_ARRAY, 1490 .tlv_type = 0x13, 1491 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1492 data_len), 1493 }, 1494 { 1495 .data_type = QMI_UNSIGNED_1_BYTE, 1496 .elem_len = QMI_WLANFW_MAX_DATA_SIZE_V01, 1497 .elem_size = sizeof(u8), 1498 .array_type = VAR_LEN_ARRAY, 1499 .tlv_type = 0x13, 1500 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1501 data), 1502 }, 1503 { 1504 .data_type = QMI_OPT_FLAG, 1505 .elem_len = 1, 1506 .elem_size = sizeof(u8), 1507 .array_type = NO_ARRAY, 1508 .tlv_type = 0x14, 1509 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1510 end_valid), 1511 }, 1512 { 1513 .data_type = QMI_UNSIGNED_1_BYTE, 1514 .elem_len = 1, 1515 .elem_size = sizeof(u8), 1516 .array_type = NO_ARRAY, 1517 .tlv_type = 0x14, 1518 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1519 end), 1520 }, 1521 { 1522 .data_type = QMI_OPT_FLAG, 1523 .elem_len = 1, 1524 .elem_size = sizeof(u8), 1525 .array_type = NO_ARRAY, 1526 .tlv_type = 0x15, 1527 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1528 bdf_type_valid), 1529 }, 1530 { 1531 .data_type = QMI_UNSIGNED_1_BYTE, 1532 .elem_len = 1, 1533 .elem_size = sizeof(u8), 1534 .array_type = NO_ARRAY, 1535 .tlv_type = 0x15, 1536 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01, 1537 bdf_type), 1538 }, 1539 1540 { 1541 .data_type = QMI_EOTI, 1542 .array_type = NO_ARRAY, 1543 .tlv_type = QMI_COMMON_TLV_TYPE, 1544 }, 1545 }; 1546 1547 static const struct qmi_elem_info qmi_wlanfw_bdf_download_resp_msg_v01_ei[] = { 1548 { 1549 .data_type = QMI_STRUCT, 1550 .elem_len = 1, 1551 .elem_size = sizeof(struct qmi_response_type_v01), 1552 .array_type = NO_ARRAY, 1553 .tlv_type = 0x02, 1554 .offset = offsetof(struct qmi_wlanfw_bdf_download_resp_msg_v01, 1555 resp), 1556 .ei_array = qmi_response_type_v01_ei, 1557 }, 1558 { 1559 .data_type = QMI_EOTI, 1560 .array_type = NO_ARRAY, 1561 .tlv_type = QMI_COMMON_TLV_TYPE, 1562 }, 1563 }; 1564 1565 static const struct qmi_elem_info qmi_wlanfw_m3_info_req_msg_v01_ei[] = { 1566 { 1567 .data_type = QMI_UNSIGNED_8_BYTE, 1568 .elem_len = 1, 1569 .elem_size = sizeof(u64), 1570 .array_type = NO_ARRAY, 1571 .tlv_type = 0x01, 1572 .offset = offsetof(struct qmi_wlanfw_m3_info_req_msg_v01, addr), 1573 }, 1574 { 1575 .data_type = QMI_UNSIGNED_4_BYTE, 1576 .elem_len = 1, 1577 .elem_size = sizeof(u32), 1578 .array_type = NO_ARRAY, 1579 .tlv_type = 0x02, 1580 .offset = offsetof(struct qmi_wlanfw_m3_info_req_msg_v01, size), 1581 }, 1582 { 1583 .data_type = QMI_EOTI, 1584 .array_type = NO_ARRAY, 1585 .tlv_type = QMI_COMMON_TLV_TYPE, 1586 }, 1587 }; 1588 1589 static const struct qmi_elem_info qmi_wlanfw_m3_info_resp_msg_v01_ei[] = { 1590 { 1591 .data_type = QMI_STRUCT, 1592 .elem_len = 1, 1593 .elem_size = sizeof(struct qmi_response_type_v01), 1594 .array_type = NO_ARRAY, 1595 .tlv_type = 0x02, 1596 .offset = offsetof(struct qmi_wlanfw_m3_info_resp_msg_v01, resp), 1597 .ei_array = qmi_response_type_v01_ei, 1598 }, 1599 { 1600 .data_type = QMI_EOTI, 1601 .array_type = NO_ARRAY, 1602 .tlv_type = QMI_COMMON_TLV_TYPE, 1603 }, 1604 }; 1605 1606 static const struct qmi_elem_info qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei[] = { 1607 { 1608 .data_type = QMI_UNSIGNED_4_BYTE, 1609 .elem_len = 1, 1610 .elem_size = sizeof(u32), 1611 .array_type = NO_ARRAY, 1612 .tlv_type = 0, 1613 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01, 1614 pipe_num), 1615 }, 1616 { 1617 .data_type = QMI_SIGNED_4_BYTE_ENUM, 1618 .elem_len = 1, 1619 .elem_size = sizeof(enum qmi_wlanfw_pipedir_enum_v01), 1620 .array_type = NO_ARRAY, 1621 .tlv_type = 0, 1622 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01, 1623 pipe_dir), 1624 }, 1625 { 1626 .data_type = QMI_UNSIGNED_4_BYTE, 1627 .elem_len = 1, 1628 .elem_size = sizeof(u32), 1629 .array_type = NO_ARRAY, 1630 .tlv_type = 0, 1631 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01, 1632 nentries), 1633 }, 1634 { 1635 .data_type = QMI_UNSIGNED_4_BYTE, 1636 .elem_len = 1, 1637 .elem_size = sizeof(u32), 1638 .array_type = NO_ARRAY, 1639 .tlv_type = 0, 1640 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01, 1641 nbytes_max), 1642 }, 1643 { 1644 .data_type = QMI_UNSIGNED_4_BYTE, 1645 .elem_len = 1, 1646 .elem_size = sizeof(u32), 1647 .array_type = NO_ARRAY, 1648 .tlv_type = 0, 1649 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01, 1650 flags), 1651 }, 1652 { 1653 .data_type = QMI_EOTI, 1654 .array_type = NO_ARRAY, 1655 .tlv_type = QMI_COMMON_TLV_TYPE, 1656 }, 1657 }; 1658 1659 static const struct qmi_elem_info qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei[] = { 1660 { 1661 .data_type = QMI_UNSIGNED_4_BYTE, 1662 .elem_len = 1, 1663 .elem_size = sizeof(u32), 1664 .array_type = NO_ARRAY, 1665 .tlv_type = 0, 1666 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01, 1667 service_id), 1668 }, 1669 { 1670 .data_type = QMI_SIGNED_4_BYTE_ENUM, 1671 .elem_len = 1, 1672 .elem_size = sizeof(enum qmi_wlanfw_pipedir_enum_v01), 1673 .array_type = NO_ARRAY, 1674 .tlv_type = 0, 1675 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01, 1676 pipe_dir), 1677 }, 1678 { 1679 .data_type = QMI_UNSIGNED_4_BYTE, 1680 .elem_len = 1, 1681 .elem_size = sizeof(u32), 1682 .array_type = NO_ARRAY, 1683 .tlv_type = 0, 1684 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01, 1685 pipe_num), 1686 }, 1687 { 1688 .data_type = QMI_EOTI, 1689 .array_type = NO_ARRAY, 1690 .tlv_type = QMI_COMMON_TLV_TYPE, 1691 }, 1692 }; 1693 1694 static const struct qmi_elem_info qmi_wlanfw_shadow_reg_cfg_s_v01_ei[] = { 1695 { 1696 .data_type = QMI_UNSIGNED_2_BYTE, 1697 .elem_len = 1, 1698 .elem_size = sizeof(u16), 1699 .array_type = NO_ARRAY, 1700 .tlv_type = 0, 1701 .offset = offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01, id), 1702 }, 1703 { 1704 .data_type = QMI_UNSIGNED_2_BYTE, 1705 .elem_len = 1, 1706 .elem_size = sizeof(u16), 1707 .array_type = NO_ARRAY, 1708 .tlv_type = 0, 1709 .offset = offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01, 1710 offset), 1711 }, 1712 { 1713 .data_type = QMI_EOTI, 1714 .array_type = QMI_COMMON_TLV_TYPE, 1715 }, 1716 }; 1717 1718 static const struct qmi_elem_info qmi_wlanfw_shadow_reg_v3_cfg_s_v01_ei[] = { 1719 { 1720 .data_type = QMI_UNSIGNED_4_BYTE, 1721 .elem_len = 1, 1722 .elem_size = sizeof(u32), 1723 .array_type = NO_ARRAY, 1724 .tlv_type = 0, 1725 .offset = offsetof(struct qmi_wlanfw_shadow_reg_v3_cfg_s_v01, 1726 addr), 1727 }, 1728 { 1729 .data_type = QMI_EOTI, 1730 .array_type = NO_ARRAY, 1731 .tlv_type = QMI_COMMON_TLV_TYPE, 1732 }, 1733 }; 1734 1735 static const struct qmi_elem_info qmi_wlanfw_wlan_mode_req_msg_v01_ei[] = { 1736 { 1737 .data_type = QMI_UNSIGNED_4_BYTE, 1738 .elem_len = 1, 1739 .elem_size = sizeof(u32), 1740 .array_type = NO_ARRAY, 1741 .tlv_type = 0x01, 1742 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01, 1743 mode), 1744 }, 1745 { 1746 .data_type = QMI_OPT_FLAG, 1747 .elem_len = 1, 1748 .elem_size = sizeof(u8), 1749 .array_type = NO_ARRAY, 1750 .tlv_type = 0x10, 1751 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01, 1752 hw_debug_valid), 1753 }, 1754 { 1755 .data_type = QMI_UNSIGNED_1_BYTE, 1756 .elem_len = 1, 1757 .elem_size = sizeof(u8), 1758 .array_type = NO_ARRAY, 1759 .tlv_type = 0x10, 1760 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01, 1761 hw_debug), 1762 }, 1763 { 1764 .data_type = QMI_EOTI, 1765 .array_type = NO_ARRAY, 1766 .tlv_type = QMI_COMMON_TLV_TYPE, 1767 }, 1768 }; 1769 1770 static const struct qmi_elem_info qmi_wlanfw_wlan_mode_resp_msg_v01_ei[] = { 1771 { 1772 .data_type = QMI_STRUCT, 1773 .elem_len = 1, 1774 .elem_size = sizeof(struct qmi_response_type_v01), 1775 .array_type = NO_ARRAY, 1776 .tlv_type = 0x02, 1777 .offset = offsetof(struct qmi_wlanfw_wlan_mode_resp_msg_v01, 1778 resp), 1779 .ei_array = qmi_response_type_v01_ei, 1780 }, 1781 { 1782 .data_type = QMI_EOTI, 1783 .array_type = NO_ARRAY, 1784 .tlv_type = QMI_COMMON_TLV_TYPE, 1785 }, 1786 }; 1787 1788 static const struct qmi_elem_info qmi_wlanfw_wlan_cfg_req_msg_v01_ei[] = { 1789 { 1790 .data_type = QMI_OPT_FLAG, 1791 .elem_len = 1, 1792 .elem_size = sizeof(u8), 1793 .array_type = NO_ARRAY, 1794 .tlv_type = 0x10, 1795 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1796 host_version_valid), 1797 }, 1798 { 1799 .data_type = QMI_STRING, 1800 .elem_len = QMI_WLANFW_MAX_STR_LEN_V01 + 1, 1801 .elem_size = sizeof(char), 1802 .array_type = NO_ARRAY, 1803 .tlv_type = 0x10, 1804 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1805 host_version), 1806 }, 1807 { 1808 .data_type = QMI_OPT_FLAG, 1809 .elem_len = 1, 1810 .elem_size = sizeof(u8), 1811 .array_type = NO_ARRAY, 1812 .tlv_type = 0x11, 1813 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1814 tgt_cfg_valid), 1815 }, 1816 { 1817 .data_type = QMI_DATA_LEN, 1818 .elem_len = 1, 1819 .elem_size = sizeof(u8), 1820 .array_type = NO_ARRAY, 1821 .tlv_type = 0x11, 1822 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1823 tgt_cfg_len), 1824 }, 1825 { 1826 .data_type = QMI_STRUCT, 1827 .elem_len = QMI_WLANFW_MAX_NUM_CE_V01, 1828 .elem_size = sizeof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01), 1829 .array_type = VAR_LEN_ARRAY, 1830 .tlv_type = 0x11, 1831 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1832 tgt_cfg), 1833 .ei_array = qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei, 1834 }, 1835 { 1836 .data_type = QMI_OPT_FLAG, 1837 .elem_len = 1, 1838 .elem_size = sizeof(u8), 1839 .array_type = NO_ARRAY, 1840 .tlv_type = 0x12, 1841 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1842 svc_cfg_valid), 1843 }, 1844 { 1845 .data_type = QMI_DATA_LEN, 1846 .elem_len = 1, 1847 .elem_size = sizeof(u8), 1848 .array_type = NO_ARRAY, 1849 .tlv_type = 0x12, 1850 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1851 svc_cfg_len), 1852 }, 1853 { 1854 .data_type = QMI_STRUCT, 1855 .elem_len = QMI_WLANFW_MAX_NUM_SVC_V01, 1856 .elem_size = sizeof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01), 1857 .array_type = VAR_LEN_ARRAY, 1858 .tlv_type = 0x12, 1859 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1860 svc_cfg), 1861 .ei_array = qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei, 1862 }, 1863 { 1864 .data_type = QMI_OPT_FLAG, 1865 .elem_len = 1, 1866 .elem_size = sizeof(u8), 1867 .array_type = NO_ARRAY, 1868 .tlv_type = 0x13, 1869 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1870 shadow_reg_valid), 1871 }, 1872 { 1873 .data_type = QMI_DATA_LEN, 1874 .elem_len = 1, 1875 .elem_size = sizeof(u8), 1876 .array_type = NO_ARRAY, 1877 .tlv_type = 0x13, 1878 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1879 shadow_reg_len), 1880 }, 1881 { 1882 .data_type = QMI_STRUCT, 1883 .elem_len = QMI_WLANFW_MAX_NUM_SHADOW_REG_V01, 1884 .elem_size = sizeof(struct qmi_wlanfw_shadow_reg_cfg_s_v01), 1885 .array_type = VAR_LEN_ARRAY, 1886 .tlv_type = 0x13, 1887 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1888 shadow_reg), 1889 .ei_array = qmi_wlanfw_shadow_reg_cfg_s_v01_ei, 1890 }, 1891 { 1892 .data_type = QMI_OPT_FLAG, 1893 .elem_len = 1, 1894 .elem_size = sizeof(u8), 1895 .array_type = NO_ARRAY, 1896 .tlv_type = 0x17, 1897 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1898 shadow_reg_v3_valid), 1899 }, 1900 { 1901 .data_type = QMI_DATA_LEN, 1902 .elem_len = 1, 1903 .elem_size = sizeof(u8), 1904 .array_type = NO_ARRAY, 1905 .tlv_type = 0x17, 1906 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1907 shadow_reg_v3_len), 1908 }, 1909 { 1910 .data_type = QMI_STRUCT, 1911 .elem_len = QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01, 1912 .elem_size = sizeof(struct qmi_wlanfw_shadow_reg_v3_cfg_s_v01), 1913 .array_type = VAR_LEN_ARRAY, 1914 .tlv_type = 0x17, 1915 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01, 1916 shadow_reg_v3), 1917 .ei_array = qmi_wlanfw_shadow_reg_v3_cfg_s_v01_ei, 1918 }, 1919 { 1920 .data_type = QMI_EOTI, 1921 .array_type = NO_ARRAY, 1922 .tlv_type = QMI_COMMON_TLV_TYPE, 1923 }, 1924 }; 1925 1926 static const struct qmi_elem_info qmi_wlanfw_wlan_cfg_resp_msg_v01_ei[] = { 1927 { 1928 .data_type = QMI_STRUCT, 1929 .elem_len = 1, 1930 .elem_size = sizeof(struct qmi_response_type_v01), 1931 .array_type = NO_ARRAY, 1932 .tlv_type = 0x02, 1933 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_resp_msg_v01, resp), 1934 .ei_array = qmi_response_type_v01_ei, 1935 }, 1936 { 1937 .data_type = QMI_EOTI, 1938 .array_type = NO_ARRAY, 1939 .tlv_type = QMI_COMMON_TLV_TYPE, 1940 }, 1941 }; 1942 1943 static const struct qmi_elem_info qmi_wlanfw_mem_ready_ind_msg_v01_ei[] = { 1944 { 1945 .data_type = QMI_EOTI, 1946 .array_type = NO_ARRAY, 1947 }, 1948 }; 1949 1950 static const struct qmi_elem_info qmi_wlanfw_fw_ready_ind_msg_v01_ei[] = { 1951 { 1952 .data_type = QMI_EOTI, 1953 .array_type = NO_ARRAY, 1954 }, 1955 }; 1956 1957 static void ath12k_host_cap_parse_mlo(struct ath12k_base *ab, 1958 struct qmi_wlanfw_host_cap_req_msg_v01 *req) 1959 { 1960 struct wlfw_host_mlo_chip_info_s_v01 *info; 1961 u8 hw_link_id = 0; 1962 int i; 1963 1964 if (!ab->qmi.num_radios || ab->qmi.num_radios == U8_MAX) { 1965 ath12k_dbg(ab, ATH12K_DBG_QMI, 1966 "skip QMI MLO cap due to invalid num_radio %d\n", 1967 ab->qmi.num_radios); 1968 return; 1969 } 1970 1971 req->mlo_capable_valid = 1; 1972 req->mlo_capable = 1; 1973 req->mlo_chip_id_valid = 1; 1974 req->mlo_chip_id = 0; 1975 req->mlo_group_id_valid = 1; 1976 req->mlo_group_id = 0; 1977 req->max_mlo_peer_valid = 1; 1978 /* Max peer number generally won't change for the same device 1979 * but needs to be synced with host driver. 1980 */ 1981 req->max_mlo_peer = ab->hw_params->max_mlo_peer; 1982 req->mlo_num_chips_valid = 1; 1983 req->mlo_num_chips = 1; 1984 1985 info = &req->mlo_chip_info[0]; 1986 info->chip_id = 0; 1987 info->num_local_links = ab->qmi.num_radios; 1988 1989 for (i = 0; i < info->num_local_links; i++) { 1990 info->hw_link_id[i] = hw_link_id; 1991 info->valid_mlo_link_id[i] = 1; 1992 1993 hw_link_id++; 1994 } 1995 1996 req->mlo_chip_info_valid = 1; 1997 } 1998 1999 static int ath12k_qmi_host_cap_send(struct ath12k_base *ab) 2000 { 2001 struct qmi_wlanfw_host_cap_req_msg_v01 req = {}; 2002 struct qmi_wlanfw_host_cap_resp_msg_v01 resp = {}; 2003 struct qmi_txn txn; 2004 int ret = 0; 2005 2006 req.num_clients_valid = 1; 2007 req.num_clients = 1; 2008 req.mem_cfg_mode = ab->qmi.target_mem_mode; 2009 req.mem_cfg_mode_valid = 1; 2010 req.bdf_support_valid = 1; 2011 req.bdf_support = 1; 2012 2013 req.m3_support_valid = 1; 2014 req.m3_support = 1; 2015 req.m3_cache_support_valid = 1; 2016 req.m3_cache_support = 1; 2017 2018 req.cal_done_valid = 1; 2019 req.cal_done = ab->qmi.cal_done; 2020 2021 if (ab->hw_params->qmi_cnss_feature_bitmap) { 2022 req.feature_list_valid = 1; 2023 req.feature_list = ab->hw_params->qmi_cnss_feature_bitmap; 2024 } 2025 2026 /* BRINGUP: here we are piggybacking a lot of stuff using 2027 * internal_sleep_clock, should it be split? 2028 */ 2029 if (ab->hw_params->internal_sleep_clock) { 2030 req.nm_modem_valid = 1; 2031 2032 /* Notify firmware that this is non-qualcomm platform. */ 2033 req.nm_modem |= HOST_CSTATE_BIT; 2034 2035 /* Notify firmware about the sleep clock selection, 2036 * nm_modem_bit[1] is used for this purpose. Host driver on 2037 * non-qualcomm platforms should select internal sleep 2038 * clock. 2039 */ 2040 req.nm_modem |= SLEEP_CLOCK_SELECT_INTERNAL_BIT; 2041 req.nm_modem |= PLATFORM_CAP_PCIE_GLOBAL_RESET; 2042 } 2043 2044 ath12k_host_cap_parse_mlo(ab, &req); 2045 2046 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2047 qmi_wlanfw_host_cap_resp_msg_v01_ei, &resp); 2048 if (ret < 0) 2049 goto out; 2050 2051 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2052 QMI_WLANFW_HOST_CAP_REQ_V01, 2053 QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN, 2054 qmi_wlanfw_host_cap_req_msg_v01_ei, &req); 2055 if (ret < 0) { 2056 qmi_txn_cancel(&txn); 2057 ath12k_warn(ab, "Failed to send host capability request,err = %d\n", ret); 2058 goto out; 2059 } 2060 2061 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2062 if (ret < 0) 2063 goto out; 2064 2065 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2066 ath12k_warn(ab, "Host capability request failed, result: %d, err: %d\n", 2067 resp.resp.result, resp.resp.error); 2068 ret = -EINVAL; 2069 goto out; 2070 } 2071 2072 out: 2073 return ret; 2074 } 2075 2076 static void ath12k_qmi_phy_cap_send(struct ath12k_base *ab) 2077 { 2078 struct qmi_wlanfw_phy_cap_req_msg_v01 req = {}; 2079 struct qmi_wlanfw_phy_cap_resp_msg_v01 resp = {}; 2080 struct qmi_txn txn; 2081 int ret; 2082 2083 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2084 qmi_wlanfw_phy_cap_resp_msg_v01_ei, &resp); 2085 if (ret < 0) 2086 goto out; 2087 2088 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2089 QMI_WLANFW_PHY_CAP_REQ_V01, 2090 QMI_WLANFW_PHY_CAP_REQ_MSG_V01_MAX_LEN, 2091 qmi_wlanfw_phy_cap_req_msg_v01_ei, &req); 2092 if (ret < 0) { 2093 qmi_txn_cancel(&txn); 2094 ath12k_warn(ab, "failed to send phy capability request: %d\n", ret); 2095 goto out; 2096 } 2097 2098 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2099 if (ret < 0) 2100 goto out; 2101 2102 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2103 ret = -EOPNOTSUPP; 2104 goto out; 2105 } 2106 2107 if (!resp.num_phy_valid) { 2108 ret = -ENODATA; 2109 goto out; 2110 } 2111 2112 ab->qmi.num_radios = resp.num_phy; 2113 2114 ath12k_dbg(ab, ATH12K_DBG_QMI, "phy capability resp valid %d num_phy %d valid %d board_id %d\n", 2115 resp.num_phy_valid, resp.num_phy, 2116 resp.board_id_valid, resp.board_id); 2117 2118 return; 2119 2120 out: 2121 /* If PHY capability not advertised then rely on default num link */ 2122 ab->qmi.num_radios = ab->hw_params->def_num_link; 2123 2124 ath12k_dbg(ab, ATH12K_DBG_QMI, 2125 "no valid response from PHY capability, choose default num_phy %d\n", 2126 ab->qmi.num_radios); 2127 } 2128 2129 static int ath12k_qmi_fw_ind_register_send(struct ath12k_base *ab) 2130 { 2131 struct qmi_wlanfw_ind_register_req_msg_v01 *req; 2132 struct qmi_wlanfw_ind_register_resp_msg_v01 *resp; 2133 struct qmi_handle *handle = &ab->qmi.handle; 2134 struct qmi_txn txn; 2135 int ret; 2136 2137 req = kzalloc(sizeof(*req), GFP_KERNEL); 2138 if (!req) 2139 return -ENOMEM; 2140 2141 resp = kzalloc(sizeof(*resp), GFP_KERNEL); 2142 if (!resp) { 2143 ret = -ENOMEM; 2144 goto resp_out; 2145 } 2146 2147 req->client_id_valid = 1; 2148 req->client_id = QMI_WLANFW_CLIENT_ID; 2149 req->fw_ready_enable_valid = 1; 2150 req->fw_ready_enable = 1; 2151 req->request_mem_enable_valid = 1; 2152 req->request_mem_enable = 1; 2153 req->fw_mem_ready_enable_valid = 1; 2154 req->fw_mem_ready_enable = 1; 2155 req->cal_done_enable_valid = 1; 2156 req->cal_done_enable = 1; 2157 req->fw_init_done_enable_valid = 1; 2158 req->fw_init_done_enable = 1; 2159 2160 req->pin_connect_result_enable_valid = 0; 2161 req->pin_connect_result_enable = 0; 2162 2163 ret = qmi_txn_init(handle, &txn, 2164 qmi_wlanfw_ind_register_resp_msg_v01_ei, resp); 2165 if (ret < 0) 2166 goto out; 2167 2168 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2169 QMI_WLANFW_IND_REGISTER_REQ_V01, 2170 QMI_WLANFW_IND_REGISTER_REQ_MSG_V01_MAX_LEN, 2171 qmi_wlanfw_ind_register_req_msg_v01_ei, req); 2172 if (ret < 0) { 2173 qmi_txn_cancel(&txn); 2174 ath12k_warn(ab, "Failed to send indication register request, err = %d\n", 2175 ret); 2176 goto out; 2177 } 2178 2179 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2180 if (ret < 0) { 2181 ath12k_warn(ab, "failed to register fw indication %d\n", ret); 2182 goto out; 2183 } 2184 2185 if (resp->resp.result != QMI_RESULT_SUCCESS_V01) { 2186 ath12k_warn(ab, "FW Ind register request failed, result: %d, err: %d\n", 2187 resp->resp.result, resp->resp.error); 2188 ret = -EINVAL; 2189 goto out; 2190 } 2191 2192 out: 2193 kfree(resp); 2194 resp_out: 2195 kfree(req); 2196 return ret; 2197 } 2198 2199 static int ath12k_qmi_respond_fw_mem_request(struct ath12k_base *ab) 2200 { 2201 struct qmi_wlanfw_respond_mem_req_msg_v01 *req; 2202 struct qmi_wlanfw_respond_mem_resp_msg_v01 resp = {}; 2203 struct qmi_txn txn; 2204 int ret = 0, i; 2205 bool delayed; 2206 2207 req = kzalloc(sizeof(*req), GFP_KERNEL); 2208 if (!req) 2209 return -ENOMEM; 2210 2211 /* Some targets by default request a block of big contiguous 2212 * DMA memory, it's hard to allocate from kernel. So host returns 2213 * failure to firmware and firmware then request multiple blocks of 2214 * small chunk size memory. 2215 */ 2216 if (ab->qmi.target_mem_delayed) { 2217 delayed = true; 2218 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi delays mem_request %d\n", 2219 ab->qmi.mem_seg_count); 2220 } else { 2221 delayed = false; 2222 req->mem_seg_len = ab->qmi.mem_seg_count; 2223 for (i = 0; i < req->mem_seg_len ; i++) { 2224 req->mem_seg[i].addr = ab->qmi.target_mem[i].paddr; 2225 req->mem_seg[i].size = ab->qmi.target_mem[i].size; 2226 req->mem_seg[i].type = ab->qmi.target_mem[i].type; 2227 ath12k_dbg(ab, ATH12K_DBG_QMI, 2228 "qmi req mem_seg[%d] %pad %u %u\n", i, 2229 &ab->qmi.target_mem[i].paddr, 2230 ab->qmi.target_mem[i].size, 2231 ab->qmi.target_mem[i].type); 2232 } 2233 } 2234 2235 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2236 qmi_wlanfw_respond_mem_resp_msg_v01_ei, &resp); 2237 if (ret < 0) 2238 goto out; 2239 2240 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2241 QMI_WLANFW_RESPOND_MEM_REQ_V01, 2242 QMI_WLANFW_RESPOND_MEM_REQ_MSG_V01_MAX_LEN, 2243 qmi_wlanfw_respond_mem_req_msg_v01_ei, req); 2244 if (ret < 0) { 2245 qmi_txn_cancel(&txn); 2246 ath12k_warn(ab, "qmi failed to respond memory request, err = %d\n", 2247 ret); 2248 goto out; 2249 } 2250 2251 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2252 if (ret < 0) { 2253 ath12k_warn(ab, "qmi failed memory request, err = %d\n", ret); 2254 goto out; 2255 } 2256 2257 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2258 /* the error response is expected when 2259 * target_mem_delayed is true. 2260 */ 2261 if (delayed && resp.resp.error == 0) 2262 goto out; 2263 2264 ath12k_warn(ab, "Respond mem req failed, result: %d, err: %d\n", 2265 resp.resp.result, resp.resp.error); 2266 ret = -EINVAL; 2267 goto out; 2268 } 2269 out: 2270 kfree(req); 2271 return ret; 2272 } 2273 2274 static void ath12k_qmi_free_target_mem_chunk(struct ath12k_base *ab) 2275 { 2276 int i; 2277 2278 for (i = 0; i < ab->qmi.mem_seg_count; i++) { 2279 if (!ab->qmi.target_mem[i].v.addr) 2280 continue; 2281 dma_free_coherent(ab->dev, 2282 ab->qmi.target_mem[i].size, 2283 ab->qmi.target_mem[i].v.addr, 2284 ab->qmi.target_mem[i].paddr); 2285 ab->qmi.target_mem[i].v.addr = NULL; 2286 } 2287 } 2288 2289 static int ath12k_qmi_alloc_target_mem_chunk(struct ath12k_base *ab) 2290 { 2291 int i; 2292 struct target_mem_chunk *chunk; 2293 2294 ab->qmi.target_mem_delayed = false; 2295 2296 for (i = 0; i < ab->qmi.mem_seg_count; i++) { 2297 chunk = &ab->qmi.target_mem[i]; 2298 2299 /* Allocate memory for the region and the functionality supported 2300 * on the host. For the non-supported memory region, host does not 2301 * allocate memory, assigns NULL and FW will handle this without crashing. 2302 */ 2303 switch (chunk->type) { 2304 case HOST_DDR_REGION_TYPE: 2305 case M3_DUMP_REGION_TYPE: 2306 case PAGEABLE_MEM_REGION_TYPE: 2307 case CALDB_MEM_REGION_TYPE: 2308 chunk->v.addr = dma_alloc_coherent(ab->dev, 2309 chunk->size, 2310 &chunk->paddr, 2311 GFP_KERNEL | __GFP_NOWARN); 2312 if (!chunk->v.addr) { 2313 if (chunk->size > ATH12K_QMI_MAX_CHUNK_SIZE) { 2314 ab->qmi.target_mem_delayed = true; 2315 ath12k_warn(ab, 2316 "qmi dma allocation failed (%d B type %u), will try later with small size\n", 2317 chunk->size, 2318 chunk->type); 2319 ath12k_qmi_free_target_mem_chunk(ab); 2320 return 0; 2321 } 2322 ath12k_warn(ab, "memory allocation failure for %u size: %d\n", 2323 chunk->type, chunk->size); 2324 return -ENOMEM; 2325 } 2326 break; 2327 default: 2328 ath12k_warn(ab, "memory type %u not supported\n", 2329 chunk->type); 2330 chunk->paddr = 0; 2331 chunk->v.addr = NULL; 2332 break; 2333 } 2334 } 2335 return 0; 2336 } 2337 2338 static int ath12k_qmi_request_target_cap(struct ath12k_base *ab) 2339 { 2340 struct qmi_wlanfw_cap_req_msg_v01 req = {}; 2341 struct qmi_wlanfw_cap_resp_msg_v01 resp = {}; 2342 struct qmi_txn txn; 2343 unsigned int board_id = ATH12K_BOARD_ID_DEFAULT; 2344 int ret = 0; 2345 int r; 2346 int i; 2347 2348 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2349 qmi_wlanfw_cap_resp_msg_v01_ei, &resp); 2350 if (ret < 0) 2351 goto out; 2352 2353 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2354 QMI_WLANFW_CAP_REQ_V01, 2355 QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN, 2356 qmi_wlanfw_cap_req_msg_v01_ei, &req); 2357 if (ret < 0) { 2358 qmi_txn_cancel(&txn); 2359 ath12k_warn(ab, "qmi failed to send target cap request, err = %d\n", 2360 ret); 2361 goto out; 2362 } 2363 2364 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2365 if (ret < 0) { 2366 ath12k_warn(ab, "qmi failed target cap request %d\n", ret); 2367 goto out; 2368 } 2369 2370 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2371 ath12k_warn(ab, "qmi targetcap req failed, result: %d, err: %d\n", 2372 resp.resp.result, resp.resp.error); 2373 ret = -EINVAL; 2374 goto out; 2375 } 2376 2377 if (resp.chip_info_valid) { 2378 ab->qmi.target.chip_id = resp.chip_info.chip_id; 2379 ab->qmi.target.chip_family = resp.chip_info.chip_family; 2380 } 2381 2382 if (resp.board_info_valid) 2383 ab->qmi.target.board_id = resp.board_info.board_id; 2384 else 2385 ab->qmi.target.board_id = board_id; 2386 2387 if (resp.soc_info_valid) 2388 ab->qmi.target.soc_id = resp.soc_info.soc_id; 2389 2390 if (resp.fw_version_info_valid) { 2391 ab->qmi.target.fw_version = resp.fw_version_info.fw_version; 2392 strscpy(ab->qmi.target.fw_build_timestamp, 2393 resp.fw_version_info.fw_build_timestamp, 2394 sizeof(ab->qmi.target.fw_build_timestamp)); 2395 } 2396 2397 if (resp.fw_build_id_valid) 2398 strscpy(ab->qmi.target.fw_build_id, resp.fw_build_id, 2399 sizeof(ab->qmi.target.fw_build_id)); 2400 2401 if (resp.dev_mem_info_valid) { 2402 for (i = 0; i < ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01; i++) { 2403 ab->qmi.dev_mem[i].start = 2404 resp.dev_mem[i].start; 2405 ab->qmi.dev_mem[i].size = 2406 resp.dev_mem[i].size; 2407 ath12k_dbg(ab, ATH12K_DBG_QMI, 2408 "devmem [%d] start ox%llx size %llu\n", i, 2409 ab->qmi.dev_mem[i].start, 2410 ab->qmi.dev_mem[i].size); 2411 } 2412 } 2413 2414 if (resp.eeprom_caldata_read_timeout_valid) { 2415 ab->qmi.target.eeprom_caldata = resp.eeprom_caldata_read_timeout; 2416 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi cal data supported from eeprom\n"); 2417 } 2418 2419 ath12k_info(ab, "chip_id 0x%x chip_family 0x%x board_id 0x%x soc_id 0x%x\n", 2420 ab->qmi.target.chip_id, ab->qmi.target.chip_family, 2421 ab->qmi.target.board_id, ab->qmi.target.soc_id); 2422 2423 ath12k_info(ab, "fw_version 0x%x fw_build_timestamp %s fw_build_id %s", 2424 ab->qmi.target.fw_version, 2425 ab->qmi.target.fw_build_timestamp, 2426 ab->qmi.target.fw_build_id); 2427 2428 r = ath12k_core_check_smbios(ab); 2429 if (r) 2430 ath12k_dbg(ab, ATH12K_DBG_QMI, "SMBIOS bdf variant name not set.\n"); 2431 2432 out: 2433 return ret; 2434 } 2435 2436 static int ath12k_qmi_load_file_target_mem(struct ath12k_base *ab, 2437 const u8 *data, u32 len, u8 type) 2438 { 2439 struct qmi_wlanfw_bdf_download_req_msg_v01 *req; 2440 struct qmi_wlanfw_bdf_download_resp_msg_v01 resp = {}; 2441 struct qmi_txn txn; 2442 const u8 *temp = data; 2443 int ret; 2444 u32 remaining = len; 2445 2446 req = kzalloc(sizeof(*req), GFP_KERNEL); 2447 if (!req) 2448 return -ENOMEM; 2449 2450 while (remaining) { 2451 req->valid = 1; 2452 req->file_id_valid = 1; 2453 req->file_id = ab->qmi.target.board_id; 2454 req->total_size_valid = 1; 2455 req->total_size = remaining; 2456 req->seg_id_valid = 1; 2457 req->data_valid = 1; 2458 req->bdf_type = type; 2459 req->bdf_type_valid = 1; 2460 req->end_valid = 1; 2461 req->end = 0; 2462 2463 if (remaining > QMI_WLANFW_MAX_DATA_SIZE_V01) { 2464 req->data_len = QMI_WLANFW_MAX_DATA_SIZE_V01; 2465 } else { 2466 req->data_len = remaining; 2467 req->end = 1; 2468 } 2469 2470 if (type == ATH12K_QMI_FILE_TYPE_EEPROM) { 2471 req->data_valid = 0; 2472 req->end = 1; 2473 req->data_len = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE; 2474 } else { 2475 memcpy(req->data, temp, req->data_len); 2476 } 2477 2478 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2479 qmi_wlanfw_bdf_download_resp_msg_v01_ei, 2480 &resp); 2481 if (ret < 0) 2482 goto out; 2483 2484 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi bdf download req fixed addr type %d\n", 2485 type); 2486 2487 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2488 QMI_WLANFW_BDF_DOWNLOAD_REQ_V01, 2489 QMI_WLANFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_LEN, 2490 qmi_wlanfw_bdf_download_req_msg_v01_ei, req); 2491 if (ret < 0) { 2492 qmi_txn_cancel(&txn); 2493 goto out; 2494 } 2495 2496 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2497 if (ret < 0) 2498 goto out; 2499 2500 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2501 ath12k_warn(ab, "qmi BDF download failed, result: %d, err: %d\n", 2502 resp.resp.result, resp.resp.error); 2503 ret = -EINVAL; 2504 goto out; 2505 } 2506 2507 if (type == ATH12K_QMI_FILE_TYPE_EEPROM) { 2508 remaining = 0; 2509 } else { 2510 remaining -= req->data_len; 2511 temp += req->data_len; 2512 req->seg_id++; 2513 ath12k_dbg(ab, ATH12K_DBG_QMI, 2514 "qmi bdf download request remaining %i\n", 2515 remaining); 2516 } 2517 } 2518 2519 out: 2520 kfree(req); 2521 return ret; 2522 } 2523 2524 static int ath12k_qmi_load_bdf_qmi(struct ath12k_base *ab, 2525 enum ath12k_qmi_bdf_type type) 2526 { 2527 struct device *dev = ab->dev; 2528 char filename[ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE]; 2529 const struct firmware *fw_entry; 2530 struct ath12k_board_data bd; 2531 u32 fw_size, file_type; 2532 int ret = 0; 2533 const u8 *tmp; 2534 2535 memset(&bd, 0, sizeof(bd)); 2536 2537 switch (type) { 2538 case ATH12K_QMI_BDF_TYPE_ELF: 2539 ret = ath12k_core_fetch_bdf(ab, &bd); 2540 if (ret) { 2541 ath12k_warn(ab, "qmi failed to load bdf:\n"); 2542 goto out; 2543 } 2544 2545 if (bd.len >= SELFMAG && memcmp(bd.data, ELFMAG, SELFMAG) == 0) 2546 type = ATH12K_QMI_BDF_TYPE_ELF; 2547 else 2548 type = ATH12K_QMI_BDF_TYPE_BIN; 2549 2550 break; 2551 case ATH12K_QMI_BDF_TYPE_REGDB: 2552 ret = ath12k_core_fetch_regdb(ab, &bd); 2553 if (ret) { 2554 ath12k_warn(ab, "qmi failed to load regdb bin:\n"); 2555 goto out; 2556 } 2557 break; 2558 case ATH12K_QMI_BDF_TYPE_CALIBRATION: 2559 2560 if (ab->qmi.target.eeprom_caldata) { 2561 file_type = ATH12K_QMI_FILE_TYPE_EEPROM; 2562 tmp = filename; 2563 fw_size = ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE; 2564 } else { 2565 file_type = ATH12K_QMI_FILE_TYPE_CALDATA; 2566 2567 /* cal-<bus>-<id>.bin */ 2568 snprintf(filename, sizeof(filename), "cal-%s-%s.bin", 2569 ath12k_bus_str(ab->hif.bus), dev_name(dev)); 2570 fw_entry = ath12k_core_firmware_request(ab, filename); 2571 if (!IS_ERR(fw_entry)) 2572 goto success; 2573 2574 fw_entry = ath12k_core_firmware_request(ab, 2575 ATH12K_DEFAULT_CAL_FILE); 2576 if (IS_ERR(fw_entry)) { 2577 ret = PTR_ERR(fw_entry); 2578 ath12k_warn(ab, 2579 "qmi failed to load CAL data file:%s\n", 2580 filename); 2581 goto out; 2582 } 2583 2584 success: 2585 fw_size = min_t(u32, ab->hw_params->fw.board_size, 2586 fw_entry->size); 2587 tmp = fw_entry->data; 2588 } 2589 ret = ath12k_qmi_load_file_target_mem(ab, tmp, fw_size, file_type); 2590 if (ret < 0) { 2591 ath12k_warn(ab, "qmi failed to load caldata\n"); 2592 goto out_qmi_cal; 2593 } 2594 2595 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi caldata downloaded: type: %u\n", 2596 file_type); 2597 2598 out_qmi_cal: 2599 if (!ab->qmi.target.eeprom_caldata) 2600 release_firmware(fw_entry); 2601 return ret; 2602 default: 2603 ath12k_warn(ab, "unknown file type for load %d", type); 2604 goto out; 2605 } 2606 2607 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi bdf_type %d\n", type); 2608 2609 fw_size = min_t(u32, ab->hw_params->fw.board_size, bd.len); 2610 2611 ret = ath12k_qmi_load_file_target_mem(ab, bd.data, fw_size, type); 2612 if (ret < 0) 2613 ath12k_warn(ab, "qmi failed to load bdf file\n"); 2614 2615 out: 2616 ath12k_core_free_bdf(ab, &bd); 2617 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi BDF download sequence completed\n"); 2618 2619 return ret; 2620 } 2621 2622 static int ath12k_qmi_m3_load(struct ath12k_base *ab) 2623 { 2624 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; 2625 const struct firmware *fw; 2626 char path[100]; 2627 int ret; 2628 2629 if (m3_mem->vaddr || m3_mem->size) 2630 return 0; 2631 2632 fw = ath12k_core_firmware_request(ab, ATH12K_M3_FILE); 2633 if (IS_ERR(fw)) { 2634 ret = PTR_ERR(fw); 2635 ath12k_core_create_firmware_path(ab, ATH12K_M3_FILE, 2636 path, sizeof(path)); 2637 ath12k_err(ab, "failed to load %s: %d\n", path, ret); 2638 return ret; 2639 } 2640 2641 m3_mem->vaddr = dma_alloc_coherent(ab->dev, 2642 fw->size, &m3_mem->paddr, 2643 GFP_KERNEL); 2644 if (!m3_mem->vaddr) { 2645 ath12k_err(ab, "failed to allocate memory for M3 with size %zu\n", 2646 fw->size); 2647 release_firmware(fw); 2648 return -ENOMEM; 2649 } 2650 2651 memcpy(m3_mem->vaddr, fw->data, fw->size); 2652 m3_mem->size = fw->size; 2653 release_firmware(fw); 2654 2655 return 0; 2656 } 2657 2658 static void ath12k_qmi_m3_free(struct ath12k_base *ab) 2659 { 2660 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; 2661 2662 if (!m3_mem->vaddr) 2663 return; 2664 2665 dma_free_coherent(ab->dev, m3_mem->size, 2666 m3_mem->vaddr, m3_mem->paddr); 2667 m3_mem->vaddr = NULL; 2668 m3_mem->size = 0; 2669 } 2670 2671 static int ath12k_qmi_wlanfw_m3_info_send(struct ath12k_base *ab) 2672 { 2673 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem; 2674 struct qmi_wlanfw_m3_info_req_msg_v01 req = {}; 2675 struct qmi_wlanfw_m3_info_resp_msg_v01 resp = {}; 2676 struct qmi_txn txn; 2677 int ret = 0; 2678 2679 ret = ath12k_qmi_m3_load(ab); 2680 if (ret) { 2681 ath12k_err(ab, "failed to load m3 firmware: %d", ret); 2682 return ret; 2683 } 2684 2685 req.addr = m3_mem->paddr; 2686 req.size = m3_mem->size; 2687 2688 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2689 qmi_wlanfw_m3_info_resp_msg_v01_ei, &resp); 2690 if (ret < 0) 2691 goto out; 2692 2693 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2694 QMI_WLANFW_M3_INFO_REQ_V01, 2695 QMI_WLANFW_M3_INFO_REQ_MSG_V01_MAX_MSG_LEN, 2696 qmi_wlanfw_m3_info_req_msg_v01_ei, &req); 2697 if (ret < 0) { 2698 qmi_txn_cancel(&txn); 2699 ath12k_warn(ab, "qmi failed to send M3 information request, err = %d\n", 2700 ret); 2701 goto out; 2702 } 2703 2704 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2705 if (ret < 0) { 2706 ath12k_warn(ab, "qmi failed M3 information request %d\n", ret); 2707 goto out; 2708 } 2709 2710 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2711 ath12k_warn(ab, "qmi M3 info request failed, result: %d, err: %d\n", 2712 resp.resp.result, resp.resp.error); 2713 ret = -EINVAL; 2714 goto out; 2715 } 2716 out: 2717 return ret; 2718 } 2719 2720 static int ath12k_qmi_wlanfw_mode_send(struct ath12k_base *ab, 2721 u32 mode) 2722 { 2723 struct qmi_wlanfw_wlan_mode_req_msg_v01 req = {}; 2724 struct qmi_wlanfw_wlan_mode_resp_msg_v01 resp = {}; 2725 struct qmi_txn txn; 2726 int ret = 0; 2727 2728 req.mode = mode; 2729 req.hw_debug_valid = 1; 2730 req.hw_debug = 0; 2731 2732 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2733 qmi_wlanfw_wlan_mode_resp_msg_v01_ei, &resp); 2734 if (ret < 0) 2735 goto out; 2736 2737 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2738 QMI_WLANFW_WLAN_MODE_REQ_V01, 2739 QMI_WLANFW_WLAN_MODE_REQ_MSG_V01_MAX_LEN, 2740 qmi_wlanfw_wlan_mode_req_msg_v01_ei, &req); 2741 if (ret < 0) { 2742 qmi_txn_cancel(&txn); 2743 ath12k_warn(ab, "qmi failed to send mode request, mode: %d, err = %d\n", 2744 mode, ret); 2745 goto out; 2746 } 2747 2748 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2749 if (ret < 0) { 2750 if (mode == ATH12K_FIRMWARE_MODE_OFF && ret == -ENETRESET) { 2751 ath12k_warn(ab, "WLFW service is dis-connected\n"); 2752 return 0; 2753 } 2754 ath12k_warn(ab, "qmi failed set mode request, mode: %d, err = %d\n", 2755 mode, ret); 2756 goto out; 2757 } 2758 2759 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2760 ath12k_warn(ab, "Mode request failed, mode: %d, result: %d err: %d\n", 2761 mode, resp.resp.result, resp.resp.error); 2762 ret = -EINVAL; 2763 goto out; 2764 } 2765 2766 out: 2767 return ret; 2768 } 2769 2770 static int ath12k_qmi_wlanfw_wlan_cfg_send(struct ath12k_base *ab) 2771 { 2772 struct qmi_wlanfw_wlan_cfg_req_msg_v01 *req; 2773 struct qmi_wlanfw_wlan_cfg_resp_msg_v01 resp = {}; 2774 struct ce_pipe_config *ce_cfg; 2775 struct service_to_pipe *svc_cfg; 2776 struct qmi_txn txn; 2777 int ret = 0, pipe_num; 2778 2779 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce; 2780 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map; 2781 2782 req = kzalloc(sizeof(*req), GFP_KERNEL); 2783 if (!req) 2784 return -ENOMEM; 2785 2786 req->host_version_valid = 1; 2787 strscpy(req->host_version, ATH12K_HOST_VERSION_STRING, 2788 sizeof(req->host_version)); 2789 2790 req->tgt_cfg_valid = 1; 2791 /* This is number of CE configs */ 2792 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len; 2793 for (pipe_num = 0; pipe_num < req->tgt_cfg_len ; pipe_num++) { 2794 req->tgt_cfg[pipe_num].pipe_num = ce_cfg[pipe_num].pipenum; 2795 req->tgt_cfg[pipe_num].pipe_dir = ce_cfg[pipe_num].pipedir; 2796 req->tgt_cfg[pipe_num].nentries = ce_cfg[pipe_num].nentries; 2797 req->tgt_cfg[pipe_num].nbytes_max = ce_cfg[pipe_num].nbytes_max; 2798 req->tgt_cfg[pipe_num].flags = ce_cfg[pipe_num].flags; 2799 } 2800 2801 req->svc_cfg_valid = 1; 2802 /* This is number of Service/CE configs */ 2803 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len; 2804 for (pipe_num = 0; pipe_num < req->svc_cfg_len; pipe_num++) { 2805 req->svc_cfg[pipe_num].service_id = svc_cfg[pipe_num].service_id; 2806 req->svc_cfg[pipe_num].pipe_dir = svc_cfg[pipe_num].pipedir; 2807 req->svc_cfg[pipe_num].pipe_num = svc_cfg[pipe_num].pipenum; 2808 } 2809 2810 /* set shadow v3 configuration */ 2811 if (ab->hw_params->supports_shadow_regs) { 2812 req->shadow_reg_v3_valid = 1; 2813 req->shadow_reg_v3_len = min_t(u32, 2814 ab->qmi.ce_cfg.shadow_reg_v3_len, 2815 QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01); 2816 memcpy(&req->shadow_reg_v3, ab->qmi.ce_cfg.shadow_reg_v3, 2817 sizeof(u32) * req->shadow_reg_v3_len); 2818 } else { 2819 req->shadow_reg_v3_valid = 0; 2820 } 2821 2822 ret = qmi_txn_init(&ab->qmi.handle, &txn, 2823 qmi_wlanfw_wlan_cfg_resp_msg_v01_ei, &resp); 2824 if (ret < 0) 2825 goto out; 2826 2827 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn, 2828 QMI_WLANFW_WLAN_CFG_REQ_V01, 2829 QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN, 2830 qmi_wlanfw_wlan_cfg_req_msg_v01_ei, req); 2831 if (ret < 0) { 2832 qmi_txn_cancel(&txn); 2833 ath12k_warn(ab, "qmi failed to send wlan config request, err = %d\n", 2834 ret); 2835 goto out; 2836 } 2837 2838 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH12K_QMI_WLANFW_TIMEOUT_MS)); 2839 if (ret < 0) { 2840 ath12k_warn(ab, "qmi failed wlan config request, err = %d\n", ret); 2841 goto out; 2842 } 2843 2844 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) { 2845 ath12k_warn(ab, "qmi wlan config request failed, result: %d, err: %d\n", 2846 resp.resp.result, resp.resp.error); 2847 ret = -EINVAL; 2848 goto out; 2849 } 2850 2851 out: 2852 kfree(req); 2853 return ret; 2854 } 2855 2856 void ath12k_qmi_firmware_stop(struct ath12k_base *ab) 2857 { 2858 int ret; 2859 2860 ret = ath12k_qmi_wlanfw_mode_send(ab, ATH12K_FIRMWARE_MODE_OFF); 2861 if (ret < 0) { 2862 ath12k_warn(ab, "qmi failed to send wlan mode off\n"); 2863 return; 2864 } 2865 } 2866 2867 int ath12k_qmi_firmware_start(struct ath12k_base *ab, 2868 u32 mode) 2869 { 2870 int ret; 2871 2872 ret = ath12k_qmi_wlanfw_wlan_cfg_send(ab); 2873 if (ret < 0) { 2874 ath12k_warn(ab, "qmi failed to send wlan cfg:%d\n", ret); 2875 return ret; 2876 } 2877 2878 ret = ath12k_qmi_wlanfw_mode_send(ab, mode); 2879 if (ret < 0) { 2880 ath12k_warn(ab, "qmi failed to send wlan fw mode:%d\n", ret); 2881 return ret; 2882 } 2883 2884 return 0; 2885 } 2886 2887 static int 2888 ath12k_qmi_driver_event_post(struct ath12k_qmi *qmi, 2889 enum ath12k_qmi_event_type type, 2890 void *data) 2891 { 2892 struct ath12k_qmi_driver_event *event; 2893 2894 event = kzalloc(sizeof(*event), GFP_ATOMIC); 2895 if (!event) 2896 return -ENOMEM; 2897 2898 event->type = type; 2899 event->data = data; 2900 2901 spin_lock(&qmi->event_lock); 2902 list_add_tail(&event->list, &qmi->event_list); 2903 spin_unlock(&qmi->event_lock); 2904 2905 queue_work(qmi->event_wq, &qmi->event_work); 2906 2907 return 0; 2908 } 2909 2910 static int ath12k_qmi_event_server_arrive(struct ath12k_qmi *qmi) 2911 { 2912 struct ath12k_base *ab = qmi->ab; 2913 int ret; 2914 2915 ath12k_qmi_phy_cap_send(ab); 2916 2917 ret = ath12k_qmi_fw_ind_register_send(ab); 2918 if (ret < 0) { 2919 ath12k_warn(ab, "qmi failed to send FW indication QMI:%d\n", ret); 2920 return ret; 2921 } 2922 2923 ret = ath12k_qmi_host_cap_send(ab); 2924 if (ret < 0) { 2925 ath12k_warn(ab, "qmi failed to send host cap QMI:%d\n", ret); 2926 return ret; 2927 } 2928 2929 return ret; 2930 } 2931 2932 static int ath12k_qmi_event_mem_request(struct ath12k_qmi *qmi) 2933 { 2934 struct ath12k_base *ab = qmi->ab; 2935 int ret; 2936 2937 ret = ath12k_qmi_respond_fw_mem_request(ab); 2938 if (ret < 0) { 2939 ath12k_warn(ab, "qmi failed to respond fw mem req:%d\n", ret); 2940 return ret; 2941 } 2942 2943 return ret; 2944 } 2945 2946 static int ath12k_qmi_event_load_bdf(struct ath12k_qmi *qmi) 2947 { 2948 struct ath12k_base *ab = qmi->ab; 2949 int ret; 2950 2951 ret = ath12k_qmi_request_target_cap(ab); 2952 if (ret < 0) { 2953 ath12k_warn(ab, "qmi failed to req target capabilities:%d\n", ret); 2954 return ret; 2955 } 2956 2957 ret = ath12k_qmi_load_bdf_qmi(ab, ATH12K_QMI_BDF_TYPE_REGDB); 2958 if (ret < 0) { 2959 ath12k_warn(ab, "qmi failed to load regdb file:%d\n", ret); 2960 return ret; 2961 } 2962 2963 ret = ath12k_qmi_load_bdf_qmi(ab, ATH12K_QMI_BDF_TYPE_ELF); 2964 if (ret < 0) { 2965 ath12k_warn(ab, "qmi failed to load board data file:%d\n", ret); 2966 return ret; 2967 } 2968 2969 if (ab->hw_params->download_calib) { 2970 ret = ath12k_qmi_load_bdf_qmi(ab, ATH12K_QMI_BDF_TYPE_CALIBRATION); 2971 if (ret < 0) 2972 ath12k_warn(ab, "qmi failed to load calibrated data :%d\n", ret); 2973 } 2974 2975 ret = ath12k_qmi_wlanfw_m3_info_send(ab); 2976 if (ret < 0) { 2977 ath12k_warn(ab, "qmi failed to send m3 info req:%d\n", ret); 2978 return ret; 2979 } 2980 2981 return ret; 2982 } 2983 2984 static void ath12k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl, 2985 struct sockaddr_qrtr *sq, 2986 struct qmi_txn *txn, 2987 const void *data) 2988 { 2989 struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle); 2990 struct ath12k_base *ab = qmi->ab; 2991 const struct qmi_wlanfw_request_mem_ind_msg_v01 *msg = data; 2992 int i, ret; 2993 2994 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi firmware request memory request\n"); 2995 2996 if (msg->mem_seg_len == 0 || 2997 msg->mem_seg_len > ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01) 2998 ath12k_warn(ab, "Invalid memory segment length: %u\n", 2999 msg->mem_seg_len); 3000 3001 ab->qmi.mem_seg_count = msg->mem_seg_len; 3002 3003 for (i = 0; i < qmi->mem_seg_count ; i++) { 3004 ab->qmi.target_mem[i].type = msg->mem_seg[i].type; 3005 ab->qmi.target_mem[i].size = msg->mem_seg[i].size; 3006 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi mem seg type %d size %d\n", 3007 msg->mem_seg[i].type, msg->mem_seg[i].size); 3008 } 3009 3010 ret = ath12k_qmi_alloc_target_mem_chunk(ab); 3011 if (ret) { 3012 ath12k_warn(ab, "qmi failed to alloc target memory: %d\n", 3013 ret); 3014 return; 3015 } 3016 3017 ath12k_qmi_driver_event_post(qmi, ATH12K_QMI_EVENT_REQUEST_MEM, NULL); 3018 } 3019 3020 static void ath12k_qmi_msg_mem_ready_cb(struct qmi_handle *qmi_hdl, 3021 struct sockaddr_qrtr *sq, 3022 struct qmi_txn *txn, 3023 const void *decoded) 3024 { 3025 struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle); 3026 struct ath12k_base *ab = qmi->ab; 3027 3028 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi firmware memory ready indication\n"); 3029 ath12k_qmi_driver_event_post(qmi, ATH12K_QMI_EVENT_FW_MEM_READY, NULL); 3030 } 3031 3032 static void ath12k_qmi_msg_fw_ready_cb(struct qmi_handle *qmi_hdl, 3033 struct sockaddr_qrtr *sq, 3034 struct qmi_txn *txn, 3035 const void *decoded) 3036 { 3037 struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle); 3038 struct ath12k_base *ab = qmi->ab; 3039 3040 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi firmware ready\n"); 3041 ath12k_qmi_driver_event_post(qmi, ATH12K_QMI_EVENT_FW_READY, NULL); 3042 } 3043 3044 static const struct qmi_msg_handler ath12k_qmi_msg_handlers[] = { 3045 { 3046 .type = QMI_INDICATION, 3047 .msg_id = QMI_WLFW_REQUEST_MEM_IND_V01, 3048 .ei = qmi_wlanfw_request_mem_ind_msg_v01_ei, 3049 .decoded_size = sizeof(struct qmi_wlanfw_request_mem_ind_msg_v01), 3050 .fn = ath12k_qmi_msg_mem_request_cb, 3051 }, 3052 { 3053 .type = QMI_INDICATION, 3054 .msg_id = QMI_WLFW_FW_MEM_READY_IND_V01, 3055 .ei = qmi_wlanfw_mem_ready_ind_msg_v01_ei, 3056 .decoded_size = sizeof(struct qmi_wlanfw_fw_mem_ready_ind_msg_v01), 3057 .fn = ath12k_qmi_msg_mem_ready_cb, 3058 }, 3059 { 3060 .type = QMI_INDICATION, 3061 .msg_id = QMI_WLFW_FW_READY_IND_V01, 3062 .ei = qmi_wlanfw_fw_ready_ind_msg_v01_ei, 3063 .decoded_size = sizeof(struct qmi_wlanfw_fw_ready_ind_msg_v01), 3064 .fn = ath12k_qmi_msg_fw_ready_cb, 3065 }, 3066 }; 3067 3068 static int ath12k_qmi_ops_new_server(struct qmi_handle *qmi_hdl, 3069 struct qmi_service *service) 3070 { 3071 struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle); 3072 struct ath12k_base *ab = qmi->ab; 3073 struct sockaddr_qrtr *sq = &qmi->sq; 3074 int ret; 3075 3076 sq->sq_family = AF_QIPCRTR; 3077 sq->sq_node = service->node; 3078 sq->sq_port = service->port; 3079 3080 ret = kernel_connect(qmi_hdl->sock, (struct sockaddr *)sq, 3081 sizeof(*sq), 0); 3082 if (ret) { 3083 ath12k_warn(ab, "qmi failed to connect to remote service %d\n", ret); 3084 return ret; 3085 } 3086 3087 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi wifi fw qmi service connected\n"); 3088 ath12k_qmi_driver_event_post(qmi, ATH12K_QMI_EVENT_SERVER_ARRIVE, NULL); 3089 3090 return ret; 3091 } 3092 3093 static void ath12k_qmi_ops_del_server(struct qmi_handle *qmi_hdl, 3094 struct qmi_service *service) 3095 { 3096 struct ath12k_qmi *qmi = container_of(qmi_hdl, struct ath12k_qmi, handle); 3097 struct ath12k_base *ab = qmi->ab; 3098 3099 ath12k_dbg(ab, ATH12K_DBG_QMI, "qmi wifi fw del server\n"); 3100 ath12k_qmi_driver_event_post(qmi, ATH12K_QMI_EVENT_SERVER_EXIT, NULL); 3101 } 3102 3103 static const struct qmi_ops ath12k_qmi_ops = { 3104 .new_server = ath12k_qmi_ops_new_server, 3105 .del_server = ath12k_qmi_ops_del_server, 3106 }; 3107 3108 static void ath12k_qmi_driver_event_work(struct work_struct *work) 3109 { 3110 struct ath12k_qmi *qmi = container_of(work, struct ath12k_qmi, 3111 event_work); 3112 struct ath12k_qmi_driver_event *event; 3113 struct ath12k_base *ab = qmi->ab; 3114 int ret; 3115 3116 spin_lock(&qmi->event_lock); 3117 while (!list_empty(&qmi->event_list)) { 3118 event = list_first_entry(&qmi->event_list, 3119 struct ath12k_qmi_driver_event, list); 3120 list_del(&event->list); 3121 spin_unlock(&qmi->event_lock); 3122 3123 if (test_bit(ATH12K_FLAG_UNREGISTERING, &ab->dev_flags)) 3124 goto skip; 3125 3126 switch (event->type) { 3127 case ATH12K_QMI_EVENT_SERVER_ARRIVE: 3128 ret = ath12k_qmi_event_server_arrive(qmi); 3129 if (ret < 0) 3130 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); 3131 break; 3132 case ATH12K_QMI_EVENT_SERVER_EXIT: 3133 set_bit(ATH12K_FLAG_CRASH_FLUSH, &ab->dev_flags); 3134 set_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); 3135 break; 3136 case ATH12K_QMI_EVENT_REQUEST_MEM: 3137 ret = ath12k_qmi_event_mem_request(qmi); 3138 if (ret < 0) 3139 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); 3140 break; 3141 case ATH12K_QMI_EVENT_FW_MEM_READY: 3142 ret = ath12k_qmi_event_load_bdf(qmi); 3143 if (ret < 0) 3144 set_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); 3145 break; 3146 case ATH12K_QMI_EVENT_FW_READY: 3147 clear_bit(ATH12K_FLAG_QMI_FAIL, &ab->dev_flags); 3148 if (test_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags)) { 3149 ath12k_hal_dump_srng_stats(ab); 3150 queue_work(ab->workqueue, &ab->restart_work); 3151 break; 3152 } 3153 3154 clear_bit(ATH12K_FLAG_CRASH_FLUSH, 3155 &ab->dev_flags); 3156 clear_bit(ATH12K_FLAG_RECOVERY, &ab->dev_flags); 3157 ath12k_core_qmi_firmware_ready(ab); 3158 set_bit(ATH12K_FLAG_REGISTERED, &ab->dev_flags); 3159 3160 break; 3161 default: 3162 ath12k_warn(ab, "invalid event type: %d", event->type); 3163 break; 3164 } 3165 3166 skip: 3167 kfree(event); 3168 spin_lock(&qmi->event_lock); 3169 } 3170 spin_unlock(&qmi->event_lock); 3171 } 3172 3173 int ath12k_qmi_init_service(struct ath12k_base *ab) 3174 { 3175 int ret; 3176 3177 memset(&ab->qmi.target, 0, sizeof(struct target_info)); 3178 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk)); 3179 ab->qmi.ab = ab; 3180 3181 ab->qmi.target_mem_mode = ATH12K_QMI_TARGET_MEM_MODE_DEFAULT; 3182 ret = qmi_handle_init(&ab->qmi.handle, ATH12K_QMI_RESP_LEN_MAX, 3183 &ath12k_qmi_ops, ath12k_qmi_msg_handlers); 3184 if (ret < 0) { 3185 ath12k_warn(ab, "failed to initialize qmi handle\n"); 3186 return ret; 3187 } 3188 3189 ab->qmi.event_wq = alloc_ordered_workqueue("ath12k_qmi_driver_event", 0); 3190 if (!ab->qmi.event_wq) { 3191 ath12k_err(ab, "failed to allocate workqueue\n"); 3192 return -EFAULT; 3193 } 3194 3195 INIT_LIST_HEAD(&ab->qmi.event_list); 3196 spin_lock_init(&ab->qmi.event_lock); 3197 INIT_WORK(&ab->qmi.event_work, ath12k_qmi_driver_event_work); 3198 3199 ret = qmi_add_lookup(&ab->qmi.handle, ATH12K_QMI_WLFW_SERVICE_ID_V01, 3200 ATH12K_QMI_WLFW_SERVICE_VERS_V01, 3201 ab->qmi.service_ins_id); 3202 if (ret < 0) { 3203 ath12k_warn(ab, "failed to add qmi lookup\n"); 3204 destroy_workqueue(ab->qmi.event_wq); 3205 return ret; 3206 } 3207 3208 return ret; 3209 } 3210 3211 void ath12k_qmi_deinit_service(struct ath12k_base *ab) 3212 { 3213 qmi_handle_release(&ab->qmi.handle); 3214 cancel_work_sync(&ab->qmi.event_work); 3215 destroy_workqueue(ab->qmi.event_wq); 3216 ath12k_qmi_m3_free(ab); 3217 ath12k_qmi_free_target_mem_chunk(ab); 3218 } 3219 3220 void ath12k_qmi_free_resource(struct ath12k_base *ab) 3221 { 3222 ath12k_qmi_free_target_mem_chunk(ab); 3223 ath12k_qmi_m3_free(ab); 3224 } 3225