1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_I2C_BUS_H__
3 #define __NVKM_I2C_BUS_H__
6 struct nvkm_i2c_bus_func
{
7 void (*init
)(struct nvkm_i2c_bus
*);
8 void (*drive_scl
)(struct nvkm_i2c_bus
*, int state
);
9 void (*drive_sda
)(struct nvkm_i2c_bus
*, int state
);
10 int (*sense_scl
)(struct nvkm_i2c_bus
*);
11 int (*sense_sda
)(struct nvkm_i2c_bus
*);
12 int (*xfer
)(struct nvkm_i2c_bus
*, struct i2c_msg
*, int num
);
15 int nvkm_i2c_bus_ctor(const struct nvkm_i2c_bus_func
*, struct nvkm_i2c_pad
*,
16 int id
, struct nvkm_i2c_bus
*);
17 int nvkm_i2c_bus_new_(const struct nvkm_i2c_bus_func
*, struct nvkm_i2c_pad
*,
18 int id
, struct nvkm_i2c_bus
**);
19 void nvkm_i2c_bus_del(struct nvkm_i2c_bus
**);
20 void nvkm_i2c_bus_init(struct nvkm_i2c_bus
*);
21 void nvkm_i2c_bus_fini(struct nvkm_i2c_bus
*);
23 int nvkm_i2c_bit_xfer(struct nvkm_i2c_bus
*, struct i2c_msg
*, int);
25 int nv04_i2c_bus_new(struct nvkm_i2c_pad
*, int, u8
, u8
,
26 struct nvkm_i2c_bus
**);
28 int nv4e_i2c_bus_new(struct nvkm_i2c_pad
*, int, u8
, struct nvkm_i2c_bus
**);
29 int nv50_i2c_bus_new(struct nvkm_i2c_pad
*, int, u8
, struct nvkm_i2c_bus
**);
30 int gf119_i2c_bus_new(struct nvkm_i2c_pad
*, int, u8
, struct nvkm_i2c_bus
**);
32 #define BUS_MSG(b,l,f,a...) do { \
33 struct nvkm_i2c_bus *_bus = (b); \
34 nvkm_##l(&_bus->pad->i2c->subdev, "bus %04x: "f"\n", _bus->id, ##a); \
36 #define BUS_ERR(b,f,a...) BUS_MSG((b), error, f, ##a)
37 #define BUS_DBG(b,f,a...) BUS_MSG((b), debug, f, ##a)
38 #define BUS_TRACE(b,f,a...) BUS_MSG((b), trace, f, ##a)