| 
 
| 平台是nuc972,现在的问题是I2c bus 上面添加设备无效,卡了好几天,希望大神来解决,跪谢。 
 I2C 总线1  连接的是 音频设备NAU8822
 
 现在8822的驱动是ok的,要在I2C bus 1上添加这个设备,添加方法如下,在这个文件里面添加Dev.c (arch\arm\mach-nuc970)
 
 #ifdef CONFIG_I2C_BUS_NUC970_P1
 //port 1
 /* I2C clients */ 下面这个结构体是新建的,并且nau8822 名称和 8822 driver 里面是对应的,设备ID 也是正确的
 static struct i2c_board_info __initdata nuc970_i2c_clients1[] =
 {
 #ifdef CONFIG_SND_SOC_NAU8822
 {I2C_BOARD_INFO("nau8822", 0x1a),},
 #endif
 };,
 
 
 static struct nuc970_platform_i2c nuc970_i2c1_data = {
 .bus_num = 1,
 .bus_freq = 100000,
 };
 
 static struct resource nuc970_i2c_p1_resource[] = {
 [0] = {
 .start = NUC970_PA_I2C1,
 .end   = NUC970_PA_I2C1+ NUC970_SZ_I2C1 - 1,
 .flags = IORESOURCE_MEM,
 },
 [1] = {
 .start = IRQ_I2C1,
 .end   = IRQ_I2C1,
 .flags = IORESOURCE_IRQ,
 }
 
 };
 
 struct platform_device nuc970_device_i2c1 = {
 .name                  = "nuc970-i2c1",
 .id                  = -1,
 .num_resources          = ARRAY_SIZE(nuc970_i2c_p1_resource),
 .resource          = nuc970_i2c_p1_resource,
 .dev = {
 .platform_data = &nuc970_i2c1_data,
 }
 };
 #endif
 
 复制代码
 
 下面是注册那个client
 // 注册的第一个参数 是 Busnum,也是对的
 
 #ifdef CONFIG_I2C_BUS_NUC970_P1
 i2c_register_board_info(1, nuc970_i2c_clients1, sizeof(nuc970_i2c_clients1)/sizeof(struct i2c_board_info));
 #endif
 
 复制代码
 
 8822driver  nau8822.c 里面的driver struct
 
 
 static struct i2c_driver nau8822_i2c_driver = {
 .driver = {
 .name = "nau8822",
 .owner = THIS_MODULE,
 },
 .probe =    nau8822_i2c_probe,
 .remove =   nau8822_i2c_remove,
 .id_table = nau8822_i2c_id,
 };
 
 
 
 这是i2c tools的测试结果
 
 /mnt/i2c # ./i2cdetect -l
 i2c-0   i2c             nuc970-i2c0                             I2C adapter
 i2c-1   i2c             nuc970-i2c1                             I2C adapter
 /mnt/i2c # ./i2cdetect -y 0
 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 00:          -- -- -- -- -- -- -- -- -- -- -- -- --
 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 30: -- -- -- -- -- -- -- -- -- -- -- -- -- 3d -- --
 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 70: -- -- -- -- -- -- -- --
 /mnt/i2c # ./i2cdetect -y 1
 0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 00:          nuc970-i2c1 nuc970-i2c1: cannot get bus (error -110)
 
 | 
 |