之前 论坛中有大佬遇到过类似问题
求教
平台nuc970 问题是I2C bus 上面添加设备无效,希望大神来解决,跪谢
I2C 总线0 连接的是音频sgtl5000
往总线0上添加这个设备 arch/arm/mach-nuc970/dev.c
#if defined(CONFIG_I2C_BUS_NUC970_P0) || defined(CONFIG_I2C_BUS_NUC970_P0_MODULE)
// port 0
/* I2C clients */
static struct i2c_board_info __initdata nuc970_i2c_clients0[] =
{
{I2C_BOARD_INFO("sgtl5000", 0x0a),},
};
static struct resource nuc970_i2c0_resource[] = {
[0] = {
.start = NUC970_PA_I2C0,
.end = NUC970_PA_I2C0 + NUC970_SZ_I2C0 - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_I2C0,
.end = IRQ_I2C0,
.flags = IORESOURCE_IRQ,
}
};
static struct nuc970_platform_i2c nuc970_i2c0_data = {
.bus_num = 0,
.bus_freq = 100000,
};
struct platform_device nuc970_device_i2c0 = {
.name = "nuc970-i2c0",
.id = -1,
.num_resources = ARRAY_SIZE(nuc970_i2c0_resource),
.resource = nuc970_i2c0_resource,
.dev = {
.platform_data = &nuc970_i2c0_data,
}
};
#endif
注册client
#if defined(CONFIG_I2C_BUS_NUC970_P0) || defined(CONFIG_I2C_BUS_NUC970_P0_MODULE)
i2c_register_board_info(0, nuc970_i2c_clients0, sizeof(nuc970_i2c_clients0)/sizeof(struct i2c_board_info));
sgtl5000.c里的driver struct
static struct i2c_driver sgtl5000_i2c_driver = {
.driver = {
.name = "sgtl5000",
.owner = THIS_MODULE,
.of_match_table = sgtl5000_dt_ids,
},
.probe = sgtl5000_i2c_probe,
.remove = sgtl5000_i2c_remove,
.id_table = sgtl5000_id,
};
这里是i2c tools的测试结果
[root@mcuzone two]#./i2cdetect -y 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: [ 2515.410000] nuc970-i2c0 nuc970-i2c0: cannot get bus (
error -110)
|