日期:2014-05-16 浏览次数:20954 次
现在做的是RK平台的I2C驱动,不是说linux每个外设对应一个设备文件吗?可是找了一下一直没找到,今天特别搞了一下。I2C设备是注册为platform平台驱动的。
下面是我用adb命令查看的
linux的设备文件不一定只在dev/这个目录下面,像sys/ 目录下面也会有一些设备文件的
MID下面的I2C设备的设备文件
1|root@android:/ # ls sys/bus/i2c/drivers/ RK610_CODEC/ gc0308/ ir-kbd-i2c/ sensors/ tps65910/ act8846/ gc0328/ nt99340/ sp0838/ wm831x/ dummy/ gc2035/ rk610_ctl/ sp2518/ ft5x0x_touch/ gslX680/ rk610_hdmi/ sp2541/
root@android:/ # ls sys/bus/i2c/devices/ 0-004c/ 1-002d/ 1-005a/ 2-0040/ 3-003c/ 4-0042/ 4-0060/ i2c-1/ i2c-3/ 1-0014/ 1-0034/ 2-0038/ 3-0021/ 4-0040/ 4-0046/ i2c-0/ i2c-2/ i2c-4/
static void __init rk30_i2c_register_board_info(void)
{
#ifdef CONFIG_I2C0_RK30
i2c_register_board_info(0, i2c0_info, ARRAY_SIZE(i2c0_info));
#endif
#ifdef CONFIG_I2C1_RK30
i2c_register_board_info(1, i2c1_info, ARRAY_SIZE(i2c1_info));
#endif
#ifdef CONFIG_I2C2_RK30
i2c_register_board_info(2, i2c2_info, ARRAY_SIZE(i2c2_info));
#endif
#ifdef CONFIG_I2C3_RK30
i2c_register_board_info(3, i2c3_info, ARRAY_SIZE(i2c3_info));
#endif
#ifdef CONFIG_I2C4_RK30
i2c_register_board_info(4, i2c4_info, ARRAY_SIZE(i2c4_info));
#endif
#ifdef CONFIG_I2C_GPIO_RK30
i2c_register_board_info(5, i2c_gpio_info, ARRAY_SIZE(i2c_gpio_info));
#endif
}#if defined (CONFIG_TOUCHSCREEN_GSLX680)
{
.type = "gslX680",
.addr = 0x40,
.flags = 0,
.platform_data =&gslx680_info,
},
#endif
static const struct i2c_device_id gsl_ts_id[] = {
{GSLX680_I2C_NAME, 0},
{}
};
MODULE_DEVICE_TABLE(i2c, gsl_ts_id);
static struct i2c_driver gsl_ts_driver = {
.driver = {
.name = GSLX680_I2C_NAME,
.owner = THIS_MODULE,
},
#ifndef CONFIG_HAS_EARLYSUSPEND
.suspend = gsl_ts_suspend,
.resume = gsl_ts_resume,
#endif
.probe = gsl_ts_probe,
.remove = __devexit_p(gsl_ts_remove),
.id_table = gsl_ts_id,
};
static int __init gsl_ts_init(void)
{
int ret;
printk("==gsl_ts_init==\n");
ret = i2c_add_driver(&gsl_ts_driver);
printk("ret=%d\n",ret);
return ret;
}
static void __exit gsl_ts_exit(void)
{
printk("==gsl_ts_exit==\n");
i2c_del_driver(&gsl_ts_driver);
return;
}
module_init(gsl_ts_init);
module_exit(gsl_ts_exit)