1 /* Copyright (c) 2022 Intel Corporation
2  * SPDX-License-Identifier: Apache-2.0
3  */
4 #ifndef ZEPHYR_TESTS_INTEL_ADSP_TESTS_H
5 #define ZEPHYR_TESTS_INTEL_ADSP_TESTS_H
6 
7 #include <zephyr/sys_clock.h>
8 #include <intel_adsp_ipc.h>
9 #include <cavstool.h>
10 #include <stdint.h>
11 #include <zephyr/device.h>
12 #include <zephyr/ztest.h>
13 
14 /* Turn this define on to see register dumps after each step */
15 #define INTEL_ADSP_HDA_DBG 0
16 
17 #define CONCAT3(x, y, z) x ## y ## z
18 
19 #define STREAM_SET_BASE(stream_set) CONCAT3(HDA_, stream_set, _BASE)
20 #define STREAM_SET_NAME(stream_set) STRINGIFY(stream_set)
21 
22 #if INTEL_ADSP_HDA_DBG
23 #define hda_dump_regs(stream_set, regblock_size, stream_id, ...) \
24 	printk(__VA_ARGS__); printk(": ");        \
25 	intel_adsp_hda_dbg(STREAM_SET_NAME(stream_set), STREAM_SET_BASE(stream_set), \
26 		regblock_size, stream_id)
27 #else
28 #define hda_dump_regs(stream_set, regblock_size, stream_id, msg, ...) do {} while (0)
29 #endif
30 
hda_ipc_msg(const struct device * dev,uint32_t data,uint32_t ext,k_timeout_t timeout)31 static inline void hda_ipc_msg(const struct device *dev, uint32_t data,
32 			       uint32_t ext, k_timeout_t timeout)
33 {
34 	int ret = intel_adsp_ipc_send_message_sync(dev, data, ext, timeout);
35 
36 	zassert_true(!ret, "Unexpected ipc send message failure, error code: %d", ret);
37 }
38 
39 #endif /* ZEPHYR_TESTS_INTEL_ADSP_TESTS_H */
40