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/kernel.h>
13 #include <zephyr/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 
35 #define VND_I2C_INIT(n)							       \
36 	I2C_DEVICE_DT_INST_DEFINE(n, NULL, NULL, NULL, NULL, POST_KERNEL,      \
37 				  CONFIG_I2C_INIT_PRIORITY, &vnd_i2c_api);
38 
39 DT_INST_FOREACH_STATUS_OKAY(VND_I2C_INIT)
40