skl-sst-ipc.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /*
  2. * Intel SKL IPC Support
  3. *
  4. * 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. */
  15. #ifndef __SKL_IPC_H
  16. #define __SKL_IPC_H
  17. #include <linux/irqreturn.h>
  18. #include "../common/sst-ipc.h"
  19. struct sst_dsp;
  20. struct skl_sst;
  21. struct sst_generic_ipc;
  22. enum skl_ipc_pipeline_state {
  23. PPL_INVALID_STATE = 0,
  24. PPL_UNINITIALIZED = 1,
  25. PPL_RESET = 2,
  26. PPL_PAUSED = 3,
  27. PPL_RUNNING = 4,
  28. PPL_ERROR_STOP = 5,
  29. PPL_SAVED = 6,
  30. PPL_RESTORED = 7
  31. };
  32. struct skl_ipc_dxstate_info {
  33. u32 core_mask;
  34. u32 dx_mask;
  35. };
  36. struct skl_ipc_header {
  37. u32 primary;
  38. u32 extension;
  39. };
  40. struct skl_dsp_cores {
  41. unsigned int count;
  42. enum skl_dsp_states *state;
  43. int *usage_count;
  44. };
  45. /**
  46. * skl_d0i3_data: skl D0i3 counters data struct
  47. *
  48. * @streaming: Count of usecases that can attempt streaming D0i3
  49. * @non_streaming: Count of usecases that can attempt non-streaming D0i3
  50. * @non_d0i3: Count of usecases that cannot attempt D0i3
  51. * @state: current state
  52. * @work: D0i3 worker thread
  53. */
  54. struct skl_d0i3_data {
  55. int streaming;
  56. int non_streaming;
  57. int non_d0i3;
  58. enum skl_dsp_d0i3_states state;
  59. struct delayed_work work;
  60. };
  61. #define SKL_LIB_NAME_LENGTH 128
  62. #define SKL_MAX_LIB 16
  63. struct skl_lib_info {
  64. char name[SKL_LIB_NAME_LENGTH];
  65. const struct firmware *fw;
  66. };
  67. struct skl_sst {
  68. struct device *dev;
  69. struct sst_dsp *dsp;
  70. /* boot */
  71. wait_queue_head_t boot_wait;
  72. bool boot_complete;
  73. /* module load */
  74. wait_queue_head_t mod_load_wait;
  75. bool mod_load_complete;
  76. bool mod_load_status;
  77. /* IPC messaging */
  78. struct sst_generic_ipc ipc;
  79. /* callback for miscbdge */
  80. void (*enable_miscbdcge)(struct device *dev, bool enable);
  81. /* Is CGCTL.MISCBDCGE disabled */
  82. bool miscbdcg_disabled;
  83. /* Populate module information */
  84. struct list_head uuid_list;
  85. /* Is firmware loaded */
  86. bool fw_loaded;
  87. /* first boot ? */
  88. bool is_first_boot;
  89. /* multi-core */
  90. struct skl_dsp_cores cores;
  91. /* library info */
  92. struct skl_lib_info lib_info[SKL_MAX_LIB];
  93. int lib_count;
  94. /* Callback to update D0i3C register */
  95. void (*update_d0i3c)(struct device *dev, bool enable);
  96. struct skl_d0i3_data d0i3;
  97. const struct skl_dsp_ops *dsp_ops;
  98. /* Callback to update dynamic clock and power gating registers */
  99. void (*clock_power_gating)(struct device *dev, bool enable);
  100. };
  101. struct skl_ipc_init_instance_msg {
  102. u32 module_id;
  103. u32 instance_id;
  104. u16 param_data_size;
  105. u8 ppl_instance_id;
  106. u8 core_id;
  107. u8 domain;
  108. };
  109. struct skl_ipc_bind_unbind_msg {
  110. u32 module_id;
  111. u32 instance_id;
  112. u32 dst_module_id;
  113. u32 dst_instance_id;
  114. u8 src_queue;
  115. u8 dst_queue;
  116. bool bind;
  117. };
  118. struct skl_ipc_large_config_msg {
  119. u32 module_id;
  120. u32 instance_id;
  121. u32 large_param_id;
  122. u32 param_data_size;
  123. };
  124. struct skl_ipc_d0ix_msg {
  125. u32 module_id;
  126. u32 instance_id;
  127. u8 streaming;
  128. u8 wake;
  129. };
  130. #define SKL_IPC_BOOT_MSECS 3000
  131. #define SKL_IPC_D3_MASK 0
  132. #define SKL_IPC_D0_MASK 3
  133. irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);
  134. int skl_ipc_create_pipeline(struct sst_generic_ipc *sst_ipc,
  135. u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode);
  136. int skl_ipc_delete_pipeline(struct sst_generic_ipc *sst_ipc, u8 instance_id);
  137. int skl_ipc_set_pipeline_state(struct sst_generic_ipc *sst_ipc,
  138. u8 instance_id, enum skl_ipc_pipeline_state state);
  139. int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
  140. u8 instance_id, int dma_id);
  141. int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
  142. int skl_ipc_init_instance(struct sst_generic_ipc *sst_ipc,
  143. struct skl_ipc_init_instance_msg *msg, void *param_data);
  144. int skl_ipc_bind_unbind(struct sst_generic_ipc *sst_ipc,
  145. struct skl_ipc_bind_unbind_msg *msg);
  146. int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
  147. u8 module_cnt, void *data);
  148. int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
  149. u8 module_cnt, void *data);
  150. int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
  151. u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);
  152. int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
  153. struct skl_ipc_large_config_msg *msg, u32 *param);
  154. int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
  155. struct skl_ipc_large_config_msg *msg, u32 *param);
  156. int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
  157. u8 dma_id, u8 table_id, bool wait);
  158. int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc,
  159. struct skl_ipc_d0ix_msg *msg);
  160. int skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state);
  161. void skl_ipc_int_enable(struct sst_dsp *dsp);
  162. void skl_ipc_op_int_enable(struct sst_dsp *ctx);
  163. void skl_ipc_op_int_disable(struct sst_dsp *ctx);
  164. void skl_ipc_int_disable(struct sst_dsp *dsp);
  165. bool skl_ipc_int_status(struct sst_dsp *dsp);
  166. void skl_ipc_free(struct sst_generic_ipc *ipc);
  167. int skl_ipc_init(struct device *dev, struct skl_sst *skl);
  168. void skl_clear_module_cnt(struct sst_dsp *ctx);
  169. void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
  170. struct skl_ipc_header header);
  171. int skl_ipc_process_notification(struct sst_generic_ipc *ipc,
  172. struct skl_ipc_header header);
  173. void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data,
  174. size_t tx_size);
  175. #endif /* __SKL_IPC_H */