请教一下关于sensor问题。
板子是DM368,用到的sensor是MT9P031,I2C电平转换用的PCA9306,平台是DVSDK4.02。
问题:PCA9306是没有器件地址的,PCA9543是有器件地址的,现在用PCA9306来替换PCA9543,是不是只需要在DVSDK里屏蔽PCA9543就可以了。
Eason Wang:
如你所述的情况,应该是可以这么做
Kai Li2:
回复 Eason Wang:
多谢Eason的回答。
下面应该是I2C设备信息,那sensor是不是也要在这添加
static struct i2c_board_info i2c_info[] = {
{ I2C_BOARD_INFO("dm365evm_keys", 0x25), },
{ I2C_BOARD_INFO("24c256", 0x50), .platform_data = &eeprom_info, },
{ I2C_BOARD_INFO("tlv320aic3x", 0x18), },
{ I2C_BOARD_INFO("ths7303", 0x2c), },
{ I2C_BOARD_INFO("PCA9543A", 0x73), },
};
因为这里有注册
static void __init evm_init_i2c(void)
{ davinci_init_i2c(&i2c_pdata);
//if (have_imager())
//i2c_add_driver(&pca9543a_driver);
i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));
}
但是为什么有些I2C设备又没添加在static struct i2c_board_info i2c_info[],比如TVP5146
tvp5146首先是这样的
static struct tvp514x_platform_data tvp5146_pdata =
{ .clk_polarity = 0, .hs_polarity = 1, .vs_polarity = 1 };
然后在static struct vpfe_subdev_info vpfe_sub_devs[] 中会这样,
.board_info = { I2C_BOARD_INFO("tvp5146", 0x5d), .platform_data = &tvp5146_pdata,},
这两者是不是都可以注册I2C设备
Kai Li2:
回复 Eason Wang:
此外,原本的PCA9543A的处理是这样的,
static struct i2c_client *pca9543a;
static int pca9543a_probe(struct i2c_client *client, const struct i2c_device_id *id) { printk("pca9543a_probe\n"); pca9543a = client; return 0; }
static int pca9543a_remove(struct i2c_client *client) { pca9543a = NULL; return 0; }
static const struct i2c_device_id pca9543a_ids[] = { { "PCA9543A", 0, }, { /* end of list */ }, };
/* This is for i2c driver for the MT9P031 header i2c switch */ static struct i2c_driver pca9543a_driver = { .driver.name = "PCA9543A", .id_table = pca9543a_ids, .probe = pca9543a_probe, .remove = pca9543a_remove, };
static int dm365evm_enable_pca9543a(int en) { static char val = 1; int status; struct i2c_msg msg = { .flags = 0, .len = 1, .buf = &val, };
printk("dm365evm_enable_pca9543a\n"); if (!en) val = 0;
if (!pca9543a) return -ENXIO;
msg.addr = pca9543a->addr; /* turn i2c switch, pca9543a, on/off */ status = i2c_transfer(pca9543a->adapter, &msg, 1); printk("dm365evm_enable_pca9543a, status = %d\n", status); return status; return 0; }
static int dm365evm_setup_video_input(enum vpfe_subdev_id id)中
case VPFE_SUBDEV_MT9P031: mux |= CPLD_VIDEO_INPUT_MUX_IMAGER; resets |= BIT(0); /* Put TVP5146 in reset */ label = "HD imager";
dm365evm_reset_imager(1); /* Switch on pca9543a i2c switch */ if (have_imager()) dm365evm_enable_pca9543a(1); break;
static void __init evm_init_i2c(void)
{ davinci_init_i2c(&i2c_pdata); if (have_imager()) i2c_add_driver(&pca9543a_driver); i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info)); }