1 /*
2  * Copyright (c) 2021, Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /*
8  * This is not a real I2C driver. It is used to instantiate struct
9  * devices for the "vnd,i2c" devicetree compatible used in test code.
10  */
11 
12 #include <zephyr.h>
13 #include <drivers/i2c.h>
14 
15 #define DT_DRV_COMPAT vnd_i2c
16 
vnd_i2c_configure(const struct device * dev,uint32_t dev_config)17 static int vnd_i2c_configure(const struct device *dev,
18 			     uint32_t dev_config)
19 {
20 	return -ENOTSUP;
21 }
22 
vnd_i2c_transfer(const struct device * dev,struct i2c_msg * msgs,uint8_t num_msgs,uint16_t addr)23 static int vnd_i2c_transfer(const struct device *dev,
24 			    struct i2c_msg *msgs,
25 			    uint8_t num_msgs, uint16_t addr)
26 {
27 	return -ENOTSUP;
28 }
29 
30 static const struct i2c_driver_api vnd_i2c_api = {
31 	.configure = vnd_i2c_configure,
32 	.transfer  = vnd_i2c_transfer,
33 };
34 
vnd_i2c_init(const struct device * dev)35 static int vnd_i2c_init(const struct device *dev)
36 {
37 	return 0;
38 }
39 
40 #define VND_I2C_INIT(n)						\
41 	DEVICE_DT_INST_DEFINE(n, &vnd_i2c_init, NULL,			\
42 			      NULL, NULL, POST_KERNEL,			\
43 			      CONFIG_KERNEL_INIT_PRIORITY_DEVICE,	\
44 			      &vnd_i2c_api);
45 
46 DT_INST_FOREACH_STATUS_OKAY(VND_I2C_INIT)
47