九鼎创展论坛
标题: /sys/bus/i2c/devices下的内容与i2c_board_info结构体 [打印本页]
作者: armeasy 时间: 2012-9-28 17:56
标题: /sys/bus/i2c/devices下的内容与i2c_board_info结构体
在目录/sys/bus/i2c/devices下能发现系统中的I2C设备,如下:
[cpp] view plaincopy
- # ls
- 0-0034
- 0-0030
- 0-0011
- 0-0058
这些设备就是系统中存在的设备。
这些设备是怎么来的?
在你对应的machine配置里会执行“i2c_register_board_info”一个函数,它会将一个i2c_board_info的结构体注册进系统,
这个i2c_board_info的结构体里就描述了板载的所有I2C设备信息,如下例:
[c-sharp] view plaincopy
- static struct i2c_board_info littleton_i2c_board_info[] = {
- #if defined(CONFIG_PXA3xx_MICCO) || defined(CONFIG_PXA3xx_MICCO_MODULE)
- {
- .type = "micco",
- .addr = 0x34,
- .platform_data = &micco_data,
- .irq = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO18)),
- },
- #endif
- #if defined(CONFIG_GPIO_MAX7320) || defined(CONFIG_GPIO_MAX7320_MODULE)
- {
- .type = "max7320",
- .addr = 0x50,
- .platform_data = &exp0_pdata,
- },
- #endif
- #if defined(CONFIG_GPIO_MAX7321) || defined(CONFIG_GPIO_MAX7321_MODULE)
- {
- /* on 8385 WLAN Board */
- .type = "max7321",
- .addr = 0x60,
- .platform_data = &exp1_pdata[BOARD_8385_WLAN],
- },
- {
- /* on UMTS Board */
- .type = "max7321",
- .addr = 0x61,
- .platform_data = &exp1_pdata[BOARD_UMTS],
- },
- {
- /* on Siemens Baseband Radio Interposer Board */
- .type = "max7321",
- .addr = 0x62,
- .platform_data = &exp1_pdata[BOARD_SIEMENS_BASEBAND],
- },
- {
- /* on 8688 WLAN/Camera Board */
- .type = "max7321",
- .addr = 0x63,
- .platform_data = &exp1_pdata[BOARD_8688_WLAN_CAMERA],
- },
- {
- /* on Camera Board */
- .type = "max7321",
- .addr = 0x64,
- .platform_data = &exp1_pdata[BOARD_CAMERA],
- },
- {
- /* on 8686 WLAN/Camera Board */
- .type = "max7321",
- .addr = 0x66,
- .platform_data = &exp1_pdata[BOARD_8386_WLAN_CAMERA],
- },
- {
- /* on 8385 WLAN/Camera Board */
- .type = "max7321",
- .addr = 0x6c,
- .platform_data = &exp1_pdata[BOARD_8385_WLAN_CAMERA],
- },
- {
- /* on 8688 WLAN Board */
- .type = "max7321",
- .addr = 0x6d,
- .platform_data = &exp1_pdata[BOARD_8688_WLAN],
- .irq = IRQ_GPIO(mfp_to_gpio(MFP_PIN_GPIO77)),
- },
- #endif
- #if defined(CONFIG_PXA_CAMERA)
- {
- .type = "sensor_ov7673",
- .addr = 0x21,
- .platform_data = &ov7673_sensor_data,
- },
- {
- .type = "sensor_ov5623",
- .addr = 0x30,
- .platform_data = &ov5623_sensor_data,
- },
- #endif
- };
可以发现,在目录/sys/bus/i2c/devices下的设备就是这个i2c_board_info结构体里所描述的I2C设备,
而/sys/bus/i2c/devices下的设备名字就是根据i2c_board_info结构体中定义的I2C Address来命名的。
所以添加一个I2C设备时,除了需要编写这个I2C设备的驱动之外,还需要在machine里面加入I2C设备的i2c_board_info内容。
欢迎光临 九鼎创展论坛 (http://bbs.9tripod.com/) |
Powered by Discuz! X3.2 |