IIC driver 重要结构体
来源:互联网 发布:电脑看美剧软件 编辑:程序博客网 时间:2024/05/29 13:51
借用一下其他的照片,这样方便我们分析driver;
IIC子系统可以分
i2c-dev:代表挂在bus上的设备
i2c client:代表了完整的从设备,由i2c-dev,i2c-driver组成;
i2c-adapter:代表IIC控制器,
i2c-algorithm:代表了IIC通信的规范
i2c-core:提供了IIC总线上总线驱动和设备驱动的注册、注销方法,IIC通信方法(即algorithm),与具体适配器无关的代码以及probe设备,检测设备地址的上层代码等
大概是这么理解的,下面就先粗看一下include/linux/i2c.h中列举出的重要结构体,来更进一步理解上述几个部分怎么联系起来的;
struct i2c_adapter { struct module *owner; unsigned int class; /* classes to allow probing for */ const struct i2c_algorithm *algo; /* the algorithm to access the bus */ 使用的通信规范方法的集合指针,代表了具体怎么干 void *algo_data; 通信方法也需要处理数据啊,这个就是告诉你干什么的 /* data fields that are valid for all devices */ struct rt_mutex bus_lock; 锁,目前不明白用在什么地方. int timeout; /* in jiffies */ 超时时间?在规定的时间内没有接受到有效回应? int retries; 失败时请求重试,什么时候会失败呢?多个从设备争相发起事务是? struct device dev; /* the adapter device */ 控制器设备 int nr; //用途不明 char name[48]; struct completion dev_released; ? struct mutex userspace_clients_lock; ? struct list_head userspace_clients; ? struct i2c_bus_recovery_info *bus_recovery_info; ? };<pre name="code" class="html">struct i2c_algorithm { /* If an adapter algorithm can't do I2C-level access, set master_xfer to NULL. If an adapter algorithm can do SMBus access, set smbus_xfer. If set to NULL, the SMBus protocol is simulated using common I2C messages */ /* master_xfer should return the number of messages successfully processed, or a negative value on error */ int (*master_xfer)(struct i2c_adapter *adap, struct i2c_msg *msgs, 这个就是中断来临时怎么处理的,告诉哪个IIC控制器要处理什么信息 int num); int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, smbus是IIC的一个子集 unsigned short flags, char read_write, u8 command, int size, union i2c_smbus_data *data); /* To determine what the adapter supports */ u32 (*functionality) (struct i2c_adapter *); };
struct i2c_client { unsigned short flags; /* div., see below */ unsigned short addr; /* chip address - NOTE: 7bit */ 每个IIC都有自己的地址,具体看芯片手册 /* addresses are stored in the */ /* _LOWER_ 7 bits */ char name[I2C_NAME_SIZE]; IIC设备的名称,这个是和driver配对时需要用到的 struct i2c_adapter *adapter; /* the adapter we sit on */ 这个设备和哪个IIC控制器的bus连在一起 struct i2c_driver *driver; /* and our access routines */ 怎么驱动我 struct device dev; /* the device structure */ 我自己的一些属性 int irq; /* irq issued by device */ 我局有哪些中断资源呢 struct list_head detected; };
struct i2c_driver { unsigned int class; 这个class是干什么呢? /* Notifies the driver that a new bus has appeared. You should avoid * using this, it will be removed in a near future. */ int (*attach_adapter)(struct i2c_adapter *) __deprecated; /* Standard driver model interfaces */ int (*probe)(struct i2c_client *, const struct i2c_device_id *); 初始化这个i2c设备 int (*remove)(struct i2c_client *); 删除这个i2c设备 /* driver model interfaces that don't relate to enumeration */ void (*shutdown)(struct i2c_client *); int (*suspend)(struct i2c_client *, pm_message_t mesg); int (*resume)(struct i2c_client *); /* Alert callback, for example for the SMBus alert protocol. * The format and meaning of the data value depends on the protocol. * For the SMBus alert protocol, there is a single bit of data passed * as the alert response's low bit ("event flag"). */ void (*alert)(struct i2c_client *, unsigned int data); /* a ioctl like command that can be used to perform specific functions * with the device. */ int (*command)(struct i2c_client *client, unsigned int cmd, void *arg); struct device_driver driver; const struct i2c_device_id *id_table; 这个匹配表表示匹配规则 /* Device detection callback for automatic device creation */ int (*detect)(struct i2c_client *, struct i2c_board_info *); const unsigned short *address_list; struct list_head clients;};
0 0
- IIC driver 重要结构体
- AD5669 IIC DAC driver
- driver的结构体
- madwifi重要结构体
- LINUX IIC总线 MISC driver
- linux IIC driver详解以及 IIC sensor 驱动
- ffmpeg 重要结构体说明
- x264中重要结构体说明
- 结构体与地址!!(重要)
- 网络中几个重要的结构体
- 几个重要的网络结构体
- Linux 内存管理 重要结构体 (转)
- input子系统中重要结构体分析
- x264中重要结构体说明
- kernel networking两个重要结构体
- libevent重要结构体之event_base分析
- x264中重要结构体说明
- ffmpeg重要结构体之AVFrame
- Linux进程间通信——使用命名管道
- c++ 时间类型详解 time_t
- Json转换利器Gson之实例三-Map处理(上)
- opencart 为品牌管理增加检索名称和状态项
- SSO单点登录
- IIC driver 重要结构体
- Android开发之旅:环境搭建及HelloWorld
- Mac Appium Python 环境搭建
- TP 自动创建
- Json转换利器Gson之实例四-Map处理(下)
- Android Studio集成SVN报错:can't use subversion command line client : svn
- Halcon 学习总结——仿射变换
- 分解质因数
- 官方的ae cs4英文版下载 含注册机 汉化补丁提供在线视频安装教程