1. Wiki首页
  2. MediaTek X20 软件开发
  3. How to debug I2C
  4. 2.I2C code

2.I2C code

2.1 Define I2C driver

Before the definition of I2C driver, Define of_device_id and i2c_device_id.Of_device_id is used to call the device information defined in the DTS file in the device drive, which is defined as follows:

Note: id_table indicates the device supported by the device drive.

2.2 Registered I2C driver


When callIing i2c_add_driver to registered I2C driver,OS will traverse the I2C device.if the I2C driver support the traversal of the device, it will call the probe function of the device driver.

2.3 I2C communication

After registering a good I2C driver, you can exchange data by I2C.

So Host can use the API (mt8193_i2c_read ,mt8193_i2c_write) to communicate with the slave.