1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* Copyright (C) IBM Corporation 2023 */ 3 4#ifndef DRIVERS_FSI_MASTER_I2CR_H 5#define DRIVERS_FSI_MASTER_I2CR_H 6 7#include <linux/i2c.h> 8#include <linux/mutex.h> 9 10#include "fsi-master.h" 11 12struct i2c_client; 13 14struct fsi_master_i2cr { 15 struct fsi_master master; 16 struct mutex lock; /* protect HW access */ 17 struct i2c_client *client; 18}; 19 20#define to_fsi_master_i2cr(m) container_of(m, struct fsi_master_i2cr, master) 21 22int fsi_master_i2cr_read(struct fsi_master_i2cr *i2cr, u32 addr, u64 *data); 23int fsi_master_i2cr_write(struct fsi_master_i2cr *i2cr, u32 addr, u64 data); 24 25static inline bool is_fsi_master_i2cr(struct fsi_master *master) 26{ 27 if (master->dev.parent && master->dev.parent->type == &i2c_client_type) 28 return true; 29 30 return false; 31} 32 33#endif /* DRIVERS_FSI_MASTER_I2CR_H */ 34