1 /*
2  * Copyright (c) 2023 NXP Semiconductors
3  * Copyright (c) 2023 Cognipilot Foundation
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 /*
9  * Bus-specific functionality for IST8310 accessed via I2C.
10  */
11 
12 #include "ist8310.h"
13 
ist8310_bus_check_i2c(const union ist8310_bus * bus)14 static int ist8310_bus_check_i2c(const union ist8310_bus *bus)
15 {
16 	return i2c_is_ready_dt(&bus->i2c) ? 0 : -ENODEV;
17 }
18 
ist8310_reg_read_i2c(const union ist8310_bus * bus,uint8_t start,uint8_t * buf,int size)19 static int ist8310_reg_read_i2c(const union ist8310_bus *bus, uint8_t start, uint8_t *buf, int size)
20 {
21 	return i2c_burst_read_dt(&bus->i2c, start, buf, size);
22 }
23 
ist8310_reg_write_i2c(const union ist8310_bus * bus,uint8_t reg,uint8_t val)24 static int ist8310_reg_write_i2c(const union ist8310_bus *bus, uint8_t reg, uint8_t val)
25 {
26 	return i2c_reg_write_byte_dt(&bus->i2c, reg, val);
27 }
28 
29 const struct ist8310_bus_io ist8310_bus_io_i2c = {
30 	.check = ist8310_bus_check_i2c,
31 	.read = ist8310_reg_read_i2c,
32 	.write = ist8310_reg_write_i2c,
33 };
34