Linux I2C 主机设备驱动分为两部分:
- I2C总线控制器驱动:SOC的I2C控制器外设驱动
- I2C设备驱动:基于I2C总线控制器驱动编写,针对具体的I2C从机设备
一、I2C总线控制器驱动
基于platform平台驱动框架,Linux内核将SOC的I2C外设抽象为i2c_adapter结构体。
1. i2c_adapter结构
i2c_adapter结构体定义在 include/linux/i2c.h
文件中,如下:
/*
* i2c_adapter is the structure used to identify a physical i2c bus along
* with the access algorithms necessary to access it.
*/
struct i2c_adapter {
struct