一:Linux I2C驱动框架
Linux内核将I2C驱动分为两部分:
(1)I2C总线驱动,I2C总线驱动就是SOC的I2C控制器驱动,也叫做I2C适配器驱动
(2)I2C设备驱动,I2C设备驱动就是针对具体的I2C设备而编写的驱动。
作为SOC开发者来讲无需关心i2c总线驱动,只需关注i2c设备驱动即可。
1、I2C总线驱动
I2C设备与platform设备不同的是,I2C拥有自己的总线即I2C总线而不需要虚拟出一条来。I2C总线驱动重点是I2C适配器(SOC的I2C接口控制器)驱动,其中有两个重要的数据结构:i2c_adapter和i2c_algorithm,Linux内核将I2C适配器抽象成i2c_adapter结构体:
include/linux/i2c.h
struct i2c_adapter {
struct module *owner;
unsigned int class; /* classes to allow probing for */
const struct i2c_algorithm *algo; /* the algorithm to access the bus */
void *algo_data;
/* data fields that are valid f