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