1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2021-2023 Digiteq Automotive 4 * author: Martin Tuma <martin.tuma@digiteqautomotive.com> 5 */ 6 7 #ifndef __MGB4_I2C_H__ 8 #define __MGB4_I2C_H__ 9 10 #include <linux/i2c.h> 11 12 struct mgb4_i2c_client { 13 struct i2c_client *client; 14 int addr_size; 15 }; 16 17 struct mgb4_i2c_kv { 18 u16 reg; 19 u8 mask; 20 u8 val; 21 }; 22 23 int mgb4_i2c_init(struct mgb4_i2c_client *client, struct i2c_adapter *adap, 24 struct i2c_board_info const *info, int addr_size); 25 void mgb4_i2c_free(struct mgb4_i2c_client *client); 26 27 s32 mgb4_i2c_read_byte(struct mgb4_i2c_client *client, u16 reg); 28 s32 mgb4_i2c_write_byte(struct mgb4_i2c_client *client, u16 reg, u8 val); 29 s32 mgb4_i2c_mask_byte(struct mgb4_i2c_client *client, u16 reg, u8 mask, 30 u8 val); 31 32 int mgb4_i2c_configure(struct mgb4_i2c_client *client, 33 const struct mgb4_i2c_kv *values, size_t count); 34 35 #endif 36