int i2c_del_driver(struct i2c_driver *driver); inline int i2c_add_driver(struct i2c_driver *driver); 创建并注册一个新的I2C设备 struct i2c_client *i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info); I2C 传输、发送和接收 int i2c_transfer(struct i2c_adapter * ad...
I2C适配器驱动(I2C Adapter Driver):【芯片厂提供】I2C适配器驱动负责与硬件的I2C控制器进行交互,完成硬件层面的初始化、配置和操作。它将底层硬件的特定接口与I2C总线核心驱动进行连接,使得核心驱动能够通过适配器驱动来访问硬件。 I2C设备驱动(I2C Device Driver):【开发者编写】I2C设备驱动是针对特定类型的I2C设备编写...
为了更方便和有效地使用I2C设备,我们可以为一个具体的I2C设备开发特定的I2C设备驱动程序,在驱动中完成对特定的数据格式的解释以及实现一些专用的功能。 在chips目录下包含着各种device 的driver,完成各种从设备的注册。作为一般的I2C设备,使用i2c-dev.c里的操作足够完成操作了。 当然如果不能完成,则需要独立完成该驱动,...
struct i2c_driver{unsigned intclass;int(*attach_adapter)(struct i2c_adapter*)__deprecated;int(*probe)(struct i2c_client*,conststruct i2c_device_id*);int(*remove)(struct i2c_client*);void(*shutdown)(struct i2c_client*);void(*alert)(struct i2c_client*,enumi2c_alert_protocol protocol,unsigned...
根据前面的总线设备驱动的框架,有driver那么肯定会有device。这两者的匹配靠的是.id_table 对于gc0308,具体可以通过kernel/arch/mips/xburst/soc-x1000/chip-x1000/halley2/common/i2c_bus.c 可以看到向I2C总线注册的device的是gc0308 如果匹配上了,则调用driver的.probe函数。下面我们来看一下该函数具体做了什么...
int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); int (*remove)(struct i2c_client *client); /* New driver model interface to aid the seamless removal of the * current probe()'s, more commonly unused than used second parameter. ...
I2C设备驱动程序框架分为两个部分:driver和device。 分别将driver和device加载到内存中,i2c bus在程序加载时会自动调用match函数,根据名称来匹配driver和device,匹配完成时调用probe() 在driver中,定义probe()函数,在probe函数中创建设备节点,针对不同的设备实现不同的功能。
i2c_add_driver,和i2c_transfer函数 ---I2c-dev.c 通用的i2c设备驱动 ---Kconfig ---Makefile 开始在内核编译i2c-dev通用驱动 1)在linux-2.6.32.2/内核目录下make menuconfig,选择如下Device Drivers 2)进入Device Drivers目录,选择I2C Support,表示编译I2C驱动模块,会将i2c-core.c编译成模块文件i2c-core.ko 3...
struct device dev; /* 控制器设备 */ int nr; char name[48]; /* 控制器名称 */ struct completion dev_released; /* 用于同步 */ struct mutex userspace_clients_lock; struct list_head userspace_clients; }; 1. 2. 3. 4. 5. 6. ...
I2C驱动中的关键API解析如下:I2C Core相关API:i2c_new_device:用于创建一个新的I2C设备,并将其与指定的I2C适配器绑定。返回的是一个i2c_client指针,驱动可以直接使用这个指针与设备进行通信。i2c_device_match:检查设备与设备驱动程序之间是否存在匹配关系,通常在I2C子系统的设备驱动程序注册过程中使用...