xref: /linux-6.15/sound/soc/sof/sof-priv.h (revision b4dcafe4)
1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2c16211d6SLiam Girdwood /*
3c16211d6SLiam Girdwood  * This file is provided under a dual BSD/GPLv2 license.  When using or
4c16211d6SLiam Girdwood  * redistributing this file, you may do so under either license.
5c16211d6SLiam Girdwood  *
6c16211d6SLiam Girdwood  * Copyright(c) 2018 Intel Corporation. All rights reserved.
7c16211d6SLiam Girdwood  *
8c16211d6SLiam Girdwood  * Author: Liam Girdwood <[email protected]>
9c16211d6SLiam Girdwood  */
10c16211d6SLiam Girdwood 
11c16211d6SLiam Girdwood #ifndef __SOUND_SOC_SOF_PRIV_H
12c16211d6SLiam Girdwood #define __SOUND_SOC_SOF_PRIV_H
13c16211d6SLiam Girdwood 
14c16211d6SLiam Girdwood #include <linux/device.h>
15c16211d6SLiam Girdwood #include <sound/hdaudio.h>
16c16211d6SLiam Girdwood #include <sound/sof.h>
17c16211d6SLiam Girdwood #include <sound/sof/info.h>
18c16211d6SLiam Girdwood #include <sound/sof/pm.h>
19c16211d6SLiam Girdwood #include <sound/sof/trace.h>
20c16211d6SLiam Girdwood #include <uapi/sound/sof/fw.h>
21e984f3efSFred Oh #include <sound/sof/ext_manifest.h>
22c16211d6SLiam Girdwood 
23beb6ade1SPeter Ujfalusi /* Flag definitions used in sof_core_debug (sof_debug module parameter) */
242ab4c50fSPierre-Louis Bossart #define SOF_DBG_ENABLE_TRACE	BIT(0)
25fbfa22ecSRanjani Sridharan #define SOF_DBG_RETAIN_CTX	BIT(1)	/* prevent DSP D3 on FW exception */
26c0e7969cSRanjani Sridharan #define SOF_DBG_VERIFY_TPLG	BIT(2) /* verify topology during load */
27ea6bfbbeSPierre-Louis Bossart #define SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE	BIT(3) /* 0: use topology token
28ea6bfbbeSPierre-Louis Bossart 							* 1: override topology
29ea6bfbbeSPierre-Louis Bossart 							*/
30ea6bfbbeSPierre-Louis Bossart #define SOF_DBG_DYNAMIC_PIPELINES_ENABLE	BIT(4) /* 0: use static pipelines
31ea6bfbbeSPierre-Louis Bossart 							* 1: use dynamic pipelines
32ea6bfbbeSPierre-Louis Bossart 							*/
331539c8c5SPierre-Louis Bossart #define SOF_DBG_DISABLE_MULTICORE		BIT(5) /* schedule all pipelines/widgets
341539c8c5SPierre-Louis Bossart 							* on primary core
351539c8c5SPierre-Louis Bossart 							*/
369ff90859SPeter Ujfalusi #define SOF_DBG_PRINT_ALL_DUMPS		BIT(6) /* Print all ipc and dsp dumps */
37d7a8fbd1SKeyon Jie #define SOF_DBG_IGNORE_D3_PERSISTENT		BIT(7) /* ignore the DSP D3 persistent capability
38d7a8fbd1SKeyon Jie 							* and always download firmware upon D3 exit
39d7a8fbd1SKeyon Jie 							*/
40fbfa22ecSRanjani Sridharan 
41beb6ade1SPeter Ujfalusi /* Flag definitions used for controlling the DSP dump behavior */
42fbfa22ecSRanjani Sridharan #define SOF_DBG_DUMP_REGS		BIT(0)
43fbfa22ecSRanjani Sridharan #define SOF_DBG_DUMP_MBOX		BIT(1)
44fbfa22ecSRanjani Sridharan #define SOF_DBG_DUMP_TEXT		BIT(2)
45fbfa22ecSRanjani Sridharan #define SOF_DBG_DUMP_PCI		BIT(3)
46beb6ade1SPeter Ujfalusi /* Output this dump (at the DEBUG level) only when SOF_DBG_PRINT_ALL_DUMPS is set */
47beb6ade1SPeter Ujfalusi #define SOF_DBG_DUMP_OPTIONAL		BIT(4)
48c16211d6SLiam Girdwood 
492ab4c50fSPierre-Louis Bossart /* global debug state set by SOF_DBG_ flags */
50f902b21aSPeter Ujfalusi bool sof_debug_check_flag(int mask);
512ab4c50fSPierre-Louis Bossart 
52c16211d6SLiam Girdwood /* max BARs mmaped devices can use */
53c16211d6SLiam Girdwood #define SND_SOF_BARS	8
54c16211d6SLiam Girdwood 
55c16211d6SLiam Girdwood /* time in ms for runtime suspend delay */
56c16211d6SLiam Girdwood #define SND_SOF_SUSPEND_DELAY_MS	2000
57c16211d6SLiam Girdwood 
58c16211d6SLiam Girdwood /* DMA buffer size for trace */
59c16211d6SLiam Girdwood #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16)
60c16211d6SLiam Girdwood 
61c16211d6SLiam Girdwood #define SOF_IPC_DSP_REPLY		0
62c16211d6SLiam Girdwood #define SOF_IPC_HOST_REPLY		1
63c16211d6SLiam Girdwood 
64c16211d6SLiam Girdwood /* convenience constructor for DAI driver streams */
65c16211d6SLiam Girdwood #define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
66c16211d6SLiam Girdwood 	{.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
67c16211d6SLiam Girdwood 	 .rates = srates, .formats = sfmt}
68c16211d6SLiam Girdwood 
69c16211d6SLiam Girdwood #define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
70c16211d6SLiam Girdwood 	SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)
71c16211d6SLiam Girdwood 
720dcdf842SGuennadi Liakhovetski /* So far the primary core on all DSPs has ID 0 */
730dcdf842SGuennadi Liakhovetski #define SOF_DSP_PRIMARY_CORE 0
740dcdf842SGuennadi Liakhovetski 
755974f684SRanjani Sridharan /* max number of DSP cores */
765974f684SRanjani Sridharan #define SOF_MAX_DSP_NUM_CORES 8
775974f684SRanjani Sridharan 
7861e285caSRanjani Sridharan struct sof_dsp_power_state {
7961e285caSRanjani Sridharan 	u32 state;
8061e285caSRanjani Sridharan 	u32 substate; /* platform-specific */
814c19030cSKeyon Jie };
824c19030cSKeyon Jie 
83043ae13bSRanjani Sridharan /* System suspend target state */
84043ae13bSRanjani Sridharan enum sof_system_suspend_state {
85043ae13bSRanjani Sridharan 	SOF_SUSPEND_NONE = 0,
86043ae13bSRanjani Sridharan 	SOF_SUSPEND_S0IX,
87043ae13bSRanjani Sridharan 	SOF_SUSPEND_S3,
88043ae13bSRanjani Sridharan };
89043ae13bSRanjani Sridharan 
9007e833b4SPeter Ujfalusi enum sof_dfsentry_type {
9107e833b4SPeter Ujfalusi 	SOF_DFSENTRY_TYPE_IOMEM = 0,
9207e833b4SPeter Ujfalusi 	SOF_DFSENTRY_TYPE_BUF,
9307e833b4SPeter Ujfalusi };
9407e833b4SPeter Ujfalusi 
9507e833b4SPeter Ujfalusi enum sof_debugfs_access_type {
9607e833b4SPeter Ujfalusi 	SOF_DEBUGFS_ACCESS_ALWAYS = 0,
9707e833b4SPeter Ujfalusi 	SOF_DEBUGFS_ACCESS_D0_ONLY,
9807e833b4SPeter Ujfalusi };
9907e833b4SPeter Ujfalusi 
100c16211d6SLiam Girdwood struct snd_sof_dev;
101c16211d6SLiam Girdwood struct snd_sof_ipc_msg;
102c16211d6SLiam Girdwood struct snd_sof_ipc;
103c16211d6SLiam Girdwood struct snd_sof_debugfs_map;
104c16211d6SLiam Girdwood struct snd_soc_tplg_ops;
105c16211d6SLiam Girdwood struct snd_soc_component;
106c16211d6SLiam Girdwood struct snd_sof_pdata;
107c16211d6SLiam Girdwood 
10831f60a0cSPeter Ujfalusi /**
10931f60a0cSPeter Ujfalusi  * struct snd_sof_platform_stream_params - platform dependent stream parameters
11031f60a0cSPeter Ujfalusi  * @stream_tag:		Stream tag to use
11131f60a0cSPeter Ujfalusi  * @use_phy_addr:	Use the provided @phy_addr for configuration
11231f60a0cSPeter Ujfalusi  * @phy_addr:		Platform dependent address to be used, if  @use_phy_addr
11331f60a0cSPeter Ujfalusi  *			is true
11431f60a0cSPeter Ujfalusi  * @no_ipc_position:	Disable position update IPC from firmware
11531f60a0cSPeter Ujfalusi  */
11631f60a0cSPeter Ujfalusi struct snd_sof_platform_stream_params {
11731f60a0cSPeter Ujfalusi 	u16 stream_tag;
11831f60a0cSPeter Ujfalusi 	bool use_phy_address;
11931f60a0cSPeter Ujfalusi 	u32 phy_addr;
12031f60a0cSPeter Ujfalusi 	bool no_ipc_position;
12131f60a0cSPeter Ujfalusi };
12231f60a0cSPeter Ujfalusi 
123c16211d6SLiam Girdwood /*
124c16211d6SLiam Girdwood  * SOF DSP HW abstraction operations.
125c16211d6SLiam Girdwood  * Used to abstract DSP HW architecture and any IO busses between host CPU
126c16211d6SLiam Girdwood  * and DSP device(s).
127c16211d6SLiam Girdwood  */
128c16211d6SLiam Girdwood struct snd_sof_dsp_ops {
129c16211d6SLiam Girdwood 
1307edb3051SKeyon Jie 	/* probe/remove/shutdown */
131c16211d6SLiam Girdwood 	int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
132c16211d6SLiam Girdwood 	int (*remove)(struct snd_sof_dev *sof_dev); /* optional */
1337edb3051SKeyon Jie 	int (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */
134c16211d6SLiam Girdwood 
135c16211d6SLiam Girdwood 	/* DSP core boot / reset */
136c16211d6SLiam Girdwood 	int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
137a70eb708SFred Oh 	int (*stall)(struct snd_sof_dev *sof_dev, unsigned int core_mask); /* optional */
138c16211d6SLiam Girdwood 	int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
139c414d5dfSRanjani Sridharan 	int (*core_get)(struct snd_sof_dev *sof_dev, int core); /* optional */
140c414d5dfSRanjani Sridharan 	int (*core_put)(struct snd_sof_dev *sof_dev, int core); /* optional */
141c16211d6SLiam Girdwood 
142c16211d6SLiam Girdwood 	/*
143c16211d6SLiam Girdwood 	 * Register IO: only used by respective drivers themselves,
144c16211d6SLiam Girdwood 	 * TODO: consider removing these operations and calling respective
145c16211d6SLiam Girdwood 	 * implementations directly
146c16211d6SLiam Girdwood 	 */
147c16211d6SLiam Girdwood 	void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
148c16211d6SLiam Girdwood 		      u32 value); /* optional */
149c16211d6SLiam Girdwood 	u32 (*read)(struct snd_sof_dev *sof_dev,
150c16211d6SLiam Girdwood 		    void __iomem *addr); /* optional */
151c16211d6SLiam Girdwood 	void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
152c16211d6SLiam Girdwood 			u64 value); /* optional */
153c16211d6SLiam Girdwood 	u64 (*read64)(struct snd_sof_dev *sof_dev,
154c16211d6SLiam Girdwood 		      void __iomem *addr); /* optional */
155c16211d6SLiam Girdwood 
156c16211d6SLiam Girdwood 	/* memcpy IO */
1574624bb2fSPeter Ujfalusi 	int (*block_read)(struct snd_sof_dev *sof_dev,
1584624bb2fSPeter Ujfalusi 			  enum snd_sof_fw_blk_type type, u32 offset,
1594624bb2fSPeter Ujfalusi 			  void *dest, size_t size); /* mandatory */
1604624bb2fSPeter Ujfalusi 	int (*block_write)(struct snd_sof_dev *sof_dev,
1614624bb2fSPeter Ujfalusi 			   enum snd_sof_fw_blk_type type, u32 offset,
1624624bb2fSPeter Ujfalusi 			   void *src, size_t size); /* mandatory */
163c16211d6SLiam Girdwood 
164f71f59ddSDaniel Baluta 	/* Mailbox IO */
165f71f59ddSDaniel Baluta 	void (*mailbox_read)(struct snd_sof_dev *sof_dev,
166f71f59ddSDaniel Baluta 			     u32 offset, void *dest,
167f71f59ddSDaniel Baluta 			     size_t size); /* optional */
168f71f59ddSDaniel Baluta 	void (*mailbox_write)(struct snd_sof_dev *sof_dev,
169f71f59ddSDaniel Baluta 			      u32 offset, void *src,
170f71f59ddSDaniel Baluta 			      size_t size); /* optional */
171f71f59ddSDaniel Baluta 
172c16211d6SLiam Girdwood 	/* doorbell */
173c16211d6SLiam Girdwood 	irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
174c16211d6SLiam Girdwood 	irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
175c16211d6SLiam Girdwood 
176c16211d6SLiam Girdwood 	/* ipc */
177c16211d6SLiam Girdwood 	int (*send_msg)(struct snd_sof_dev *sof_dev,
178c16211d6SLiam Girdwood 			struct snd_sof_ipc_msg *msg); /* mandatory */
179c16211d6SLiam Girdwood 
180c16211d6SLiam Girdwood 	/* FW loading */
181c16211d6SLiam Girdwood 	int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
182c16211d6SLiam Girdwood 	int (*load_module)(struct snd_sof_dev *sof_dev,
183c16211d6SLiam Girdwood 			   struct snd_sof_mod_hdr *hdr); /* optional */
184c16211d6SLiam Girdwood 	/*
185c16211d6SLiam Girdwood 	 * FW ready checks for ABI compatibility and creates
186c16211d6SLiam Girdwood 	 * memory windows at first boot
187c16211d6SLiam Girdwood 	 */
1888692d498SRanjani Sridharan 	int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* mandatory */
189c16211d6SLiam Girdwood 
190c16211d6SLiam Girdwood 	/* connect pcm substream to a host stream */
191c16211d6SLiam Girdwood 	int (*pcm_open)(struct snd_sof_dev *sdev,
192c16211d6SLiam Girdwood 			struct snd_pcm_substream *substream); /* optional */
193c16211d6SLiam Girdwood 	/* disconnect pcm substream to a host stream */
194c16211d6SLiam Girdwood 	int (*pcm_close)(struct snd_sof_dev *sdev,
195c16211d6SLiam Girdwood 			 struct snd_pcm_substream *substream); /* optional */
196c16211d6SLiam Girdwood 
197c16211d6SLiam Girdwood 	/* host stream hw params */
198c16211d6SLiam Girdwood 	int (*pcm_hw_params)(struct snd_sof_dev *sdev,
199c16211d6SLiam Girdwood 			     struct snd_pcm_substream *substream,
200c16211d6SLiam Girdwood 			     struct snd_pcm_hw_params *params,
20131f60a0cSPeter Ujfalusi 			     struct snd_sof_platform_stream_params *platform_params); /* optional */
202c16211d6SLiam Girdwood 
20393146bc2SRanjani Sridharan 	/* host stream hw_free */
20493146bc2SRanjani Sridharan 	int (*pcm_hw_free)(struct snd_sof_dev *sdev,
20593146bc2SRanjani Sridharan 			   struct snd_pcm_substream *substream); /* optional */
20693146bc2SRanjani Sridharan 
207c16211d6SLiam Girdwood 	/* host stream trigger */
208c16211d6SLiam Girdwood 	int (*pcm_trigger)(struct snd_sof_dev *sdev,
209c16211d6SLiam Girdwood 			   struct snd_pcm_substream *substream,
210c16211d6SLiam Girdwood 			   int cmd); /* optional */
211c16211d6SLiam Girdwood 
212c16211d6SLiam Girdwood 	/* host stream pointer */
213c16211d6SLiam Girdwood 	snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
214c16211d6SLiam Girdwood 					 struct snd_pcm_substream *substream); /* optional */
215c16211d6SLiam Girdwood 
2164a39ea3fSRanjani Sridharan 	/* pcm ack */
2174a39ea3fSRanjani Sridharan 	int (*pcm_ack)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); /* optional */
2184a39ea3fSRanjani Sridharan 
219c16211d6SLiam Girdwood 	/* host read DSP stream data */
2206a0ba071SGuennadi Liakhovetski 	int (*ipc_msg_data)(struct snd_sof_dev *sdev,
221c16211d6SLiam Girdwood 			    struct snd_pcm_substream *substream,
222c16211d6SLiam Girdwood 			    void *p, size_t sz); /* mandatory */
223c16211d6SLiam Girdwood 
224757ce810SPeter Ujfalusi 	/* host side configuration of the stream's data offset in stream mailbox area */
225757ce810SPeter Ujfalusi 	int (*set_stream_data_offset)(struct snd_sof_dev *sdev,
226757ce810SPeter Ujfalusi 				      struct snd_pcm_substream *substream,
227757ce810SPeter Ujfalusi 				      size_t posn_offset); /* optional */
228757ce810SPeter Ujfalusi 
229c16211d6SLiam Girdwood 	/* pre/post firmware run */
230c16211d6SLiam Girdwood 	int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
231c16211d6SLiam Girdwood 	int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
232c16211d6SLiam Girdwood 
233e984f3efSFred Oh 	/* parse platform specific extended manifest, optional */
234e984f3efSFred Oh 	int (*parse_platform_ext_manifest)(struct snd_sof_dev *sof_dev,
235e984f3efSFred Oh 					   const struct sof_ext_man_elem_header *hdr);
236e984f3efSFred Oh 
237c16211d6SLiam Girdwood 	/* DSP PM */
23861e285caSRanjani Sridharan 	int (*suspend)(struct snd_sof_dev *sof_dev,
23961e285caSRanjani Sridharan 		       u32 target_state); /* optional */
240c16211d6SLiam Girdwood 	int (*resume)(struct snd_sof_dev *sof_dev); /* optional */
2411c38c922SFred Oh 	int (*runtime_suspend)(struct snd_sof_dev *sof_dev); /* optional */
242c16211d6SLiam Girdwood 	int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
24362fde977SKai Vehmanen 	int (*runtime_idle)(struct snd_sof_dev *sof_dev); /* optional */
2447077a07aSRanjani Sridharan 	int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
245e8f112d8SKeyon Jie 	int (*set_power_state)(struct snd_sof_dev *sdev,
24661e285caSRanjani Sridharan 			       const struct sof_dsp_power_state *target_state); /* optional */
247c16211d6SLiam Girdwood 
248c16211d6SLiam Girdwood 	/* DSP clocking */
249c16211d6SLiam Girdwood 	int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
250c16211d6SLiam Girdwood 
251c16211d6SLiam Girdwood 	/* debug */
252c16211d6SLiam Girdwood 	const struct snd_sof_debugfs_map *debug_map; /* optional */
253c16211d6SLiam Girdwood 	int debug_map_count; /* optional */
254c16211d6SLiam Girdwood 	void (*dbg_dump)(struct snd_sof_dev *sof_dev,
255c16211d6SLiam Girdwood 			 u32 flags); /* optional */
2565e4a27fdSPan Xiuli 	void (*ipc_dump)(struct snd_sof_dev *sof_dev); /* optional */
25707e833b4SPeter Ujfalusi 	int (*debugfs_add_region_item)(struct snd_sof_dev *sdev,
25807e833b4SPeter Ujfalusi 				       enum snd_sof_fw_blk_type blk_type, u32 offset,
25907e833b4SPeter Ujfalusi 				       size_t size, const char *name,
26007e833b4SPeter Ujfalusi 				       enum sof_debugfs_access_type access_type); /* optional */
261c16211d6SLiam Girdwood 
262c16211d6SLiam Girdwood 	/* host DMA trace initialization */
263c16211d6SLiam Girdwood 	int (*trace_init)(struct snd_sof_dev *sdev,
264bab05b50SPeter Ujfalusi 			  struct sof_ipc_dma_trace_params_ext *dtrace_params); /* optional */
265c16211d6SLiam Girdwood 	int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
266c16211d6SLiam Girdwood 	int (*trace_trigger)(struct snd_sof_dev *sdev,
267c16211d6SLiam Girdwood 			     int cmd); /* optional */
268c16211d6SLiam Girdwood 
269ce8234a6SDaniel Baluta 	/* misc */
270ce8234a6SDaniel Baluta 	int (*get_bar_index)(struct snd_sof_dev *sdev,
271ce8234a6SDaniel Baluta 			     u32 type); /* optional */
272bb9c93f5SDaniel Baluta 	int (*get_mailbox_offset)(struct snd_sof_dev *sdev);/* mandatory for common loader code */
273e17422cdSDaniel Baluta 	int (*get_window_offset)(struct snd_sof_dev *sdev,
274e17422cdSDaniel Baluta 				 u32 id);/* mandatory for common loader code */
275bb9c93f5SDaniel Baluta 
276285880a2SDaniel Baluta 	/* machine driver ops */
277285880a2SDaniel Baluta 	int (*machine_register)(struct snd_sof_dev *sdev,
278285880a2SDaniel Baluta 				void *pdata); /* optional */
279285880a2SDaniel Baluta 	void (*machine_unregister)(struct snd_sof_dev *sdev,
280285880a2SDaniel Baluta 				   void *pdata); /* optional */
281cb515f10SGuennadi Liakhovetski 	struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */
282cb515f10SGuennadi Liakhovetski 	void (*set_mach_params)(struct snd_soc_acpi_mach *mach,
28317e9d6b0SPierre-Louis Bossart 				struct snd_sof_dev *sdev); /* optional */
284285880a2SDaniel Baluta 
2856955d951SPeter Ujfalusi 	/* IPC client ops */
2866955d951SPeter Ujfalusi 	int (*register_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
2876955d951SPeter Ujfalusi 	void (*unregister_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
2886955d951SPeter Ujfalusi 
289c16211d6SLiam Girdwood 	/* DAI ops */
290c16211d6SLiam Girdwood 	struct snd_soc_dai_driver *drv;
291c16211d6SLiam Girdwood 	int num_drv;
29227e322faSPierre-Louis Bossart 
29327e322faSPierre-Louis Bossart 	/* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */
29427e322faSPierre-Louis Bossart 	u32 hw_info;
2950f501c7cSPierre-Louis Bossart 
2960ed66cb7SPeter Ujfalusi 	const struct dsp_arch_ops *dsp_arch_ops;
297c16211d6SLiam Girdwood };
298c16211d6SLiam Girdwood 
299c16211d6SLiam Girdwood /* DSP architecture specific callbacks for oops and stack dumps */
3000ed66cb7SPeter Ujfalusi struct dsp_arch_ops {
301b9f0bfd1SPeter Ujfalusi 	void (*dsp_oops)(struct snd_sof_dev *sdev, const char *level, void *oops);
302b9f0bfd1SPeter Ujfalusi 	void (*dsp_stack)(struct snd_sof_dev *sdev, const char *level, void *oops,
303c16211d6SLiam Girdwood 			  u32 *stack, u32 stack_words);
304c16211d6SLiam Girdwood };
305c16211d6SLiam Girdwood 
3060ed66cb7SPeter Ujfalusi #define sof_dsp_arch_ops(sdev) ((sdev)->pdata->desc->ops->dsp_arch_ops)
307c16211d6SLiam Girdwood 
308c16211d6SLiam Girdwood /* FS entry for debug files that can expose DSP memories, registers */
309c16211d6SLiam Girdwood struct snd_sof_dfsentry {
310c16211d6SLiam Girdwood 	size_t size;
3115b10b629SKarol Trzcinski 	size_t buf_data_size;  /* length of buffered data for file read operation */
312c16211d6SLiam Girdwood 	enum sof_dfsentry_type type;
313c16211d6SLiam Girdwood 	/*
314c16211d6SLiam Girdwood 	 * access_type specifies if the
315c16211d6SLiam Girdwood 	 * memory -> DSP resource (memory, register etc) is always accessible
316c16211d6SLiam Girdwood 	 * or if it is accessible only when the DSP is in D0.
317c16211d6SLiam Girdwood 	 */
318c16211d6SLiam Girdwood 	enum sof_debugfs_access_type access_type;
3196e9548cdSRanjani Sridharan #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
320c16211d6SLiam Girdwood 	char *cache_buf; /* buffer to cache the contents of debugfs memory */
321c16211d6SLiam Girdwood #endif
322c16211d6SLiam Girdwood 	struct snd_sof_dev *sdev;
323c16211d6SLiam Girdwood 	struct list_head list;  /* list in sdev dfsentry list */
324c16211d6SLiam Girdwood 	union {
325c16211d6SLiam Girdwood 		void __iomem *io_mem;
326c16211d6SLiam Girdwood 		void *buf;
327c16211d6SLiam Girdwood 	};
328c16211d6SLiam Girdwood };
329c16211d6SLiam Girdwood 
330c16211d6SLiam Girdwood /* Debug mapping for any DSP memory or registers that can used for debug */
331c16211d6SLiam Girdwood struct snd_sof_debugfs_map {
332c16211d6SLiam Girdwood 	const char *name;
333c16211d6SLiam Girdwood 	u32 bar;
334c16211d6SLiam Girdwood 	u32 offset;
335c16211d6SLiam Girdwood 	u32 size;
336c16211d6SLiam Girdwood 	/*
337c16211d6SLiam Girdwood 	 * access_type specifies if the memory is always accessible
338c16211d6SLiam Girdwood 	 * or if it is accessible only when the DSP is in D0.
339c16211d6SLiam Girdwood 	 */
340c16211d6SLiam Girdwood 	enum sof_debugfs_access_type access_type;
341c16211d6SLiam Girdwood };
342c16211d6SLiam Girdwood 
343c16211d6SLiam Girdwood /* mailbox descriptor, used for host <-> DSP IPC */
344c16211d6SLiam Girdwood struct snd_sof_mailbox {
345c16211d6SLiam Girdwood 	u32 offset;
346c16211d6SLiam Girdwood 	size_t size;
347c16211d6SLiam Girdwood };
348c16211d6SLiam Girdwood 
349c16211d6SLiam Girdwood /* IPC message descriptor for host <-> DSP IO */
350c16211d6SLiam Girdwood struct snd_sof_ipc_msg {
351c16211d6SLiam Girdwood 	/* message data */
352c16211d6SLiam Girdwood 	void *msg_data;
353c16211d6SLiam Girdwood 	void *reply_data;
354c16211d6SLiam Girdwood 	size_t msg_size;
355c16211d6SLiam Girdwood 	size_t reply_size;
356c16211d6SLiam Girdwood 	int reply_error;
357c16211d6SLiam Girdwood 
358c16211d6SLiam Girdwood 	wait_queue_head_t waitq;
359c16211d6SLiam Girdwood 	bool ipc_complete;
360c16211d6SLiam Girdwood };
361c16211d6SLiam Girdwood 
362657774acSRanjani Sridharan /**
363657774acSRanjani Sridharan  * struct sof_ipc_pm_ops - IPC-specific PM ops
364657774acSRanjani Sridharan  * @ctx_save:		Function pointer for context save
365657774acSRanjani Sridharan  * @ctx_restore:	Function pointer for context restore
366657774acSRanjani Sridharan  */
367657774acSRanjani Sridharan struct sof_ipc_pm_ops {
368657774acSRanjani Sridharan 	int (*ctx_save)(struct snd_sof_dev *sdev);
369657774acSRanjani Sridharan 	int (*ctx_restore)(struct snd_sof_dev *sdev);
370657774acSRanjani Sridharan };
371657774acSRanjani Sridharan 
372226abb75SRanjani Sridharan struct sof_ipc_tplg_ops;
373967885eeSRanjani Sridharan struct sof_ipc_pcm_ops;
374226abb75SRanjani Sridharan 
375226abb75SRanjani Sridharan /**
376226abb75SRanjani Sridharan  * struct sof_ipc_ops - IPC-specific ops
377226abb75SRanjani Sridharan  * @tplg:	Pointer to IPC-specific topology ops
378657774acSRanjani Sridharan  * @pm:		Pointer to PM ops
379967885eeSRanjani Sridharan  * @pcm:	Pointer to PCM ops
380226abb75SRanjani Sridharan  */
381226abb75SRanjani Sridharan struct sof_ipc_ops {
382226abb75SRanjani Sridharan 	const struct sof_ipc_tplg_ops *tplg;
383657774acSRanjani Sridharan 	const struct sof_ipc_pm_ops *pm;
384967885eeSRanjani Sridharan 	const struct sof_ipc_pcm_ops *pcm;
385226abb75SRanjani Sridharan };
386226abb75SRanjani Sridharan 
387f535880bSRander Wang /* SOF generic IPC data */
388f535880bSRander Wang struct snd_sof_ipc {
389f535880bSRander Wang 	struct snd_sof_dev *sdev;
390f535880bSRander Wang 
391f535880bSRander Wang 	/* protects messages and the disable flag */
392f535880bSRander Wang 	struct mutex tx_mutex;
393f535880bSRander Wang 	/* disables further sending of ipc's */
394f535880bSRander Wang 	bool disable_ipc_tx;
395f535880bSRander Wang 
396a3e6b369SPeter Ujfalusi 	/* Maximum allowed size of a single IPC message/reply */
397a3e6b369SPeter Ujfalusi 	size_t max_payload_size;
398a3e6b369SPeter Ujfalusi 
399f535880bSRander Wang 	struct snd_sof_ipc_msg msg;
400226abb75SRanjani Sridharan 
401226abb75SRanjani Sridharan 	/* IPC ops based on version */
402226abb75SRanjani Sridharan 	const struct sof_ipc_ops *ops;
403f535880bSRander Wang };
404f535880bSRander Wang 
405758f24d4SLibin Yang enum sof_dtrace_state {
406758f24d4SLibin Yang 	SOF_DTRACE_DISABLED,
407758f24d4SLibin Yang 	SOF_DTRACE_STOPPED,
408758f24d4SLibin Yang 	SOF_DTRACE_ENABLED,
409758f24d4SLibin Yang };
410758f24d4SLibin Yang 
411c16211d6SLiam Girdwood /*
412c16211d6SLiam Girdwood  * SOF Device Level.
413c16211d6SLiam Girdwood  */
414c16211d6SLiam Girdwood struct snd_sof_dev {
415c16211d6SLiam Girdwood 	struct device *dev;
416c16211d6SLiam Girdwood 	spinlock_t ipc_lock;	/* lock for IPC users */
417c16211d6SLiam Girdwood 	spinlock_t hw_lock;	/* lock for HW IO access */
418c16211d6SLiam Girdwood 
419c16211d6SLiam Girdwood 	/*
420c16211d6SLiam Girdwood 	 * ASoC components. plat_drv fields are set dynamically so
421c16211d6SLiam Girdwood 	 * can't use const
422c16211d6SLiam Girdwood 	 */
423c16211d6SLiam Girdwood 	struct snd_soc_component_driver plat_drv;
424c16211d6SLiam Girdwood 
42561e285caSRanjani Sridharan 	/* current DSP power state */
42661e285caSRanjani Sridharan 	struct sof_dsp_power_state dsp_power_state;
4278b66d7c5SKeyon Jie 	/* mutex to protect the dsp_power_state access */
4288b66d7c5SKeyon Jie 	struct mutex power_state_access;
429043ae13bSRanjani Sridharan 
430043ae13bSRanjani Sridharan 	/* Intended power target of system suspend */
431043ae13bSRanjani Sridharan 	enum sof_system_suspend_state system_suspend_target;
4324c19030cSKeyon Jie 
433c16211d6SLiam Girdwood 	/* DSP firmware boot */
434c16211d6SLiam Girdwood 	wait_queue_head_t boot_wait;
435d41607d3SPeter Ujfalusi 	enum sof_fw_state fw_state;
436f738d815SGuennadi Liakhovetski 	bool first_boot;
437c16211d6SLiam Girdwood 
438c16211d6SLiam Girdwood 	/* work queue in case the probe is implemented in two steps */
439c16211d6SLiam Girdwood 	struct work_struct probe_work;
440271d9373SKai Vehmanen 	bool probe_completed;
441c16211d6SLiam Girdwood 
442c16211d6SLiam Girdwood 	/* DSP HW differentiation */
443c16211d6SLiam Girdwood 	struct snd_sof_pdata *pdata;
444c16211d6SLiam Girdwood 
445c16211d6SLiam Girdwood 	/* IPC */
446c16211d6SLiam Girdwood 	struct snd_sof_ipc *ipc;
447c16211d6SLiam Girdwood 	struct snd_sof_mailbox dsp_box;		/* DSP initiated IPC */
448c16211d6SLiam Girdwood 	struct snd_sof_mailbox host_box;	/* Host initiated IPC */
449c16211d6SLiam Girdwood 	struct snd_sof_mailbox stream_box;	/* Stream position update */
450e17b7389SIulian Olaru 	struct snd_sof_mailbox debug_box;	/* Debug info updates */
451c16211d6SLiam Girdwood 	struct snd_sof_ipc_msg *msg;
452c16211d6SLiam Girdwood 	int ipc_irq;
453c16211d6SLiam Girdwood 	u32 next_comp_id; /* monotonic - reset during S3 */
454c16211d6SLiam Girdwood 
455c16211d6SLiam Girdwood 	/* memory bases for mmaped DSPs - set by dsp_init() */
456c16211d6SLiam Girdwood 	void __iomem *bar[SND_SOF_BARS];	/* DSP base address */
457c16211d6SLiam Girdwood 	int mmio_bar;
458c16211d6SLiam Girdwood 	int mailbox_bar;
459c16211d6SLiam Girdwood 	size_t dsp_oops_offset;
460c16211d6SLiam Girdwood 
461c16211d6SLiam Girdwood 	/* debug */
462c16211d6SLiam Girdwood 	struct dentry *debugfs_root;
463c16211d6SLiam Girdwood 	struct list_head dfsentry_list;
4649ff90859SPeter Ujfalusi 	bool dbg_dump_printed;
4659ff90859SPeter Ujfalusi 	bool ipc_dump_printed;
466c16211d6SLiam Girdwood 
467c16211d6SLiam Girdwood 	/* firmware loader */
468c16211d6SLiam Girdwood 	struct sof_ipc_fw_ready fw_ready;
469c16211d6SLiam Girdwood 	struct sof_ipc_fw_version fw_version;
47059283959SKarol Trzcinski 	struct sof_ipc_cc_version *cc_version;
471c16211d6SLiam Girdwood 
472c16211d6SLiam Girdwood 	/* topology */
473c16211d6SLiam Girdwood 	struct snd_soc_tplg_ops *tplg_ops;
474c16211d6SLiam Girdwood 	struct list_head pcm_list;
475c16211d6SLiam Girdwood 	struct list_head kcontrol_list;
476c16211d6SLiam Girdwood 	struct list_head widget_list;
477c16211d6SLiam Girdwood 	struct list_head dai_list;
4780af0f463SRanjani Sridharan 	struct list_head dai_link_list;
479c16211d6SLiam Girdwood 	struct list_head route_list;
480c16211d6SLiam Girdwood 	struct snd_soc_component *component;
481c16211d6SLiam Girdwood 	u32 enabled_cores_mask; /* keep track of enabled cores */
4829b014266SJaroslav Kysela 	bool led_present;
483c16211d6SLiam Girdwood 
484c16211d6SLiam Girdwood 	/* FW configuration */
485c16211d6SLiam Girdwood 	struct sof_ipc_window *info_window;
486c16211d6SLiam Girdwood 
487c16211d6SLiam Girdwood 	/* IPC timeouts in ms */
488c16211d6SLiam Girdwood 	int ipc_timeout;
489c16211d6SLiam Girdwood 	int boot_timeout;
490c16211d6SLiam Girdwood 
491c16211d6SLiam Girdwood 	/* DMA for Trace */
492c16211d6SLiam Girdwood 	struct snd_dma_buffer dmatb;
493c16211d6SLiam Girdwood 	struct snd_dma_buffer dmatp;
494c16211d6SLiam Girdwood 	int dma_trace_pages;
495c16211d6SLiam Girdwood 	wait_queue_head_t trace_sleep;
496c16211d6SLiam Girdwood 	u32 host_offset;
497f738d815SGuennadi Liakhovetski 	bool dtrace_is_supported; /* set with Kconfig or module parameter */
498f738d815SGuennadi Liakhovetski 	bool dtrace_error;
499f738d815SGuennadi Liakhovetski 	bool dtrace_draining;
500758f24d4SLibin Yang 	enum sof_dtrace_state dtrace_state;
501ec9025e5SKai Vehmanen 
502672ff5e3SGuennadi Liakhovetski 	bool msi_enabled;
503c16211d6SLiam Girdwood 
5045974f684SRanjani Sridharan 	/* DSP core context */
5055974f684SRanjani Sridharan 	u32 num_cores;
5065974f684SRanjani Sridharan 
5075974f684SRanjani Sridharan 	/*
5085974f684SRanjani Sridharan 	 * ref count per core that will be modified during system suspend/resume and during pcm
5095974f684SRanjani Sridharan 	 * hw_params/hw_free. This doesn't need to be protected with a mutex because pcm
5105974f684SRanjani Sridharan 	 * hw_params/hw_free are already protected by the PCM mutex in the ALSA framework in
5115974f684SRanjani Sridharan 	 * sound/core/ when streams are active and during system suspend/resume, streams are
5125974f684SRanjani Sridharan 	 * already suspended.
5135974f684SRanjani Sridharan 	 */
5145974f684SRanjani Sridharan 	int dsp_core_ref_count[SOF_MAX_DSP_NUM_CORES];
5155974f684SRanjani Sridharan 
5166955d951SPeter Ujfalusi 	/*
5176955d951SPeter Ujfalusi 	 * Used to keep track of registered IPC client devices so that they can
5186955d951SPeter Ujfalusi 	 * be removed when the parent SOF module is removed.
5196955d951SPeter Ujfalusi 	 */
5206955d951SPeter Ujfalusi 	struct list_head ipc_client_list;
5216955d951SPeter Ujfalusi 
5226955d951SPeter Ujfalusi 	/* mutex to protect client list */
5236955d951SPeter Ujfalusi 	struct mutex ipc_client_mutex;
5246955d951SPeter Ujfalusi 
5256955d951SPeter Ujfalusi 	/*
5266955d951SPeter Ujfalusi 	 * Used for tracking the IPC client's RX registration for DSP initiated
5276955d951SPeter Ujfalusi 	 * message handling.
5286955d951SPeter Ujfalusi 	 */
5296955d951SPeter Ujfalusi 	struct list_head ipc_rx_handler_list;
5306955d951SPeter Ujfalusi 
5316955d951SPeter Ujfalusi 	/*
5326955d951SPeter Ujfalusi 	 * Used for tracking the IPC client's registration for DSP state change
5336955d951SPeter Ujfalusi 	 * notification
5346955d951SPeter Ujfalusi 	 */
5356955d951SPeter Ujfalusi 	struct list_head fw_state_handler_list;
5366955d951SPeter Ujfalusi 
5376955d951SPeter Ujfalusi 	/* to protect the ipc_rx_handler_list  and  dsp_state_handler_list list */
5386955d951SPeter Ujfalusi 	struct mutex client_event_handler_mutex;
5396955d951SPeter Ujfalusi 
540c16211d6SLiam Girdwood 	void *private;			/* core does not touch this */
541c16211d6SLiam Girdwood };
542c16211d6SLiam Girdwood 
543c16211d6SLiam Girdwood /*
544c16211d6SLiam Girdwood  * Device Level.
545c16211d6SLiam Girdwood  */
546c16211d6SLiam Girdwood 
547c16211d6SLiam Girdwood int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
548c16211d6SLiam Girdwood int snd_sof_device_remove(struct device *dev);
5497edb3051SKeyon Jie int snd_sof_device_shutdown(struct device *dev);
550271d9373SKai Vehmanen bool snd_sof_device_probe_completed(struct device *dev);
551c16211d6SLiam Girdwood 
552c16211d6SLiam Girdwood int snd_sof_runtime_suspend(struct device *dev);
553c16211d6SLiam Girdwood int snd_sof_runtime_resume(struct device *dev);
55462fde977SKai Vehmanen int snd_sof_runtime_idle(struct device *dev);
555c16211d6SLiam Girdwood int snd_sof_resume(struct device *dev);
556c16211d6SLiam Girdwood int snd_sof_suspend(struct device *dev);
5573541aef1SMarcin Rajwa int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev);
5580b50b3b1SKeyon Jie int snd_sof_prepare(struct device *dev);
5590b50b3b1SKeyon Jie void snd_sof_complete(struct device *dev);
560c16211d6SLiam Girdwood 
561c16211d6SLiam Girdwood void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
562c16211d6SLiam Girdwood 
563c16211d6SLiam Girdwood /*
56429990588SPeter Ujfalusi  * Compress support
56529990588SPeter Ujfalusi  */
56629990588SPeter Ujfalusi extern struct snd_compress_ops sof_compressed_ops;
56729990588SPeter Ujfalusi 
56829990588SPeter Ujfalusi /*
569c16211d6SLiam Girdwood  * Firmware loading.
570c16211d6SLiam Girdwood  */
571c16211d6SLiam Girdwood int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev);
572c16211d6SLiam Girdwood int snd_sof_load_firmware_memcpy(struct snd_sof_dev *sdev);
573c16211d6SLiam Girdwood int snd_sof_run_firmware(struct snd_sof_dev *sdev);
574c16211d6SLiam Girdwood int snd_sof_parse_module_memcpy(struct snd_sof_dev *sdev,
575c16211d6SLiam Girdwood 				struct snd_sof_mod_hdr *module);
576c16211d6SLiam Girdwood void snd_sof_fw_unload(struct snd_sof_dev *sdev);
577c16211d6SLiam Girdwood 
578c16211d6SLiam Girdwood /*
579c16211d6SLiam Girdwood  * IPC low level APIs.
580c16211d6SLiam Girdwood  */
581c16211d6SLiam Girdwood struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev);
582c16211d6SLiam Girdwood void snd_sof_ipc_free(struct snd_sof_dev *sdev);
5838ae77801SPeter Ujfalusi void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev);
584d7a1ed26SRanjani Sridharan void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id);
585c16211d6SLiam Girdwood void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev);
586c16211d6SLiam Girdwood int snd_sof_ipc_valid(struct snd_sof_dev *sdev);
5872a51c0f8SPeter Ujfalusi int sof_ipc_tx_message(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
5882a51c0f8SPeter Ujfalusi 		       void *reply_data, size_t reply_bytes);
5892a51c0f8SPeter Ujfalusi int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
59063e51fd3SRanjani Sridharan 			     void *reply_data, size_t reply_bytes);
591*b4dcafe4SPeter Ujfalusi int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
592*b4dcafe4SPeter Ujfalusi 		     size_t reply_bytes);
593febf5da8SRander Wang int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev);
5948ae77801SPeter Ujfalusi static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_id)
5958ae77801SPeter Ujfalusi {
5968ae77801SPeter Ujfalusi 	snd_sof_ipc_get_reply(sdev);
5978ae77801SPeter Ujfalusi 	snd_sof_ipc_reply(sdev, msg_id);
5988ae77801SPeter Ujfalusi }
599c16211d6SLiam Girdwood 
600c16211d6SLiam Girdwood /*
601c16211d6SLiam Girdwood  * Trace/debug
602c16211d6SLiam Girdwood  */
603c16211d6SLiam Girdwood int snd_sof_init_trace(struct snd_sof_dev *sdev);
604c16211d6SLiam Girdwood void snd_sof_free_trace(struct snd_sof_dev *sdev);
605c16211d6SLiam Girdwood int snd_sof_dbg_init(struct snd_sof_dev *sdev);
606c16211d6SLiam Girdwood void snd_sof_free_debug(struct snd_sof_dev *sdev);
607c16211d6SLiam Girdwood int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
608c16211d6SLiam Girdwood 			     void *base, size_t size,
6095c9714f6SRanjani Sridharan 			     const char *name, mode_t mode);
610c16211d6SLiam Girdwood int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
611c16211d6SLiam Girdwood 			     struct sof_ipc_dma_trace_posn *posn);
612c16211d6SLiam Girdwood void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev);
6134995ffceSPeter Ujfalusi void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
6144995ffceSPeter Ujfalusi 			      u32 panic_code, u32 tracep_code, void *oops,
615c16211d6SLiam Girdwood 			      struct sof_ipc_panic_info *panic_info,
616c16211d6SLiam Girdwood 			      void *stack, size_t stack_words);
617758f24d4SLibin Yang void snd_sof_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
618758f24d4SLibin Yang int snd_sof_trace_resume(struct snd_sof_dev *sdev);
6199a06508bSLiam Girdwood void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
6205b10b629SKarol Trzcinski int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
62107e833b4SPeter Ujfalusi int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
62207e833b4SPeter Ujfalusi 		enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
62307e833b4SPeter Ujfalusi 		const char *name, enum sof_debugfs_access_type access_type);
624c16211d6SLiam Girdwood 
625c16211d6SLiam Girdwood /*
626c16211d6SLiam Girdwood  * DSP Architectures.
627c16211d6SLiam Girdwood  */
628b9f0bfd1SPeter Ujfalusi static inline void sof_stack(struct snd_sof_dev *sdev, const char *level,
629b9f0bfd1SPeter Ujfalusi 			     void *oops, u32 *stack, u32 stack_words)
630c16211d6SLiam Girdwood {
631b9f0bfd1SPeter Ujfalusi 		sof_dsp_arch_ops(sdev)->dsp_stack(sdev, level,  oops, stack,
632b9f0bfd1SPeter Ujfalusi 						  stack_words);
633c16211d6SLiam Girdwood }
634c16211d6SLiam Girdwood 
635b9f0bfd1SPeter Ujfalusi static inline void sof_oops(struct snd_sof_dev *sdev, const char *level, void *oops)
636c16211d6SLiam Girdwood {
6370ed66cb7SPeter Ujfalusi 	if (sof_dsp_arch_ops(sdev)->dsp_oops)
638b9f0bfd1SPeter Ujfalusi 		sof_dsp_arch_ops(sdev)->dsp_oops(sdev, level, oops);
639c16211d6SLiam Girdwood }
640c16211d6SLiam Girdwood 
6410ed66cb7SPeter Ujfalusi extern const struct dsp_arch_ops sof_xtensa_arch_ops;
642c16211d6SLiam Girdwood 
643c16211d6SLiam Girdwood /*
64458a5c9a4SPeter Ujfalusi  * Firmware state tracking
64558a5c9a4SPeter Ujfalusi  */
6466955d951SPeter Ujfalusi void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state);
64758a5c9a4SPeter Ujfalusi 
64858a5c9a4SPeter Ujfalusi /*
649c16211d6SLiam Girdwood  * Utilities
650c16211d6SLiam Girdwood  */
651c16211d6SLiam Girdwood void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value);
652c16211d6SLiam Girdwood void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value);
653c16211d6SLiam Girdwood u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr);
654c16211d6SLiam Girdwood u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr);
655c16211d6SLiam Girdwood void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
656c16211d6SLiam Girdwood 		       void *message, size_t bytes);
657c16211d6SLiam Girdwood void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
658c16211d6SLiam Girdwood 		      void *message, size_t bytes);
6594624bb2fSPeter Ujfalusi int sof_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
6604624bb2fSPeter Ujfalusi 		    u32 offset, void *src, size_t size);
6614624bb2fSPeter Ujfalusi int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
6624624bb2fSPeter Ujfalusi 		   u32 offset, void *dest, size_t size);
663c16211d6SLiam Girdwood 
66483ee7ab1SDaniel Baluta int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id);
66583ee7ab1SDaniel Baluta 
66697e22cbdSBud Liviu-Alexandru int sof_ipc_msg_data(struct snd_sof_dev *sdev,
667c16211d6SLiam Girdwood 		     struct snd_pcm_substream *substream,
668c16211d6SLiam Girdwood 		     void *p, size_t sz);
6699a0a809aSPeter Ujfalusi int sof_set_stream_data_offset(struct snd_sof_dev *sdev,
6709a0a809aSPeter Ujfalusi 			       struct snd_pcm_substream *substream,
6719a0a809aSPeter Ujfalusi 			       size_t posn_offset);
672c16211d6SLiam Girdwood 
67397e22cbdSBud Liviu-Alexandru int sof_stream_pcm_open(struct snd_sof_dev *sdev,
674c16211d6SLiam Girdwood 			struct snd_pcm_substream *substream);
67597e22cbdSBud Liviu-Alexandru int sof_stream_pcm_close(struct snd_sof_dev *sdev,
676c16211d6SLiam Girdwood 			 struct snd_pcm_substream *substream);
677c16211d6SLiam Girdwood 
678285880a2SDaniel Baluta int sof_machine_check(struct snd_sof_dev *sdev);
6796955d951SPeter Ujfalusi 
6806955d951SPeter Ujfalusi /* SOF client support */
6816955d951SPeter Ujfalusi #if IS_ENABLED(CONFIG_SND_SOC_SOF_CLIENT)
6826955d951SPeter Ujfalusi int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
6836955d951SPeter Ujfalusi 			    const void *data, size_t size);
6846955d951SPeter Ujfalusi void sof_client_dev_unregister(struct snd_sof_dev *sdev, const char *name, u32 id);
6856955d951SPeter Ujfalusi int sof_register_clients(struct snd_sof_dev *sdev);
6866955d951SPeter Ujfalusi void sof_unregister_clients(struct snd_sof_dev *sdev);
6876955d951SPeter Ujfalusi void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf);
6886955d951SPeter Ujfalusi void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev);
6891069967aSPeter Ujfalusi int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state);
6901069967aSPeter Ujfalusi int sof_resume_clients(struct snd_sof_dev *sdev);
6916955d951SPeter Ujfalusi #else /* CONFIG_SND_SOC_SOF_CLIENT */
6926955d951SPeter Ujfalusi static inline int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name,
6936955d951SPeter Ujfalusi 					  u32 id, const void *data, size_t size)
6946955d951SPeter Ujfalusi {
6956955d951SPeter Ujfalusi 	return 0;
6966955d951SPeter Ujfalusi }
6976955d951SPeter Ujfalusi 
6986955d951SPeter Ujfalusi static inline void sof_client_dev_unregister(struct snd_sof_dev *sdev,
6996955d951SPeter Ujfalusi 					     const char *name, u32 id)
7006955d951SPeter Ujfalusi {
7016955d951SPeter Ujfalusi }
7026955d951SPeter Ujfalusi 
7036955d951SPeter Ujfalusi static inline int sof_register_clients(struct snd_sof_dev *sdev)
7046955d951SPeter Ujfalusi {
7056955d951SPeter Ujfalusi 	return 0;
7066955d951SPeter Ujfalusi }
7076955d951SPeter Ujfalusi 
7086955d951SPeter Ujfalusi static inline  void sof_unregister_clients(struct snd_sof_dev *sdev)
7096955d951SPeter Ujfalusi {
7106955d951SPeter Ujfalusi }
7116955d951SPeter Ujfalusi 
7126955d951SPeter Ujfalusi static inline void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf)
7136955d951SPeter Ujfalusi {
7146955d951SPeter Ujfalusi }
7156955d951SPeter Ujfalusi 
7166955d951SPeter Ujfalusi static inline void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev)
7176955d951SPeter Ujfalusi {
7186955d951SPeter Ujfalusi }
7191069967aSPeter Ujfalusi 
7201069967aSPeter Ujfalusi static inline int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state)
7211069967aSPeter Ujfalusi {
7221069967aSPeter Ujfalusi 	return 0;
7231069967aSPeter Ujfalusi }
7241069967aSPeter Ujfalusi 
7251069967aSPeter Ujfalusi static inline int sof_resume_clients(struct snd_sof_dev *sdev)
7261069967aSPeter Ujfalusi {
7271069967aSPeter Ujfalusi 	return 0;
7281069967aSPeter Ujfalusi }
7296955d951SPeter Ujfalusi #endif /* CONFIG_SND_SOC_SOF_CLIENT */
7306955d951SPeter Ujfalusi 
731c16211d6SLiam Girdwood #endif
732