I2C chip Drivers

1 i2c_board_info数据结构的定义

 

static struct i2c_board_info __initdata stargate2_i2c_board_info[] = { /* Techically this a pca9500 - but it's compatible with the 8574 * for gpio expansion and the 24c02 for eeprom access. */ { .type = "pcf8574", .addr = 0x27, .platform_data = &platform_data_pcf857x, }, { .type = "24c02", .addr = 0x57, .platform_data = &pca9500_eeprom_pdata, }, { .type = "max1238", .addr = 0x35, }, { /* ITS400 Sensor board only */ .type = "max1363", .addr = 0x34, /* Through a nand gate - Also beware, on V2 sensor board the * pull up resistors are missing. */ .irq = IRQ_GPIO(99), }, { /* ITS400 Sensor board only */ .type = "tsl2561", .addr = 0x49, /* Through a nand gate - Also beware, on V2 sensor board the * pull up resistors are missing. */ .irq = IRQ_GPIO(99), }, { /* ITS400 Sensor board only */ .type = "tmp175", .addr = 0x4A, .irq = IRQ_GPIO(96), }, }; static struct i2c_board_info __initdata stargate2_pwr_i2c_board_info[] = { { .type = "da9030", .addr = 0x49, .platform_data = &stargate2_da9030_pdata, .irq = gpio_to_irq(1), }, };

 

Note:Pay attetion on the value of the addr member.(addr=chip_address>>1)

2 I2C 器件注册到I2C Bus

 i2c_register_board_info(0, ARRAY_AND_SIZE(stargate2_i2c_board_info));
 i2c_register_board_info(1,
    ARRAY_AND_SIZE(stargate2_pwr_i2c_board_info));

Note: The first parameter is the I2C Bus ID.

Author: WoodPecker <[email protected]>

你可能感兴趣的:(数据结构,c,struct,UP)