1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
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.
5 *
6 * Copyright(c) 2018 Intel Corporation. All rights reserved.
7 *
8 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9 */
10
11 #ifndef __SOUND_SOC_SOF_PRIV_H
12 #define __SOUND_SOC_SOF_PRIV_H
13
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>
22
23 /* debug flags */
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
29 */
30 #define SOF_DBG_DYNAMIC_PIPELINES_ENABLE BIT(4) /* 0: use static pipelines
31 * 1: use dynamic pipelines
32 */
33 #define SOF_DBG_DISABLE_MULTICORE BIT(5) /* schedule all pipelines/widgets
34 * on primary core
35 */
36 #define SOF_DBG_PRINT_ALL_DUMPS BIT(6) /* Print all ipc and dsp dumps */
37
38 #define SOF_DBG_DUMP_REGS BIT(0)
39 #define SOF_DBG_DUMP_MBOX BIT(1)
40 #define SOF_DBG_DUMP_TEXT BIT(2)
41 #define SOF_DBG_DUMP_PCI BIT(3)
42 #define SOF_DBG_DUMP_OPTIONAL BIT(4) /* only dump if SOF_DBG_PRINT_ALL_DUMPS is set */
43
44 /* global debug state set by SOF_DBG_ flags */
45 extern int sof_core_debug;
46
47 /* max BARs mmaped devices can use */
48 #define SND_SOF_BARS 8
49
50 /* time in ms for runtime suspend delay */
51 #define SND_SOF_SUSPEND_DELAY_MS 2000
52
53 /* DMA buffer size for trace */
54 #define DMA_BUF_SIZE_FOR_TRACE (PAGE_SIZE * 16)
55
56 #define SOF_IPC_DSP_REPLY 0
57 #define SOF_IPC_HOST_REPLY 1
58
59 /* convenience constructor for DAI driver streams */
60 #define SOF_DAI_STREAM(sname, scmin, scmax, srates, sfmt) \
61 {.stream_name = sname, .channels_min = scmin, .channels_max = scmax, \
62 .rates = srates, .formats = sfmt}
63
64 #define SOF_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | \
65 SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_FLOAT)
66
67 #define ENABLE_DEBUGFS_CACHEBUF \
68 (IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_ENABLE_DEBUGFS_CACHE) || \
69 IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST))
70
71 /* So far the primary core on all DSPs has ID 0 */
72 #define SOF_DSP_PRIMARY_CORE 0
73
74 /* DSP power state */
75 enum sof_dsp_power_states {
76 SOF_DSP_PM_D0,
77 SOF_DSP_PM_D1,
78 SOF_DSP_PM_D2,
79 SOF_DSP_PM_D3_HOT,
80 SOF_DSP_PM_D3,
81 SOF_DSP_PM_D3_COLD,
82 };
83
84 struct sof_dsp_power_state {
85 u32 state;
86 u32 substate; /* platform-specific */
87 };
88
89 /* System suspend target state */
90 enum sof_system_suspend_state {
91 SOF_SUSPEND_NONE = 0,
92 SOF_SUSPEND_S0IX,
93 SOF_SUSPEND_S3,
94 };
95
96 enum sof_dfsentry_type {
97 SOF_DFSENTRY_TYPE_IOMEM = 0,
98 SOF_DFSENTRY_TYPE_BUF,
99 };
100
101 enum sof_debugfs_access_type {
102 SOF_DEBUGFS_ACCESS_ALWAYS = 0,
103 SOF_DEBUGFS_ACCESS_D0_ONLY,
104 };
105
106 struct snd_sof_dev;
107 struct snd_sof_ipc_msg;
108 struct snd_sof_ipc;
109 struct snd_sof_debugfs_map;
110 struct snd_soc_tplg_ops;
111 struct snd_soc_component;
112 struct snd_sof_pdata;
113
114 /*
115 * SOF DSP HW abstraction operations.
116 * Used to abstract DSP HW architecture and any IO busses between host CPU
117 * and DSP device(s).
118 */
119 struct snd_sof_dsp_ops {
120
121 /* probe/remove/shutdown */
122 int (*probe)(struct snd_sof_dev *sof_dev); /* mandatory */
123 int (*remove)(struct snd_sof_dev *sof_dev); /* optional */
124 int (*shutdown)(struct snd_sof_dev *sof_dev); /* optional */
125
126 /* DSP core boot / reset */
127 int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
128 int (*stall)(struct snd_sof_dev *sof_dev, unsigned int core_mask); /* optional */
129 int (*reset)(struct snd_sof_dev *sof_dev); /* optional */
130 int (*core_power_up)(struct snd_sof_dev *sof_dev,
131 unsigned int core_mask); /* optional */
132 int (*core_power_down)(struct snd_sof_dev *sof_dev,
133 unsigned int core_mask); /* optional */
134
135 /*
136 * Register IO: only used by respective drivers themselves,
137 * TODO: consider removing these operations and calling respective
138 * implementations directly
139 */
140 void (*write)(struct snd_sof_dev *sof_dev, void __iomem *addr,
141 u32 value); /* optional */
142 u32 (*read)(struct snd_sof_dev *sof_dev,
143 void __iomem *addr); /* optional */
144 void (*write64)(struct snd_sof_dev *sof_dev, void __iomem *addr,
145 u64 value); /* optional */
146 u64 (*read64)(struct snd_sof_dev *sof_dev,
147 void __iomem *addr); /* optional */
148
149 /* memcpy IO */
150 int (*block_read)(struct snd_sof_dev *sof_dev,
151 enum snd_sof_fw_blk_type type, u32 offset,
152 void *dest, size_t size); /* mandatory */
153 int (*block_write)(struct snd_sof_dev *sof_dev,
154 enum snd_sof_fw_blk_type type, u32 offset,
155 void *src, size_t size); /* mandatory */
156
157 /* Mailbox IO */
158 void (*mailbox_read)(struct snd_sof_dev *sof_dev,
159 u32 offset, void *dest,
160 size_t size); /* optional */
161 void (*mailbox_write)(struct snd_sof_dev *sof_dev,
162 u32 offset, void *src,
163 size_t size); /* optional */
164
165 /* doorbell */
166 irqreturn_t (*irq_handler)(int irq, void *context); /* optional */
167 irqreturn_t (*irq_thread)(int irq, void *context); /* optional */
168
169 /* ipc */
170 int (*send_msg)(struct snd_sof_dev *sof_dev,
171 struct snd_sof_ipc_msg *msg); /* mandatory */
172
173 /* FW loading */
174 int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
175 int (*load_module)(struct snd_sof_dev *sof_dev,
176 struct snd_sof_mod_hdr *hdr); /* optional */
177 /*
178 * FW ready checks for ABI compatibility and creates
179 * memory windows at first boot
180 */
181 int (*fw_ready)(struct snd_sof_dev *sdev, u32 msg_id); /* mandatory */
182
183 /* connect pcm substream to a host stream */
184 int (*pcm_open)(struct snd_sof_dev *sdev,
185 struct snd_pcm_substream *substream); /* optional */
186 /* disconnect pcm substream to a host stream */
187 int (*pcm_close)(struct snd_sof_dev *sdev,
188 struct snd_pcm_substream *substream); /* optional */
189
190 /* host stream hw params */
191 int (*pcm_hw_params)(struct snd_sof_dev *sdev,
192 struct snd_pcm_substream *substream,
193 struct snd_pcm_hw_params *params,
194 struct sof_ipc_stream_params *ipc_params); /* optional */
195
196 /* host stream hw_free */
197 int (*pcm_hw_free)(struct snd_sof_dev *sdev,
198 struct snd_pcm_substream *substream); /* optional */
199
200 /* host stream trigger */
201 int (*pcm_trigger)(struct snd_sof_dev *sdev,
202 struct snd_pcm_substream *substream,
203 int cmd); /* optional */
204
205 /* host stream pointer */
206 snd_pcm_uframes_t (*pcm_pointer)(struct snd_sof_dev *sdev,
207 struct snd_pcm_substream *substream); /* optional */
208
209 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
210 /* Except for probe_pointer, all probe ops are mandatory */
211 int (*probe_assign)(struct snd_sof_dev *sdev,
212 struct snd_compr_stream *cstream,
213 struct snd_soc_dai *dai); /* mandatory */
214 int (*probe_free)(struct snd_sof_dev *sdev,
215 struct snd_compr_stream *cstream,
216 struct snd_soc_dai *dai); /* mandatory */
217 int (*probe_set_params)(struct snd_sof_dev *sdev,
218 struct snd_compr_stream *cstream,
219 struct snd_compr_params *params,
220 struct snd_soc_dai *dai); /* mandatory */
221 int (*probe_trigger)(struct snd_sof_dev *sdev,
222 struct snd_compr_stream *cstream, int cmd,
223 struct snd_soc_dai *dai); /* mandatory */
224 int (*probe_pointer)(struct snd_sof_dev *sdev,
225 struct snd_compr_stream *cstream,
226 struct snd_compr_tstamp *tstamp,
227 struct snd_soc_dai *dai); /* optional */
228 #endif
229
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 */
234
235 /* host configure DSP HW parameters */
236 int (*ipc_pcm_params)(struct snd_sof_dev *sdev,
237 struct snd_pcm_substream *substream,
238 const struct sof_ipc_pcm_params_reply *reply); /* mandatory */
239
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 */
243
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);
247
248 /* DSP PM */
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 */
258
259 /* DSP clocking */
260 int (*set_clk)(struct snd_sof_dev *sof_dev, u32 freq); /* optional */
261
262 /* debug */
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 */
272
273 /* host DMA trace initialization */
274 int (*trace_init)(struct snd_sof_dev *sdev,
275 u32 *stream_tag); /* optional */
276 int (*trace_release)(struct snd_sof_dev *sdev); /* optional */
277 int (*trace_trigger)(struct snd_sof_dev *sdev,
278 int cmd); /* optional */
279
280 /* misc */
281 int (*get_bar_index)(struct snd_sof_dev *sdev,
282 u32 type); /* optional */
283 int (*get_mailbox_offset)(struct snd_sof_dev *sdev);/* mandatory for common loader code */
284 int (*get_window_offset)(struct snd_sof_dev *sdev,
285 u32 id);/* mandatory for common loader code */
286
287 /* machine driver ops */
288 int (*machine_register)(struct snd_sof_dev *sdev,
289 void *pdata); /* optional */
290 void (*machine_unregister)(struct snd_sof_dev *sdev,
291 void *pdata); /* optional */
292 void (*machine_select)(struct snd_sof_dev *sdev); /* optional */
293 void (*set_mach_params)(const struct snd_soc_acpi_mach *mach,
294 struct snd_sof_dev *sdev); /* optional */
295
296 /* DAI ops */
297 struct snd_soc_dai_driver *drv;
298 int num_drv;
299
300 /* ALSA HW info flags, will be stored in snd_pcm_runtime.hw.info */
301 u32 hw_info;
302
303 const struct dsp_arch_ops *dsp_arch_ops;
304 };
305
306 /* DSP architecture specific callbacks for oops and stack dumps */
307 struct dsp_arch_ops {
308 void (*dsp_oops)(struct snd_sof_dev *sdev, void *oops);
309 void (*dsp_stack)(struct snd_sof_dev *sdev, void *oops,
310 u32 *stack, u32 stack_words);
311 };
312
313 #define sof_dsp_arch_ops(sdev) ((sdev)->pdata->desc->ops->dsp_arch_ops)
314
315 /* FS entry for debug files that can expose DSP memories, registers */
316 struct snd_sof_dfsentry {
317 size_t size;
318 size_t buf_data_size; /* length of buffered data for file read operation */
319 enum sof_dfsentry_type type;
320 /*
321 * access_type specifies if the
322 * memory -> DSP resource (memory, register etc) is always accessible
323 * or if it is accessible only when the DSP is in D0.
324 */
325 enum sof_debugfs_access_type access_type;
326 #if ENABLE_DEBUGFS_CACHEBUF
327 char *cache_buf; /* buffer to cache the contents of debugfs memory */
328 #endif
329 struct snd_sof_dev *sdev;
330 struct list_head list; /* list in sdev dfsentry list */
331 union {
332 void __iomem *io_mem;
333 void *buf;
334 };
335 };
336
337 /* Debug mapping for any DSP memory or registers that can used for debug */
338 struct snd_sof_debugfs_map {
339 const char *name;
340 u32 bar;
341 u32 offset;
342 u32 size;
343 /*
344 * access_type specifies if the memory is always accessible
345 * or if it is accessible only when the DSP is in D0.
346 */
347 enum sof_debugfs_access_type access_type;
348 };
349
350 /* mailbox descriptor, used for host <-> DSP IPC */
351 struct snd_sof_mailbox {
352 u32 offset;
353 size_t size;
354 };
355
356 /* IPC message descriptor for host <-> DSP IO */
357 struct snd_sof_ipc_msg {
358 /* message data */
359 u32 header;
360 void *msg_data;
361 void *reply_data;
362 size_t msg_size;
363 size_t reply_size;
364 int reply_error;
365
366 wait_queue_head_t waitq;
367 bool ipc_complete;
368 };
369
370 enum snd_sof_fw_state {
371 SOF_FW_BOOT_NOT_STARTED = 0,
372 SOF_FW_BOOT_PREPARE,
373 SOF_FW_BOOT_IN_PROGRESS,
374 SOF_FW_BOOT_FAILED,
375 SOF_FW_BOOT_READY_FAILED, /* firmware booted but fw_ready op failed */
376 SOF_FW_BOOT_COMPLETE,
377 };
378
379 /*
380 * SOF Device Level.
381 */
382 struct snd_sof_dev {
383 struct device *dev;
384 spinlock_t ipc_lock; /* lock for IPC users */
385 spinlock_t hw_lock; /* lock for HW IO access */
386
387 /*
388 * ASoC components. plat_drv fields are set dynamically so
389 * can't use const
390 */
391 struct snd_soc_component_driver plat_drv;
392
393 /* current DSP power state */
394 struct sof_dsp_power_state dsp_power_state;
395 /* mutex to protect the dsp_power_state access */
396 struct mutex power_state_access;
397
398 /* Intended power target of system suspend */
399 enum sof_system_suspend_state system_suspend_target;
400
401 /* DSP firmware boot */
402 wait_queue_head_t boot_wait;
403 enum snd_sof_fw_state fw_state;
404 bool first_boot;
405
406 /* work queue in case the probe is implemented in two steps */
407 struct work_struct probe_work;
408 bool probe_completed;
409
410 /* DSP HW differentiation */
411 struct snd_sof_pdata *pdata;
412
413 /* IPC */
414 struct snd_sof_ipc *ipc;
415 struct snd_sof_mailbox dsp_box; /* DSP initiated IPC */
416 struct snd_sof_mailbox host_box; /* Host initiated IPC */
417 struct snd_sof_mailbox stream_box; /* Stream position update */
418 struct snd_sof_mailbox debug_box; /* Debug info updates */
419 struct snd_sof_ipc_msg *msg;
420 int ipc_irq;
421 u32 next_comp_id; /* monotonic - reset during S3 */
422
423 /* memory bases for mmaped DSPs - set by dsp_init() */
424 void __iomem *bar[SND_SOF_BARS]; /* DSP base address */
425 int mmio_bar;
426 int mailbox_bar;
427 size_t dsp_oops_offset;
428
429 /* debug */
430 struct dentry *debugfs_root;
431 struct list_head dfsentry_list;
432 bool dbg_dump_printed;
433 bool ipc_dump_printed;
434
435 /* firmware loader */
436 struct snd_dma_buffer dmab;
437 struct snd_dma_buffer dmab_bdl;
438 struct sof_ipc_fw_ready fw_ready;
439 struct sof_ipc_fw_version fw_version;
440 struct sof_ipc_cc_version *cc_version;
441
442 /* topology */
443 struct snd_soc_tplg_ops *tplg_ops;
444 struct list_head pcm_list;
445 struct list_head kcontrol_list;
446 struct list_head widget_list;
447 struct list_head dai_list;
448 struct list_head route_list;
449 struct snd_soc_component *component;
450 u32 enabled_cores_mask; /* keep track of enabled cores */
451
452 /* FW configuration */
453 struct sof_ipc_window *info_window;
454
455 /* IPC timeouts in ms */
456 int ipc_timeout;
457 int boot_timeout;
458
459 #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_PROBES)
460 unsigned int extractor_stream_tag;
461 #endif
462
463 /* DMA for Trace */
464 struct snd_dma_buffer dmatb;
465 struct snd_dma_buffer dmatp;
466 int dma_trace_pages;
467 wait_queue_head_t trace_sleep;
468 u32 host_offset;
469 bool dtrace_is_supported; /* set with Kconfig or module parameter */
470 bool dtrace_is_enabled;
471 bool dtrace_error;
472 bool dtrace_draining;
473
474 bool msi_enabled;
475
476 void *private; /* core does not touch this */
477 };
478
479 /*
480 * Device Level.
481 */
482
483 int snd_sof_device_probe(struct device *dev, struct snd_sof_pdata *plat_data);
484 int snd_sof_device_remove(struct device *dev);
485 int snd_sof_device_shutdown(struct device *dev);
486 bool snd_sof_device_probe_completed(struct device *dev);
487
488 int snd_sof_runtime_suspend(struct device *dev);
489 int snd_sof_runtime_resume(struct device *dev);
490 int snd_sof_runtime_idle(struct device *dev);
491 int snd_sof_resume(struct device *dev);
492 int snd_sof_suspend(struct device *dev);
493 int snd_sof_dsp_power_down_notify(struct snd_sof_dev *sdev);
494 int snd_sof_prepare(struct device *dev);
495 void snd_sof_complete(struct device *dev);
496
497 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
498
499 int snd_sof_create_page_table(struct device *dev,
500 struct snd_dma_buffer *dmab,
501 unsigned char *page_table, size_t size);
502
503 /*
504 * Firmware loading.
505 */
506 int snd_sof_load_firmware_raw(struct snd_sof_dev *sdev);
507 int snd_sof_load_firmware_memcpy(struct snd_sof_dev *sdev);
508 int snd_sof_run_firmware(struct snd_sof_dev *sdev);
509 int snd_sof_parse_module_memcpy(struct snd_sof_dev *sdev,
510 struct snd_sof_mod_hdr *module);
511 void snd_sof_fw_unload(struct snd_sof_dev *sdev);
512
513 /*
514 * IPC low level APIs.
515 */
516 struct snd_sof_ipc *snd_sof_ipc_init(struct snd_sof_dev *sdev);
517 void snd_sof_ipc_free(struct snd_sof_dev *sdev);
518 void snd_sof_ipc_reply(struct snd_sof_dev *sdev, u32 msg_id);
519 void snd_sof_ipc_msgs_rx(struct snd_sof_dev *sdev);
520 int snd_sof_ipc_stream_pcm_params(struct snd_sof_dev *sdev,
521 struct sof_ipc_pcm_params *params);
522 int snd_sof_ipc_valid(struct snd_sof_dev *sdev);
523 int sof_ipc_tx_message(struct snd_sof_ipc *ipc, u32 header,
524 void *msg_data, size_t msg_bytes, void *reply_data,
525 size_t reply_bytes);
526 int sof_ipc_tx_message_no_pm(struct snd_sof_ipc *ipc, u32 header,
527 void *msg_data, size_t msg_bytes,
528 void *reply_data, size_t reply_bytes);
529 int sof_ipc_init_msg_memory(struct snd_sof_dev *sdev);
530
531 /*
532 * Trace/debug
533 */
534 int snd_sof_init_trace(struct snd_sof_dev *sdev);
535 void snd_sof_release_trace(struct snd_sof_dev *sdev);
536 void snd_sof_free_trace(struct snd_sof_dev *sdev);
537 int snd_sof_dbg_init(struct snd_sof_dev *sdev);
538 void snd_sof_free_debug(struct snd_sof_dev *sdev);
539 int snd_sof_debugfs_buf_item(struct snd_sof_dev *sdev,
540 void *base, size_t size,
541 const char *name, mode_t mode);
542 int snd_sof_trace_update_pos(struct snd_sof_dev *sdev,
543 struct sof_ipc_dma_trace_posn *posn);
544 void snd_sof_trace_notify_for_error(struct snd_sof_dev *sdev);
545 void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
546 u32 tracep_code, void *oops,
547 struct sof_ipc_panic_info *panic_info,
548 void *stack, size_t stack_words);
549 int snd_sof_init_trace_ipc(struct snd_sof_dev *sdev);
550 void snd_sof_handle_fw_exception(struct snd_sof_dev *sdev);
551 int snd_sof_dbg_memory_info_init(struct snd_sof_dev *sdev);
552 int snd_sof_debugfs_add_region_item_iomem(struct snd_sof_dev *sdev,
553 enum snd_sof_fw_blk_type blk_type, u32 offset, size_t size,
554 const char *name, enum sof_debugfs_access_type access_type);
555
556 /*
557 * DSP Architectures.
558 */
sof_stack(struct snd_sof_dev * sdev,void * oops,u32 * stack,u32 stack_words)559 static inline void sof_stack(struct snd_sof_dev *sdev, void *oops, u32 *stack,
560 u32 stack_words)
561 {
562 sof_dsp_arch_ops(sdev)->dsp_stack(sdev, oops, stack, stack_words);
563 }
564
sof_oops(struct snd_sof_dev * sdev,void * oops)565 static inline void sof_oops(struct snd_sof_dev *sdev, void *oops)
566 {
567 if (sof_dsp_arch_ops(sdev)->dsp_oops)
568 sof_dsp_arch_ops(sdev)->dsp_oops(sdev, oops);
569 }
570
571 extern const struct dsp_arch_ops sof_xtensa_arch_ops;
572
573 /*
574 * Firmware state tracking
575 */
sof_set_fw_state(struct snd_sof_dev * sdev,enum snd_sof_fw_state new_state)576 static inline void sof_set_fw_state(struct snd_sof_dev *sdev,
577 enum snd_sof_fw_state new_state)
578 {
579 if (sdev->fw_state == new_state)
580 return;
581
582 dev_dbg(sdev->dev, "fw_state change: %d -> %d\n", sdev->fw_state, new_state);
583 sdev->fw_state = new_state;
584 }
585
586 /*
587 * Utilities
588 */
589 void sof_io_write(struct snd_sof_dev *sdev, void __iomem *addr, u32 value);
590 void sof_io_write64(struct snd_sof_dev *sdev, void __iomem *addr, u64 value);
591 u32 sof_io_read(struct snd_sof_dev *sdev, void __iomem *addr);
592 u64 sof_io_read64(struct snd_sof_dev *sdev, void __iomem *addr);
593 void sof_mailbox_write(struct snd_sof_dev *sdev, u32 offset,
594 void *message, size_t bytes);
595 void sof_mailbox_read(struct snd_sof_dev *sdev, u32 offset,
596 void *message, size_t bytes);
597 int sof_block_write(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
598 u32 offset, void *src, size_t size);
599 int sof_block_read(struct snd_sof_dev *sdev, enum snd_sof_fw_blk_type blk_type,
600 u32 offset, void *dest, size_t size);
601
602 int sof_fw_ready(struct snd_sof_dev *sdev, u32 msg_id);
603
604 int sof_ipc_msg_data(struct snd_sof_dev *sdev,
605 struct snd_pcm_substream *substream,
606 void *p, size_t sz);
607 int sof_ipc_pcm_params(struct snd_sof_dev *sdev,
608 struct snd_pcm_substream *substream,
609 const struct sof_ipc_pcm_params_reply *reply);
610
611 int sof_stream_pcm_open(struct snd_sof_dev *sdev,
612 struct snd_pcm_substream *substream);
613 int sof_stream_pcm_close(struct snd_sof_dev *sdev,
614 struct snd_pcm_substream *substream);
615
616 int sof_machine_check(struct snd_sof_dev *sdev);
617 #endif
618