ref: d1cebf608b05e45b148108ac6c16ae94f6862097
dir: /sys/src/9/port/i2c.h/
typedef struct I2Cbus I2Cbus; struct I2Cbus { char *name; int speed; void *ctlr; int (*init)(I2Cbus *bus); int (*io)(I2Cbus *bus, uchar *pkt, int olen, int ilen); int probed; QLock; }; typedef struct I2Cdev I2Cdev; struct I2Cdev { I2Cbus *bus; int a10; int addr; int subaddr; ulong size; }; /* * Register busses (controllers) and devices (addresses) */ extern void addi2cbus(I2Cbus *bus); extern void addi2cdev(I2Cdev *dev); /* * Look-up busses and devices by name and address */ extern I2Cbus* i2cbus(char *name); extern I2Cdev* i2cdev(I2Cbus *bus, int addr); /* * generic I/O */ extern int i2cbusio(I2Cbus *bus, uchar *pkt, int olen, int ilen); extern int i2crecv(I2Cdev *dev, void *data, int len, vlong addr); extern int i2csend(I2Cdev *dev, void *data, int len, vlong addr); /* * common I/O for SMbus */ extern int i2cquick(I2Cdev *dev, int rw); extern int i2crecvbyte(I2Cdev *dev); extern int i2csendbyte(I2Cdev *dev, uchar b); extern int i2creadbyte(I2Cdev *dev, ulong addr); extern int i2cwritebyte(I2Cdev *dev, ulong addr, uchar b); extern int i2creadword(I2Cdev *dev, ulong addr); extern int i2cwriteword(I2Cdev *dev, ulong addr, ushort w); extern vlong i2cread32(I2Cdev *dev, ulong addr); extern vlong i2cwrite32(I2Cdev *dev, ulong addr, ulong u);