147d7195dSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b81fd263SSubhransu S. Prusty /*
3b81fd263SSubhransu S. Prusty  * Intel SKL IPC Support
4b81fd263SSubhransu S. Prusty  *
5b81fd263SSubhransu S. Prusty  * Copyright (C) 2014-15, Intel Corporation.
6b81fd263SSubhransu S. Prusty  */
7b81fd263SSubhransu S. Prusty 
8b81fd263SSubhransu S. Prusty #ifndef __SKL_IPC_H
9b81fd263SSubhransu S. Prusty #define __SKL_IPC_H
10b81fd263SSubhransu S. Prusty 
11b81fd263SSubhransu S. Prusty #include <linux/irqreturn.h>
12b81fd263SSubhransu S. Prusty #include "../common/sst-ipc.h"
13bcc2a2dcSCezary Rojewski #include "skl-sst-dsp.h"
14b81fd263SSubhransu S. Prusty 
15b81fd263SSubhransu S. Prusty struct sst_dsp;
16b81fd263SSubhransu S. Prusty struct sst_generic_ipc;
17b81fd263SSubhransu S. Prusty 
18b81fd263SSubhransu S. Prusty enum skl_ipc_pipeline_state {
19b81fd263SSubhransu S. Prusty 	PPL_INVALID_STATE =	0,
20b81fd263SSubhransu S. Prusty 	PPL_UNINITIALIZED =	1,
21b81fd263SSubhransu S. Prusty 	PPL_RESET =		2,
22b81fd263SSubhransu S. Prusty 	PPL_PAUSED =		3,
23b81fd263SSubhransu S. Prusty 	PPL_RUNNING =		4,
24b81fd263SSubhransu S. Prusty 	PPL_ERROR_STOP =	5,
25b81fd263SSubhransu S. Prusty 	PPL_SAVED =		6,
26b81fd263SSubhransu S. Prusty 	PPL_RESTORED =		7
27b81fd263SSubhransu S. Prusty };
28b81fd263SSubhransu S. Prusty 
29b81fd263SSubhransu S. Prusty struct skl_ipc_dxstate_info {
30b81fd263SSubhransu S. Prusty 	u32 core_mask;
31b81fd263SSubhransu S. Prusty 	u32 dx_mask;
32b81fd263SSubhransu S. Prusty };
33b81fd263SSubhransu S. Prusty 
34b81fd263SSubhransu S. Prusty struct skl_ipc_header {
35b81fd263SSubhransu S. Prusty 	u32 primary;
36b81fd263SSubhransu S. Prusty 	u32 extension;
37b81fd263SSubhransu S. Prusty };
38b81fd263SSubhransu S. Prusty 
39052f103cSJayachandran B struct skl_dsp_cores {
40052f103cSJayachandran B 	unsigned int count;
41f0a550a8SGuneshwor Singh 	enum skl_dsp_states *state;
42f0a550a8SGuneshwor Singh 	int *usage_count;
43052f103cSJayachandran B };
44052f103cSJayachandran B 
455bb4cd46SJayachandran B /**
465bb4cd46SJayachandran B  * skl_d0i3_data: skl D0i3 counters data struct
475bb4cd46SJayachandran B  *
485bb4cd46SJayachandran B  * @streaming: Count of usecases that can attempt streaming D0i3
495bb4cd46SJayachandran B  * @non_streaming: Count of usecases that can attempt non-streaming D0i3
505bb4cd46SJayachandran B  * @non_d0i3: Count of usecases that cannot attempt D0i3
515bb4cd46SJayachandran B  * @state: current state
525bb4cd46SJayachandran B  * @work: D0i3 worker thread
535bb4cd46SJayachandran B  */
545bb4cd46SJayachandran B struct skl_d0i3_data {
555bb4cd46SJayachandran B 	int streaming;
565bb4cd46SJayachandran B 	int non_streaming;
575bb4cd46SJayachandran B 	int non_d0i3;
585bb4cd46SJayachandran B 	enum skl_dsp_d0i3_states state;
595bb4cd46SJayachandran B 	struct delayed_work work;
605bb4cd46SJayachandran B };
615bb4cd46SJayachandran B 
62b26199eaSJeeja KP #define SKL_LIB_NAME_LENGTH 128
63b26199eaSJeeja KP #define SKL_MAX_LIB 16
64b26199eaSJeeja KP 
65b26199eaSJeeja KP struct skl_lib_info {
66b26199eaSJeeja KP 	char name[SKL_LIB_NAME_LENGTH];
67b26199eaSJeeja KP 	const struct firmware *fw;
68b26199eaSJeeja KP };
69b26199eaSJeeja KP 
70b81fd263SSubhransu S. Prusty struct skl_ipc_init_instance_msg {
71b81fd263SSubhransu S. Prusty 	u32 module_id;
72b81fd263SSubhransu S. Prusty 	u32 instance_id;
73b81fd263SSubhransu S. Prusty 	u16 param_data_size;
74b81fd263SSubhransu S. Prusty 	u8 ppl_instance_id;
75b81fd263SSubhransu S. Prusty 	u8 core_id;
763d4006cdSSenthilnathan Veppur 	u8 domain;
77b81fd263SSubhransu S. Prusty };
78b81fd263SSubhransu S. Prusty 
79b81fd263SSubhransu S. Prusty struct skl_ipc_bind_unbind_msg {
80b81fd263SSubhransu S. Prusty 	u32 module_id;
81b81fd263SSubhransu S. Prusty 	u32 instance_id;
82b81fd263SSubhransu S. Prusty 	u32 dst_module_id;
83b81fd263SSubhransu S. Prusty 	u32 dst_instance_id;
84b81fd263SSubhransu S. Prusty 	u8 src_queue;
85b81fd263SSubhransu S. Prusty 	u8 dst_queue;
86b81fd263SSubhransu S. Prusty 	bool bind;
87b81fd263SSubhransu S. Prusty };
88b81fd263SSubhransu S. Prusty 
89b81fd263SSubhransu S. Prusty struct skl_ipc_large_config_msg {
90b81fd263SSubhransu S. Prusty 	u32 module_id;
91b81fd263SSubhransu S. Prusty 	u32 instance_id;
92b81fd263SSubhransu S. Prusty 	u32 large_param_id;
93b81fd263SSubhransu S. Prusty 	u32 param_data_size;
94b81fd263SSubhransu S. Prusty };
95b81fd263SSubhransu S. Prusty 
9641b7523fSPardha Saradhi K struct skl_ipc_d0ix_msg {
9741b7523fSPardha Saradhi K 	u32 module_id;
9841b7523fSPardha Saradhi K 	u32 instance_id;
9941b7523fSPardha Saradhi K 	u8 streaming;
10041b7523fSPardha Saradhi K 	u8 wake;
10141b7523fSPardha Saradhi K };
10241b7523fSPardha Saradhi K 
103b81fd263SSubhransu S. Prusty #define SKL_IPC_BOOT_MSECS		3000
104b81fd263SSubhransu S. Prusty 
105b81fd263SSubhransu S. Prusty #define SKL_IPC_D3_MASK	0
106b81fd263SSubhransu S. Prusty #define SKL_IPC_D0_MASK	3
107b81fd263SSubhransu S. Prusty 
108b81fd263SSubhransu S. Prusty irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);
109b81fd263SSubhransu S. Prusty 
1108f0ccd59SPierre-Louis Bossart int skl_ipc_create_pipeline(struct sst_generic_ipc *ipc,
1118a0cb236SVinod Koul 		u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode);
112b81fd263SSubhransu S. Prusty 
1138f0ccd59SPierre-Louis Bossart int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
114b81fd263SSubhransu S. Prusty 
1158f0ccd59SPierre-Louis Bossart int skl_ipc_set_pipeline_state(struct sst_generic_ipc *ipc,
116b81fd263SSubhransu S. Prusty 		u8 instance_id,	enum skl_ipc_pipeline_state state);
117b81fd263SSubhransu S. Prusty 
118b81fd263SSubhransu S. Prusty int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
119b81fd263SSubhransu S. Prusty 		u8 instance_id, int dma_id);
120b81fd263SSubhransu S. Prusty 
121b81fd263SSubhransu S. Prusty int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);
122b81fd263SSubhransu S. Prusty 
1238f0ccd59SPierre-Louis Bossart int skl_ipc_init_instance(struct sst_generic_ipc *ipc,
124b81fd263SSubhransu S. Prusty 		struct skl_ipc_init_instance_msg *msg, void *param_data);
125b81fd263SSubhransu S. Prusty 
1268f0ccd59SPierre-Louis Bossart int skl_ipc_bind_unbind(struct sst_generic_ipc *ipc,
127b81fd263SSubhransu S. Prusty 		struct skl_ipc_bind_unbind_msg *msg);
128b81fd263SSubhransu S. Prusty 
1296c5768b3SDharageswari R int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
1306c5768b3SDharageswari R 				u8 module_cnt, void *data);
1316c5768b3SDharageswari R 
1326c5768b3SDharageswari R int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
1336c5768b3SDharageswari R 				u8 module_cnt, void *data);
1346c5768b3SDharageswari R 
135b81fd263SSubhransu S. Prusty int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
136b81fd263SSubhransu S. Prusty 		u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);
137b81fd263SSubhransu S. Prusty 
138b81fd263SSubhransu S. Prusty int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
139b81fd263SSubhransu S. Prusty 		struct skl_ipc_large_config_msg *msg, u32 *param);
140b81fd263SSubhransu S. Prusty 
141cce1c7f3SMousami Jana int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
14236004c42SCezary Rojewski 		struct skl_ipc_large_config_msg *msg,
14336004c42SCezary Rojewski 		u32 **payload, size_t *bytes);
144cce1c7f3SMousami Jana 
14520fb2fbdSRamesh Babu int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
146100e7f39SSubhransu S. Prusty 			u8 dma_id, u8 table_id, bool wait);
14720fb2fbdSRamesh Babu 
14841b7523fSPardha Saradhi K int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc,
14941b7523fSPardha Saradhi K 		struct skl_ipc_d0ix_msg *msg);
15041b7523fSPardha Saradhi K 
151a83e3b4cSVinod Koul int skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state);
152a83e3b4cSVinod Koul 
1538f0ccd59SPierre-Louis Bossart void skl_ipc_int_enable(struct sst_dsp *ctx);
154b81fd263SSubhransu S. Prusty void skl_ipc_op_int_enable(struct sst_dsp *ctx);
15584c9e283SJeeja KP void skl_ipc_op_int_disable(struct sst_dsp *ctx);
1568f0ccd59SPierre-Louis Bossart void skl_ipc_int_disable(struct sst_dsp *ctx);
157b81fd263SSubhransu S. Prusty 
1588f0ccd59SPierre-Louis Bossart bool skl_ipc_int_status(struct sst_dsp *ctx);
159b81fd263SSubhransu S. Prusty void skl_ipc_free(struct sst_generic_ipc *ipc);
160bcc2a2dcSCezary Rojewski int skl_ipc_init(struct device *dev, struct skl_dev *skl);
161fe3f4442SDharageswari R void skl_clear_module_cnt(struct sst_dsp *ctx);
162b81fd263SSubhransu S. Prusty 
1634bdb04f0SGuneshwor Singh void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
1644bdb04f0SGuneshwor Singh 		struct skl_ipc_header header);
1654bdb04f0SGuneshwor Singh int skl_ipc_process_notification(struct sst_generic_ipc *ipc,
1664bdb04f0SGuneshwor Singh 		struct skl_ipc_header header);
1674bdb04f0SGuneshwor Singh void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data,
1684bdb04f0SGuneshwor Singh 		size_t tx_size);
169b81fd263SSubhransu S. Prusty #endif /* __SKL_IPC_H */
170