1 /*
2  * Copyright 2023 Google LLC
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_
8 #define ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_
9 
10 #include <zephyr/device.h>
11 #include <zephyr/devicetree.h>
12 
13 /*
14  * Needed for emulators without corresponding DEVICE_DT_DEFINE drivers
15  */
16 
17 struct emul_stub_dev_data {
18 	/* Stub */
19 };
20 struct emul_stub_dev_config {
21 	/* Stub */
22 };
23 struct emul_stub_dev_api {
24 	/* Stub */
25 };
26 
27 /* For every instance of a DT_DRV_COMPAT stub out a device for that instance */
28 #define EMUL_STUB_DEVICE(n)                                                                        \
29 	__maybe_unused static int emul_init_stub_##n(const struct device *dev)                     \
30 	{                                                                                          \
31 		ARG_UNUSED(dev);                                                                   \
32 		return 0;                                                                          \
33 	}                                                                                          \
34                                                                                                    \
35 	static struct emul_stub_dev_data stub_data_##n;                                            \
36 	static struct emul_stub_dev_config stub_config_##n;                                        \
37 	static struct emul_stub_dev_api stub_api_##n;                                              \
38 	DEVICE_DT_INST_DEFINE(n, &emul_init_stub_##n, NULL, &stub_data_##n, &stub_config_##n,      \
39 			      POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &stub_api_##n);
40 
41 #endif /* ZEPHYR_INCLUDE_EMUL_STUB_DEVICE_H_ */
42