698 /* I2C based DS2460 on I2C1 */
699 // i2c_register_board_info(0, smartarm3250_i2c_ds2460_info,
700 // ARRAY_SIZE(smartarm3250_i2c_ds2460_info));
这是行不通的。
只能来硬的,直接在i2c驱动中增加i2c器件的绑定:
drivers/i2c/busses/i2c-pnx.c
656 if (pdev->id == 1) { //I2C2
657 struct i2c_board_info info = {
658 I2C_BOARD_INFO("pcf8563", 0xa3 >> 1),
659 };
660 client = i2c_new_device(i2c_pnx->adapter, &info);
661
662 if (client == NULL) {
663 printk("check pcf8563 failed \n");
664 }
665 }
666
667 if (pdev->id == 0) { //I2C1
668 struct i2c_board_info info2 = {
669 I2C_BOARD_INFO("ds2460", 0x80 >> 1),
670 };
671 client = i2c_new_device(i2c_pnx->adapter, &info2);
672
673 if (client == NULL) {
674 printk("check ds2460 failed \n");
675 }
676 }
注意,这里的I2C_BOARD_INFO中的名称一定要与ds2460.c的id表中的一致,否则无法注册。
另外,郁闷的事情还在后面,读取EEPROM的时候,使用了i2c_transfer函数,结果老是读取出错,然而这个读取函数在OMAP3530上是没有任何问题的,代码如下:
25 int read_from_ds2460(unsigned char *kbuf, int start_addr, int len)
26 {
27 unsigned char tempbuf[8] = {start_addr};
28 int i;
29 int ret = 0;
30
31 // printk("###ABING in %s %d\n", __FUNCTION__, __LINE__);
32 #if 0
33 struct i2c_msg msgs[] = {
34 { ds2460_client->addr, 0, 1, tempbuf }, /* setup read ptr -- start_addr */
35 { ds2460_client->addr, I2C_M_RD, len, kbuf }, /* read from ds2460 */
36 };
37
38 if (kbuf == NULL) {
39 printk("a NULL pointer found!\n");
40 return -ENOSYS;
41 }
42
43 return i2c_transfer(ds2460_client->adapter, msgs, 2);
44 #else
45
46 ret = i2c_master_send(ds2460_client, tempbuf, 1);
47 if (ret < 0) {
48 printk("I2C err: %s, %d send data to i2c bus failed \n", __FUNCTION__,__LINE__);
49 return ret;
50 }
51
52 ret = i2c_master_recv(ds2460_client, kbuf, len);
53 if (ret < 0) {
54 printk("I2C err: %s, %d get i2c bus data failed \n", __FUNCTION__,__LINE__);
55 return ret;
56 }
57
58 return 0;
59 #endif
60 }
改为i2c_master_send和i2c_master_recv就没有问题了。