fsi-master-i2cr.h 824 B

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