去"class表示的这一类"I2C适配器,用"detect函数"来确定能否找到"address_list里的设备",
如果能找到就调用i2c_new_device来注册i2c_client, 这会和i2c_driver的id_table比较,
如果匹配,调用probe
i2c_add_driver
i2c_register_driver
a. at24cxx_driver放入i2c_bus_type的drv链表
并且从dev链表里取出能匹配的i2c_client并调用probe
driver_register
b. 对于每一个适配器,调用__process_new_driver
对于每一个适配器,调用它的函数确定address_list里的设备是否存在
如果存在,再调用detect进一步确定、设置,然后i2c_new_device
// Walk the adapters that are already present //
i2c_for_each_dev(driver, __process_new_driver);
__process_new_driver
i2c_do_add_adapter
// Detect supported devices on that bus, and instantiate them //
i2c_detect(adap, driver);
for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
err = i2c_detect_address(temp_client, driver);
// 判断这个设备是否存在:简单的发出S信号确定有ACK //
if (!i2c_default_probe(adapter, addr))
return 0;
memset(&info, 0, sizeof(struct i2c_board_info));
info.addr = addr;
// 设置info.type
err = driver->detect(temp_client, &info);
i2c_new_device
b. 驱动的写法
2. 完善设备驱动程序
3. 不自己写驱动直接访问
Device Drivers
I2C support
<*> I2C device interface
4. 编写"总线(适配器adapter)"驱动
Device Drivers
I2C support
I2C Hardware Bus support
< > S3C2410 I2C Driver
nfs 30000000 192.168.1.123:/work/nfs_root/uImage_noi2cbus; bootm 30000000