I2C Driver

Block Diagram

The block diagram of I2C driver is shown in the following figure.
Figure 1. Block Diagram
The I2C subsystem includes the following sub-modules.
  • interface: The sub-module provides interfaces to interact with i2c_adapter or i2c_client.
  • i2c-core: The sub-module builds the core functions of I2C subsystem. It provides i2c_adapter and i2c_client APIs.
  • Synopsys DesignWare I2C adapter driver: The sub-module registers the i2c_adapter and provide functions for receive/send operations.
  • i2c driver: The sub-module uses application interfaces to receive/send data.

I2C Driver Device Tree Source Code

The following code block shows the device tree source code of the I2C driver.
   i2c0: i2c@10030000 {
		compatible = "snps,designware-i2c";
		reg = <0x0 0x10030000 0x0 0x10000>;
		clocks = <&clkgen JH7110_I2C0_CLK_CORE>,
			 <&clkgen JH7110_I2C0_CLK_APB>;
		clock-names = "ref", "pclk";
		resets = <&rstgen RSTN_U0_DW_I2C_APB>;
		interrupts = <35>;
		#address-cells = <1>;
		#size-cells = <0>;
		status = "disabled";
	};
The following table describes the DT parameters:
Table 1. I2C DT Parameters
Parameter Description
compatible Compatibility information, used to associate the driver and its target device
reg Register base address "0x10030000" and range "0x4000".
clocks The clocks used by the I2C module
clock-names The names of the clocks used by the I2C module
resets The reset signals used by the I2C module
reset_names The names of the reset signals
interrupts Hardware interrupt ID
status

The work status of the I2C module. To enable the module, set this bit to okay. To disable the module, set this bit to disabled.

Source Code Structure

The following code block displays the source code structure for the I2C Subsystem layer.
├── drivers
│   ├── i2c
│   │   ├── i2c-core.h
│   │   ├── i2c-boardinfo.c
│   │   ├── i2c-core-of.c
│   │   ├── i2c-core-slave.c
│   │   ├── i2c-mux.c
│   │   ├── i2c-core-acpi.c
│   │   ├── i2c-core-smbus.c
│   │   ├── i2c-smbus.c
│   │   ├── i2c-core-base.c
│   │   └── i2c-dev.c
The following code block displays the source code structure for the Synopsys DesignWare I2C adapter driver.
linux-5.15.0
├── drivers
│   ├── i2c
│   │   ├── busses
│   │   │   ├── i2c-designware-core.h
│   │   │   ├── i2c-designware-common.c
│   │   │   ├── i2c-designware-master.c
│   │   │   ├── i2c-designware-slave.c
│   │   │   ├── i2c-designware-pcidrv.c
│   │   │   ├── i2c-designware-baytrail.c
│   │   │   └── i2c-designware-platdrv.c