主题 : tiny210中 iic-at24cxx 是如何编进内核的,求解 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 100558
精华: 0
发帖: 10
金钱: 55 两
威望: 11 点
综合积分: 20 分
注册时间: 2014-02-15
最后登录: 2014-07-31
楼主  发表于: 2014-05-05 16:52

 tiny210中 iic-at24cxx 是如何编进内核的,求解

就是友善的at24cxx这个驱动怎么编进内核的, 设备节点在哪的?
i2c-s3c2410.c 应该是关于适配器的文件,那么iic设备at24cxx对应的应该是at24.c文件是吗,config中at24.c是没有被编进内核的啊???
但是测试程序却可以测试eeprom,求大神能够解答下
非常感谢!!!
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2014-05-05 18:40

 回 楼主(liuchaoneo) 的帖子

友善之臂的测试程序用的是I2C dev接口,也就是通过连接AT24的I2C controller驱动接口,去控制EEPROM的。参考eeprog.c中的相关部分代码:

复制代码
  1. int main(int argc, char** argv)
  2. {
  3.     struct eeprom e;
  4.     int op;
  5.     op = 0;
  6.     usage_if(argc != 2 || argv[1][0] != '-' || argv[1][2] != '\0');
  7.     op = argv[1][1];
  8.     fprintf(stderr, "Open /dev/i2c/0 with 8bit mode\n");
  9.     die_if(eeprom_open("/dev/i2c/0", 0x50, EEPROM_TYPE_8BIT_ADDR, &e) < 0,
  10.             "unable to open eeprom device file "
  11.             "(check that the file exists and that it's readable)");


关于I2C dev接口的更多信息,参考内核源代码目录下的Documentation/i2c/dev-interface
"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: 100558
精华: 0
发帖: 10
金钱: 55 两
威望: 11 点
综合积分: 20 分
注册时间: 2014-02-15
最后登录: 2014-07-31
2楼  发表于: 2014-05-05 19:54

 回 1楼(kasim) 的帖子

嗯,好的,谢谢版主,刚看到了代码,还有点小疑问:
在i2cdev_attach_adapter 注册设备节点:
                 /* register this i2c device with the driver core */
    i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
                     MKDEV(I2C_MAJOR, adap->nr), NULL,
                     "i2c-%d", adap->nr);

设备节点为什么是/dev/i2c/0   而不是 /dev/i2c-0 呢????
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
3楼  发表于: 2014-05-05 21:13
/dev/i2c/0应该是指向/dev/i2c-0的符号链接,在qtopia根文件系统的/etc/mdev.conf里有:

复制代码
  1. # i2c devices
  2. i2c-0        0:0    0666    =i2c/0
  3. i2c-1        0:0    0666    =i2c/1
"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: 100558
精华: 0
发帖: 10
金钱: 55 两
威望: 11 点
综合积分: 20 分
注册时间: 2014-02-15
最后登录: 2014-07-31
4楼  发表于: 2014-05-06 08:49

 回 3楼(kasim) 的帖子

非常感谢!