1 /*
2 * Copyright (c) 2024 Ambiq Micro Inc. <www.ambiq.com>
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6 #include <zephyr/device.h>
7 #include <zephyr/devicetree.h>
8 #include <zephyr/drivers/emul.h>
9 #include <zephyr/drivers/mspi.h>
10 #include <zephyr/drivers/mspi_emul.h>
11 #define DT_DRV_COMPAT zephyr_mspi_emul_device
12
13 /* Stub out a mspi device struct to use mspi_device emulator. */
emul_mspi_device_init_stub(const struct device * dev)14 static int emul_mspi_device_init_stub(const struct device *dev)
15 {
16 ARG_UNUSED(dev);
17
18 return 0;
19 }
20
emul_mspi_init_stub(const struct emul * stub_emul,const struct device * bus)21 static int emul_mspi_init_stub(const struct emul *stub_emul, const struct device *bus)
22 {
23 ARG_UNUSED(stub_emul);
24 ARG_UNUSED(bus);
25
26 return 0;
27 }
28
29 struct emul_mspi_device_stub_dev_data {
30 /* Stub */
31 };
32 struct emul_mspi_device_stub_dev_config {
33 /* Stub */
34 };
35 struct emul_mspi_device_stub_dev_api {
36 /* Stub */
37 };
38
39 #define EMUL_MSPI_DEVICE_DEVICE_STUB(n) \
40 static struct emul_mspi_device_stub_dev_data stub_device_data_##n; \
41 static struct emul_mspi_device_stub_dev_config stub_device_config_##n; \
42 static struct emul_mspi_device_stub_dev_api stub_device_api_##n; \
43 DEVICE_DT_INST_DEFINE(n, \
44 emul_mspi_device_init_stub, \
45 NULL, \
46 &stub_device_data_##n, \
47 &stub_device_config_##n, \
48 POST_KERNEL, \
49 CONFIG_MSPI_INIT_PRIORITY, \
50 &stub_device_api_##n);
51
52 #define EMUL_TEST(n) \
53 EMUL_DT_INST_DEFINE(n, \
54 emul_mspi_init_stub, \
55 NULL, \
56 NULL, \
57 NULL, \
58 NULL);
59
60 DT_INST_FOREACH_STATUS_OKAY(EMUL_TEST)
61
62 DT_INST_FOREACH_STATUS_OKAY(EMUL_MSPI_DEVICE_DEVICE_STUB)
63