主题 : 请教I2C驱动 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 2177
精华: 0
发帖: 70
金钱: 620 两
威望: 463 点
综合积分: 140 分
注册时间: 2008-10-30
最后登录: 2015-01-12
楼主  发表于: 2009-09-02 10:21

 请教I2C驱动

想请教大家一个问题,关于linux下i2c驱动的,我基于开发板引出的i2c接口,通过两块pcf8574芯片进行io口的扩展。在linux内核里面,已经提供了pcf8574芯片的驱动,我将其编译进内核。但是,编入内核后,我不知道内核在什么地方为其创建了节点,用户应用程序应该如何才能读取和写入来对pcf8574进行控制。这方便的内容我断断续续的看了好长一段时间,一直没有搞明白,希望各位能指点指点,谢谢了。
-
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-09-02 11:19
我想对于你要的情况,是由I2C device interface(CONFIG_I2C_CHARDEV=y)负责为S3C2440A的I2C Adapter创建节点i2c-x (x=0,1,2...),由应用程序通过Ioctl和其他文件系统接口设定I2C Slave(比如PCF8574)的地址并且读写芯片里的寄存器,就像友善之臂提供的操作I2C接口EEPROM测试程序做的一样。需要注意的是,这种情况下,似乎并不需要I2C Slave本身的驱动,I2C device interface就是一个通用的I2C Slave驱动。
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
2楼  发表于: 2009-09-02 11:21
I2C device interface的源代码在drivers\i2c\i2c-dev.c
内核对它的描述是

config I2C_CHARDEV
    tristate "I2C device interface"
    help
      Say Y here to use i2c-* device files, usually found in the /dev
      directory on your system.  They make it possible to have user-space
      programs use the I2C bus.  Information on how to do this is
      contained in the file <file:Documentation/i2c/dev-interface>.

      This support is also available as a module.  If so, the module
      will be called i2c-dev.
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 2177
精华: 0
发帖: 70
金钱: 620 两
威望: 463 点
综合积分: 140 分
注册时间: 2008-10-30
最后登录: 2015-01-12
3楼  发表于: 2009-09-02 20:02
谢谢版主的回复,虽然我现在还是不太明白版主的意思,不过我会先认真看版主提到的上述文件,有不懂的再向版主请教。
-