2 * skl-sst-ipc.c - Intel skl IPC Support
4 * Copyright (C) 2014-15, Intel Corporation.
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.
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.
15 #include <linux/device.h>
17 #include "../common/sst-dsp.h"
18 #include "../common/sst-dsp-priv.h"
19 #include "skl-sst-dsp.h"
20 #include "skl-sst-ipc.h"
23 #define IPC_IXC_STATUS_BITS 24
25 /* Global Message - Generic */
26 #define IPC_GLB_TYPE_SHIFT 24
27 #define IPC_GLB_TYPE_MASK (0xf << IPC_GLB_TYPE_SHIFT)
28 #define IPC_GLB_TYPE(x) ((x) << IPC_GLB_TYPE_SHIFT)
30 /* Global Message - Reply */
31 #define IPC_GLB_REPLY_STATUS_SHIFT 24
32 #define IPC_GLB_REPLY_STATUS_MASK ((0x1 << IPC_GLB_REPLY_STATUS_SHIFT) - 1)
33 #define IPC_GLB_REPLY_STATUS(x) ((x) << IPC_GLB_REPLY_STATUS_SHIFT)
35 #define IPC_TIMEOUT_MSECS 3000
37 #define IPC_EMPTY_LIST_SIZE 8
39 #define IPC_MSG_TARGET_SHIFT 30
40 #define IPC_MSG_TARGET_MASK 0x1
41 #define IPC_MSG_TARGET(x) (((x) & IPC_MSG_TARGET_MASK) \
42 << IPC_MSG_TARGET_SHIFT)
44 #define IPC_MSG_DIR_SHIFT 29
45 #define IPC_MSG_DIR_MASK 0x1
46 #define IPC_MSG_DIR(x) (((x) & IPC_MSG_DIR_MASK) \
48 /* Global Notification Message */
49 #define IPC_GLB_NOTIFY_TYPE_SHIFT 16
50 #define IPC_GLB_NOTIFY_TYPE_MASK 0xFF
51 #define IPC_GLB_NOTIFY_TYPE(x) (((x) >> IPC_GLB_NOTIFY_TYPE_SHIFT) \
52 & IPC_GLB_NOTIFY_TYPE_MASK)
54 #define IPC_GLB_NOTIFY_MSG_TYPE_SHIFT 24
55 #define IPC_GLB_NOTIFY_MSG_TYPE_MASK 0x1F
56 #define IPC_GLB_NOTIFY_MSG_TYPE(x) (((x) >> IPC_GLB_NOTIFY_MSG_TYPE_SHIFT) \
57 & IPC_GLB_NOTIFY_MSG_TYPE_MASK)
59 #define IPC_GLB_NOTIFY_RSP_SHIFT 29
60 #define IPC_GLB_NOTIFY_RSP_MASK 0x1
61 #define IPC_GLB_NOTIFY_RSP_TYPE(x) (((x) >> IPC_GLB_NOTIFY_RSP_SHIFT) \
62 & IPC_GLB_NOTIFY_RSP_MASK)
64 /* Pipeline operations */
66 /* Create pipeline message */
67 #define IPC_PPL_MEM_SIZE_SHIFT 0
68 #define IPC_PPL_MEM_SIZE_MASK 0x7FF
69 #define IPC_PPL_MEM_SIZE(x) (((x) & IPC_PPL_MEM_SIZE_MASK) \
70 << IPC_PPL_MEM_SIZE_SHIFT)
72 #define IPC_PPL_TYPE_SHIFT 11
73 #define IPC_PPL_TYPE_MASK 0x1F
74 #define IPC_PPL_TYPE(x) (((x) & IPC_PPL_TYPE_MASK) \
75 << IPC_PPL_TYPE_SHIFT)
77 #define IPC_INSTANCE_ID_SHIFT 16
78 #define IPC_INSTANCE_ID_MASK 0xFF
79 #define IPC_INSTANCE_ID(x) (((x) & IPC_INSTANCE_ID_MASK) \
80 << IPC_INSTANCE_ID_SHIFT)
82 /* Set pipeline state message */
83 #define IPC_PPL_STATE_SHIFT 0
84 #define IPC_PPL_STATE_MASK 0x1F
85 #define IPC_PPL_STATE(x) (((x) & IPC_PPL_STATE_MASK) \
86 << IPC_PPL_STATE_SHIFT)
88 /* Module operations primary register */
89 #define IPC_MOD_ID_SHIFT 0
90 #define IPC_MOD_ID_MASK 0xFFFF
91 #define IPC_MOD_ID(x) (((x) & IPC_MOD_ID_MASK) \
94 #define IPC_MOD_INSTANCE_ID_SHIFT 16
95 #define IPC_MOD_INSTANCE_ID_MASK 0xFF
96 #define IPC_MOD_INSTANCE_ID(x) (((x) & IPC_MOD_INSTANCE_ID_MASK) \
97 << IPC_MOD_INSTANCE_ID_SHIFT)
99 /* Init instance message extension register */
100 #define IPC_PARAM_BLOCK_SIZE_SHIFT 0
101 #define IPC_PARAM_BLOCK_SIZE_MASK 0xFFFF
102 #define IPC_PARAM_BLOCK_SIZE(x) (((x) & IPC_PARAM_BLOCK_SIZE_MASK) \
103 << IPC_PARAM_BLOCK_SIZE_SHIFT)
105 #define IPC_PPL_INSTANCE_ID_SHIFT 16
106 #define IPC_PPL_INSTANCE_ID_MASK 0xFF
107 #define IPC_PPL_INSTANCE_ID(x) (((x) & IPC_PPL_INSTANCE_ID_MASK) \
108 << IPC_PPL_INSTANCE_ID_SHIFT)
110 #define IPC_CORE_ID_SHIFT 24
111 #define IPC_CORE_ID_MASK 0x1F
112 #define IPC_CORE_ID(x) (((x) & IPC_CORE_ID_MASK) \
113 << IPC_CORE_ID_SHIFT)
115 /* Bind/Unbind message extension register */
116 #define IPC_DST_MOD_ID_SHIFT 0
117 #define IPC_DST_MOD_ID(x) (((x) & IPC_MOD_ID_MASK) \
118 << IPC_DST_MOD_ID_SHIFT)
120 #define IPC_DST_MOD_INSTANCE_ID_SHIFT 16
121 #define IPC_DST_MOD_INSTANCE_ID(x) (((x) & IPC_MOD_INSTANCE_ID_MASK) \
122 << IPC_DST_MOD_INSTANCE_ID_SHIFT)
124 #define IPC_DST_QUEUE_SHIFT 24
125 #define IPC_DST_QUEUE_MASK 0x7
126 #define IPC_DST_QUEUE(x) (((x) & IPC_DST_QUEUE_MASK) \
127 << IPC_DST_QUEUE_SHIFT)
129 #define IPC_SRC_QUEUE_SHIFT 27
130 #define IPC_SRC_QUEUE_MASK 0x7
131 #define IPC_SRC_QUEUE(x) (((x) & IPC_SRC_QUEUE_MASK) \
132 << IPC_SRC_QUEUE_SHIFT)
134 /* Save pipeline messgae extension register */
135 #define IPC_DMA_ID_SHIFT 0
136 #define IPC_DMA_ID_MASK 0x1F
137 #define IPC_DMA_ID(x) (((x) & IPC_DMA_ID_MASK) \
139 /* Large Config message extension register */
140 #define IPC_DATA_OFFSET_SZ_SHIFT 0
141 #define IPC_DATA_OFFSET_SZ_MASK 0xFFFFF
142 #define IPC_DATA_OFFSET_SZ(x) (((x) & IPC_DATA_OFFSET_SZ_MASK) \
143 << IPC_DATA_OFFSET_SZ_SHIFT)
144 #define IPC_DATA_OFFSET_SZ_CLEAR ~(IPC_DATA_OFFSET_SZ_MASK \
145 << IPC_DATA_OFFSET_SZ_SHIFT)
147 #define IPC_LARGE_PARAM_ID_SHIFT 20
148 #define IPC_LARGE_PARAM_ID_MASK 0xFF
149 #define IPC_LARGE_PARAM_ID(x) (((x) & IPC_LARGE_PARAM_ID_MASK) \
150 << IPC_LARGE_PARAM_ID_SHIFT)
152 #define IPC_FINAL_BLOCK_SHIFT 28
153 #define IPC_FINAL_BLOCK_MASK 0x1
154 #define IPC_FINAL_BLOCK(x) (((x) & IPC_FINAL_BLOCK_MASK) \
155 << IPC_FINAL_BLOCK_SHIFT)
157 #define IPC_INITIAL_BLOCK_SHIFT 29
158 #define IPC_INITIAL_BLOCK_MASK 0x1
159 #define IPC_INITIAL_BLOCK(x) (((x) & IPC_INITIAL_BLOCK_MASK) \
160 << IPC_INITIAL_BLOCK_SHIFT)
161 #define IPC_INITIAL_BLOCK_CLEAR ~(IPC_INITIAL_BLOCK_MASK \
162 << IPC_INITIAL_BLOCK_SHIFT)
164 enum skl_ipc_msg_target
{
169 enum skl_ipc_msg_direction
{
174 /* Global Message Types */
175 enum skl_ipc_glb_type
{
176 IPC_GLB_GET_FW_VERSION
= 0, /* Retrieves firmware version */
177 IPC_GLB_LOAD_MULTIPLE_MODS
= 15,
178 IPC_GLB_UNLOAD_MULTIPLE_MODS
= 16,
179 IPC_GLB_CREATE_PPL
= 17,
180 IPC_GLB_DELETE_PPL
= 18,
181 IPC_GLB_SET_PPL_STATE
= 19,
182 IPC_GLB_GET_PPL_STATE
= 20,
183 IPC_GLB_GET_PPL_CONTEXT_SIZE
= 21,
184 IPC_GLB_SAVE_PPL
= 22,
185 IPC_GLB_RESTORE_PPL
= 23,
187 IPC_GLB_MAX_IPC_MSG_NUMBER
= 31 /* Maximum message number */
190 enum skl_ipc_glb_reply
{
191 IPC_GLB_REPLY_SUCCESS
= 0,
193 IPC_GLB_REPLY_UNKNOWN_MSG_TYPE
= 1,
194 IPC_GLB_REPLY_ERROR_INVALID_PARAM
= 2,
196 IPC_GLB_REPLY_BUSY
= 3,
197 IPC_GLB_REPLY_PENDING
= 4,
198 IPC_GLB_REPLY_FAILURE
= 5,
199 IPC_GLB_REPLY_INVALID_REQUEST
= 6,
201 IPC_GLB_REPLY_OUT_OF_MEMORY
= 7,
202 IPC_GLB_REPLY_OUT_OF_MIPS
= 8,
204 IPC_GLB_REPLY_INVALID_RESOURCE_ID
= 9,
205 IPC_GLB_REPLY_INVALID_RESOURCE_STATE
= 10,
207 IPC_GLB_REPLY_MOD_MGMT_ERROR
= 100,
208 IPC_GLB_REPLY_MOD_LOAD_CL_FAILED
= 101,
209 IPC_GLB_REPLY_MOD_LOAD_INVALID_HASH
= 102,
211 IPC_GLB_REPLY_MOD_UNLOAD_INST_EXIST
= 103,
212 IPC_GLB_REPLY_MOD_NOT_INITIALIZED
= 104,
214 IPC_GLB_REPLY_INVALID_CONFIG_PARAM_ID
= 120,
215 IPC_GLB_REPLY_INVALID_CONFIG_DATA_LEN
= 121,
216 IPC_GLB_REPLY_GATEWAY_NOT_INITIALIZED
= 140,
217 IPC_GLB_REPLY_GATEWAY_NOT_EXIST
= 141,
219 IPC_GLB_REPLY_PPL_NOT_INITIALIZED
= 160,
220 IPC_GLB_REPLY_PPL_NOT_EXIST
= 161,
221 IPC_GLB_REPLY_PPL_SAVE_FAILED
= 162,
222 IPC_GLB_REPLY_PPL_RESTORE_FAILED
= 163,
224 IPC_MAX_STATUS
= ((1<<IPC_IXC_STATUS_BITS
)-1)
227 enum skl_ipc_notification_type
{
228 IPC_GLB_NOTIFY_GLITCH
= 0,
229 IPC_GLB_NOTIFY_OVERRUN
= 1,
230 IPC_GLB_NOTIFY_UNDERRUN
= 2,
231 IPC_GLB_NOTIFY_END_STREAM
= 3,
232 IPC_GLB_NOTIFY_PHRASE_DETECTED
= 4,
233 IPC_GLB_NOTIFY_RESOURCE_EVENT
= 5,
234 IPC_GLB_NOTIFY_LOG_BUFFER_STATUS
= 6,
235 IPC_GLB_NOTIFY_TIMESTAMP_CAPTURED
= 7,
236 IPC_GLB_NOTIFY_FW_READY
= 8
239 /* Module Message Types */
240 enum skl_ipc_module_msg
{
241 IPC_MOD_INIT_INSTANCE
= 0,
242 IPC_MOD_CONFIG_GET
= 1,
243 IPC_MOD_CONFIG_SET
= 2,
244 IPC_MOD_LARGE_CONFIG_GET
= 3,
245 IPC_MOD_LARGE_CONFIG_SET
= 4,
251 static void skl_ipc_tx_data_copy(struct ipc_message
*msg
, char *tx_data
,
255 memcpy(msg
->tx_data
, tx_data
, tx_size
);
258 static bool skl_ipc_is_dsp_busy(struct sst_dsp
*dsp
)
262 hipci
= sst_dsp_shim_read_unlocked(dsp
, SKL_ADSP_REG_HIPCI
);
263 return (hipci
& SKL_ADSP_REG_HIPCI_BUSY
);
266 /* Lock to be held by caller */
267 static void skl_ipc_tx_msg(struct sst_generic_ipc
*ipc
, struct ipc_message
*msg
)
269 struct skl_ipc_header
*header
= (struct skl_ipc_header
*)(&msg
->header
);
272 sst_dsp_outbox_write(ipc
->dsp
, msg
->tx_data
, msg
->tx_size
);
273 sst_dsp_shim_write_unlocked(ipc
->dsp
, SKL_ADSP_REG_HIPCIE
,
275 sst_dsp_shim_write_unlocked(ipc
->dsp
, SKL_ADSP_REG_HIPCI
,
276 header
->primary
| SKL_ADSP_REG_HIPCI_BUSY
);
279 static struct ipc_message
*skl_ipc_reply_get_msg(struct sst_generic_ipc
*ipc
,
282 struct ipc_message
*msg
= NULL
;
283 struct skl_ipc_header
*header
= (struct skl_ipc_header
*)(&ipc_header
);
285 if (list_empty(&ipc
->rx_list
)) {
286 dev_err(ipc
->dev
, "ipc: rx list is empty but received 0x%x\n",
291 msg
= list_first_entry(&ipc
->rx_list
, struct ipc_message
, list
);
298 static int skl_ipc_process_notification(struct sst_generic_ipc
*ipc
,
299 struct skl_ipc_header header
)
301 struct skl_sst
*skl
= container_of(ipc
, struct skl_sst
, ipc
);
303 if (IPC_GLB_NOTIFY_MSG_TYPE(header
.primary
)) {
304 switch (IPC_GLB_NOTIFY_TYPE(header
.primary
)) {
306 case IPC_GLB_NOTIFY_UNDERRUN
:
307 dev_err(ipc
->dev
, "FW Underrun %x\n", header
.primary
);
310 case IPC_GLB_NOTIFY_RESOURCE_EVENT
:
311 dev_err(ipc
->dev
, "MCPS Budget Violation: %x\n",
315 case IPC_GLB_NOTIFY_FW_READY
:
316 skl
->boot_complete
= true;
317 wake_up(&skl
->boot_wait
);
321 dev_err(ipc
->dev
, "ipc: Unhandled error msg=%x",
330 static void skl_ipc_process_reply(struct sst_generic_ipc
*ipc
,
331 struct skl_ipc_header header
)
333 struct ipc_message
*msg
;
334 u32 reply
= header
.primary
& IPC_GLB_REPLY_STATUS_MASK
;
335 u64
*ipc_header
= (u64
*)(&header
);
337 msg
= skl_ipc_reply_get_msg(ipc
, *ipc_header
);
339 dev_dbg(ipc
->dev
, "ipc: rx list is empty\n");
343 /* first process the header */
345 case IPC_GLB_REPLY_SUCCESS
:
346 dev_info(ipc
->dev
, "ipc FW reply %x: success\n", header
.primary
);
349 case IPC_GLB_REPLY_OUT_OF_MEMORY
:
350 dev_err(ipc
->dev
, "ipc fw reply: %x: no memory\n", header
.primary
);
351 msg
->errno
= -ENOMEM
;
354 case IPC_GLB_REPLY_BUSY
:
355 dev_err(ipc
->dev
, "ipc fw reply: %x: Busy\n", header
.primary
);
360 dev_err(ipc
->dev
, "Unknown ipc reply: 0x%x", reply
);
361 msg
->errno
= -EINVAL
;
365 if (reply
!= IPC_GLB_REPLY_SUCCESS
) {
366 dev_err(ipc
->dev
, "ipc FW reply: reply=%d", reply
);
367 dev_err(ipc
->dev
, "FW Error Code: %u\n",
368 ipc
->dsp
->fw_ops
.get_fw_errcode(ipc
->dsp
));
371 list_del(&msg
->list
);
372 sst_ipc_tx_msg_reply_complete(ipc
, msg
);
375 irqreturn_t
skl_dsp_irq_thread_handler(int irq
, void *context
)
377 struct sst_dsp
*dsp
= context
;
378 struct skl_sst
*skl
= sst_dsp_get_thread_context(dsp
);
379 struct sst_generic_ipc
*ipc
= &skl
->ipc
;
380 struct skl_ipc_header header
= {0};
381 u32 hipcie
, hipct
, hipcte
;
384 if (dsp
->intr_status
& SKL_ADSPIS_CL_DMA
)
385 skl_cldma_process_intr(dsp
);
387 /* Here we handle IPC interrupts only */
388 if (!(dsp
->intr_status
& SKL_ADSPIS_IPC
))
391 hipcie
= sst_dsp_shim_read_unlocked(dsp
, SKL_ADSP_REG_HIPCIE
);
392 hipct
= sst_dsp_shim_read_unlocked(dsp
, SKL_ADSP_REG_HIPCT
);
394 /* reply message from DSP */
395 if (hipcie
& SKL_ADSP_REG_HIPCIE_DONE
) {
396 sst_dsp_shim_update_bits(dsp
, SKL_ADSP_REG_HIPCCTL
,
397 SKL_ADSP_REG_HIPCCTL_DONE
, 0);
399 /* clear DONE bit - tell DSP we have completed the operation */
400 sst_dsp_shim_update_bits_forced(dsp
, SKL_ADSP_REG_HIPCIE
,
401 SKL_ADSP_REG_HIPCIE_DONE
, SKL_ADSP_REG_HIPCIE_DONE
);
405 /* unmask Done interrupt */
406 sst_dsp_shim_update_bits(dsp
, SKL_ADSP_REG_HIPCCTL
,
407 SKL_ADSP_REG_HIPCCTL_DONE
, SKL_ADSP_REG_HIPCCTL_DONE
);
410 /* New message from DSP */
411 if (hipct
& SKL_ADSP_REG_HIPCT_BUSY
) {
412 hipcte
= sst_dsp_shim_read_unlocked(dsp
, SKL_ADSP_REG_HIPCTE
);
413 header
.primary
= hipct
;
414 header
.extension
= hipcte
;
415 dev_dbg(dsp
->dev
, "IPC irq: Firmware respond primary:%x",
417 dev_dbg(dsp
->dev
, "IPC irq: Firmware respond extension:%x",
420 if (IPC_GLB_NOTIFY_RSP_TYPE(header
.primary
)) {
421 /* Handle Immediate reply from DSP Core */
422 skl_ipc_process_reply(ipc
, header
);
424 dev_dbg(dsp
->dev
, "IPC irq: Notification from firmware\n");
425 skl_ipc_process_notification(ipc
, header
);
427 /* clear busy interrupt */
428 sst_dsp_shim_update_bits_forced(dsp
, SKL_ADSP_REG_HIPCT
,
429 SKL_ADSP_REG_HIPCT_BUSY
, SKL_ADSP_REG_HIPCT_BUSY
);
436 skl_ipc_int_enable(dsp
);
438 /* continue to send any remaining messages... */
439 queue_kthread_work(&ipc
->kworker
, &ipc
->kwork
);
444 void skl_ipc_int_enable(struct sst_dsp
*ctx
)
446 sst_dsp_shim_update_bits(ctx
, SKL_ADSP_REG_ADSPIC
,
447 SKL_ADSPIC_IPC
, SKL_ADSPIC_IPC
);
450 void skl_ipc_int_disable(struct sst_dsp
*ctx
)
452 sst_dsp_shim_update_bits_unlocked(ctx
, SKL_ADSP_REG_ADSPIC
,
456 void skl_ipc_op_int_enable(struct sst_dsp
*ctx
)
458 /* enable IPC DONE interrupt */
459 sst_dsp_shim_update_bits(ctx
, SKL_ADSP_REG_HIPCCTL
,
460 SKL_ADSP_REG_HIPCCTL_DONE
, SKL_ADSP_REG_HIPCCTL_DONE
);
462 /* Enable IPC BUSY interrupt */
463 sst_dsp_shim_update_bits(ctx
, SKL_ADSP_REG_HIPCCTL
,
464 SKL_ADSP_REG_HIPCCTL_BUSY
, SKL_ADSP_REG_HIPCCTL_BUSY
);
467 void skl_ipc_op_int_disable(struct sst_dsp
*ctx
)
469 /* disable IPC DONE interrupt */
470 sst_dsp_shim_update_bits_unlocked(ctx
, SKL_ADSP_REG_HIPCCTL
,
471 SKL_ADSP_REG_HIPCCTL_DONE
, 0);
473 /* Disable IPC BUSY interrupt */
474 sst_dsp_shim_update_bits_unlocked(ctx
, SKL_ADSP_REG_HIPCCTL
,
475 SKL_ADSP_REG_HIPCCTL_BUSY
, 0);
479 bool skl_ipc_int_status(struct sst_dsp
*ctx
)
481 return sst_dsp_shim_read_unlocked(ctx
,
482 SKL_ADSP_REG_ADSPIS
) & SKL_ADSPIS_IPC
;
485 int skl_ipc_init(struct device
*dev
, struct skl_sst
*skl
)
487 struct sst_generic_ipc
*ipc
;
494 ipc
->tx_data_max_size
= SKL_ADSP_W1_SZ
;
495 ipc
->rx_data_max_size
= SKL_ADSP_W0_UP_SZ
;
497 err
= sst_ipc_init(ipc
);
501 ipc
->ops
.tx_msg
= skl_ipc_tx_msg
;
502 ipc
->ops
.tx_data_copy
= skl_ipc_tx_data_copy
;
503 ipc
->ops
.is_dsp_busy
= skl_ipc_is_dsp_busy
;
508 void skl_ipc_free(struct sst_generic_ipc
*ipc
)
510 /* Disable IPC DONE interrupt */
511 sst_dsp_shim_update_bits(ipc
->dsp
, SKL_ADSP_REG_HIPCCTL
,
512 SKL_ADSP_REG_HIPCCTL_DONE
, 0);
514 /* Disable IPC BUSY interrupt */
515 sst_dsp_shim_update_bits(ipc
->dsp
, SKL_ADSP_REG_HIPCCTL
,
516 SKL_ADSP_REG_HIPCCTL_BUSY
, 0);
521 int skl_ipc_create_pipeline(struct sst_generic_ipc
*ipc
,
522 u16 ppl_mem_size
, u8 ppl_type
, u8 instance_id
)
524 struct skl_ipc_header header
= {0};
525 u64
*ipc_header
= (u64
*)(&header
);
528 header
.primary
= IPC_MSG_TARGET(IPC_FW_GEN_MSG
);
529 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
530 header
.primary
|= IPC_GLB_TYPE(IPC_GLB_CREATE_PPL
);
531 header
.primary
|= IPC_INSTANCE_ID(instance_id
);
532 header
.primary
|= IPC_PPL_TYPE(ppl_type
);
533 header
.primary
|= IPC_PPL_MEM_SIZE(ppl_mem_size
);
535 dev_dbg(ipc
->dev
, "In %s header=%d\n", __func__
, header
.primary
);
536 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
538 dev_err(ipc
->dev
, "ipc: create pipeline fail, err: %d\n", ret
);
544 EXPORT_SYMBOL_GPL(skl_ipc_create_pipeline
);
546 int skl_ipc_delete_pipeline(struct sst_generic_ipc
*ipc
, u8 instance_id
)
548 struct skl_ipc_header header
= {0};
549 u64
*ipc_header
= (u64
*)(&header
);
552 header
.primary
= IPC_MSG_TARGET(IPC_FW_GEN_MSG
);
553 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
554 header
.primary
|= IPC_GLB_TYPE(IPC_GLB_DELETE_PPL
);
555 header
.primary
|= IPC_INSTANCE_ID(instance_id
);
557 dev_dbg(ipc
->dev
, "In %s header=%d\n", __func__
, header
.primary
);
558 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
560 dev_err(ipc
->dev
, "ipc: delete pipeline failed, err %d\n", ret
);
566 EXPORT_SYMBOL_GPL(skl_ipc_delete_pipeline
);
568 int skl_ipc_set_pipeline_state(struct sst_generic_ipc
*ipc
,
569 u8 instance_id
, enum skl_ipc_pipeline_state state
)
571 struct skl_ipc_header header
= {0};
572 u64
*ipc_header
= (u64
*)(&header
);
575 header
.primary
= IPC_MSG_TARGET(IPC_FW_GEN_MSG
);
576 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
577 header
.primary
|= IPC_GLB_TYPE(IPC_GLB_SET_PPL_STATE
);
578 header
.primary
|= IPC_INSTANCE_ID(instance_id
);
579 header
.primary
|= IPC_PPL_STATE(state
);
581 dev_dbg(ipc
->dev
, "In %s header=%d\n", __func__
, header
.primary
);
582 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
584 dev_err(ipc
->dev
, "ipc: set pipeline state failed, err: %d\n", ret
);
589 EXPORT_SYMBOL_GPL(skl_ipc_set_pipeline_state
);
592 skl_ipc_save_pipeline(struct sst_generic_ipc
*ipc
, u8 instance_id
, int dma_id
)
594 struct skl_ipc_header header
= {0};
595 u64
*ipc_header
= (u64
*)(&header
);
598 header
.primary
= IPC_MSG_TARGET(IPC_FW_GEN_MSG
);
599 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
600 header
.primary
|= IPC_GLB_TYPE(IPC_GLB_SAVE_PPL
);
601 header
.primary
|= IPC_INSTANCE_ID(instance_id
);
603 header
.extension
= IPC_DMA_ID(dma_id
);
604 dev_dbg(ipc
->dev
, "In %s header=%d\n", __func__
, header
.primary
);
605 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
607 dev_err(ipc
->dev
, "ipc: save pipeline failed, err: %d\n", ret
);
613 EXPORT_SYMBOL_GPL(skl_ipc_save_pipeline
);
615 int skl_ipc_restore_pipeline(struct sst_generic_ipc
*ipc
, u8 instance_id
)
617 struct skl_ipc_header header
= {0};
618 u64
*ipc_header
= (u64
*)(&header
);
621 header
.primary
= IPC_MSG_TARGET(IPC_FW_GEN_MSG
);
622 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
623 header
.primary
|= IPC_GLB_TYPE(IPC_GLB_RESTORE_PPL
);
624 header
.primary
|= IPC_INSTANCE_ID(instance_id
);
626 dev_dbg(ipc
->dev
, "In %s header=%d\n", __func__
, header
.primary
);
627 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
629 dev_err(ipc
->dev
, "ipc: restore pipeline failed, err: %d\n", ret
);
635 EXPORT_SYMBOL_GPL(skl_ipc_restore_pipeline
);
637 int skl_ipc_set_dx(struct sst_generic_ipc
*ipc
, u8 instance_id
,
638 u16 module_id
, struct skl_ipc_dxstate_info
*dx
)
640 struct skl_ipc_header header
= {0};
641 u64
*ipc_header
= (u64
*)(&header
);
644 header
.primary
= IPC_MSG_TARGET(IPC_MOD_MSG
);
645 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
646 header
.primary
|= IPC_GLB_TYPE(IPC_MOD_SET_DX
);
647 header
.primary
|= IPC_MOD_INSTANCE_ID(instance_id
);
648 header
.primary
|= IPC_MOD_ID(module_id
);
650 dev_dbg(ipc
->dev
, "In %s primary =%x ext=%x\n", __func__
,
651 header
.primary
, header
.extension
);
652 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
,
653 dx
, sizeof(dx
), NULL
, 0);
655 dev_err(ipc
->dev
, "ipc: set dx failed, err %d\n", ret
);
661 EXPORT_SYMBOL_GPL(skl_ipc_set_dx
);
663 int skl_ipc_init_instance(struct sst_generic_ipc
*ipc
,
664 struct skl_ipc_init_instance_msg
*msg
, void *param_data
)
666 struct skl_ipc_header header
= {0};
667 u64
*ipc_header
= (u64
*)(&header
);
669 u32
*buffer
= (u32
*)param_data
;
670 /* param_block_size must be in dwords */
671 u16 param_block_size
= msg
->param_data_size
/ sizeof(u32
);
673 print_hex_dump(KERN_DEBUG
, NULL
, DUMP_PREFIX_NONE
,
674 16, 4, buffer
, param_block_size
, false);
676 header
.primary
= IPC_MSG_TARGET(IPC_MOD_MSG
);
677 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
678 header
.primary
|= IPC_GLB_TYPE(IPC_MOD_INIT_INSTANCE
);
679 header
.primary
|= IPC_MOD_INSTANCE_ID(msg
->instance_id
);
680 header
.primary
|= IPC_MOD_ID(msg
->module_id
);
682 header
.extension
= IPC_CORE_ID(msg
->core_id
);
683 header
.extension
|= IPC_PPL_INSTANCE_ID(msg
->ppl_instance_id
);
684 header
.extension
|= IPC_PARAM_BLOCK_SIZE(param_block_size
);
686 dev_dbg(ipc
->dev
, "In %s primary =%x ext=%x\n", __func__
,
687 header
.primary
, header
.extension
);
688 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, param_data
,
689 msg
->param_data_size
, NULL
, 0);
692 dev_err(ipc
->dev
, "ipc: init instance failed\n");
698 EXPORT_SYMBOL_GPL(skl_ipc_init_instance
);
700 int skl_ipc_bind_unbind(struct sst_generic_ipc
*ipc
,
701 struct skl_ipc_bind_unbind_msg
*msg
)
703 struct skl_ipc_header header
= {0};
704 u64
*ipc_header
= (u64
*)(&header
);
705 u8 bind_unbind
= msg
->bind
? IPC_MOD_BIND
: IPC_MOD_UNBIND
;
708 header
.primary
= IPC_MSG_TARGET(IPC_MOD_MSG
);
709 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
710 header
.primary
|= IPC_GLB_TYPE(bind_unbind
);
711 header
.primary
|= IPC_MOD_INSTANCE_ID(msg
->instance_id
);
712 header
.primary
|= IPC_MOD_ID(msg
->module_id
);
714 header
.extension
= IPC_DST_MOD_ID(msg
->dst_module_id
);
715 header
.extension
|= IPC_DST_MOD_INSTANCE_ID(msg
->dst_instance_id
);
716 header
.extension
|= IPC_DST_QUEUE(msg
->dst_queue
);
717 header
.extension
|= IPC_SRC_QUEUE(msg
->src_queue
);
719 dev_dbg(ipc
->dev
, "In %s hdr=%x ext=%x\n", __func__
, header
.primary
,
721 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
, NULL
, 0, NULL
, 0);
723 dev_err(ipc
->dev
, "ipc: bind/unbind faileden");
729 EXPORT_SYMBOL_GPL(skl_ipc_bind_unbind
);
731 int skl_ipc_set_large_config(struct sst_generic_ipc
*ipc
,
732 struct skl_ipc_large_config_msg
*msg
, u32
*param
)
734 struct skl_ipc_header header
= {0};
735 u64
*ipc_header
= (u64
*)(&header
);
737 size_t sz_remaining
, tx_size
, data_offset
;
739 header
.primary
= IPC_MSG_TARGET(IPC_MOD_MSG
);
740 header
.primary
|= IPC_MSG_DIR(IPC_MSG_REQUEST
);
741 header
.primary
|= IPC_GLB_TYPE(IPC_MOD_LARGE_CONFIG_SET
);
742 header
.primary
|= IPC_MOD_INSTANCE_ID(msg
->instance_id
);
743 header
.primary
|= IPC_MOD_ID(msg
->module_id
);
745 header
.extension
= IPC_DATA_OFFSET_SZ(msg
->param_data_size
);
746 header
.extension
|= IPC_LARGE_PARAM_ID(msg
->large_param_id
);
747 header
.extension
|= IPC_FINAL_BLOCK(0);
748 header
.extension
|= IPC_INITIAL_BLOCK(1);
750 sz_remaining
= msg
->param_data_size
;
752 while (sz_remaining
!= 0) {
753 tx_size
= sz_remaining
> SKL_ADSP_W1_SZ
754 ? SKL_ADSP_W1_SZ
: sz_remaining
;
755 if (tx_size
== sz_remaining
)
756 header
.extension
|= IPC_FINAL_BLOCK(1);
758 dev_dbg(ipc
->dev
, "In %s primary=%#x ext=%#x\n", __func__
,
759 header
.primary
, header
.extension
);
760 dev_dbg(ipc
->dev
, "transmitting offset: %#x, size: %#x\n",
761 (unsigned)data_offset
, (unsigned)tx_size
);
762 ret
= sst_ipc_tx_message_wait(ipc
, *ipc_header
,
763 ((char *)param
) + data_offset
,
767 "ipc: set large config fail, err: %d\n", ret
);
770 sz_remaining
-= tx_size
;
771 data_offset
= msg
->param_data_size
- sz_remaining
;
773 /* clear the fields */
774 header
.extension
&= IPC_INITIAL_BLOCK_CLEAR
;
775 header
.extension
&= IPC_DATA_OFFSET_SZ_CLEAR
;
776 /* fill the fields */
777 header
.extension
|= IPC_INITIAL_BLOCK(0);
778 header
.extension
|= IPC_DATA_OFFSET_SZ(data_offset
);
783 EXPORT_SYMBOL_GPL(skl_ipc_set_large_config
);