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
41 /* Flag definitions used for controlling the DSP dump behavior */
42 #define SOF_DBG_DUMP_REGS BIT(0)
43 #define SOF_DBG_DUMP_MBOX BIT(1)
44 #define SOF_DBG_DUMP_TEXT BIT(2)
45 #define SOF_DBG_DUMP_PCI BIT(3)
46 /* Output this dump (at the DEBUG level) only when SOF_DBG_PRINT_ALL_DUMPS is set */
47 #define SOF_DBG_DUMP_OPTIONAL BIT(4)
49 /* global debug state set by SOF_DBG_ flags */
50 bool sof_debug_check_flag(int mask);
52 /* max BARs mmaped devices can use */
53 #define SND_SOF_BARS 8
55 /* time in ms for runtime suspend delay */
56 #define SND_SOF_SUSPEND_DELAY_MS 2000
58 /* DMA buffer size for trace */
59 #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16)
61 #define SOF_IPC_DSP_REPLY 0
62 #define SOF_IPC_HOST_REPLY 1
64 /* convenience constructor for DAI driver streams */
65 #define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
66 {.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
67 .rates = srates, .formats = sfmt}
69 #define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
70 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)
72 /* So far the primary core on all DSPs has ID 0 */
73 #define SOF_DSP_PRIMARY_CORE 0
75 /* max number of DSP cores */
76 #define SOF_MAX_DSP_NUM_CORES 8
78 struct sof_dsp_power_state {
80 u32 substate; /* platform-specific */
83 /* System suspend target state */
84 enum sof_system_suspend_state {
92 enum sof_dfsentry_type {
93 SOF_DFSENTRY_TYPE_IOMEM = 0,
94 SOF_DFSENTRY_TYPE_BUF,
97 enum sof_debugfs_access_type {
98 SOF_DEBUGFS_ACCESS_ALWAYS = 0,
99 SOF_DEBUGFS_ACCESS_D0_ONLY,
103 struct snd_sof_ipc_msg;
105 struct snd_sof_debugfs_map;
106 struct snd_soc_tplg_ops;
107 struct snd_soc_component;
108 struct snd_sof_pdata;
111 * struct snd_sof_platform_stream_params - platform dependent stream parameters
112 * @stream_tag: Stream tag to use
113 * @use_phy_addr: Use the provided @phy_addr for configuration
114 * @phy_addr: Platform dependent address to be used, if @use_phy_addr
116 * @no_ipc_position: Disable position update IPC from firmware
118 struct snd_sof_platform_stream_params {
120 bool use_phy_address;
122 bool no_ipc_position;
126 * SOF DSP HW abstraction operations.
127 * Used to abstract DSP HW architecture and any IO busses between host CPU
130 struct snd_sof_dsp_ops {
132 /* probe/remove/shutdown */
133 int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
134 int (*remove)(struct snd_sof_dev *sof_dev); /* optional */
135 int (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */
137 /* DSP core boot / reset */
138 int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
139 int (*stall)(struct snd_sof_dev *sof_dev, unsigned int core_mask); /* optional */
140 int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
141 int (*core_get)(struct snd_sof_dev *sof_dev, int core); /* optional */
142 int (*core_put)(struct snd_sof_dev *sof_dev, int core); /* optional */
145 * Register IO: only used by respective drivers themselves,
146 * TODO: consider removing these operations and calling respective
147 * implementations directly
149 void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
150 u32 value); /* optional */
151 u32 (*read)(struct snd_sof_dev *sof_dev,
152 void __iomem *addr); /* optional */
153 void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
154 u64 value); /* optional */
155 u64 (*read64)(struct snd_sof_dev *sof_dev,
156 void __iomem *addr); /* optional */
159 int (*block_read)(struct snd_sof_dev *sof_dev,
160 enum snd_sof_fw_blk_type type, u32 offset,
161 void *dest, size_t size); /* mandatory */
162 int (*block_write)(struct snd_sof_dev *sof_dev,
163 enum snd_sof_fw_blk_type type, u32 offset,
164 void *src, size_t size); /* mandatory */
167 void (*mailbox_read)(struct snd_sof_dev *sof_dev,
168 u32 offset, void *dest,
169 size_t size); /* optional */
170 void (*mailbox_write)(struct snd_sof_dev *sof_dev,
171 u32 offset, void *src,
172 size_t size); /* optional */
175 irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
176 irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
179 int (*send_msg)(struct snd_sof_dev *sof_dev,
180 struct snd_sof_ipc_msg *msg); /* mandatory */
183 int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
184 int (*load_module)(struct snd_sof_dev *sof_dev,
185 struct snd_sof_mod_hdr *hdr); /* optional */
187 /* connect pcm substream to a host stream */
188 int (*pcm_open)(struct snd_sof_dev *sdev,
189 struct snd_pcm_substream *substream); /* optional */
190 /* disconnect pcm substream to a host stream */
191 int (*pcm_close)(struct snd_sof_dev *sdev,
192 struct snd_pcm_substream *substream); /* optional */
194 /* host stream hw params */
195 int (*pcm_hw_params)(struct snd_sof_dev *sdev,
196 struct snd_pcm_substream *substream,
197 struct snd_pcm_hw_params *params,
198 struct snd_sof_platform_stream_params *platform_params); /* optional */
200 /* host stream hw_free */
201 int (*pcm_hw_free)(struct snd_sof_dev *sdev,
202 struct snd_pcm_substream *substream); /* optional */
204 /* host stream trigger */
205 int (*pcm_trigger)(struct snd_sof_dev *sdev,
206 struct snd_pcm_substream *substream,
207 int cmd); /* optional */
209 /* host stream pointer */
210 snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
211 struct snd_pcm_substream *substream); /* optional */
214 int (*pcm_ack)(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream); /* optional */
216 /* host read DSP stream data */
217 int (*ipc_msg_data)(struct snd_sof_dev *sdev,
218 struct snd_pcm_substream *substream,
219 void *p, size_t sz); /* mandatory */
221 /* host side configuration of the stream's data offset in stream mailbox area */
222 int (*set_stream_data_offset)(struct snd_sof_dev *sdev,
223 struct snd_pcm_substream *substream,
224 size_t posn_offset); /* optional */
226 /* pre/post firmware run */
227 int (*pre_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
228 int (*post_fw_run)(struct snd_sof_dev *sof_dev); /* optional */
230 /* parse platform specific extended manifest, optional */
231 int (*parse_platform_ext_manifest)(struct snd_sof_dev *sof_dev,
232 const struct sof_ext_man_elem_header *hdr);
235 int (*suspend)(struct snd_sof_dev *sof_dev,
236 u32 target_state); /* optional */
237 int (*resume)(struct snd_sof_dev *sof_dev); /* optional */
238 int (*runtime_suspend)(struct snd_sof_dev *sof_dev); /* optional */
239 int (*runtime_resume)(struct snd_sof_dev *sof_dev); /* optional */
240 int (*runtime_idle)(struct snd_sof_dev *sof_dev); /* optional */
241 int (*set_hw_params_upon_resume)(struct snd_sof_dev *sdev); /* optional */
242 int (*set_power_state)(struct snd_sof_dev *sdev,
243 const struct sof_dsp_power_state *target_state); /* optional */
246 int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
249 const struct snd_sof_debugfs_map *debug_map; /* optional */
250 int debug_map_count; /* optional */
251 void (*dbg_dump)(struct snd_sof_dev *sof_dev,
252 u32 flags); /* optional */
253 void (*ipc_dump)(struct snd_sof_dev *sof_dev); /* optional */
254 int (*debugfs_add_region_item)(struct snd_sof_dev *sdev,
255 enum snd_sof_fw_blk_type blk_type, u32 offset,
256 size_t size, const char *name,
257 enum sof_debugfs_access_type access_type); /* optional */
259 /* host DMA trace (IPC3) */
260 int (*trace_init)(struct snd_sof_dev *sdev,
261 struct snd_dma_buffer *dmatb,
262 struct sof_ipc_dma_trace_params_ext *dtrace_params); /* optional */
263 int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
264 int (*trace_trigger)(struct snd_sof_dev *sdev,
265 int cmd); /* optional */
268 int (*get_bar_index)(struct snd_sof_dev *sdev,
269 u32 type); /* optional */
270 int (*get_mailbox_offset)(struct snd_sof_dev *sdev);/* mandatory for common loader code */
271 int (*get_window_offset)(struct snd_sof_dev *sdev,
272 u32 id);/* mandatory for common loader code */
274 /* machine driver ops */
275 int (*machine_register)(struct snd_sof_dev *sdev,
276 void *pdata); /* optional */
277 void (*machine_unregister)(struct snd_sof_dev *sdev,
278 void *pdata); /* optional */
279 struct snd_soc_acpi_mach * (*machine_select)(struct snd_sof_dev *sdev); /* optional */
280 void (*set_mach_params)(struct snd_soc_acpi_mach *mach,
281 struct snd_sof_dev *sdev); /* optional */
284 int (*register_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
285 void (*unregister_ipc_clients)(struct snd_sof_dev *sdev); /* optional */
288 struct snd_soc_dai_driver *drv;
291 /* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */
294 const struct dsp_arch_ops *dsp_arch_ops;
297 /* DSP architecture specific callbacks for oops and stack dumps */
298 struct dsp_arch_ops {
299 void (*dsp_oops)(struct snd_sof_dev *sdev, const char *level, void *oops);
300 void (*dsp_stack)(struct snd_sof_dev *sdev, const char *level, void *oops,
301 u32 *stack, u32 stack_words);
304 #define sof_dsp_arch_ops(sdev) ((sdev)->pdata->desc->ops->dsp_arch_ops)
306 /* FS entry for debug files that can expose DSP memories, registers */
307 struct snd_sof_dfsentry {
309 size_t buf_data_size; /* length of buffered data for file read operation */
310 enum sof_dfsentry_type type;
312 * access_type specifies if the
313 * memory -> DSP resource (memory, register etc) is always accessible
314 * or if it is accessible only when the DSP is in D0.
316 enum sof_debugfs_access_type access_type;
317 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE)
318 char *cache_buf; /* buffer to cache the contents of debugfs memory */
320 struct snd_sof_dev *sdev;
321 struct list_head list; /* list in sdev dfsentry list */
323 void __iomem *io_mem;
328 /* Debug mapping for any DSP memory or registers that can used for debug */
329 struct snd_sof_debugfs_map {
335 * access_type specifies if the memory is always accessible
336 * or if it is accessible only when the DSP is in D0.
338 enum sof_debugfs_access_type access_type;
341 /* mailbox descriptor, used for host <-> DSP IPC */
342 struct snd_sof_mailbox {
347 /* IPC message descriptor for host <-> DSP IO */
348 struct snd_sof_ipc_msg {
356 /* notification, firmware initiated messages */
359 wait_queue_head_t waitq;
364 * struct sof_ipc_fw_tracing_ops - IPC-specific firmware tracing ops
365 * @init: Function pointer for initialization of the tracing
366 * @free: Optional function pointer for freeing of the tracing
367 * @fw_crashed: Optional function pointer to notify the tracing of a firmware crash
368 * @suspend: Function pointer for system/runtime suspend
369 * @resume: Function pointer for system/runtime resume
371 struct sof_ipc_fw_tracing_ops {
372 int (*init)(struct snd_sof_dev *sdev);
373 void (*free)(struct snd_sof_dev *sdev);
374 void (*fw_crashed)(struct snd_sof_dev *sdev);
375 void (*suspend)(struct snd_sof_dev *sdev, pm_message_t pm_state);
376 int (*resume)(struct snd_sof_dev *sdev);
380 * struct sof_ipc_pm_ops - IPC-specific PM ops
381 * @ctx_save: Function pointer for context save
382 * @ctx_restore: Function pointer for context restore
384 struct sof_ipc_pm_ops {
385 int (*ctx_save)(struct snd_sof_dev *sdev);
386 int (*ctx_restore)(struct snd_sof_dev *sdev);
390 * struct sof_ipc_fw_loader_ops - IPC/FW-specific loader ops
391 * @validate: Function pointer for validating the firmware image
392 * @parse_ext_manifest: Function pointer for parsing the manifest of the firmware
393 * @load_fw_to_dsp: Optional function pointer for loading the firmware to the
395 * The function implements generic, hardware independent way
396 * of loading the initial firmware and its modules (if any).
397 * @query_fw_configuration: Optional function pointer to query information and
398 * configuration from the booted firmware.
399 * Executed after the first successful firmware boot.
401 struct sof_ipc_fw_loader_ops {
402 int (*validate)(struct snd_sof_dev *sdev);
403 size_t (*parse_ext_manifest)(struct snd_sof_dev *sdev);
404 int (*load_fw_to_dsp)(struct snd_sof_dev *sdev);
405 int (*query_fw_configuration)(struct snd_sof_dev *sdev);
408 struct sof_ipc_tplg_ops;
409 struct sof_ipc_pcm_ops;
412 * struct sof_ipc_ops - IPC-specific ops
413 * @tplg: Pointer to IPC-specific topology ops
414 * @pm: Pointer to PM ops
415 * @pcm: Pointer to PCM ops
416 * @fw_loader: Pointer to Firmware Loader ops
417 * @fw_tracing: Pointer to Firmware tracing ops
419 * @tx_msg: Function pointer for sending a 'short' IPC message
420 * @set_get_data: Function pointer for set/get data ('large' IPC message). This
421 * function may split up the 'large' message and use the @tx_msg
422 * path to transfer individual chunks, or use other means to transfer
424 * @get_reply: Function pointer for fetching the reply to
425 * sdev->ipc->msg.reply_data
426 * @rx_msg: Function pointer for handling a received message
428 * Note: both @tx_msg and @set_get_data considered as TX functions and they are
429 * serialized for the duration of the instructed transfer. A large message sent
430 * via @set_get_data is a single transfer even if at the hardware level it is
431 * handled with multiple chunks.
434 const struct sof_ipc_tplg_ops *tplg;
435 const struct sof_ipc_pm_ops *pm;
436 const struct sof_ipc_pcm_ops *pcm;
437 const struct sof_ipc_fw_loader_ops *fw_loader;
438 const struct sof_ipc_fw_tracing_ops *fw_tracing;
440 int (*tx_msg)(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
441 void *reply_data, size_t reply_bytes, bool no_pm);
442 int (*set_get_data)(struct snd_sof_dev *sdev, void *data, size_t data_bytes,
444 int (*get_reply)(struct snd_sof_dev *sdev);
445 void (*rx_msg)(struct snd_sof_dev *sdev);
448 /* SOF generic IPC data */
450 struct snd_sof_dev *sdev;
452 /* protects messages and the disable flag */
453 struct mutex tx_mutex;
454 /* disables further sending of ipc's */
457 /* Maximum allowed size of a single IPC message/reply */
458 size_t max_payload_size;
460 struct snd_sof_ipc_msg msg;
462 /* IPC ops based on version */
463 const struct sof_ipc_ops *ops;
471 spinlock_t ipc_lock; /* lock for IPC users */
472 spinlock_t hw_lock; /* lock for HW IO access */
475 * ASoC components. plat_drv fields are set dynamically so
478 struct snd_soc_component_driver plat_drv;
480 /* current DSP power state */
481 struct sof_dsp_power_state dsp_power_state;
482 /* mutex to protect the dsp_power_state access */
483 struct mutex power_state_access;
485 /* Intended power target of system suspend */
486 enum sof_system_suspend_state system_suspend_target;
488 /* DSP firmware boot */
489 wait_queue_head_t boot_wait;
490 enum sof_fw_state fw_state;
493 /* work queue in case the probe is implemented in two steps */
494 struct work_struct probe_work;
495 bool probe_completed;
497 /* DSP HW differentiation */
498 struct snd_sof_pdata *pdata;
501 struct snd_sof_ipc *ipc;
502 struct snd_sof_mailbox dsp_box; /* DSP initiated IPC */
503 struct snd_sof_mailbox host_box; /* Host initiated IPC */
504 struct snd_sof_mailbox stream_box; /* Stream position update */
505 struct snd_sof_mailbox debug_box; /* Debug info updates */
506 struct snd_sof_ipc_msg *msg;
508 u32 next_comp_id; /* monotonic - reset during S3 */
510 /* memory bases for mmaped DSPs - set by dsp_init() */
511 void __iomem *bar[SND_SOF_BARS]; /* DSP base address */
514 size_t dsp_oops_offset;
517 struct dentry *debugfs_root;
518 struct list_head dfsentry_list;
519 bool dbg_dump_printed;
520 bool ipc_dump_printed;
522 /* firmware loader */
523 struct sof_ipc_fw_ready fw_ready;
524 struct sof_ipc_fw_version fw_version;
525 struct sof_ipc_cc_version *cc_version;
528 struct snd_soc_tplg_ops *tplg_ops;
529 struct list_head pcm_list;
530 struct list_head kcontrol_list;
531 struct list_head widget_list;
532 struct list_head dai_list;
533 struct list_head dai_link_list;
534 struct list_head route_list;
535 struct snd_soc_component *component;
536 u32 enabled_cores_mask; /* keep track of enabled cores */
539 /* FW configuration */
540 struct sof_ipc_window *info_window;
542 /* IPC timeouts in ms */
546 /* firmwre tracing */
547 bool fw_trace_is_supported; /* set with Kconfig or module parameter */
548 void *fw_trace_data; /* private data used by firmware tracing implementation */
552 /* DSP core context */
556 * ref count per core that will be modified during system suspend/resume and during pcm
557 * hw_params/hw_free. This doesn't need to be protected with a mutex because pcm
558 * hw_params/hw_free are already protected by the PCM mutex in the ALSA framework in
559 * sound/core/ when streams are active and during system suspend/resume, streams are
562 int dsp_core_ref_count[SOF_MAX_DSP_NUM_CORES];
565 * Used to keep track of registered IPC client devices so that they can
566 * be removed when the parent SOF module is removed.
568 struct list_head ipc_client_list;
570 /* mutex to protect client list */
571 struct mutex ipc_client_mutex;
574 * Used for tracking the IPC client's RX registration for DSP initiated
577 struct list_head ipc_rx_handler_list;
580 * Used for tracking the IPC client's registration for DSP state change
583 struct list_head fw_state_handler_list;
585 /* to protect the ipc_rx_handler_list and dsp_state_handler_list list */
586 struct mutex client_event_handler_mutex;
588 void *private; /* core does not touch this */
595 int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
596 int snd_sof_device_remove(struct device *dev);
597 int snd_sof_device_shutdown(struct device *dev);
598 bool snd_sof_device_probe_completed(struct device *dev);
600 int snd_sof_runtime_suspend(struct device *dev);
601 int snd_sof_runtime_resume(struct device *dev);
602 int snd_sof_runtime_idle(struct device *dev);
603 int snd_sof_resume(struct device *dev);
604 int snd_sof_suspend(struct device *dev);
605 int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev);
606 int snd_sof_prepare(struct device *dev);
607 void snd_sof_complete(struct device *dev);
609 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
614 extern struct snd_compress_ops sof_compressed_ops;
619 int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev);
620 int snd_sof_load_firmware_memcpy(struct snd_sof_dev *sdev);
621 int snd_sof_run_firmware(struct snd_sof_dev *sdev);
622 void snd_sof_fw_unload(struct snd_sof_dev *sdev);
625 * IPC low level APIs.
627 struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev);
628 void snd_sof_ipc_free(struct snd_sof_dev *sdev);
629 void snd_sof_ipc_get_reply(struct snd_sof_dev *sdev);
630 void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id);
631 static inline void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev)
633 sdev->ipc->ops->rx_msg(sdev);
635 int sof_ipc_tx_message(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
636 void *reply_data, size_t reply_bytes);
637 int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, void *msg_data, size_t msg_bytes,
638 void *reply_data, size_t reply_bytes);
639 int sof_ipc_send_msg(struct snd_sof_dev *sdev, void *msg_data, size_t msg_bytes,
642 static inline void snd_sof_ipc_process_reply(struct snd_sof_dev *sdev, u32 msg_id)
644 snd_sof_ipc_get_reply(sdev);
645 snd_sof_ipc_reply(sdev, msg_id);
651 int snd_sof_dbg_init(struct snd_sof_dev *sdev);
652 void snd_sof_free_debug(struct snd_sof_dev *sdev);
653 int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
654 void *base, size_t size,
655 const char *name, mode_t mode);
656 void sof_print_oops_and_stack(struct snd_sof_dev *sdev, const char *level,
657 u32 panic_code, u32 tracep_code, void *oops,
658 struct sof_ipc_panic_info *panic_info,
659 void *stack, size_t stack_words);
660 void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
661 int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
662 int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
663 enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
664 const char *name, enum sof_debugfs_access_type access_type);
665 /* Firmware tracing */
666 int sof_fw_trace_init(struct snd_sof_dev *sdev);
667 void sof_fw_trace_free(struct snd_sof_dev *sdev);
668 void sof_fw_trace_fw_crashed(struct snd_sof_dev *sdev);
669 void sof_fw_trace_suspend(struct snd_sof_dev *sdev, pm_message_t pm_state);
670 int sof_fw_trace_resume(struct snd_sof_dev *sdev);
675 static inline void sof_stack(struct snd_sof_dev *sdev, const char *level,
676 void *oops, u32 *stack, u32 stack_words)
678 sof_dsp_arch_ops(sdev)->dsp_stack(sdev, level, oops, stack,
682 static inline void sof_oops(struct snd_sof_dev *sdev, const char *level, void *oops)
684 if (sof_dsp_arch_ops(sdev)->dsp_oops)
685 sof_dsp_arch_ops(sdev)->dsp_oops(sdev, level, oops);
688 extern const struct dsp_arch_ops sof_xtensa_arch_ops;
691 * Firmware state tracking
693 void sof_set_fw_state(struct snd_sof_dev *sdev, enum sof_fw_state new_state);
698 void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value);
699 void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value);
700 u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr);
701 u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr);
702 void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
703 void *message, size_t bytes);
704 void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
705 void *message, size_t bytes);
706 int sof_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
707 u32 offset, void *src, size_t size);
708 int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
709 u32 offset, void *dest, size_t size);
711 int sof_ipc_msg_data(struct snd_sof_dev *sdev,
712 struct snd_pcm_substream *substream,
714 int sof_set_stream_data_offset(struct snd_sof_dev *sdev,
715 struct snd_pcm_substream *substream,
718 int sof_stream_pcm_open(struct snd_sof_dev *sdev,
719 struct snd_pcm_substream *substream);
720 int sof_stream_pcm_close(struct snd_sof_dev *sdev,
721 struct snd_pcm_substream *substream);
723 int sof_machine_check(struct snd_sof_dev *sdev);
725 /* SOF client support */
726 #if IS_ENABLED(CONFIG_SND_SOC_SOF_CLIENT)
727 int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name, u32 id,
728 const void *data, size_t size);
729 void sof_client_dev_unregister(struct snd_sof_dev *sdev, const char *name, u32 id);
730 int sof_register_clients(struct snd_sof_dev *sdev);
731 void sof_unregister_clients(struct snd_sof_dev *sdev);
732 void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf);
733 void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev);
734 int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state);
735 int sof_resume_clients(struct snd_sof_dev *sdev);
736 #else /* CONFIG_SND_SOC_SOF_CLIENT */
737 static inline int sof_client_dev_register(struct snd_sof_dev *sdev, const char *name,
738 u32 id, const void *data, size_t size)
743 static inline void sof_client_dev_unregister(struct snd_sof_dev *sdev,
744 const char *name, u32 id)
748 static inline int sof_register_clients(struct snd_sof_dev *sdev)
753 static inline void sof_unregister_clients(struct snd_sof_dev *sdev)
757 static inline void sof_client_ipc_rx_dispatcher(struct snd_sof_dev *sdev, void *msg_buf)
761 static inline void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev)
765 static inline int sof_suspend_clients(struct snd_sof_dev *sdev, pm_message_t state)
770 static inline int sof_resume_clients(struct snd_sof_dev *sdev)
774 #endif /* CONFIG_SND_SOC_SOF_CLIENT */
776 /* Main ops for IPC implementations */
777 extern const struct sof_ipc_ops ipc3_ops;
778 extern const struct sof_ipc_ops ipc4_ops;