skl-sst-ipc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. #define SKL_DSP_CORES_MAX 2
  41. struct skl_dsp_cores {
  42. unsigned int count;
  43. enum skl_dsp_states state[SKL_DSP_CORES_MAX];
  44. int usage_count[SKL_DSP_CORES_MAX];
  45. };
  46. /**
  47. * skl_d0i3_data: skl D0i3 counters data struct
  48. *
  49. * @streaming: Count of usecases that can attempt streaming D0i3
  50. * @non_streaming: Count of usecases that can attempt non-streaming D0i3
  51. * @non_d0i3: Count of usecases that cannot attempt D0i3
  52. * @state: current state
  53. * @work: D0i3 worker thread
  54. */
  55. struct skl_d0i3_data {
  56. int streaming;
  57. int non_streaming;
  58. int non_d0i3;
  59. enum skl_dsp_d0i3_states state;
  60. struct delayed_work work;
  61. };
  62. struct skl_sst {
  63. struct device *dev;
  64. struct sst_dsp *dsp;
  65. /* boot */
  66. wait_queue_head_t boot_wait;
  67. bool boot_complete;
  68. /* IPC messaging */
  69. struct sst_generic_ipc ipc;
  70. /* callback for miscbdge */
  71. void (*enable_miscbdcge)(struct device *dev, bool enable);
  72. /* Is CGCTL.MISCBDCGE disabled */
  73. bool miscbdcg_disabled;
  74. /* Populate module information */
  75. struct list_head uuid_list;
  76. /* Is firmware loaded */
  77. bool fw_loaded;
  78. /* first boot ? */
  79. bool is_first_boot;
  80. /* multi-core */
  81. struct skl_dsp_cores cores;
  82. /* tplg manifest */
  83. struct skl_dfw_manifest manifest;
  84. /* Callback to update D0i3C register */
  85. void (*update_d0i3c)(struct device *dev, bool enable);
  86. struct skl_d0i3_data d0i3;
  87. };
  88. struct skl_ipc_init_instance_msg {
  89. u32 module_id;
  90. u32 instance_id;
  91. u16 param_data_size;
  92. u8 ppl_instance_id;
  93. u8 core_id;
  94. u8 domain;
  95. };
  96. struct skl_ipc_bind_unbind_msg {
  97. u32 module_id;
  98. u32 instance_id;
  99. u32 dst_module_id;
  100. u32 dst_instance_id;
  101. u8 src_queue;
  102. u8 dst_queue;
  103. bool bind;
  104. };
  105. struct skl_ipc_large_config_msg {
  106. u32 module_id;
  107. u32 instance_id;
  108. u32 large_param_id;
  109. u32 param_data_size;
  110. };
  111. struct skl_ipc_d0ix_msg {
  112. u32 module_id;
  113. u32 instance_id;
  114. u8 streaming;
  115. u8 wake;
  116. };
  117. #define SKL_IPC_BOOT_MSECS 3000
  118. #define SKL_IPC_D3_MASK 0
  119. #define SKL_IPC_D0_MASK 3
  120. irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);
  121. int skl_ipc_create_pipeline(struct sst_generic_ipc *sst_ipc,
  122. u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode);
  123. int skl_ipc_delete_pipeline(struct sst_generic_ipc *sst_ipc, u8 instance_id);
  124. int skl_ipc_set_pipeline_state(struct sst_generic_ipc *sst_ipc,
  125. u8 instance_id, enum skl_ipc_pipeline_state state);
  126. int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
  127. u8 instance_id, int dma_id);
  128. int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
  129. int skl_ipc_init_instance(struct sst_generic_ipc *sst_ipc,
  130. struct skl_ipc_init_instance_msg *msg, void *param_data);
  131. int skl_ipc_bind_unbind(struct sst_generic_ipc *sst_ipc,
  132. struct skl_ipc_bind_unbind_msg *msg);
  133. int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
  134. u8 module_cnt, void *data);
  135. int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
  136. u8 module_cnt, void *data);
  137. int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
  138. u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);
  139. int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
  140. struct skl_ipc_large_config_msg *msg, u32 *param);
  141. int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
  142. struct skl_ipc_large_config_msg *msg, u32 *param);
  143. int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
  144. u8 dma_id, u8 table_id);
  145. int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc,
  146. struct skl_ipc_d0ix_msg *msg);
  147. int skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state);
  148. void skl_ipc_int_enable(struct sst_dsp *dsp);
  149. void skl_ipc_op_int_enable(struct sst_dsp *ctx);
  150. void skl_ipc_op_int_disable(struct sst_dsp *ctx);
  151. void skl_ipc_int_disable(struct sst_dsp *dsp);
  152. bool skl_ipc_int_status(struct sst_dsp *dsp);
  153. void skl_ipc_free(struct sst_generic_ipc *ipc);
  154. int skl_ipc_init(struct device *dev, struct skl_sst *skl);
  155. void skl_clear_module_cnt(struct sst_dsp *ctx);
  156. #endif /* __SKL_IPC_H */