然后再用i2c_register_board_info对其进行注册:
i2c_register_board_info(2, i2c_gpio_devices, ARRAY_SIZE(i2c_gpio_devices));
这样就完成了模拟步骤,可以直接用系统的I2C相关的注册等方法对设备进行注册和读写操作。
例子2
static struct i2c_gpio_platform_data ep93xx_i2c_data = {
.sda_pin = EP93XX_GPIO_LINE_EEDAT,
.sda_is_open_drain = 0,
.scl_pin = EP93XX_GPIO_LINE_EECLK,
.scl_is_open_drain = 0,
.udelay = 2,
};
static struct platform_device ep93xx_i2c_device = {
.name = "i2c-gpio",
.id = 0,
.dev.platform_data = &ep93xx_i2c_data,
};
void __init ep93xx_register_i2c(struct i2c_board_info *devices, int num)
{
i2c_register_board_info(0, devices, num);
platform_device_register(&ep93xx_i2c_device);
}