skl-sst-ipc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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/kthread.h>
  18. #include <linux/irqreturn.h>
  19. #include "../common/sst-ipc.h"
  20. struct sst_dsp;
  21. struct skl_sst;
  22. struct sst_generic_ipc;
  23. enum skl_ipc_pipeline_state {
  24. PPL_INVALID_STATE = 0,
  25. PPL_UNINITIALIZED = 1,
  26. PPL_RESET = 2,
  27. PPL_PAUSED = 3,
  28. PPL_RUNNING = 4,
  29. PPL_ERROR_STOP = 5,
  30. PPL_SAVED = 6,
  31. PPL_RESTORED = 7
  32. };
  33. struct skl_ipc_dxstate_info {
  34. u32 core_mask;
  35. u32 dx_mask;
  36. };
  37. struct skl_ipc_header {
  38. u32 primary;
  39. u32 extension;
  40. };
  41. #define SKL_DSP_CORES_MAX 2
  42. struct skl_dsp_cores {
  43. unsigned int count;
  44. enum skl_dsp_states state[SKL_DSP_CORES_MAX];
  45. int usage_count[SKL_DSP_CORES_MAX];
  46. };
  47. struct skl_sst {
  48. struct device *dev;
  49. struct sst_dsp *dsp;
  50. /* boot */
  51. wait_queue_head_t boot_wait;
  52. bool boot_complete;
  53. /* IPC messaging */
  54. struct sst_generic_ipc ipc;
  55. /* callback for miscbdge */
  56. void (*enable_miscbdcge)(struct device *dev, bool enable);
  57. /* Is CGCTL.MISCBDCGE disabled */
  58. bool miscbdcg_disabled;
  59. /* Populate module information */
  60. struct list_head uuid_list;
  61. /* Is firmware loaded */
  62. bool fw_loaded;
  63. /* first boot ? */
  64. bool is_first_boot;
  65. /* multi-core */
  66. struct skl_dsp_cores cores;
  67. /* tplg manifest */
  68. struct skl_dfw_manifest manifest;
  69. };
  70. struct skl_ipc_init_instance_msg {
  71. u32 module_id;
  72. u32 instance_id;
  73. u16 param_data_size;
  74. u8 ppl_instance_id;
  75. u8 core_id;
  76. u8 domain;
  77. };
  78. struct skl_ipc_bind_unbind_msg {
  79. u32 module_id;
  80. u32 instance_id;
  81. u32 dst_module_id;
  82. u32 dst_instance_id;
  83. u8 src_queue;
  84. u8 dst_queue;
  85. bool bind;
  86. };
  87. struct skl_ipc_large_config_msg {
  88. u32 module_id;
  89. u32 instance_id;
  90. u32 large_param_id;
  91. u32 param_data_size;
  92. };
  93. #define SKL_IPC_BOOT_MSECS 3000
  94. #define SKL_IPC_D3_MASK 0
  95. #define SKL_IPC_D0_MASK 3
  96. irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);
  97. int skl_ipc_create_pipeline(struct sst_generic_ipc *sst_ipc,
  98. u16 ppl_mem_size, u8 ppl_type, u8 instance_id);
  99. int skl_ipc_delete_pipeline(struct sst_generic_ipc *sst_ipc, u8 instance_id);
  100. int skl_ipc_set_pipeline_state(struct sst_generic_ipc *sst_ipc,
  101. u8 instance_id, enum skl_ipc_pipeline_state state);
  102. int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
  103. u8 instance_id, int dma_id);
  104. int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
  105. int skl_ipc_init_instance(struct sst_generic_ipc *sst_ipc,
  106. struct skl_ipc_init_instance_msg *msg, void *param_data);
  107. int skl_ipc_bind_unbind(struct sst_generic_ipc *sst_ipc,
  108. struct skl_ipc_bind_unbind_msg *msg);
  109. int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
  110. u8 module_cnt, void *data);
  111. int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
  112. u8 module_cnt, void *data);
  113. int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
  114. u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);
  115. int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
  116. struct skl_ipc_large_config_msg *msg, u32 *param);
  117. int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
  118. struct skl_ipc_large_config_msg *msg, u32 *param);
  119. int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
  120. u8 dma_id, u8 table_id);
  121. void skl_ipc_int_enable(struct sst_dsp *dsp);
  122. void skl_ipc_op_int_enable(struct sst_dsp *ctx);
  123. void skl_ipc_op_int_disable(struct sst_dsp *ctx);
  124. void skl_ipc_int_disable(struct sst_dsp *dsp);
  125. bool skl_ipc_int_status(struct sst_dsp *dsp);
  126. void skl_ipc_free(struct sst_generic_ipc *ipc);
  127. int skl_ipc_init(struct device *dev, struct skl_sst *skl);
  128. void skl_clear_module_cnt(struct sst_dsp *ctx);
  129. #endif /* __SKL_IPC_H */