• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_I2C_BUS_H__
3 #define __NVKM_I2C_BUS_H__
4 #include "pad.h"
5 
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);
13 };
14 
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 *);
22 
23 int nvkm_i2c_bit_xfer(struct nvkm_i2c_bus *, struct i2c_msg *, int);
24 
25 int nv04_i2c_bus_new(struct nvkm_i2c_pad *, int, u8, u8,
26 		     struct nvkm_i2c_bus **);
27 
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 **);
31 
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);   \
35 } while(0)
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)
39 #endif
40