1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
6 * Copyright(c) 2018 Intel Corporation. All rights reserved.
8 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
11 #ifndef __SOUND_SOC_SOF_PRIV_H
12 #define __SOUND_SOC_SOF_PRIV_H
14 #include <linux/device.h>
15 #include <sound/hdaudio.h>
16 #include <sound/sof.h>
17 #include <sound/sof/info.h>
18 #include <sound/sof/pm.h>
19 #include <sound/sof/trace.h>
20 #include <uapi/sound/sof/fw.h>
21 #include <sound/sof/ext_manifest.h>
23 /* Flag definitions used in sof_core_debug (sof_debug module parameter) */
24 #define SOF_DBG_ENABLE_TRACE BIT(0)
25 #define SOF_DBG_RETAIN_CTX BIT(1) /* prevent DSP D3 on FW exception */
26 #define SOF_DBG_VERIFY_TPLG BIT(2) /* verify topology during load */
27 #define SOF_DBG_DYNAMIC_PIPELINES_OVERRIDE BIT(3) /* 0: use topology token
28 * 1: override topology
30 #define SOF_DBG_DYNAMIC_PIPELINES_ENABLE BIT(4) /* 0: use static pipelines
31 * 1: use dynamic pipelines
33 #define SOF_DBG_DISABLE_MULTICORE BIT(5) /* schedule all pipelines/widgets
36 #define SOF_DBG_PRINT_ALL_DUMPS BIT(6) /* Print all ipc and dsp dumps */
37 #define SOF_DBG_IGNORE_D3_PERSISTENT BIT(7) /* ignore the DSP D3 persistent capability
38 * and always download firmware upon D3 exit
40 #define SOF_DBG_PRINT_DMA_POSITION_UPDATE_LOGS BIT(8) /* print DMA position updates
43 #define SOF_DBG_PRINT_IPC_SUCCESS_LOGS BIT(9) /* print IPC success
47 /* Flag definitions used for controlling the DSP dump behavior */
48 #define SOF_DBG_DUMP_REGS BIT(0)
49 #define SOF_DBG_DUMP_MBOX BIT(1)
50 #define SOF_DBG_DUMP_TEXT BIT(2)
51 #define SOF_DBG_DUMP_PCI BIT(3)
52 /* Output this dump (at the DEBUG level) only when SOF_DBG_PRINT_ALL_DUMPS is set */
53 #define SOF_DBG_DUMP_OPTIONAL BIT(4)
55 /* global debug state set by SOF_DBG_ flags */
56 bool sof_debug_check_flag(int mask);
58 /* max BARs mmaped devices can use */
59 #define SND_SOF_BARS 8
61 /* time in ms for runtime suspend delay */
62 #define SND_SOF_SUSPEND_DELAY_MS 2000
64 /* DMA buffer size for trace */
65 #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16)
67 #define SOF_IPC_DSP_REPLY 0
68 #define SOF_IPC_HOST_REPLY 1
70 /* convenience constructor for DAI driver streams */
71 #define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
72 {.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
73 .rates = srates, .formats = sfmt}
75 #define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
76 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)
78 /* So far the primary core on all DSPs has ID 0 */
79 #define SOF_DSP_PRIMARY_CORE 0
81 /* max number of DSP cores */
82 #define SOF_MAX_DSP_NUM_CORES 8
84 struct sof_dsp_power_state {
86 u32 substate; /* platform-specific */
89 /* System suspend target state */
90 enum sof_system_suspend_state {
98 enum sof_dfsentry_type {
99 SOF_DFSENTRY_TYPE_IOMEM = 0,
100 SOF_DFSENTRY_TYPE_BUF,
103 enum sof_debugfs_access_type {
104 SOF_DEBUGFS_ACCESS_ALWAYS = 0,
105 SOF_DEBUGFS_ACCESS_D0_ONLY,
108 struct sof_compr_stream {
112 u16 sample_container_bytes;
116 struct snd_sof_ipc_msg;
118 struct snd_sof_debugfs_map;
119 struct snd_soc_tplg_ops;
120 struct snd_soc_component;
121 struct snd_sof_pdata;
124 * struct snd_sof_platform_stream_params - platform dependent stream parameters
125 * @stream_tag: Stream tag to use
126 * @use_phy_addr: Use the provided @phy_addr for configuration
127 * @phy_addr: Platform dependent address to be used, if @use_phy_addr
129 * @no_ipc_position: Disable position update IPC from firmware
131 struct snd_sof_platform_stream_params {
133 bool use_phy_address;
135 bool no_ipc_position;
136 bool cont_update_posn;
140 * SOF DSP HW abstraction operations.
141 * Used to abstract DSP HW architecture and any IO busses between host CPU
144 struct snd_sof_dsp_ops {
146 /* probe/remove/shutdown */
147 int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
148 int (*remove)(struct snd_sof_dev *sof_dev); /* optional */
149 int (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */
151 /* DSP core boot / reset */
152 int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
153 int (*stall)(struct snd_sof_dev *sof_dev, unsigned int core_mask); /* optional */
154 int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
155 int (*core_get)(struct snd_sof_dev *sof_dev, int core); /* optional */
156 int (*core_put)(struct snd_sof_dev *sof_dev, int core); /* optional */
159 * Register IO: only used by respective drivers themselves,
160 * TODO: consider removing these operations and calling respective
161 * implementations directly
163 void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
164 u32 value); /* optional */
165 u32 (*read)(struct snd_sof_dev *sof_dev,
166 void __iomem *addr); /* optional */
167 void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
168 u64 value); /* optional */
169 u64 (*read64)(struct snd_sof_dev *sof_dev,
170 void __iomem *addr); /* optional */
173 int (*block_read)(struct snd_sof_dev *sof_dev,
174 enum snd_sof_fw_blk_type type, u32 offset,
175 void *dest, size_t size); /* mandatory */
176 int (*block_write)(struct snd_sof_dev *sof_dev,
177 enum snd_sof_fw_blk_type type, u32 offset,
178 void *src, size_t size); /* mandatory */
181 void (*mailbox_read)(struct snd_sof_dev *sof_dev,
182 u32 offset, void *dest,
183 size_t size); /* optional */
184 void (*mailbox_write)(struct snd_sof_dev *sof_dev,
185 u32 offset, void *src,
186 size_t size); /* optional */
189 irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
190 irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
193 int (*send_msg)(struct snd_sof_dev *sof_dev,
194 struct snd_sof_ipc_msg *msg); /* mandatory */
197 int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
198 int (*load_module)(struct snd_sof_dev *sof_dev,
199 struct snd_sof_mod_hdr *hdr); /* optional */
201 /* connect pcm substream to a host stream */
202 int (*pcm_open)(struct snd_sof_dev *sdev,
203 struct snd_pcm_substream *substream); /* optional */
204 /* disconnect pcm substream to a host stream */
205 int (*pcm_close)(struct snd_sof_dev *sdev,
206 struct snd_pcm_substream *substream); /* optional */
208 /* host stream hw params */
209 int (*pcm_hw_params)(struct snd_sof_dev *sdev,
210 struct snd_pcm_substream *substream,
211 struct snd_pcm_hw_params *params,
212 struct snd_sof_platform_stream_params *platform_params); /* optional */
214 /* host stream hw_free */
215 int (*pcm_hw_free)(struct snd_sof_dev *sdev,
216 struct snd_pcm_substream *substream); /* optional */
218 /* host stream trigger */
219 int (*pcm_trigger)(struct snd_sof_dev *sdev,
220 struct snd_pcm_substream *substream,
221 int cmd); /* optional */
223 /* host stream pointer */
224 snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
225 struct snd_pcm_substream *substream); /* optional */
228 int (*pcm_ack)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); /* optional */
230 /* host read DSP stream data */
231 int (*ipc_msg_data)(struct snd_sof_dev *sdev,
232 struct snd_pcm_substream *substream,
233 void *p, size_t sz); /* mandatory */
235 /* host side configuration of the stream's data offset in stream mailbox area */
236 int (*set_stream_data_offset)(struct snd_sof_dev *sdev,
237 struct snd_pcm_substream *substream,
238 size_t posn_offset); /* optional */
240 /* pre/post firmware run */
241 int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
242 int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
244 /* parse platform specific extended manifest, optional */
245 int (*parse_platform_ext_manifest)(struct snd_sof_dev *sof_dev,
246 const struct sof_ext_man_elem_header *hdr);
249 int (*suspend)(struct snd_sof_dev *sof_dev,
250 u32 target_state); /* optional */
251 int (*resume)(struct snd_sof_dev *sof_dev); /* optional */
252 int (*runtime_suspend)(struct snd_sof_dev *sof_dev); /* optional */
253 int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
254 int (*runtime_idle)(struct snd_sof_dev *sof_dev); /* optional */
255 int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
256 int (*set_power_state)(struct snd_sof_dev *sdev,
257 const struct sof_dsp_power_state *target_state); /* optional */
260 int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
263 const struct snd_sof_debugfs_map *debug_map; /* optional */
264 int debug_map_count; /* optional */
265 void (*dbg_dump)(struct snd_sof_dev *sof_dev,
266 u32 flags); /* optional */
267 void (*ipc_dump)(struct snd_sof_dev *sof_dev); /* optional */
268 int (*debugfs_add_region_item)(struct snd_sof_dev *sdev,
269 enum snd_sof_fw_blk_type blk_type, u32 offset,
270 size_t size, const char *name,
271 enum sof_debugfs_access_type access_type); /* optional */
273 /* host DMA trace (IPC3) */
274 int (*trace_init)(struct snd_sof_dev *sdev,
275 struct snd_dma_buffer *dmatb,
276 struct sof_ipc_dma_trace_params_ext *dtrace_params); /* optional */
277 int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
278 int (*trace_trigger)(struct snd_sof_dev *sdev,
279 int cmd); /* optional */
282 int (*get_bar_index)(struct snd_sof_dev *sdev,
283 u32 type); /* optional */
284 int (*get_mailbox_offset)(struct snd_sof_dev *sdev);/* mandatory for common loader code */
285 int (*get_window_offset)(struct snd_sof_dev *sdev,
286 u32 id);/* mandatory for common loader code */
288 /* machine driver ops */
289 int (*machine_register)(struct snd_sof_dev *sdev,
290 void *pdata); /* optional */
291 void (*machine_unregister)(struct snd_sof_dev *sdev,
292 void *pdata); /* optional */
293 struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */
294 void (*set_mach_params)(struct snd_soc_acpi_mach *mach,
295 struct snd_sof_dev *sdev); /* optional */
298 int (*register_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
299 void (*unregister_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
302 struct snd_soc_dai_driver *drv;
305 /* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */
308 const struct dsp_arch_ops *dsp_arch_ops;
311 /* DSP architecture specific callbacks for oops and stack dumps */
312 struct dsp_arch_ops {
313 void (*dsp_oops)(struct snd_sof_dev *sdev, const char *level, void *oops);
314 void (*dsp_stack)(struct snd_sof_dev *sdev, const char *level, void *oops,
315 u32 *stack, u32 stack_words);
318 #define sof_dsp_arch_ops(sdev) ((sdev)->pdata->desc->ops->dsp_arch_ops)
320 /* FS entry for debug files that can expose DSP memories, registers */
321 struct snd_sof_dfsentry {
323 size_t buf_data_size; /* length of buffered data for file read operation */
324 enum sof_dfsentry_type type;
326 * access_type specifies if the
327 * memory -> DSP resource (memory, register etc) is always accessible
328 * or if it is accessible only when the DSP is in D0.
330 enum sof_debugfs_access_type access_type;
331 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
332 char *cache_buf; /* buffer to cache the contents of debugfs memory */
334 struct snd_sof_dev *sdev;
335 struct list_head list; /* list in sdev dfsentry list */
337 void __iomem *io_mem;
342 /* Debug mapping for any DSP memory or registers that can used for debug */
343 struct snd_sof_debugfs_map {
349 * access_type specifies if the memory is always accessible
350 * or if it is accessible only when the DSP is in D0.
352 enum sof_debugfs_access_type access_type;
355 /* mailbox descriptor, used for host <-> DSP IPC */
356 struct snd_sof_mailbox {
361 /* IPC message descriptor for host <-> DSP IO */
362 struct snd_sof_ipc_msg {
370 /* notification, firmware initiated messages */
373 wait_queue_head_t waitq;
378 * struct sof_ipc_fw_tracing_ops - IPC-specific firmware tracing ops
379 * @init: Function pointer for initialization of the tracing
380 * @free: Optional function pointer for freeing of the tracing
381 * @fw_crashed: Optional function pointer to notify the tracing of a firmware crash
382 * @suspend: Function pointer for system/runtime suspend
383 * @resume: Function pointer for system/runtime resume
385 struct sof_ipc_fw_tracing_ops {
386 int (*init)(struct snd_sof_dev *sdev);
387 void (*free)(struct snd_sof_dev *sdev);
388 void (*fw_crashed)(struct snd_sof_dev *sdev);
389 void (*suspend)(struct snd_sof_dev *sdev, pm_message_t pm_state);
390 int (*resume)(struct snd_sof_dev *sdev);
394 * struct sof_ipc_pm_ops - IPC-specific PM ops
395 * @ctx_save: Optional function pointer for context save
396 * @ctx_restore: Optional function pointer for context restore
397 * @set_core_state: Optional function pointer for turning on/off a DSP core
399 struct sof_ipc_pm_ops {
400 int (*ctx_save)(struct snd_sof_dev *sdev);
401 int (*ctx_restore)(struct snd_sof_dev *sdev);
402 int (*set_core_state)(struct snd_sof_dev *sdev, int core_idx, bool on);
406 * struct sof_ipc_fw_loader_ops - IPC/FW-specific loader ops
407 * @validate: Function pointer for validating the firmware image
408 * @parse_ext_manifest: Function pointer for parsing the manifest of the firmware
409 * @load_fw_to_dsp: Optional function pointer for loading the firmware to the
411 * The function implements generic, hardware independent way
412 * of loading the initial firmware and its modules (if any).
413 * @query_fw_configuration: Optional function pointer to query information and
414 * configuration from the booted firmware.
415 * Executed after the first successful firmware boot.
417 struct sof_ipc_fw_loader_ops {
418 int (*validate)(struct snd_sof_dev *sdev);
419 size_t (*parse_ext_manifest)(struct snd_sof_dev *sdev);
420 int (*load_fw_to_dsp)(struct snd_sof_dev *sdev);
421 int (*query_fw_configuration)(struct snd_sof_dev *sdev);
424 struct sof_ipc_tplg_ops;
425 struct sof_ipc_pcm_ops;
428 * struct sof_ipc_ops - IPC-specific ops
429 * @tplg: Pointer to IPC-specific topology ops
430 * @pm: Pointer to PM ops
431 * @pcm: Pointer to PCM ops
432 * @fw_loader: Pointer to Firmware Loader ops
433 * @fw_tracing: Pointer to Firmware tracing ops
435 * @tx_msg: Function pointer for sending a 'short' IPC message
436 * @set_get_data: Function pointer for set/get data ('large' IPC message). This
437 * function may split up the 'large' message and use the @tx_msg
438 * path to transfer individual chunks, or use other means to transfer
440 * @get_reply: Function pointer for fetching the reply to
441 * sdev->ipc->msg.reply_data
442 * @rx_msg: Function pointer for handling a received message
444 * Note: both @tx_msg and @set_get_data considered as TX functions and they are
445 * serialized for the duration of the instructed transfer. A large message sent
446 * via @set_get_data is a single transfer even if at the hardware level it is
447 * handled with multiple chunks.
450 const struct sof_ipc_tplg_ops *tplg;
451 const struct sof_ipc_pm_ops *pm;
452 const struct sof_ipc_pcm_ops *pcm;
453 const struct sof_ipc_fw_loader_ops *fw_loader;
454 const struct sof_ipc_fw_tracing_ops *fw_tracing;
456 int (*tx_msg)(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
457 void *reply_data, size_t reply_bytes, bool no_pm);
458 int (*set_get_data)(struct snd_sof_dev *sdev, void *data, size_t data_bytes,
460 int (*get_reply)(struct snd_sof_dev *sdev);
461 void (*rx_msg)(struct snd_sof_dev *sdev);
464 /* SOF generic IPC data */
466 struct snd_sof_dev *sdev;
468 /* protects messages and the disable flag */
469 struct mutex tx_mutex;
470 /* disables further sending of ipc's */
473 /* Maximum allowed size of a single IPC message/reply */
474 size_t max_payload_size;
476 struct snd_sof_ipc_msg msg;
478 /* IPC ops based on version */
479 const struct sof_ipc_ops *ops;
487 spinlock_t ipc_lock; /* lock for IPC users */
488 spinlock_t hw_lock; /* lock for HW IO access */
491 * ASoC components. plat_drv fields are set dynamically so
494 struct snd_soc_component_driver plat_drv;
496 /* current DSP power state */
497 struct sof_dsp_power_state dsp_power_state;
498 /* mutex to protect the dsp_power_state access */
499 struct mutex power_state_access;
501 /* Intended power target of system suspend */
502 enum sof_system_suspend_state system_suspend_target;
504 /* DSP firmware boot */
505 wait_queue_head_t boot_wait;
506 enum sof_fw_state fw_state;
509 /* work queue in case the probe is implemented in two steps */
510 struct work_struct probe_work;
511 bool probe_completed;
513 /* DSP HW differentiation */
514 struct snd_sof_pdata *pdata;
517 struct snd_sof_ipc *ipc;
518 struct snd_sof_mailbox dsp_box; /* DSP initiated IPC */
519 struct snd_sof_mailbox host_box; /* Host initiated IPC */
520 struct snd_sof_mailbox stream_box; /* Stream position update */
521 struct snd_sof_mailbox debug_box; /* Debug info updates */
522 struct snd_sof_ipc_msg *msg;
524 u32 next_comp_id; /* monotonic - reset during S3 */
526 /* memory bases for mmaped DSPs - set by dsp_init() */
527 void __iomem *bar[SND_SOF_BARS]; /* DSP base address */
530 size_t dsp_oops_offset;
533 struct dentry *debugfs_root;
534 struct list_head dfsentry_list;
535 bool dbg_dump_printed;
536 bool ipc_dump_printed;
538 /* firmware loader */
539 struct sof_ipc_fw_ready fw_ready;
540 struct sof_ipc_fw_version fw_version;
541 struct sof_ipc_cc_version *cc_version;
544 struct snd_soc_tplg_ops *tplg_ops;
545 struct list_head pcm_list;
546 struct list_head kcontrol_list;
547 struct list_head widget_list;
548 struct list_head dai_list;
549 struct list_head dai_link_list;
550 struct list_head route_list;
551 struct snd_soc_component *component;
552 u32 enabled_cores_mask; /* keep track of enabled cores */
555 /* FW configuration */
556 struct sof_ipc_window *info_window;
558 /* IPC timeouts in ms */
562 /* firmwre tracing */
563 bool fw_trace_is_supported; /* set with Kconfig or module parameter */
564 void *fw_trace_data; /* private data used by firmware tracing implementation */
568 /* DSP core context */
572 * ref count per core that will be modified during system suspend/resume and during pcm
573 * hw_params/hw_free. This doesn't need to be protected with a mutex because pcm
574 * hw_params/hw_free are already protected by the PCM mutex in the ALSA framework in
575 * sound/core/ when streams are active and during system suspend/resume, streams are
578 int dsp_core_ref_count[SOF_MAX_DSP_NUM_CORES];
581 * Used to keep track of registered IPC client devices so that they can
582 * be removed when the parent SOF module is removed.
584 struct list_head ipc_client_list;
586 /* mutex to protect client list */
587 struct mutex ipc_client_mutex;
590 * Used for tracking the IPC client's RX registration for DSP initiated
593 struct list_head ipc_rx_handler_list;
596 * Used for tracking the IPC client's registration for DSP state change
599 struct list_head fw_state_handler_list;
601 /* to protect the ipc_rx_handler_list and dsp_state_handler_list list */
602 struct mutex client_event_handler_mutex;
604 /* quirks to override topology values */
605 bool mclk_id_override;
606 u16 mclk_id_quirk; /* same size as in IPC3 definitions */
608 void *private; /* core does not touch this */
615 int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
616 int snd_sof_device_remove(struct device *dev);
617 int snd_sof_device_shutdown(struct device *dev);
618 bool snd_sof_device_probe_completed(struct device *dev);
620 int snd_sof_runtime_suspend(struct device *dev);
621 int snd_sof_runtime_resume(struct device *dev);
622 int snd_sof_runtime_idle(struct device *dev);
623 int snd_sof_resume(struct device *dev);
624 int snd_sof_suspend(struct device *dev);
625 int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev);
626 int snd_sof_prepare(struct device *dev);
627 void snd_sof_complete(struct device *dev);
629 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
634 extern struct snd_compress_ops sof_compressed_ops;
639 int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev);
640 int snd_sof_load_firmware_memcpy(struct snd_sof_dev *sdev);
641 int snd_sof_run_firmware(struct snd_sof_dev *sdev);
642 void snd_sof_fw_unload(struct snd_sof_dev *sdev);
645 * IPC low level APIs.
647 struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev);
648 void snd_sof_ipc_free(struct snd_sof_dev *sdev);
649 void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev);
650 void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id);
651 static inline void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev)
653 sdev->ipc->ops->rx_msg(sdev);
655 int sof_ipc_tx_message(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
656 void *reply_data, size_t reply_bytes);
657 int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
658 void *reply_data, size_t reply_bytes);
659 int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
662 static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_id)
664 snd_sof_ipc_get_reply(sdev);
665 snd_sof_ipc_reply(sdev, msg_id);
671 int snd_sof_dbg_init(struct snd_sof_dev *sdev);
672 void snd_sof_free_debug(struct snd_sof_dev *sdev);
673 int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
674 void *base, size_t size,
675 const char *name, mode_t mode);
676 void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
677 u32 panic_code, u32 tracep_code, void *oops,
678 struct sof_ipc_panic_info *panic_info,
679 void *stack, size_t stack_words);
680 void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev, const char *msg);
681 int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
682 int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
683 enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
684 const char *name, enum sof_debugfs_access_type access_type);
685 /* Firmware tracing */
686 int sof_fw_trace_init(struct snd_sof_dev *sdev);
687 void sof_fw_trace_free(struct snd_sof_dev *sdev);
688 void sof_fw_trace_fw_crashed(struct snd_sof_dev *sdev);
689 void sof_fw_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
690 int sof_fw_trace_resume(struct snd_sof_dev *sdev);
695 static inline void sof_stack(struct snd_sof_dev *sdev, const char *level,
696 void *oops, u32 *stack, u32 stack_words)
698 sof_dsp_arch_ops(sdev)->dsp_stack(sdev, level, oops, stack,
702 static inline void sof_oops(struct snd_sof_dev *sdev, const char *level, void *oops)
704 if (sof_dsp_arch_ops(sdev)->dsp_oops)
705 sof_dsp_arch_ops(sdev)->dsp_oops(sdev, level, oops);
708 extern const struct dsp_arch_ops sof_xtensa_arch_ops;
711 * Firmware state tracking
713 void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state);
718 void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value);
719 void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value);
720 u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr);
721 u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr);
722 void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
723 void *message, size_t bytes);
724 void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
725 void *message, size_t bytes);
726 int sof_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
727 u32 offset, void *src, size_t size);
728 int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
729 u32 offset, void *dest, size_t size);
731 int sof_ipc_msg_data(struct snd_sof_dev *sdev,
732 struct snd_pcm_substream *substream,
734 int sof_set_stream_data_offset(struct snd_sof_dev *sdev,
735 struct snd_pcm_substream *substream,
738 int sof_stream_pcm_open(struct snd_sof_dev *sdev,
739 struct snd_pcm_substream *substream);
740 int sof_stream_pcm_close(struct snd_sof_dev *sdev,
741 struct snd_pcm_substream *substream);
743 int sof_machine_check(struct snd_sof_dev *sdev);
745 /* SOF client support */
746 #if IS_ENABLED(CONFIG_SND_SOC_SOF_CLIENT)
747 int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
748 const void *data, size_t size);
749 void sof_client_dev_unregister(struct snd_sof_dev *sdev, const char *name, u32 id);
750 int sof_register_clients(struct snd_sof_dev *sdev);
751 void sof_unregister_clients(struct snd_sof_dev *sdev);
752 void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf);
753 void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev);
754 int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state);
755 int sof_resume_clients(struct snd_sof_dev *sdev);
756 #else /* CONFIG_SND_SOC_SOF_CLIENT */
757 static inline int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name,
758 u32 id, const void *data, size_t size)
763 static inline void sof_client_dev_unregister(struct snd_sof_dev *sdev,
764 const char *name, u32 id)
768 static inline int sof_register_clients(struct snd_sof_dev *sdev)
773 static inline void sof_unregister_clients(struct snd_sof_dev *sdev)
777 static inline void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf)
781 static inline void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev)
785 static inline int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state)
790 static inline int sof_resume_clients(struct snd_sof_dev *sdev)
794 #endif /* CONFIG_SND_SOC_SOF_CLIENT */
796 /* Main ops for IPC implementations */
797 extern const struct sof_ipc_ops ipc3_ops;
798 extern const struct sof_ipc_ops ipc4_ops;