Notes on Linux I2C

vmlinz posted @ Wed, 29 Jun 2011 14:57:23 +0800 in Linux with tags linux driver i2c , 3492 readers

Linux i2c 笔记

i2c 总线简介

i2c(IIC, 读作/ˈaɪ skwɛərd ˈsiː/或者/ˈaɪ tuː ˈsiː/) 的意思是inter IC,也就是芯片间通信。i2c 总线是由Philips 在80年代早期设计的,用来实现同一个电路板上的各个芯片之间简易通信的总线。

i2c 的主要特性

  • 只有两条连接线,SDL(串行数据线)和SCL(串行时钟线)
  • 没有严格的波特率要求
  • 芯片间是简单的主/从关系,每个总线上的设备可以通过一个唯一的地址识别
  • i2c 是一个真正的多主总线,提供仲裁逻辑和冲突检测

i2c 子系统架构

i2c 子系统架构

  • i2c-client i2c 总线上的设备驱动
  • i2c-core 子系统实现的i2c 协议以及其他公共工具函数
  • i2c-algorithm 通用算法,给i2c-adapter 驱动提供和子系统交互的接口
  • i2c-adapter 操作特定的i2c 总线硬件,实现核心子系统中提供的总线操作
  • i2c-dev 用于实现用户空间的i2c 驱动

i2c 总线驱动

  • struct i2c_adapter; i2c 总线驱动硬件适配结构体,实现具体总线的操作
  • struct i2c_algorithm; i2c 总线驱动的具体操作接口,实现新总线操作时需要实现这个具体的硬件操作接口
  • int i2c_add_adapter(struct i2c_adapter *); 添加总线驱动
  • int i2c_del_adapter(struct i2c_adapter *); 删除总线驱动

i2c 设备驱动

  • struct i2c_client; i2c 设备结构体,包含struct device,用于向驱动模型注册设备
  • struct i2c_driver; i2c 驱动结构体,包含struct device_driver,向系统注册驱动
  • int i2c_register_driver(struct module *, struct i2c_driver *); 注册设备驱动
  • void i2c_del_driver(struct i2c_driver *); 删除设备驱动

i2c 设备和驱动匹配

  • int i2c_register_driver(struct module *, struct i2c_driver *); 阅读这个函数来理解i2c 设备和驱动的动态绑定过程,其中分成两种情况。一种是类似于驱动模型的probe 过程,另一种是调用attach函数。

i2c 相关的资源和链接

Avatar_small
AAA said:
Sat, 19 Feb 2022 04:38:51 +0800

Hi my loved one! I want to say that this article is amazing, great written and include almost all vital infos. I would like to peer more posts like this . how to be a payment processor

Avatar_small
AAA said:
Sun, 20 Feb 2022 04:05:39 +0800

I believe this web site has some rattling wonderful info for everyone . Payment Gateway Reseller Program

Avatar_small
AAA said:
Mon, 06 Jun 2022 22:20:32 +0800

Thank you for your wonderful post! It has long been very insightful. I hope that you’ll continue sharing your wisdom with us. 回收手提電腦

Avatar_small
Robinjack said:
Sun, 24 Sep 2023 15:35:34 +0800

Hey there! I’m at work browsing your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the outstanding work! click here

Avatar_small
Robinjack said:
Mon, 13 Nov 2023 00:03:14 +0800

Although in this article we are focusing on the uses of Artificial Intelligence and Technology inside esports, they have multiple uses in many other industries..   seed phrase crack

Avatar_small
sophia said:
Fri, 29 Dec 2023 01:42:27 +0800

A home office often hosts a variety of power-hungry devices, such as computers, printers, scanners, and copiers. To ensure their smooth operation and prevent electrical overloads, dedicated circuits are crucial. Niuyuan Carpet Edge Strip

Avatar_small
robinjack said:
Thu, 08 Feb 2024 20:16:34 +0800

There are many types of therapy to choose from. Here are four common ones your therapist may recommend you based on your tailored needs:. counseling in Glastonbury CT


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter