summaryrefslogtreecommitdiffstats
path: root/drivers/fsi/fsi-master-i2cr.h
blob: 96636bf28cacebcd22a05d9b9afadc8a13e406c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* SPDX-License-Identifier: GPL-2.0-only */
/* Copyright (C) IBM Corporation 2023 */

#ifndef DRIVERS_FSI_MASTER_I2CR_H
#define DRIVERS_FSI_MASTER_I2CR_H

#include <linux/i2c.h>
#include <linux/mutex.h>

#include "fsi-master.h"

struct i2c_client;

struct fsi_master_i2cr {
	struct fsi_master master;
	struct mutex lock;	/* protect HW access */
	struct i2c_client *client;
};

#define to_fsi_master_i2cr(m)	container_of(m, struct fsi_master_i2cr, master)

int fsi_master_i2cr_read(struct fsi_master_i2cr *i2cr, u32 addr, u64 *data);
int fsi_master_i2cr_write(struct fsi_master_i2cr *i2cr, u32 addr, u64 data);

static inline bool is_fsi_master_i2cr(struct fsi_master *master)
{
	if (master->dev.parent && master->dev.parent->type == &i2c_client_type)
		return true;

	return false;
}

#endif /* DRIVERS_FSI_MASTER_I2CR_H */