xref: /linux/sound/soc/intel/atom/sst/sst.h (revision a1c613ae4c322ddd58d5a8539dbfba2a0380a8c0)
18e8e69d6SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2b97169daSJie Yang /*
3b97169daSJie Yang  *  sst.h - Intel SST Driver for audio engine
4b97169daSJie Yang  *
5b97169daSJie Yang  *  Copyright (C) 2008-14 Intel Corporation
6b97169daSJie Yang  *  Authors:	Vinod Koul <vinod.koul@intel.com>
7b97169daSJie Yang  *		Harsha Priya <priya.harsha@intel.com>
8b97169daSJie Yang  *		Dharageswari R <dharageswari.r@intel.com>
9b97169daSJie Yang  *		KP Jeeja <jeeja.kp@intel.com>
10b97169daSJie Yang  *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11b97169daSJie Yang  *
12b97169daSJie Yang  * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13b97169daSJie Yang  *
14b97169daSJie Yang  *  Common private declarations for SST
15b97169daSJie Yang  */
16b97169daSJie Yang #ifndef __SST_H__
17b97169daSJie Yang #define __SST_H__
18b97169daSJie Yang 
19b97169daSJie Yang #include <linux/firmware.h>
20b97169daSJie Yang 
21b97169daSJie Yang /* driver names */
22b97169daSJie Yang #define SST_DRV_NAME "intel_sst_driver"
23b97169daSJie Yang 
24b97169daSJie Yang #define SST_SUSPEND_DELAY 2000
25b97169daSJie Yang #define FW_CONTEXT_MEM (64*1024)
26b97169daSJie Yang #define SST_ICCM_BOUNDARY 4
27b97169daSJie Yang #define SST_CONFIG_SSP_SIGN 0x7ffe8001
28b97169daSJie Yang 
29b97169daSJie Yang #define MRFLD_FW_VIRTUAL_BASE 0xC0000000
30b97169daSJie Yang #define MRFLD_FW_DDR_BASE_OFFSET 0x0
31b97169daSJie Yang #define MRFLD_FW_FEATURE_BASE_OFFSET 0x4
32b97169daSJie Yang #define MRFLD_FW_BSS_RESET_BIT 0
33b97169daSJie Yang 
34b972153dSCezary Rojewski /* SST Shim register map */
35b972153dSCezary Rojewski #define SST_CSR			0x00
36b972153dSCezary Rojewski #define SST_ISRX		0x18
37b972153dSCezary Rojewski #define SST_IMRX		0x28
38b972153dSCezary Rojewski #define SST_IPCX		0x38 /* IPC IA -> SST */
39b972153dSCezary Rojewski #define SST_IPCD		0x40 /* IPC SST -> IA */
40b972153dSCezary Rojewski 
41b97169daSJie Yang extern const struct dev_pm_ops intel_sst_pm;
42b97169daSJie Yang enum sst_states {
43b97169daSJie Yang 	SST_FW_LOADING = 1,
44b97169daSJie Yang 	SST_FW_RUNNING,
45b97169daSJie Yang 	SST_RESET,
46b97169daSJie Yang 	SST_SHUTDOWN,
47b97169daSJie Yang };
48b97169daSJie Yang 
49b97169daSJie Yang enum sst_algo_ops {
50b97169daSJie Yang 	SST_SET_ALGO = 0,
51b97169daSJie Yang 	SST_GET_ALGO = 1,
52b97169daSJie Yang };
53b97169daSJie Yang 
54b97169daSJie Yang #define SST_BLOCK_TIMEOUT	1000
55b97169daSJie Yang 
56b97169daSJie Yang #define FW_SIGNATURE_SIZE	4
57b97169daSJie Yang #define FW_NAME_SIZE		32
58b97169daSJie Yang 
59b97169daSJie Yang /* stream states */
60b97169daSJie Yang enum sst_stream_states {
61b97169daSJie Yang 	STREAM_UN_INIT	= 0,	/* Freed/Not used stream */
62b97169daSJie Yang 	STREAM_RUNNING	= 1,	/* Running */
63b97169daSJie Yang 	STREAM_PAUSED	= 2,	/* Paused stream */
64de983347SHans de Goede 	STREAM_INIT	= 3,	/* stream init, waiting for data */
65b97169daSJie Yang };
66b97169daSJie Yang 
67b97169daSJie Yang enum sst_ram_type {
68b97169daSJie Yang 	SST_IRAM	= 1,
69b97169daSJie Yang 	SST_DRAM	= 2,
70b97169daSJie Yang 	SST_DDR	= 5,
71b97169daSJie Yang 	SST_CUSTOM_INFO	= 7,	/* consists of FW binary information */
72b97169daSJie Yang };
73b97169daSJie Yang 
74b97169daSJie Yang /* SST shim registers to structure mapping */
75b97169daSJie Yang union interrupt_reg {
76b97169daSJie Yang 	struct {
77b97169daSJie Yang 		u64 done_interrupt:1;
78b97169daSJie Yang 		u64 busy_interrupt:1;
79b97169daSJie Yang 		u64 rsvd:62;
80b97169daSJie Yang 	} part;
81b97169daSJie Yang 	u64 full;
82b97169daSJie Yang };
83b97169daSJie Yang 
84b97169daSJie Yang union sst_pisr_reg {
85b97169daSJie Yang 	struct {
86b97169daSJie Yang 		u32 pssp0:1;
87b97169daSJie Yang 		u32 pssp1:1;
88b97169daSJie Yang 		u32 rsvd0:3;
89b97169daSJie Yang 		u32 dmac:1;
90b97169daSJie Yang 		u32 rsvd1:26;
91b97169daSJie Yang 	} part;
92b97169daSJie Yang 	u32 full;
93b97169daSJie Yang };
94b97169daSJie Yang 
95b97169daSJie Yang union sst_pimr_reg {
96b97169daSJie Yang 	struct {
97b97169daSJie Yang 		u32 ssp0:1;
98b97169daSJie Yang 		u32 ssp1:1;
99b97169daSJie Yang 		u32 rsvd0:3;
100b97169daSJie Yang 		u32 dmac:1;
101b97169daSJie Yang 		u32 rsvd1:10;
102b97169daSJie Yang 		u32 ssp0_sc:1;
103b97169daSJie Yang 		u32 ssp1_sc:1;
104b97169daSJie Yang 		u32 rsvd2:3;
105b97169daSJie Yang 		u32 dmac_sc:1;
106b97169daSJie Yang 		u32 rsvd3:10;
107b97169daSJie Yang 	} part;
108b97169daSJie Yang 	u32 full;
109b97169daSJie Yang };
110b97169daSJie Yang 
111b97169daSJie Yang union config_status_reg_mrfld {
112b97169daSJie Yang 	struct {
113b97169daSJie Yang 		u64 lpe_reset:1;
114b97169daSJie Yang 		u64 lpe_reset_vector:1;
115b97169daSJie Yang 		u64 runstall:1;
116b97169daSJie Yang 		u64 pwaitmode:1;
117b97169daSJie Yang 		u64 clk_sel:3;
118b97169daSJie Yang 		u64 rsvd2:1;
119b97169daSJie Yang 		u64 sst_clk:3;
120b97169daSJie Yang 		u64 xt_snoop:1;
121b97169daSJie Yang 		u64 rsvd3:4;
122b97169daSJie Yang 		u64 clk_sel1:6;
123b97169daSJie Yang 		u64 clk_enable:3;
124b97169daSJie Yang 		u64 rsvd4:6;
125b97169daSJie Yang 		u64 slim0baseclk:1;
126b97169daSJie Yang 		u64 rsvd:32;
127b97169daSJie Yang 	} part;
128b97169daSJie Yang 	u64 full;
129b97169daSJie Yang };
130b97169daSJie Yang 
131b97169daSJie Yang union interrupt_reg_mrfld {
132b97169daSJie Yang 	struct {
133b97169daSJie Yang 		u64 done_interrupt:1;
134b97169daSJie Yang 		u64 busy_interrupt:1;
135b97169daSJie Yang 		u64 rsvd:62;
136b97169daSJie Yang 	} part;
137b97169daSJie Yang 	u64 full;
138b97169daSJie Yang };
139b97169daSJie Yang 
140b97169daSJie Yang union sst_imr_reg_mrfld {
141b97169daSJie Yang 	struct {
142b97169daSJie Yang 		u64 done_interrupt:1;
143b97169daSJie Yang 		u64 busy_interrupt:1;
144b97169daSJie Yang 		u64 rsvd:62;
145b97169daSJie Yang 	} part;
146b97169daSJie Yang 	u64 full;
147b97169daSJie Yang };
148b97169daSJie Yang 
149b97169daSJie Yang /**
150b97169daSJie Yang  * struct sst_block - This structure is used to block a user/fw data call to another
151b97169daSJie Yang  * fw/user call
152b97169daSJie Yang  *
153b97169daSJie Yang  * @condition: condition for blocking check
154b97169daSJie Yang  * @ret_code: ret code when block is released
155b97169daSJie Yang  * @data: data ptr
156b97169daSJie Yang  * @size: size of data
157b97169daSJie Yang  * @on: block condition
158b97169daSJie Yang  * @msg_id: msg_id = msgid in mfld/ctp, mrfld = NULL
159b97169daSJie Yang  * @drv_id: str_id in mfld/ctp, = drv_id in mrfld
160b97169daSJie Yang  * @node: list head node
161b97169daSJie Yang  */
162b97169daSJie Yang struct sst_block {
163b97169daSJie Yang 	bool	condition;
164b97169daSJie Yang 	int	ret_code;
165b97169daSJie Yang 	void	*data;
166b97169daSJie Yang 	u32     size;
167b97169daSJie Yang 	bool	on;
168b97169daSJie Yang 	u32     msg_id;
169b97169daSJie Yang 	u32     drv_id;
170b97169daSJie Yang 	struct list_head node;
171b97169daSJie Yang };
172b97169daSJie Yang 
173b97169daSJie Yang /**
174b97169daSJie Yang  * struct stream_info - structure that holds the stream information
175b97169daSJie Yang  *
176b97169daSJie Yang  * @status : stream current state
177b97169daSJie Yang  * @prev : stream prev state
178bf642bf5SHans de Goede  * @resume_status : stream current state to restore on resume
179bf642bf5SHans de Goede  * @resume_prev : stream prev state to restore on resume
180b97169daSJie Yang  * @lock : stream mutex for protecting state
181473858caSHans de Goede  * @alloc_param : parameters used for stream (re-)allocation
182b97169daSJie Yang  * @pcm_substream : PCM substream
183b97169daSJie Yang  * @period_elapsed : PCM period elapsed callback
184b97169daSJie Yang  * @sfreq : stream sampling freq
185b97169daSJie Yang  * @cumm_bytes : cummulative bytes decoded
186b97169daSJie Yang  */
187b97169daSJie Yang struct stream_info {
188b97169daSJie Yang 	unsigned int		status;
189b97169daSJie Yang 	unsigned int		prev;
190bf642bf5SHans de Goede 	unsigned int		resume_status;
191bf642bf5SHans de Goede 	unsigned int		resume_prev;
192b97169daSJie Yang 	struct mutex		lock;
193473858caSHans de Goede 	struct snd_sst_alloc_mrfld alloc_param;
194b97169daSJie Yang 
195b97169daSJie Yang 	void			*pcm_substream;
196b97169daSJie Yang 	void (*period_elapsed)(void *pcm_substream);
197b97169daSJie Yang 
198b97169daSJie Yang 	unsigned int		sfreq;
199b97169daSJie Yang 	u32			cumm_bytes;
200b97169daSJie Yang 
201b97169daSJie Yang 	void			*compr_cb_param;
202b97169daSJie Yang 	void (*compr_cb)(void *compr_cb_param);
203b97169daSJie Yang 
204b97169daSJie Yang 	void			*drain_cb_param;
205b97169daSJie Yang 	void (*drain_notify)(void *drain_cb_param);
206b97169daSJie Yang 
207b97169daSJie Yang 	unsigned int		num_ch;
208b97169daSJie Yang 	unsigned int		pipe_id;
209b97169daSJie Yang 	unsigned int		task_id;
210b97169daSJie Yang };
211b97169daSJie Yang 
212b97169daSJie Yang #define SST_FW_SIGN "$SST"
213b97169daSJie Yang #define SST_FW_LIB_SIGN "$LIB"
214b97169daSJie Yang 
215b97169daSJie Yang /**
216b97169daSJie Yang  * struct sst_fw_header - FW file headers
217b97169daSJie Yang  *
218b97169daSJie Yang  * @signature : FW signature
219b97169daSJie Yang  * @file_size: size of fw image
220b97169daSJie Yang  * @modules : # of modules
221b97169daSJie Yang  * @file_format : version of header format
222b97169daSJie Yang  * @reserved : reserved fields
223b97169daSJie Yang  */
224b97169daSJie Yang struct sst_fw_header {
225b97169daSJie Yang 	unsigned char signature[FW_SIGNATURE_SIZE];
226b97169daSJie Yang 	u32 file_size;
227b97169daSJie Yang 	u32 modules;
228b97169daSJie Yang 	u32 file_format;
229b97169daSJie Yang 	u32 reserved[4];
230b97169daSJie Yang };
231b97169daSJie Yang 
232b97169daSJie Yang /**
233b97169daSJie Yang  * struct fw_module_header - module header in FW
234b97169daSJie Yang  *
235b97169daSJie Yang  * @signature: module signature
236b97169daSJie Yang  * @mod_size: size of module
237b97169daSJie Yang  * @blocks: block count
238b97169daSJie Yang  * @type: block type
239b97169daSJie Yang  * @entry_point: module netry point
240b97169daSJie Yang  */
241b97169daSJie Yang struct fw_module_header {
242b97169daSJie Yang 	unsigned char signature[FW_SIGNATURE_SIZE];
243b97169daSJie Yang 	u32 mod_size;
244b97169daSJie Yang 	u32 blocks;
245b97169daSJie Yang 	u32 type;
246b97169daSJie Yang 	u32 entry_point;
247b97169daSJie Yang };
248b97169daSJie Yang 
249b97169daSJie Yang /**
250b97169daSJie Yang  * struct fw_block_info - block header for FW
251b97169daSJie Yang  *
252b97169daSJie Yang  * @type: block ram type I/D
253b97169daSJie Yang  * @size: size of block
254b97169daSJie Yang  * @ram_offset: offset in ram
255b97169daSJie Yang  */
256b97169daSJie Yang struct fw_block_info {
257b97169daSJie Yang 	enum sst_ram_type	type;
258b97169daSJie Yang 	u32			size;
259b97169daSJie Yang 	u32			ram_offset;
260b97169daSJie Yang 	u32			rsvd;
261b97169daSJie Yang };
262b97169daSJie Yang 
263b97169daSJie Yang struct sst_runtime_param {
264b97169daSJie Yang 	struct snd_sst_runtime_params param;
265b97169daSJie Yang };
266b97169daSJie Yang 
267b97169daSJie Yang struct sst_sg_list {
268b97169daSJie Yang 	struct scatterlist *src;
269b97169daSJie Yang 	struct scatterlist *dst;
270b97169daSJie Yang 	int list_len;
271b97169daSJie Yang 	unsigned int sg_idx;
272b97169daSJie Yang };
273b97169daSJie Yang 
274b97169daSJie Yang struct sst_memcpy_list {
275b97169daSJie Yang 	struct list_head memcpylist;
276b97169daSJie Yang 	void *dstn;
277b97169daSJie Yang 	const void *src;
278b97169daSJie Yang 	u32 size;
279b97169daSJie Yang 	bool is_io;
280b97169daSJie Yang };
281b97169daSJie Yang 
282b97169daSJie Yang /*Firmware Module Information*/
283b97169daSJie Yang enum sst_lib_dwnld_status {
284b97169daSJie Yang 	SST_LIB_NOT_FOUND = 0,
285b97169daSJie Yang 	SST_LIB_FOUND,
286b97169daSJie Yang 	SST_LIB_DOWNLOADED,
287b97169daSJie Yang };
288b97169daSJie Yang 
289b97169daSJie Yang struct sst_module_info {
290b97169daSJie Yang 	const char *name; /*Library name*/
291b97169daSJie Yang 	u32	id; /*Module ID*/
292b97169daSJie Yang 	u32	entry_pt; /*Module entry point*/
293b97169daSJie Yang 	u8	status; /*module status*/
294b97169daSJie Yang 	u8	rsvd1;
295b97169daSJie Yang 	u16	rsvd2;
296b97169daSJie Yang };
297b97169daSJie Yang 
298b97169daSJie Yang /*
299b97169daSJie Yang  * Structure for managing the Library Region(1.5MB)
300b97169daSJie Yang  * in DDR in Merrifield
301b97169daSJie Yang  */
302b97169daSJie Yang struct sst_mem_mgr {
303b97169daSJie Yang 	phys_addr_t current_base;
304b97169daSJie Yang 	int avail;
305b97169daSJie Yang 	unsigned int count;
306b97169daSJie Yang };
307b97169daSJie Yang 
308b97169daSJie Yang struct sst_ipc_reg {
309b97169daSJie Yang 	int ipcx;
310b97169daSJie Yang 	int ipcd;
311b97169daSJie Yang };
312b97169daSJie Yang 
313b97169daSJie Yang struct sst_fw_save {
31475bd9086STakashi Iwai 	void *iram;	/* allocated via kvmalloc() */
31575bd9086STakashi Iwai 	void *dram;	/* allocated via kvmalloc() */
31675bd9086STakashi Iwai 	void *sram;	/* allocated via kvmalloc() */
31775bd9086STakashi Iwai 	void *ddr;	/* allocated via kvmalloc() */
318b97169daSJie Yang };
319b97169daSJie Yang 
320b97169daSJie Yang /**
321b97169daSJie Yang  * struct intel_sst_drv - driver ops
322b97169daSJie Yang  *
323b97169daSJie Yang  * @sst_state : current sst device state
324b97169daSJie Yang  * @dev_id : device identifier, pci_id for pci devices and acpi_id for acpi
325b97169daSJie Yang  * 	     devices
326b97169daSJie Yang  * @shim : SST shim pointer
327b97169daSJie Yang  * @mailbox : SST mailbox pointer
328b97169daSJie Yang  * @iram : SST IRAM pointer
329b97169daSJie Yang  * @dram : SST DRAM pointer
330b97169daSJie Yang  * @pdata : SST info passed as a part of pci platform data
331b97169daSJie Yang  * @shim_phy_add : SST shim phy addr
332b97169daSJie Yang  * @ipc_dispatch_list : ipc messages dispatched
333b97169daSJie Yang  * @rx_list : to copy the process_reply/process_msg from DSP
334b97169daSJie Yang  * @ipc_post_msg_wq : wq to post IPC messages context
335b97169daSJie Yang  * @mad_ops : MAD driver operations registered
336b97169daSJie Yang  * @mad_wq : MAD driver wq
337b97169daSJie Yang  * @post_msg_wq : wq to post IPC messages
338b97169daSJie Yang  * @streams : sst stream contexts
339b97169daSJie Yang  * @list_lock : sst driver list lock (deprecated)
340b97169daSJie Yang  * @ipc_spin_lock : spin lock to handle audio shim access and ipc queue
341b97169daSJie Yang  * @block_lock : spin lock to add block to block_list and assign pvt_id
342b97169daSJie Yang  * @rx_msg_lock : spin lock to handle the rx messages from the DSP
343b97169daSJie Yang  * @scard_ops : sst card ops
344b97169daSJie Yang  * @pci : sst pci device struture
345b97169daSJie Yang  * @dev : pointer to current device struct
346b97169daSJie Yang  * @sst_lock : sst device lock
347b97169daSJie Yang  * @pvt_id : sst private id
348b97169daSJie Yang  * @stream_cnt : total sst active stream count
349b97169daSJie Yang  * @pb_streams : total active pb streams
350b97169daSJie Yang  * @cp_streams : total active cp streams
351b97169daSJie Yang  * @audio_start : audio status
352b97169daSJie Yang  * @qos		: PM Qos struct
353b97169daSJie Yang  * firmware_name : Firmware / Library name
354b97169daSJie Yang  */
355b97169daSJie Yang struct intel_sst_drv {
356b97169daSJie Yang 	int			sst_state;
357b97169daSJie Yang 	int			irq_num;
358*2218e10eSAmadeusz Sławiński 	unsigned short		dev_id;
359b97169daSJie Yang 	void __iomem		*ddr;
360b97169daSJie Yang 	void __iomem		*shim;
361b97169daSJie Yang 	void __iomem		*mailbox;
362b97169daSJie Yang 	void __iomem		*iram;
363b97169daSJie Yang 	void __iomem		*dram;
364b97169daSJie Yang 	unsigned int		mailbox_add;
365b97169daSJie Yang 	unsigned int		iram_base;
366b97169daSJie Yang 	unsigned int		dram_base;
367b97169daSJie Yang 	unsigned int		shim_phy_add;
368b97169daSJie Yang 	unsigned int		iram_end;
369b97169daSJie Yang 	unsigned int		dram_end;
370b97169daSJie Yang 	unsigned int		ddr_end;
371b97169daSJie Yang 	unsigned int		ddr_base;
372b97169daSJie Yang 	unsigned int		mailbox_recv_offset;
373b97169daSJie Yang 	struct list_head        block_list;
374b97169daSJie Yang 	struct list_head	ipc_dispatch_list;
375b97169daSJie Yang 	struct sst_platform_info *pdata;
376b97169daSJie Yang 	struct list_head	rx_list;
377b97169daSJie Yang 	struct work_struct      ipc_post_msg_wq;
378b97169daSJie Yang 	wait_queue_head_t	wait_queue;
379b97169daSJie Yang 	struct workqueue_struct *post_msg_wq;
380b97169daSJie Yang 	unsigned int		tstamp;
381b97169daSJie Yang 	/* str_id 0 is not used */
382b97169daSJie Yang 	struct stream_info	streams[MAX_NUM_STREAMS+1];
383b97169daSJie Yang 	spinlock_t		ipc_spin_lock;
384b97169daSJie Yang 	spinlock_t              block_lock;
385b97169daSJie Yang 	spinlock_t		rx_msg_lock;
386b97169daSJie Yang 	struct pci_dev		*pci;
387b97169daSJie Yang 	struct device		*dev;
388b97169daSJie Yang 	volatile long unsigned 		pvt_id;
389b97169daSJie Yang 	struct mutex            sst_lock;
390b97169daSJie Yang 	unsigned int		stream_cnt;
391b97169daSJie Yang 	unsigned int		csr_value;
392b97169daSJie Yang 	void			*fw_in_mem;
393b97169daSJie Yang 	struct sst_sg_list	fw_sg_list, library_list;
394b97169daSJie Yang 	struct intel_sst_ops	*ops;
395b97169daSJie Yang 	struct sst_info		info;
396b97169daSJie Yang 	struct pm_qos_request	*qos;
397b97169daSJie Yang 	unsigned int		use_dma;
398b97169daSJie Yang 	unsigned int		use_lli;
399b97169daSJie Yang 	atomic_t		fw_clear_context;
400b97169daSJie Yang 	bool			lib_dwnld_reqd;
401b97169daSJie Yang 	struct list_head	memcpy_list;
402b97169daSJie Yang 	struct sst_ipc_reg	ipc_reg;
403b97169daSJie Yang 	struct sst_mem_mgr      lib_mem_mgr;
404b97169daSJie Yang 	/*
405b97169daSJie Yang 	 * Holder for firmware name. Due to async call it needs to be
406b97169daSJie Yang 	 * persistent till worker thread gets called
407b97169daSJie Yang 	 */
408b97169daSJie Yang 	char firmware_name[FW_NAME_SIZE];
409b97169daSJie Yang 
410c7da1e9dSSebastien Guiriec 	struct snd_sst_fw_version fw_version;
411b97169daSJie Yang 	struct sst_fw_save	*fw_save;
412b97169daSJie Yang };
413b97169daSJie Yang 
414b97169daSJie Yang /* misc definitions */
415b97169daSJie Yang #define FW_DWNL_ID 0x01
416b97169daSJie Yang 
417b97169daSJie Yang struct intel_sst_ops {
418b97169daSJie Yang 	irqreturn_t (*interrupt)(int, void *);
419b97169daSJie Yang 	irqreturn_t (*irq_thread)(int, void *);
420b97169daSJie Yang 	void (*clear_interrupt)(struct intel_sst_drv *ctx);
421b97169daSJie Yang 	int (*start)(struct intel_sst_drv *ctx);
422b97169daSJie Yang 	int (*reset)(struct intel_sst_drv *ctx);
423b97169daSJie Yang 	void (*process_reply)(struct intel_sst_drv *ctx, struct ipc_post *msg);
424b97169daSJie Yang 	int (*post_message)(struct intel_sst_drv *ctx,
425b97169daSJie Yang 			struct ipc_post *msg, bool sync);
426b97169daSJie Yang 	void (*process_message)(struct ipc_post *msg);
427b97169daSJie Yang 	void (*set_bypass)(bool set);
428b97169daSJie Yang 	int (*save_dsp_context)(struct intel_sst_drv *sst);
429b97169daSJie Yang 	void (*restore_dsp_context)(void);
430b97169daSJie Yang 	int (*alloc_stream)(struct intel_sst_drv *ctx, void *params);
431b97169daSJie Yang 	void (*post_download)(struct intel_sst_drv *sst);
432b97169daSJie Yang };
433b97169daSJie Yang 
434473858caSHans de Goede int sst_realloc_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
435cfe8cc94SPierre-Louis Bossart int sst_pause_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
436cfe8cc94SPierre-Louis Bossart int sst_resume_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
437cfe8cc94SPierre-Louis Bossart int sst_drop_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
438cfe8cc94SPierre-Louis Bossart int sst_free_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
439b97169daSJie Yang int sst_start_stream(struct intel_sst_drv *sst_drv_ctx, int str_id);
440cfe8cc94SPierre-Louis Bossart int sst_send_byte_stream_mrfld(struct intel_sst_drv *sst_drv_ctx,
441cfe8cc94SPierre-Louis Bossart 			struct snd_sst_bytes_v2 *bytes);
442b97169daSJie Yang int sst_set_stream_param(int str_id, struct snd_sst_params *str_param);
443b97169daSJie Yang int sst_set_metadata(int str_id, char *params);
444cfe8cc94SPierre-Louis Bossart int sst_get_stream(struct intel_sst_drv *ctx,
445b97169daSJie Yang 		struct snd_sst_params *str_param);
446b97169daSJie Yang int sst_get_stream_allocated(struct intel_sst_drv *ctx,
447b97169daSJie Yang 		struct snd_sst_params *str_param,
448b97169daSJie Yang 		struct snd_sst_lib_download **lib_dnld);
449b97169daSJie Yang int sst_drain_stream(struct intel_sst_drv *sst_drv_ctx,
450b97169daSJie Yang 		int str_id, bool partial_drain);
451cfe8cc94SPierre-Louis Bossart int sst_post_message_mrfld(struct intel_sst_drv *sst_drv_ctx,
452cfe8cc94SPierre-Louis Bossart 		struct ipc_post *ipc_msg, bool sync);
453cfe8cc94SPierre-Louis Bossart void sst_process_reply_mrfld(struct intel_sst_drv *sst_drv_ctx, struct ipc_post *msg);
454cfe8cc94SPierre-Louis Bossart int sst_start_mrfld(struct intel_sst_drv *sst_drv_ctx);
455cfe8cc94SPierre-Louis Bossart int intel_sst_reset_dsp_mrfld(struct intel_sst_drv *sst_drv_ctx);
456cfe8cc94SPierre-Louis Bossart void intel_sst_clear_intr_mrfld(struct intel_sst_drv *sst_drv_ctx);
457b97169daSJie Yang 
458cfe8cc94SPierre-Louis Bossart int sst_load_fw(struct intel_sst_drv *sst_drv_ctx);
459b97169daSJie Yang int sst_load_library(struct snd_sst_lib_download *lib, u8 ops);
460b97169daSJie Yang void sst_post_download_mrfld(struct intel_sst_drv *ctx);
461b97169daSJie Yang int sst_get_block_stream(struct intel_sst_drv *sst_drv_ctx);
462cfe8cc94SPierre-Louis Bossart void sst_memcpy_free_resources(struct intel_sst_drv *sst_drv_ctx);
463b97169daSJie Yang 
464b97169daSJie Yang int sst_wait_interruptible(struct intel_sst_drv *sst_drv_ctx,
465b97169daSJie Yang 				struct sst_block *block);
466b97169daSJie Yang int sst_wait_timeout(struct intel_sst_drv *sst_drv_ctx,
467b97169daSJie Yang 			struct sst_block *block);
468b97169daSJie Yang int sst_create_ipc_msg(struct ipc_post **arg, bool large);
469b97169daSJie Yang int free_stream_context(struct intel_sst_drv *ctx, unsigned int str_id);
470b97169daSJie Yang void sst_clean_stream(struct stream_info *stream);
471b97169daSJie Yang int intel_sst_register_compress(struct intel_sst_drv *sst);
472b97169daSJie Yang int intel_sst_remove_compress(struct intel_sst_drv *sst);
473b97169daSJie Yang void sst_cdev_fragment_elapsed(struct intel_sst_drv *ctx, int str_id);
474b97169daSJie Yang int sst_send_sync_msg(int ipc, int str_id);
475b97169daSJie Yang int sst_get_num_channel(struct snd_sst_params *str_param);
476b97169daSJie Yang int sst_get_sfreq(struct snd_sst_params *str_param);
477b97169daSJie Yang int sst_alloc_stream_mrfld(struct intel_sst_drv *sst_drv_ctx, void *params);
478b97169daSJie Yang void sst_restore_fw_context(void);
479b97169daSJie Yang struct sst_block *sst_create_block(struct intel_sst_drv *ctx,
480b97169daSJie Yang 				u32 msg_id, u32 drv_id);
481b97169daSJie Yang int sst_create_block_and_ipc_msg(struct ipc_post **arg, bool large,
482b97169daSJie Yang 		struct intel_sst_drv *sst_drv_ctx, struct sst_block **block,
483b97169daSJie Yang 		u32 msg_id, u32 drv_id);
484b97169daSJie Yang int sst_free_block(struct intel_sst_drv *ctx, struct sst_block *freed);
485b97169daSJie Yang int sst_wake_up_block(struct intel_sst_drv *ctx, int result,
486b97169daSJie Yang 		u32 drv_id, u32 ipc, void *data, u32 size);
487b97169daSJie Yang int sst_request_firmware_async(struct intel_sst_drv *ctx);
488b97169daSJie Yang int sst_driver_ops(struct intel_sst_drv *sst);
489b97169daSJie Yang struct sst_platform_info *sst_get_acpi_driver_data(const char *hid);
490b97169daSJie Yang void sst_firmware_load_cb(const struct firmware *fw, void *context);
491b97169daSJie Yang int sst_prepare_and_post_msg(struct intel_sst_drv *sst,
492b97169daSJie Yang 		int task_id, int ipc_msg, int cmd_id, int pipe_id,
493b97169daSJie Yang 		size_t mbox_data_len, const void *mbox_data, void **data,
494b97169daSJie Yang 		bool large, bool fill_dsp, bool sync, bool response);
495b97169daSJie Yang 
496b97169daSJie Yang void sst_process_pending_msg(struct work_struct *work);
497cfe8cc94SPierre-Louis Bossart int sst_assign_pvt_id(struct intel_sst_drv *drv);
498b97169daSJie Yang int sst_validate_strid(struct intel_sst_drv *sst_drv_ctx, int str_id);
499b97169daSJie Yang struct stream_info *get_stream_info(struct intel_sst_drv *sst_drv_ctx,
500b97169daSJie Yang 		int str_id);
501b97169daSJie Yang int get_stream_id_mrfld(struct intel_sst_drv *sst_drv_ctx,
502b97169daSJie Yang 		u32 pipe_id);
503b97169daSJie Yang u32 relocate_imr_addr_mrfld(u32 base_addr);
504b97169daSJie Yang void sst_add_to_dispatch_list_and_post(struct intel_sst_drv *sst,
505b97169daSJie Yang 					struct ipc_post *msg);
506b97169daSJie Yang int sst_pm_runtime_put(struct intel_sst_drv *sst_drv);
507b97169daSJie Yang int sst_shim_write(void __iomem *addr, int offset, int value);
508b97169daSJie Yang u32 sst_shim_read(void __iomem *addr, int offset);
509b97169daSJie Yang u64 sst_reg_read64(void __iomem *addr, int offset);
510b97169daSJie Yang int sst_shim_write64(void __iomem *addr, int offset, u64 value);
511b97169daSJie Yang u64 sst_shim_read64(void __iomem *addr, int offset);
512b97169daSJie Yang void sst_set_fw_state_locked(
513b97169daSJie Yang 		struct intel_sst_drv *sst_drv_ctx, int sst_state);
514b97169daSJie Yang void sst_fill_header_mrfld(union ipc_header_mrfld *header,
515b97169daSJie Yang 				int msg, int task_id, int large, int drv_id);
516b97169daSJie Yang void sst_fill_header_dsp(struct ipc_dsp_hdr *dsp, int msg,
517b97169daSJie Yang 					int pipe_id, int len);
518b97169daSJie Yang 
519b97169daSJie Yang int sst_register(struct device *);
520b97169daSJie Yang int sst_unregister(struct device *);
521b97169daSJie Yang 
522b97169daSJie Yang int sst_alloc_drv_context(struct intel_sst_drv **ctx,
523*2218e10eSAmadeusz Sławiński 		struct device *dev, unsigned short dev_id);
524b97169daSJie Yang int sst_context_init(struct intel_sst_drv *ctx);
525b97169daSJie Yang void sst_context_cleanup(struct intel_sst_drv *ctx);
526b97169daSJie Yang void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
527b97169daSJie Yang void memcpy32_toio(void __iomem *dst, const void *src, int count);
528b97169daSJie Yang void memcpy32_fromio(void *dst, const void __iomem *src, int count);
529b97169daSJie Yang 
530b97169daSJie Yang #endif
531