博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
I2C总线相关_2
阅读量:4285 次
发布时间:2019-05-27

本文共 2767 字,大约阅读时间需要 9 分钟。

/** * I2C_BOARD_INFO - macro used to list an i2c device and its address * @dev_type: identifies the device type * @dev_addr: the device's address on the bus. * * This macro initializes essential fields of a struct i2c_board_info, * declaring what has been provided on a particular board.  Optional * fields (such as associated irq, or device-specific platform_data) * are provided using conventional syntax. */#define I2C_BOARD_INFO(dev_type, dev_addr) \	.type = dev_type, .addr = (dev_addr)/** * struct i2c_board_info - template for device creation * @type: chip type, to initialize i2c_client.name * @flags: to initialize i2c_client.flags * @addr: stored in i2c_client.addr * @platform_data: stored in i2c_client.dev.platform_data * @archdata: copied into i2c_client.dev.archdata * @of_node: pointer to OpenFirmware device node * @acpi_node: ACPI device node * @irq: stored in i2c_client.irq * * I2C doesn't actually support hardware probing, although controllers and * devices may be able to use I2C_SMBUS_QUICK to tell whether or not there's * a device at a given address.  Drivers commonly need more information than * that, such as chip type, configuration, associated IRQ, and so on. * * i2c_board_info is used to build tables of information listing I2C devices * that are present.  This information is used to grow the driver model tree. * For mainboards this is done statically using i2c_register_board_info(); * bus numbers identify adapters that aren't yet available.  For add-on boards, * i2c_new_device() does this dynamically with the adapter already known. */struct i2c_board_info {
char type[I2C_NAME_SIZE]; unsigned short flags; unsigned short addr; void *platform_data; struct dev_archdata *archdata; struct device_node *of_node; struct acpi_dev_node acpi_node; int irq;};
//找到了//在busses下面有很多文件,这些文件就是i2c_driver端#define HI_I2C  "hisi_i2c"//device 端的名字在下面声明static struct i2c_board_info hi_info ={
I2C_BOARD_INFO("nvp6124", 0x60),};//上面创建了一个info结构体,然后创建设备的时候用了.struct i2c_client *i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info){
... struct i2c_client *client; ... strlcpy(client->name, info->type, sizeof(client->name)); ...}//然后在这里面,就完成了一个拷贝.
static int i2c_device_match(struct device *dev, struct device_driver *drv){
struct i2c_client *client = i2c_verify_client(dev); struct i2c_driver *driver; if (!client) return 0; /* Attempt an OF style match */ if (of_driver_match_device(dev, drv)) return 1; /* Then ACPI style match */ if (acpi_driver_match_device(dev, drv)) return 1; driver = to_i2c_driver(drv); /* match on an id table if there is one */ if (driver->id_table) return i2c_match_id(driver->id_table, client) != NULL; return 0;}//这里面是i2c的匹配过程
所以这里面就应该将设备的name 和 dirver端的name 匹配正确才行

转载地址:http://bvigi.baihongyu.com/

你可能感兴趣的文章
QT编写TCP入门+简单的实际项目(附源程序)
查看>>
VS2015和QTcreator冲突解决办法
查看>>
mmdet阅读笔记
查看>>
从零开始实现SSD目标检测(pytorch)(一)
查看>>
AutoAssign源码分析
查看>>
Rethinking Training from Scratch for Object Detection
查看>>
机器学习常用库简介
查看>>
人眼定位识别
查看>>
解决TensorFlow程序无限制占用GPU
查看>>
SSD检测几个小细节
查看>>
Kalman实际应用总结
查看>>
linux+eclipse+lua
查看>>
Linux下常见问题的解决方法
查看>>
C语言学习笔记
查看>>
Linux下设计并发网络程序
查看>>
android 多渠道打包---使用python 3.3.2
查看>>
python学习笔记
查看>>
ubuntu下lua的安装
查看>>
linux phpmyadmin
查看>>
cocos2d-x lua开发
查看>>