^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Intel SKL IPC Support
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 2014-15, Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #ifndef __SKL_IPC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #define __SKL_IPC_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/irqreturn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "../common/sst-ipc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "skl-sst-dsp.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct sst_dsp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct sst_generic_ipc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) enum skl_ipc_pipeline_state {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) PPL_INVALID_STATE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) PPL_UNINITIALIZED = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) PPL_RESET = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) PPL_PAUSED = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) PPL_RUNNING = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) PPL_ERROR_STOP = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) PPL_SAVED = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) PPL_RESTORED = 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) struct skl_ipc_dxstate_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) u32 core_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) u32 dx_mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) struct skl_ipc_header {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) u32 primary;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) u32 extension;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct skl_dsp_cores {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) unsigned int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) enum skl_dsp_states *state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int *usage_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * skl_d0i3_data: skl D0i3 counters data struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * @streaming: Count of usecases that can attempt streaming D0i3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * @non_streaming: Count of usecases that can attempt non-streaming D0i3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @non_d0i3: Count of usecases that cannot attempt D0i3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @state: current state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @work: D0i3 worker thread
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct skl_d0i3_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) int streaming;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int non_streaming;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) int non_d0i3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) enum skl_dsp_d0i3_states state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct delayed_work work;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define SKL_LIB_NAME_LENGTH 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define SKL_MAX_LIB 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct skl_lib_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) char name[SKL_LIB_NAME_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) const struct firmware *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct skl_ipc_init_instance_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) u32 module_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) u32 instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) u16 param_data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) u8 ppl_instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) u8 core_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) u8 domain;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct skl_ipc_bind_unbind_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) u32 module_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) u32 instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) u32 dst_module_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) u32 dst_instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) u8 src_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) u8 dst_queue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) bool bind;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct skl_ipc_large_config_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) u32 module_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) u32 instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u32 large_param_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) u32 param_data_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) struct skl_ipc_d0ix_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u32 module_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) u32 instance_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) u8 streaming;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) u8 wake;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #define SKL_IPC_BOOT_MSECS 3000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define SKL_IPC_D3_MASK 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define SKL_IPC_D0_MASK 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) int skl_ipc_create_pipeline(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int skl_ipc_set_pipeline_state(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u8 instance_id, enum skl_ipc_pipeline_state state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u8 instance_id, int dma_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) int skl_ipc_init_instance(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct skl_ipc_init_instance_msg *msg, void *param_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) int skl_ipc_bind_unbind(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct skl_ipc_bind_unbind_msg *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) u8 module_cnt, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) u8 module_cnt, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct skl_ipc_large_config_msg *msg, u32 *param);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) struct skl_ipc_large_config_msg *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) u32 **payload, size_t *bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) u8 dma_id, u8 table_id, bool wait);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct skl_ipc_d0ix_msg *msg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) int skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) void skl_ipc_int_enable(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) void skl_ipc_op_int_enable(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) void skl_ipc_op_int_disable(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) void skl_ipc_int_disable(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) bool skl_ipc_int_status(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) void skl_ipc_free(struct sst_generic_ipc *ipc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int skl_ipc_init(struct device *dev, struct skl_dev *skl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) void skl_clear_module_cnt(struct sst_dsp *ctx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) struct skl_ipc_header header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int skl_ipc_process_notification(struct sst_generic_ipc *ipc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) struct skl_ipc_header header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) size_t tx_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) #endif /* __SKL_IPC_H */