在/Hi3516A_SDK_V1.0.6.0/osdrv/tools/board/reg-tools-1.0.0/source/tools/i2c_ops.c里有i2c_read的实现
在ret = read(fd, recvbuf, reg_width); 里实现了读取寄存器值
追一下这个过程
之前用了ret = ioctl(fd, I2C_16BIT_REG, 1);所以肯定和ioctl在一个文件,在/driver/i2c/i2c-dev.c里i2cdev_read
调用了ret = i2c_master_recv(client, tmp, count);
接着调用了ret = i2c_master_recv(client, tmp, count);
然后调用了
ret = adap->algo->master_xfer(adap, msgs, num);
这个master_xfer在i2c-hisilicon.c
static const struct i2c_algorithm hi_i2c_algo = {
.master_xfer = hi_i2c_xfer,
.functionality = hi_i2c_func,
};
然后static int hi_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num)
{
struct hi_i2c *pinfo;
int errorcode;
pinfo = (struct hi_i2c *)i2c_get_adapdata(adap);
pinfo->msgs = msgs;
pinfo->msg_num = num;
pinfo->msg_index = 0;
if (msgs->flags & I2C_M_RD)
errorcode = hi_i2c_read(pinfo);
else
errorcode = hi_i2c_write(pinfo);
return errorcode;
}最后就是调了这两个read和write函数