| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * skl-sst-ipc.c - Intel skl IPC Support |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2014-15, Intel Corporation. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License as version 2, as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, but |
|---|
| 11 | | - * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 13 | | - * General Public License for more details. |
|---|
| 14 | 6 | */ |
|---|
| 15 | 7 | #include <linux/device.h> |
|---|
| 16 | 8 | |
|---|
| .. | .. |
|---|
| 249 | 241 | IPC_GLB_REPLY_INVALID_CONFIG_DATA_LEN = 121, |
|---|
| 250 | 242 | IPC_GLB_REPLY_GATEWAY_NOT_INITIALIZED = 140, |
|---|
| 251 | 243 | IPC_GLB_REPLY_GATEWAY_NOT_EXIST = 141, |
|---|
| 244 | + IPC_GLB_REPLY_SCLK_ALREADY_RUNNING = 150, |
|---|
| 245 | + IPC_GLB_REPLY_MCLK_ALREADY_RUNNING = 151, |
|---|
| 252 | 246 | |
|---|
| 253 | 247 | IPC_GLB_REPLY_PPL_NOT_INITIALIZED = 160, |
|---|
| 254 | 248 | IPC_GLB_REPLY_PPL_NOT_EXIST = 161, |
|---|
| .. | .. |
|---|
| 287 | 281 | size_t tx_size) |
|---|
| 288 | 282 | { |
|---|
| 289 | 283 | if (tx_size) |
|---|
| 290 | | - memcpy(msg->tx_data, tx_data, tx_size); |
|---|
| 284 | + memcpy(msg->tx.data, tx_data, tx_size); |
|---|
| 291 | 285 | } |
|---|
| 292 | 286 | |
|---|
| 293 | 287 | static bool skl_ipc_is_dsp_busy(struct sst_dsp *dsp) |
|---|
| .. | .. |
|---|
| 301 | 295 | /* Lock to be held by caller */ |
|---|
| 302 | 296 | static void skl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) |
|---|
| 303 | 297 | { |
|---|
| 304 | | - struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header); |
|---|
| 298 | + struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->tx.header); |
|---|
| 305 | 299 | |
|---|
| 306 | | - if (msg->tx_size) |
|---|
| 307 | | - sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); |
|---|
| 300 | + if (msg->tx.size) |
|---|
| 301 | + sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size); |
|---|
| 308 | 302 | sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCIE, |
|---|
| 309 | 303 | header->extension); |
|---|
| 310 | 304 | sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCI, |
|---|
| .. | .. |
|---|
| 342 | 336 | |
|---|
| 343 | 337 | msg = list_first_entry(&ipc->rx_list, struct ipc_message, list); |
|---|
| 344 | 338 | |
|---|
| 339 | + list_del(&msg->list); |
|---|
| 345 | 340 | out: |
|---|
| 346 | 341 | return msg; |
|---|
| 347 | 342 | |
|---|
| .. | .. |
|---|
| 350 | 345 | int skl_ipc_process_notification(struct sst_generic_ipc *ipc, |
|---|
| 351 | 346 | struct skl_ipc_header header) |
|---|
| 352 | 347 | { |
|---|
| 353 | | - struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc); |
|---|
| 348 | + struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc); |
|---|
| 354 | 349 | |
|---|
| 355 | 350 | if (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) { |
|---|
| 356 | 351 | switch (IPC_GLB_NOTIFY_TYPE(header.primary)) { |
|---|
| .. | .. |
|---|
| 392 | 387 | return 0; |
|---|
| 393 | 388 | } |
|---|
| 394 | 389 | |
|---|
| 395 | | -static int skl_ipc_set_reply_error_code(u32 reply) |
|---|
| 390 | +struct skl_ipc_err_map { |
|---|
| 391 | + const char *msg; |
|---|
| 392 | + enum skl_ipc_glb_reply reply; |
|---|
| 393 | + int err; |
|---|
| 394 | +}; |
|---|
| 395 | + |
|---|
| 396 | +static struct skl_ipc_err_map skl_err_map[] = { |
|---|
| 397 | + {"DSP out of memory", IPC_GLB_REPLY_OUT_OF_MEMORY, -ENOMEM}, |
|---|
| 398 | + {"DSP busy", IPC_GLB_REPLY_BUSY, -EBUSY}, |
|---|
| 399 | + {"SCLK already running", IPC_GLB_REPLY_SCLK_ALREADY_RUNNING, |
|---|
| 400 | + IPC_GLB_REPLY_SCLK_ALREADY_RUNNING}, |
|---|
| 401 | + {"MCLK already running", IPC_GLB_REPLY_MCLK_ALREADY_RUNNING, |
|---|
| 402 | + IPC_GLB_REPLY_MCLK_ALREADY_RUNNING}, |
|---|
| 403 | +}; |
|---|
| 404 | + |
|---|
| 405 | +static int skl_ipc_set_reply_error_code(struct sst_generic_ipc *ipc, u32 reply) |
|---|
| 396 | 406 | { |
|---|
| 397 | | - switch (reply) { |
|---|
| 398 | | - case IPC_GLB_REPLY_OUT_OF_MEMORY: |
|---|
| 399 | | - return -ENOMEM; |
|---|
| 407 | + int i; |
|---|
| 400 | 408 | |
|---|
| 401 | | - case IPC_GLB_REPLY_BUSY: |
|---|
| 402 | | - return -EBUSY; |
|---|
| 409 | + for (i = 0; i < ARRAY_SIZE(skl_err_map); i++) { |
|---|
| 410 | + if (skl_err_map[i].reply == reply) |
|---|
| 411 | + break; |
|---|
| 412 | + } |
|---|
| 403 | 413 | |
|---|
| 404 | | - default: |
|---|
| 414 | + if (i == ARRAY_SIZE(skl_err_map)) { |
|---|
| 415 | + dev_err(ipc->dev, "ipc FW reply: %d FW Error Code: %u\n", |
|---|
| 416 | + reply, |
|---|
| 417 | + ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp)); |
|---|
| 405 | 418 | return -EINVAL; |
|---|
| 406 | 419 | } |
|---|
| 420 | + |
|---|
| 421 | + if (skl_err_map[i].err < 0) |
|---|
| 422 | + dev_err(ipc->dev, "ipc FW reply: %s FW Error Code: %u\n", |
|---|
| 423 | + skl_err_map[i].msg, |
|---|
| 424 | + ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp)); |
|---|
| 425 | + else |
|---|
| 426 | + dev_info(ipc->dev, "ipc FW reply: %s FW Error Code: %u\n", |
|---|
| 427 | + skl_err_map[i].msg, |
|---|
| 428 | + ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp)); |
|---|
| 429 | + |
|---|
| 430 | + return skl_err_map[i].err; |
|---|
| 407 | 431 | } |
|---|
| 408 | 432 | |
|---|
| 409 | 433 | void skl_ipc_process_reply(struct sst_generic_ipc *ipc, |
|---|
| .. | .. |
|---|
| 412 | 436 | struct ipc_message *msg; |
|---|
| 413 | 437 | u32 reply = header.primary & IPC_GLB_REPLY_STATUS_MASK; |
|---|
| 414 | 438 | u64 *ipc_header = (u64 *)(&header); |
|---|
| 415 | | - struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc); |
|---|
| 439 | + struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc); |
|---|
| 416 | 440 | unsigned long flags; |
|---|
| 417 | 441 | |
|---|
| 418 | 442 | spin_lock_irqsave(&ipc->dsp->spinlock, flags); |
|---|
| .. | .. |
|---|
| 423 | 447 | return; |
|---|
| 424 | 448 | } |
|---|
| 425 | 449 | |
|---|
| 450 | + msg->rx.header = *ipc_header; |
|---|
| 426 | 451 | /* first process the header */ |
|---|
| 427 | 452 | if (reply == IPC_GLB_REPLY_SUCCESS) { |
|---|
| 428 | 453 | dev_dbg(ipc->dev, "ipc FW reply %x: success\n", header.primary); |
|---|
| 429 | 454 | /* copy the rx data from the mailbox */ |
|---|
| 430 | | - sst_dsp_inbox_read(ipc->dsp, msg->rx_data, msg->rx_size); |
|---|
| 455 | + sst_dsp_inbox_read(ipc->dsp, msg->rx.data, msg->rx.size); |
|---|
| 431 | 456 | switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) { |
|---|
| 432 | 457 | case IPC_GLB_LOAD_MULTIPLE_MODS: |
|---|
| 433 | 458 | case IPC_GLB_LOAD_LIBRARY: |
|---|
| .. | .. |
|---|
| 441 | 466 | |
|---|
| 442 | 467 | } |
|---|
| 443 | 468 | } else { |
|---|
| 444 | | - msg->errno = skl_ipc_set_reply_error_code(reply); |
|---|
| 445 | | - dev_err(ipc->dev, "ipc FW reply: reply=%d\n", reply); |
|---|
| 446 | | - dev_err(ipc->dev, "FW Error Code: %u\n", |
|---|
| 447 | | - ipc->dsp->fw_ops.get_fw_errcode(ipc->dsp)); |
|---|
| 469 | + msg->errno = skl_ipc_set_reply_error_code(ipc, reply); |
|---|
| 448 | 470 | switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) { |
|---|
| 449 | 471 | case IPC_GLB_LOAD_MULTIPLE_MODS: |
|---|
| 450 | 472 | case IPC_GLB_LOAD_LIBRARY: |
|---|
| .. | .. |
|---|
| 460 | 482 | } |
|---|
| 461 | 483 | |
|---|
| 462 | 484 | spin_lock_irqsave(&ipc->dsp->spinlock, flags); |
|---|
| 463 | | - list_del(&msg->list); |
|---|
| 464 | 485 | sst_ipc_tx_msg_reply_complete(ipc, msg); |
|---|
| 465 | 486 | spin_unlock_irqrestore(&ipc->dsp->spinlock, flags); |
|---|
| 466 | 487 | } |
|---|
| .. | .. |
|---|
| 468 | 489 | irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context) |
|---|
| 469 | 490 | { |
|---|
| 470 | 491 | struct sst_dsp *dsp = context; |
|---|
| 471 | | - struct skl_sst *skl = sst_dsp_get_thread_context(dsp); |
|---|
| 492 | + struct skl_dev *skl = dsp->thread_context; |
|---|
| 472 | 493 | struct sst_generic_ipc *ipc = &skl->ipc; |
|---|
| 473 | 494 | struct skl_ipc_header header = {0}; |
|---|
| 474 | 495 | u32 hipcie, hipct, hipcte; |
|---|
| .. | .. |
|---|
| 483 | 504 | |
|---|
| 484 | 505 | hipcie = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCIE); |
|---|
| 485 | 506 | hipct = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCT); |
|---|
| 507 | + hipcte = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCTE); |
|---|
| 486 | 508 | |
|---|
| 487 | 509 | /* reply message from DSP */ |
|---|
| 488 | 510 | if (hipcie & SKL_ADSP_REG_HIPCIE_DONE) { |
|---|
| .. | .. |
|---|
| 502 | 524 | |
|---|
| 503 | 525 | /* New message from DSP */ |
|---|
| 504 | 526 | if (hipct & SKL_ADSP_REG_HIPCT_BUSY) { |
|---|
| 505 | | - hipcte = sst_dsp_shim_read_unlocked(dsp, SKL_ADSP_REG_HIPCTE); |
|---|
| 506 | 527 | header.primary = hipct; |
|---|
| 507 | 528 | header.extension = hipcte; |
|---|
| 508 | 529 | dev_dbg(dsp->dev, "IPC irq: Firmware respond primary:%x\n", |
|---|
| .. | .. |
|---|
| 575 | 596 | SKL_ADSP_REG_ADSPIS) & SKL_ADSPIS_IPC; |
|---|
| 576 | 597 | } |
|---|
| 577 | 598 | |
|---|
| 578 | | -int skl_ipc_init(struct device *dev, struct skl_sst *skl) |
|---|
| 599 | +int skl_ipc_init(struct device *dev, struct skl_dev *skl) |
|---|
| 579 | 600 | { |
|---|
| 580 | 601 | struct sst_generic_ipc *ipc; |
|---|
| 581 | 602 | int err; |
|---|
| .. | .. |
|---|
| 615 | 636 | u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode) |
|---|
| 616 | 637 | { |
|---|
| 617 | 638 | struct skl_ipc_header header = {0}; |
|---|
| 618 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 639 | + struct sst_ipc_message request = {0}; |
|---|
| 619 | 640 | int ret; |
|---|
| 620 | 641 | |
|---|
| 621 | 642 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 626 | 647 | header.primary |= IPC_PPL_MEM_SIZE(ppl_mem_size); |
|---|
| 627 | 648 | |
|---|
| 628 | 649 | header.extension = IPC_PPL_LP_MODE(lp_mode); |
|---|
| 650 | + request.header = *(u64 *)(&header); |
|---|
| 629 | 651 | |
|---|
| 630 | 652 | dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); |
|---|
| 631 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 653 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 632 | 654 | if (ret < 0) { |
|---|
| 633 | 655 | dev_err(ipc->dev, "ipc: create pipeline fail, err: %d\n", ret); |
|---|
| 634 | 656 | return ret; |
|---|
| .. | .. |
|---|
| 641 | 663 | int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id) |
|---|
| 642 | 664 | { |
|---|
| 643 | 665 | struct skl_ipc_header header = {0}; |
|---|
| 644 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 666 | + struct sst_ipc_message request = {0}; |
|---|
| 645 | 667 | int ret; |
|---|
| 646 | 668 | |
|---|
| 647 | 669 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| 648 | 670 | header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); |
|---|
| 649 | 671 | header.primary |= IPC_GLB_TYPE(IPC_GLB_DELETE_PPL); |
|---|
| 650 | 672 | header.primary |= IPC_INSTANCE_ID(instance_id); |
|---|
| 673 | + request.header = *(u64 *)(&header); |
|---|
| 651 | 674 | |
|---|
| 652 | 675 | dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); |
|---|
| 653 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 676 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 654 | 677 | if (ret < 0) { |
|---|
| 655 | 678 | dev_err(ipc->dev, "ipc: delete pipeline failed, err %d\n", ret); |
|---|
| 656 | 679 | return ret; |
|---|
| .. | .. |
|---|
| 664 | 687 | u8 instance_id, enum skl_ipc_pipeline_state state) |
|---|
| 665 | 688 | { |
|---|
| 666 | 689 | struct skl_ipc_header header = {0}; |
|---|
| 667 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 690 | + struct sst_ipc_message request = {0}; |
|---|
| 668 | 691 | int ret; |
|---|
| 669 | 692 | |
|---|
| 670 | 693 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 672 | 695 | header.primary |= IPC_GLB_TYPE(IPC_GLB_SET_PPL_STATE); |
|---|
| 673 | 696 | header.primary |= IPC_INSTANCE_ID(instance_id); |
|---|
| 674 | 697 | header.primary |= IPC_PPL_STATE(state); |
|---|
| 698 | + request.header = *(u64 *)(&header); |
|---|
| 675 | 699 | |
|---|
| 676 | 700 | dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); |
|---|
| 677 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 701 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 678 | 702 | if (ret < 0) { |
|---|
| 679 | 703 | dev_err(ipc->dev, "ipc: set pipeline state failed, err: %d\n", ret); |
|---|
| 680 | 704 | return ret; |
|---|
| .. | .. |
|---|
| 687 | 711 | skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, u8 instance_id, int dma_id) |
|---|
| 688 | 712 | { |
|---|
| 689 | 713 | struct skl_ipc_header header = {0}; |
|---|
| 690 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 714 | + struct sst_ipc_message request = {0}; |
|---|
| 691 | 715 | int ret; |
|---|
| 692 | 716 | |
|---|
| 693 | 717 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 696 | 720 | header.primary |= IPC_INSTANCE_ID(instance_id); |
|---|
| 697 | 721 | |
|---|
| 698 | 722 | header.extension = IPC_DMA_ID(dma_id); |
|---|
| 723 | + request.header = *(u64 *)(&header); |
|---|
| 724 | + |
|---|
| 699 | 725 | dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); |
|---|
| 700 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 726 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 701 | 727 | if (ret < 0) { |
|---|
| 702 | 728 | dev_err(ipc->dev, "ipc: save pipeline failed, err: %d\n", ret); |
|---|
| 703 | 729 | return ret; |
|---|
| .. | .. |
|---|
| 710 | 736 | int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id) |
|---|
| 711 | 737 | { |
|---|
| 712 | 738 | struct skl_ipc_header header = {0}; |
|---|
| 713 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 739 | + struct sst_ipc_message request = {0}; |
|---|
| 714 | 740 | int ret; |
|---|
| 715 | 741 | |
|---|
| 716 | 742 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| 717 | 743 | header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); |
|---|
| 718 | 744 | header.primary |= IPC_GLB_TYPE(IPC_GLB_RESTORE_PPL); |
|---|
| 719 | 745 | header.primary |= IPC_INSTANCE_ID(instance_id); |
|---|
| 746 | + request.header = *(u64 *)(&header); |
|---|
| 720 | 747 | |
|---|
| 721 | 748 | dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); |
|---|
| 722 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 749 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 723 | 750 | if (ret < 0) { |
|---|
| 724 | 751 | dev_err(ipc->dev, "ipc: restore pipeline failed, err: %d\n", ret); |
|---|
| 725 | 752 | return ret; |
|---|
| .. | .. |
|---|
| 733 | 760 | u16 module_id, struct skl_ipc_dxstate_info *dx) |
|---|
| 734 | 761 | { |
|---|
| 735 | 762 | struct skl_ipc_header header = {0}; |
|---|
| 736 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 763 | + struct sst_ipc_message request; |
|---|
| 737 | 764 | int ret; |
|---|
| 738 | 765 | |
|---|
| 739 | 766 | header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); |
|---|
| .. | .. |
|---|
| 742 | 769 | header.primary |= IPC_MOD_INSTANCE_ID(instance_id); |
|---|
| 743 | 770 | header.primary |= IPC_MOD_ID(module_id); |
|---|
| 744 | 771 | |
|---|
| 772 | + request.header = *(u64 *)(&header); |
|---|
| 773 | + request.data = dx; |
|---|
| 774 | + request.size = sizeof(*dx); |
|---|
| 775 | + |
|---|
| 745 | 776 | dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__, |
|---|
| 746 | 777 | header.primary, header.extension); |
|---|
| 747 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, |
|---|
| 748 | | - dx, sizeof(*dx), NULL, 0); |
|---|
| 778 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 749 | 779 | if (ret < 0) { |
|---|
| 750 | 780 | dev_err(ipc->dev, "ipc: set dx failed, err %d\n", ret); |
|---|
| 751 | 781 | return ret; |
|---|
| .. | .. |
|---|
| 759 | 789 | struct skl_ipc_init_instance_msg *msg, void *param_data) |
|---|
| 760 | 790 | { |
|---|
| 761 | 791 | struct skl_ipc_header header = {0}; |
|---|
| 762 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 792 | + struct sst_ipc_message request; |
|---|
| 763 | 793 | int ret; |
|---|
| 764 | 794 | u32 *buffer = (u32 *)param_data; |
|---|
| 765 | 795 | /* param_block_size must be in dwords */ |
|---|
| .. | .. |
|---|
| 779 | 809 | header.extension |= IPC_PARAM_BLOCK_SIZE(param_block_size); |
|---|
| 780 | 810 | header.extension |= IPC_DOMAIN(msg->domain); |
|---|
| 781 | 811 | |
|---|
| 812 | + request.header = *(u64 *)(&header); |
|---|
| 813 | + request.data = param_data; |
|---|
| 814 | + request.size = msg->param_data_size; |
|---|
| 815 | + |
|---|
| 782 | 816 | dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__, |
|---|
| 783 | 817 | header.primary, header.extension); |
|---|
| 784 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, param_data, |
|---|
| 785 | | - msg->param_data_size, NULL, 0); |
|---|
| 818 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 786 | 819 | |
|---|
| 787 | 820 | if (ret < 0) { |
|---|
| 788 | 821 | dev_err(ipc->dev, "ipc: init instance failed\n"); |
|---|
| .. | .. |
|---|
| 797 | 830 | struct skl_ipc_bind_unbind_msg *msg) |
|---|
| 798 | 831 | { |
|---|
| 799 | 832 | struct skl_ipc_header header = {0}; |
|---|
| 800 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 833 | + struct sst_ipc_message request = {0}; |
|---|
| 801 | 834 | u8 bind_unbind = msg->bind ? IPC_MOD_BIND : IPC_MOD_UNBIND; |
|---|
| 802 | 835 | int ret; |
|---|
| 803 | 836 | |
|---|
| .. | .. |
|---|
| 811 | 844 | header.extension |= IPC_DST_MOD_INSTANCE_ID(msg->dst_instance_id); |
|---|
| 812 | 845 | header.extension |= IPC_DST_QUEUE(msg->dst_queue); |
|---|
| 813 | 846 | header.extension |= IPC_SRC_QUEUE(msg->src_queue); |
|---|
| 847 | + request.header = *(u64 *)(&header); |
|---|
| 814 | 848 | |
|---|
| 815 | 849 | dev_dbg(ipc->dev, "In %s hdr=%x ext=%x\n", __func__, header.primary, |
|---|
| 816 | 850 | header.extension); |
|---|
| 817 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 851 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 818 | 852 | if (ret < 0) { |
|---|
| 819 | 853 | dev_err(ipc->dev, "ipc: bind/unbind failed\n"); |
|---|
| 820 | 854 | return ret; |
|---|
| .. | .. |
|---|
| 834 | 868 | u8 module_cnt, void *data) |
|---|
| 835 | 869 | { |
|---|
| 836 | 870 | struct skl_ipc_header header = {0}; |
|---|
| 837 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 871 | + struct sst_ipc_message request; |
|---|
| 838 | 872 | int ret; |
|---|
| 839 | 873 | |
|---|
| 840 | 874 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 842 | 876 | header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_MULTIPLE_MODS); |
|---|
| 843 | 877 | header.primary |= IPC_LOAD_MODULE_CNT(module_cnt); |
|---|
| 844 | 878 | |
|---|
| 845 | | - ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, data, |
|---|
| 846 | | - (sizeof(u16) * module_cnt)); |
|---|
| 879 | + request.header = *(u64 *)(&header); |
|---|
| 880 | + request.data = data; |
|---|
| 881 | + request.size = sizeof(u16) * module_cnt; |
|---|
| 882 | + |
|---|
| 883 | + ret = sst_ipc_tx_message_nowait(ipc, request); |
|---|
| 847 | 884 | if (ret < 0) |
|---|
| 848 | 885 | dev_err(ipc->dev, "ipc: load modules failed :%d\n", ret); |
|---|
| 849 | 886 | |
|---|
| .. | .. |
|---|
| 855 | 892 | void *data) |
|---|
| 856 | 893 | { |
|---|
| 857 | 894 | struct skl_ipc_header header = {0}; |
|---|
| 858 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 895 | + struct sst_ipc_message request; |
|---|
| 859 | 896 | int ret; |
|---|
| 860 | 897 | |
|---|
| 861 | 898 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 863 | 900 | header.primary |= IPC_GLB_TYPE(IPC_GLB_UNLOAD_MULTIPLE_MODS); |
|---|
| 864 | 901 | header.primary |= IPC_LOAD_MODULE_CNT(module_cnt); |
|---|
| 865 | 902 | |
|---|
| 866 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, data, |
|---|
| 867 | | - (sizeof(u16) * module_cnt), NULL, 0); |
|---|
| 903 | + request.header = *(u64 *)(&header); |
|---|
| 904 | + request.data = data; |
|---|
| 905 | + request.size = sizeof(u16) * module_cnt; |
|---|
| 906 | + |
|---|
| 907 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 868 | 908 | if (ret < 0) |
|---|
| 869 | 909 | dev_err(ipc->dev, "ipc: unload modules failed :%d\n", ret); |
|---|
| 870 | 910 | |
|---|
| .. | .. |
|---|
| 876 | 916 | struct skl_ipc_large_config_msg *msg, u32 *param) |
|---|
| 877 | 917 | { |
|---|
| 878 | 918 | struct skl_ipc_header header = {0}; |
|---|
| 879 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 919 | + struct sst_ipc_message request; |
|---|
| 880 | 920 | int ret = 0; |
|---|
| 881 | 921 | size_t sz_remaining, tx_size, data_offset; |
|---|
| 882 | 922 | |
|---|
| .. | .. |
|---|
| 903 | 943 | header.primary, header.extension); |
|---|
| 904 | 944 | dev_dbg(ipc->dev, "transmitting offset: %#x, size: %#x\n", |
|---|
| 905 | 945 | (unsigned)data_offset, (unsigned)tx_size); |
|---|
| 906 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, |
|---|
| 907 | | - ((char *)param) + data_offset, |
|---|
| 908 | | - tx_size, NULL, 0); |
|---|
| 946 | + |
|---|
| 947 | + request.header = *(u64 *)(&header); |
|---|
| 948 | + request.data = ((char *)param) + data_offset; |
|---|
| 949 | + request.size = tx_size; |
|---|
| 950 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 909 | 951 | if (ret < 0) { |
|---|
| 910 | 952 | dev_err(ipc->dev, |
|---|
| 911 | 953 | "ipc: set large config fail, err: %d\n", ret); |
|---|
| .. | .. |
|---|
| 927 | 969 | EXPORT_SYMBOL_GPL(skl_ipc_set_large_config); |
|---|
| 928 | 970 | |
|---|
| 929 | 971 | int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, |
|---|
| 930 | | - struct skl_ipc_large_config_msg *msg, u32 *param) |
|---|
| 972 | + struct skl_ipc_large_config_msg *msg, |
|---|
| 973 | + u32 **payload, size_t *bytes) |
|---|
| 931 | 974 | { |
|---|
| 932 | 975 | struct skl_ipc_header header = {0}; |
|---|
| 933 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 934 | | - int ret = 0; |
|---|
| 935 | | - size_t sz_remaining, rx_size, data_offset; |
|---|
| 976 | + struct sst_ipc_message request, reply = {0}; |
|---|
| 977 | + unsigned int *buf; |
|---|
| 978 | + int ret; |
|---|
| 979 | + |
|---|
| 980 | + reply.data = kzalloc(SKL_ADSP_W1_SZ, GFP_KERNEL); |
|---|
| 981 | + if (!reply.data) |
|---|
| 982 | + return -ENOMEM; |
|---|
| 936 | 983 | |
|---|
| 937 | 984 | header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); |
|---|
| 938 | 985 | header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); |
|---|
| .. | .. |
|---|
| 945 | 992 | header.extension |= IPC_FINAL_BLOCK(1); |
|---|
| 946 | 993 | header.extension |= IPC_INITIAL_BLOCK(1); |
|---|
| 947 | 994 | |
|---|
| 948 | | - sz_remaining = msg->param_data_size; |
|---|
| 949 | | - data_offset = 0; |
|---|
| 995 | + request.header = *(u64 *)&header; |
|---|
| 996 | + request.data = *payload; |
|---|
| 997 | + request.size = *bytes; |
|---|
| 998 | + reply.size = SKL_ADSP_W1_SZ; |
|---|
| 950 | 999 | |
|---|
| 951 | | - while (sz_remaining != 0) { |
|---|
| 952 | | - rx_size = sz_remaining > SKL_ADSP_W1_SZ |
|---|
| 953 | | - ? SKL_ADSP_W1_SZ : sz_remaining; |
|---|
| 954 | | - if (rx_size == sz_remaining) |
|---|
| 955 | | - header.extension |= IPC_FINAL_BLOCK(1); |
|---|
| 1000 | + ret = sst_ipc_tx_message_wait(ipc, request, &reply); |
|---|
| 1001 | + if (ret < 0) |
|---|
| 1002 | + dev_err(ipc->dev, "ipc: get large config fail, err: %d\n", ret); |
|---|
| 956 | 1003 | |
|---|
| 957 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, |
|---|
| 958 | | - ((char *)param) + data_offset, |
|---|
| 959 | | - msg->param_data_size); |
|---|
| 960 | | - if (ret < 0) { |
|---|
| 961 | | - dev_err(ipc->dev, |
|---|
| 962 | | - "ipc: get large config fail, err: %d\n", ret); |
|---|
| 963 | | - return ret; |
|---|
| 964 | | - } |
|---|
| 965 | | - sz_remaining -= rx_size; |
|---|
| 966 | | - data_offset = msg->param_data_size - sz_remaining; |
|---|
| 967 | | - |
|---|
| 968 | | - /* clear the fields */ |
|---|
| 969 | | - header.extension &= IPC_INITIAL_BLOCK_CLEAR; |
|---|
| 970 | | - header.extension &= IPC_DATA_OFFSET_SZ_CLEAR; |
|---|
| 971 | | - /* fill the fields */ |
|---|
| 972 | | - header.extension |= IPC_INITIAL_BLOCK(1); |
|---|
| 973 | | - header.extension |= IPC_DATA_OFFSET_SZ(data_offset); |
|---|
| 974 | | - } |
|---|
| 1004 | + reply.size = (reply.header >> 32) & IPC_DATA_OFFSET_SZ_MASK; |
|---|
| 1005 | + buf = krealloc(reply.data, reply.size, GFP_KERNEL); |
|---|
| 1006 | + if (!buf) |
|---|
| 1007 | + return -ENOMEM; |
|---|
| 1008 | + *payload = buf; |
|---|
| 1009 | + *bytes = reply.size; |
|---|
| 975 | 1010 | |
|---|
| 976 | 1011 | return ret; |
|---|
| 977 | 1012 | } |
|---|
| .. | .. |
|---|
| 981 | 1016 | u8 dma_id, u8 table_id, bool wait) |
|---|
| 982 | 1017 | { |
|---|
| 983 | 1018 | struct skl_ipc_header header = {0}; |
|---|
| 984 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 1019 | + struct sst_ipc_message request = {0}; |
|---|
| 985 | 1020 | int ret = 0; |
|---|
| 986 | 1021 | |
|---|
| 987 | 1022 | header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); |
|---|
| .. | .. |
|---|
| 989 | 1024 | header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_LIBRARY); |
|---|
| 990 | 1025 | header.primary |= IPC_MOD_INSTANCE_ID(table_id); |
|---|
| 991 | 1026 | header.primary |= IPC_MOD_ID(dma_id); |
|---|
| 1027 | + request.header = *(u64 *)(&header); |
|---|
| 992 | 1028 | |
|---|
| 993 | 1029 | if (wait) |
|---|
| 994 | | - ret = sst_ipc_tx_message_wait(ipc, *ipc_header, |
|---|
| 995 | | - NULL, 0, NULL, 0); |
|---|
| 1030 | + ret = sst_ipc_tx_message_wait(ipc, request, NULL); |
|---|
| 996 | 1031 | else |
|---|
| 997 | | - ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, NULL, 0); |
|---|
| 1032 | + ret = sst_ipc_tx_message_nowait(ipc, request); |
|---|
| 998 | 1033 | |
|---|
| 999 | 1034 | if (ret < 0) |
|---|
| 1000 | 1035 | dev_err(ipc->dev, "ipc: load lib failed\n"); |
|---|
| .. | .. |
|---|
| 1006 | 1041 | int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg) |
|---|
| 1007 | 1042 | { |
|---|
| 1008 | 1043 | struct skl_ipc_header header = {0}; |
|---|
| 1009 | | - u64 *ipc_header = (u64 *)(&header); |
|---|
| 1044 | + struct sst_ipc_message request = {0}; |
|---|
| 1010 | 1045 | int ret; |
|---|
| 1011 | 1046 | |
|---|
| 1012 | 1047 | header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); |
|---|
| .. | .. |
|---|
| 1017 | 1052 | |
|---|
| 1018 | 1053 | header.extension = IPC_D0IX_WAKE(msg->wake); |
|---|
| 1019 | 1054 | header.extension |= IPC_D0IX_STREAMING(msg->streaming); |
|---|
| 1055 | + request.header = *(u64 *)(&header); |
|---|
| 1020 | 1056 | |
|---|
| 1021 | 1057 | dev_dbg(ipc->dev, "In %s primary=%x ext=%x\n", __func__, |
|---|
| 1022 | 1058 | header.primary, header.extension); |
|---|
| .. | .. |
|---|
| 1024 | 1060 | /* |
|---|
| 1025 | 1061 | * Use the nopm IPC here as we dont want it checking for D0iX |
|---|
| 1026 | 1062 | */ |
|---|
| 1027 | | - ret = sst_ipc_tx_message_nopm(ipc, *ipc_header, NULL, 0, NULL, 0); |
|---|
| 1063 | + ret = sst_ipc_tx_message_nopm(ipc, request, NULL); |
|---|
| 1028 | 1064 | if (ret < 0) |
|---|
| 1029 | 1065 | dev_err(ipc->dev, "ipc: set d0ix failed, err %d\n", ret); |
|---|
| 1030 | 1066 | |
|---|