Analysis of linux IIC subsystem (2) - overview of linux i2c architecture

Because of its simple hardware connection and communication method, I2C bus is an indispensable communication bus in many devices today. If it is used as a microcontroller to directly operate the I2C, it is actually very simple, as long as the operation timing of the IIC is correctly grasped. However, in the Linux system, the structure of the I2C subsystem is more complicated, because it involves a lot of knowledge related to the Linux kernel, and it is very difficult to understand.


(1) Overview of I2C architecture

The I2C architecture of Linux is divided into 3 components:

(1) I2C core: I2C core provides I2C bus driver and bus device registration, cancellation, and communication methods. Adapter-independent code, probe code, etc. are also provided.

(2) I2C bus driver: The I2C bus driver is the realization of the adapter driver in the I2C hardware architecture. (IIC uses the platform device driver model)

(3) I2C device driver: I2C device driver is the realization of the device side (customer driver), such as EEPROM device.


(2) I2C driver architecture diagram in linux



Hardware is our hardware device. When debugging the device, we often use an oscilloscope to track the I2C communication waveform.

According to the introduction of the I2C architecture overview, you can know:

I2C Core: I2C Core Layer

I2C bus driver (platform bus): hardware implementation control layer, access abstraction layer

I2C device driver (device driver): driver layer


Note: In our linux I2C subsystem, the platform device driver mechanism is used. The main purpose of using platform device drivers is to separate hardware/platform-related things to improve program portability.


Next, the I2C subsystem architecture is further analyzed according to the registration order of the linux i2c subsystem, which is divided into the following articles

"Linux IIC Subsystem Analysis (1) - Introduction to AT24C02 Chip"

"Linux IIC subsystem analysis (3) - I2c subsystem initialization sequence analysis"

"Analysis of linux IIC subsystem (4) - I2c bus initialization"

"Linux IIC subsystem analysis (5) - I2C plaform device initialization"

"Linux IIC subsystem analysis (6) - I2c plaform driver initialization"

"Analysis of linux IIC subsystem (7) - example analysis of operating I2C devices through i2c-dev"

"Analysis of linux IIC subsystem (8) - instance analysis of accessing I2c devices through sysfs"

"Analysis of linux IIC subsystem (9) - instance analysis to access I2c devices through device nodes"


(3) (4) (5) (6) Introduce I2C bus driver

(7) (8) (9) Examples introduce three different ways to drive i2C devices


illustrate:

1. The analyzed kernel version is linux2.6.32.2

2. The development board is the friendly arm mini2440, using the ARM9 (S3C2440A) processor

3. The linked IIC device is EEPROM (AT24C02)

4. Analyze the registration order of the kernel I2C subsystem.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324764583&siteId=291194637