msm_cvp_dsp.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef MSM_CVP_DSP_H
  6. #define MSM_CVP_DSP_H
  7. #include <linux/types.h>
  8. #include "msm_cvp_debug.h"
  9. #include "cvp_core_hfi.h"
  10. #define CVP_APPS_DSP_GLINK_GUID "cvp-glink-apps-dsp"
  11. #define CVP_APPS_DSP_SMD_GUID "cvp-smd-apps-dsp"
  12. #define VMID_CDSP_Q6 (30)
  13. #define HLOS_VM_NUM 1
  14. #define DSP_VM_NUM 2
  15. #define CVP_DSP_MAX_RESERVED 5
  16. #define CVP_DSP2CPU_RESERVED 8
  17. #define CVP_DSP_RESPONSE_TIMEOUT 300
  18. #define CVP_INVALID_RPMSG_TYPE 0xBADDFACE
  19. int cvp_dsp_device_init(void);
  20. void cvp_dsp_device_exit(void);
  21. void cvp_dsp_send_hfi_queue(void);
  22. enum CVP_DSP_COMMAND {
  23. CPU2DSP_SEND_HFI_QUEUE = 0,
  24. CPU2DSP_SUSPEND = 1,
  25. CPU2DSP_RESUME = 2,
  26. CPU2DSP_SHUTDOWN = 3,
  27. CPU2DSP_REGISTER_BUFFER = 4,
  28. CPU2DSP_DEREGISTER_BUFFER = 5,
  29. CPU2DSP_MAX_CMD = 6,
  30. DSP2CPU_POWERON = 6,
  31. DSP2CPU_POWEROFF = 7,
  32. CVP_DSP_MAX_CMD = 8,
  33. };
  34. struct cvp_dsp_cmd_msg {
  35. uint32_t type;
  36. int32_t ret;
  37. uint64_t msg_ptr;
  38. uint32_t msg_ptr_len;
  39. uint32_t buff_fd_iova;
  40. uint32_t buff_index;
  41. uint32_t buff_size;
  42. uint32_t session_id;
  43. int32_t ddr_type;
  44. uint32_t buff_fd;
  45. uint32_t buff_offset;
  46. uint32_t buff_fd_size;
  47. uint32_t reserved1;
  48. uint32_t reserved2;
  49. };
  50. struct cvp_dsp_rsp_msg {
  51. uint32_t type;
  52. int32_t ret;
  53. uint32_t reserved[CVP_DSP_MAX_RESERVED];
  54. };
  55. struct cvp_dsp2cpu_cmd_msg {
  56. uint32_t type;
  57. uint32_t ver;
  58. uint32_t len;
  59. uint32_t data[CVP_DSP2CPU_RESERVED];
  60. };
  61. struct cvp_dsp_apps {
  62. struct mutex lock;
  63. struct rpmsg_device *chan;
  64. uint32_t state;
  65. bool hyp_assigned;
  66. uint64_t addr;
  67. uint32_t size;
  68. struct completion completions[CPU2DSP_MAX_CMD + 1];
  69. struct cvp_dsp2cpu_cmd_msg pending_dsp2cpu_cmd;
  70. struct cvp_dsp_rsp_msg pending_dsp2cpu_rsp;
  71. struct task_struct *dsp_thread;
  72. };
  73. extern struct cvp_dsp_apps gfa_cv;
  74. /*
  75. * API for CVP driver to suspend CVP session during
  76. * power collapse
  77. *
  78. * @param session_flag
  79. * Flag to share details of session.
  80. */
  81. int cvp_dsp_suspend(uint32_t session_flag);
  82. /*
  83. * API for CVP driver to resume CVP session during
  84. * power collapse
  85. *
  86. * @param session_flag
  87. * Flag to share details of session.
  88. */
  89. int cvp_dsp_resume(uint32_t session_flag);
  90. /*
  91. * API for CVP driver to shutdown CVP session during
  92. * cvp subsystem error.
  93. *
  94. * @param session_flag
  95. * Flag to share details of session.
  96. */
  97. int cvp_dsp_shutdown(uint32_t session_flag);
  98. /*
  99. * API to register iova buffer address with CDSP
  100. *
  101. * @session_id: cvp session id
  102. * @buff_fd: buffer fd
  103. * @buff_fd_size: total size of fd in bytes
  104. * @buff_size: size in bytes of cvp buffer
  105. * @buff_offset: buffer offset
  106. * @buff_index: buffer index
  107. * @iova_buff_addr: IOVA buffer address
  108. */
  109. int cvp_dsp_register_buffer(uint32_t session_id, uint32_t buff_fd,
  110. uint32_t buff_fd_size, uint32_t buff_size,
  111. uint32_t buff_offset, uint32_t buff_index,
  112. uint32_t buff_fd_iova);
  113. /*
  114. * API to de-register iova buffer address from CDSP
  115. *
  116. * @session_id: cvp session id
  117. * @buff_fd: buffer fd
  118. * @buff_fd_size: total size of fd in bytes
  119. * @buff_size: size in bytes of cvp buffer
  120. * @buff_offset: buffer offset
  121. * @buff_index: buffer index
  122. * @iova_buff_addr: IOVA buffer address
  123. */
  124. int cvp_dsp_deregister_buffer(uint32_t session_id, uint32_t buff_fd,
  125. uint32_t buff_fd_size, uint32_t buff_size,
  126. uint32_t buff_offset, uint32_t buff_index,
  127. uint32_t buff_fd_iova);
  128. #endif // MSM_CVP_DSP_H