1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
5 // Common helpers for the audio DSP on i.MX8
7 #include <linux/module.h>
8 #include <sound/sof/xtensa.h>
11 #include "imx-common.h"
14 * imx8_get_registers() - This function is called in case of DSP oops
15 * in order to gather information about the registers, filename and
16 * linenumber and stack.
18 * @xoops: Stores information about registers.
19 * @panic_info: Stores information about filename and line number.
20 * @stack: Stores the stack dump.
21 * @stack_words: Size of the stack dump.
23 void imx8_get_registers(struct snd_sof_dev
*sdev
,
24 struct sof_ipc_dsp_oops_xtensa
*xoops
,
25 struct sof_ipc_panic_info
*panic_info
,
26 u32
*stack
, size_t stack_words
)
28 u32 offset
= sdev
->dsp_oops_offset
;
30 /* first read registers */
31 sof_mailbox_read(sdev
, offset
, xoops
, sizeof(*xoops
));
33 /* then get panic info */
34 if (xoops
->arch_hdr
.totalsize
> EXCEPT_MAX_HDR_SIZE
) {
35 dev_err(sdev
->dev
, "invalid header size 0x%x. FW oops is bogus\n",
36 xoops
->arch_hdr
.totalsize
);
39 offset
+= xoops
->arch_hdr
.totalsize
;
40 sof_mailbox_read(sdev
, offset
, panic_info
, sizeof(*panic_info
));
42 /* then get the stack */
43 offset
+= sizeof(*panic_info
);
44 sof_mailbox_read(sdev
, offset
, stack
, stack_words
* sizeof(u32
));
48 * imx8_dump() - This function is called when a panic message is
49 * received from the firmware.
51 * @flags: parameter not used but required by ops prototype
53 void imx8_dump(struct snd_sof_dev
*sdev
, u32 flags
)
55 struct sof_ipc_dsp_oops_xtensa xoops
;
56 struct sof_ipc_panic_info panic_info
;
57 u32 stack
[IMX8_STACK_DUMP_SIZE
];
60 /* Get information about the panic status from the debug box area.
61 * Compute the trace point based on the status.
63 sof_mailbox_read(sdev
, sdev
->debug_box
.offset
+ 0x4, &status
, 4);
65 /* Get information about the registers, the filename and line
66 * number and the stack.
68 imx8_get_registers(sdev
, &xoops
, &panic_info
, stack
,
69 IMX8_STACK_DUMP_SIZE
);
71 /* Print the information to the console */
72 snd_sof_get_status(sdev
, status
, status
, &xoops
, &panic_info
, stack
,
73 IMX8_STACK_DUMP_SIZE
);
75 EXPORT_SYMBOL(imx8_dump
);
77 MODULE_LICENSE("Dual BSD/GPL");