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