社区
Linux_Kernel
帖子详情
i2c/pca9539.c文件的新模式probe疑问
ydd19881005ydd
2010-10-15 02:40:11
linux内核是2.6.28的
新模式下client从哪里来的,我在网站上看到有人说是在i2c_register_info()函数调用过程中注册的,可是我仔细看了下i2c_register_info()函数,没有涉及到client额,还有新模式下pca9539_detect()函数主要完成些什么功能呢?
望大侠们指教一二,小弟不胜感激!
...全文
262
2
打赏
收藏
i2c/pca9539.c文件的新模式probe疑问
linux内核是2.6.28的 新模式下client从哪里来的,我在网站上看到有人说是在i2c_register_info()函数调用过程中注册的,可是我仔细看了下i2c_register_info()函数,没有涉及到client额,还有新模式下pca9539_detect()函数主要完成些什么功能呢? 望大侠们指教一二,小弟不胜感激!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
xxx8686
2010-11-02
打赏
举报
回复
http://www.embedu.org/Column/Column213.htm
看到现在我们应该会有这样的疑问,在Adapter模式中,i2c_client是我们自己构造出来的,而现在的i2c_client是从哪来的呢?看看下面的解释
● 注册i2c_board_info
对于Probe模式,通常在平台代码中要完成i2c_board_info的注册。方法如下:
static struct i2c_board_info __initdata test_i2c_devices[] = {
{
I2C_BOARD_INFO("pca9555", 0x27),//pca9555为芯片名称,0x27为芯片地址
.platform_data = &pca9555_data,
}, {
I2C_BOARD_INFO("mt9v022", 0x48),
.platform_data = &iclink[0], /* With extender */
}, {
I2C_BOARD_INFO("mt9m001", 0x5d),
.platform_data = &iclink[0], /* With extender */
},
};
i2c_register_board_info(0, test_i2c_devices,ARRAY_SIZE(test_i2c_devices)); //注册
i2c_client就是在注册过程中构建的。但有一点需要注意的是i2c_register_board_info并没有EXPORT_SYMBOL给模块使用。
我也在弄,还不是很清楚,这个也许对你有用。
充电宝111
2010-10-15
打赏
举报
回复
看i2c-core.c里面的内容
struct i2c_client *
i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
{
struct i2c_client *client;
int status;
client = kzalloc(sizeof *client, GFP_KERNEL);
if (!client)
return NULL;
client->adapter = adap;
client->dev.platform_data = info->platform_data;
if (info->archdata)
client->dev.archdata = *info->archdata;
client->flags = info->flags;
client->addr = info->addr;
client->irq = info->irq;
strlcpy(client->name, info->type, sizeof(client->name));
/* Check for address business */
status = i2c_check_addr(adap, client->addr);
if (status)
goto out_err;
client->dev.parent = &client->adapter->dev;
client->dev.bus = &i2c_bus_type;
client->dev.type = &i2c_client_type;
dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
client->addr);
status = device_register(&client->dev);
if (status)
goto out_err;
dev_dbg(&adap->dev, "client [%s] registered with bus id %s\n",
client->name, dev_name(&client->dev));
return client;
out_err:
dev_err(&adap->dev, "Failed to register i2c client %s at 0x%02x "
"(%d)\n", client->name, client->addr, status);
kfree(client);
return NULL;
}
上面注册到dev,这里面通过总线的probe找到自己的probe
static int i2c_device_probe(struct device *dev)
{
struct i2c_client *client = i2c_verify_client(dev);
struct i2c_driver *driver;
int status;
if (!client)
return 0;
driver = to_i2c_driver(dev->driver);
if (!driver->probe || !driver->id_table)
return -ENODEV;
client->driver = driver;
if (!device_can_wakeup(&client->dev))
device_init_wakeup(&client->dev,
client->flags & I2C_CLIENT_WAKE);
dev_dbg(dev, "probe\n");
status = driver->probe(client, i2c_match_id(driver->id_table, client));
if (status)
client->driver = NULL;
return status;
}
AT91RM9200的Linux下
I2C
总线驱动
主要是针对
PCA
9539
等
I2C
总线IO扩展芯片,在Linux下实现驱动
I2C
.tar.gz_
i2c
在linux2.6.22.6下运行的ARM9
I2C
总线
嵌入式系统/ARM技术中的实例解析linux内核
I2C
体系结构(2)
作者:刘洪涛,华清远见嵌入式学院讲师。 四、在内核里写
i2c
设备驱动的两种方式 前文介绍了利用/dev/
i2c
-0在应用层完成对
i2c
设备的操作,但很多时候我们还是习惯为
i2c
设备在内核层编写驱动程序。目前内核支持两种编写
i2c
驱动程序的方式。下面分别介绍这两种方式的实现。这里分别称这两种方式为“Adapter方式(LEGACY)”和“
Pro
be方式(new style)”。 (1) Adapter方式(LEGACY) (下面的实例代码是在2.6.27内核的
pca
953x.c基础上修改的,原始代码采用的是本文将要讨论的第2种方式,即
Pro
be方式) ● 构建
linux在内核下使用iic,实例解析linux内核
I2C
体系结构(2)
四、在内核里写
i2c
设备驱动的两种方式在(1) Adapter方式(LEGACY)(下面的实例代码是在2.6.27内核的
pca
953x.c基础上修改的,原始代码采用的是本文将要讨论的第2种方式,即
Pro
be方式)●构建
i2c
_driverstatic struct
i2c
_driver
pca
953x_driver = {.driver = {.name= "
pca
953x", //名称}...
Linux_Kernel
4,465
社区成员
17,462
社区内容
发帖
与我相关
我的任务
Linux_Kernel
Linux/Unix社区 内核源代码研究区
复制链接
扫一扫
分享
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章