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