Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:common:applications:gpio:i2c

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
products:sbc:common:applications:gpio:i2c [2022/07/12 04:51]
nick [Table]
products:sbc:common:applications:gpio:i2c [2023/11/07 04:51] (current)
nick [Enable I2C]
Line 3: Line 3:
 ===== Introduction ===== ===== Introduction =====
  
-This document mainly introduces the usage of I2C bus on [[products:sbc:common:applications:gpio:40pin-header|40-Pin Header]].+This page introduces the usage of I2C bus on [[products:sbc:common:applications:gpio:40pin-header|40-Pin Header]].
  
 ===== I2C Information ===== ===== I2C Information =====
  
-<tabbox VIM1/2>+|            I2C      PIN      ^  GPIO Name  ^  DT Overlays Node  ^  Bus Number  ^  Device Node  ^ 
 +^  VIM1/  |  I2C A    22(SCL)  |  GPIODV_25  |  i2c0              |  0            /dev/i2c-0   | 
 +| :::       | :::      |  23(SDA)  |  GPIODV_24  | :::                | :::          | :::           | 
 +| :::        I2C B    25(SCL)  |  GPIODV_27  |  -                  1            /dev/i2c-1   | 
 +| :::       | :::      |  26(SDA)  |  GPIODV_26  | :::                | :::          | :::           | 
 +^  VIM3/3L  |  I2CM 3  |  22(SCL)  |  GPIOA_15    i2c3              |  3            /dev/i2c-3   | 
 +| :::       | :::      |  23(SDA)  |  GPIOA_14   | :::                | :::          | :::           | 
 +| :::        I2C AO  |  25(SCL)  |  GPIOAO_2    -                  4            /dev/i2c-4   | 
 +| :::       | :::      |  26(SDA)  |  GPIOAO_3   | :::                | :::          | :::           | 
 +^  VIM4      I2CM F  |  22(SCL)  |  GPIOY_17    i2cm_f            |  5            /dev/i2c-5   | 
 +| :::       | :::      |  23(SDA)  |  GPIOY_18   | :::                | :::          | :::           | 
 +| :::        I2CM A  |  25(SCL)  |  GPIOT_20    i2cm_a            |  0            /dev/i2c-0   | 
 +| :::       | :::      |  26(SDA)  |  GPIOT_21   | :::                | :::          | :::           | 
 +^  VIM1S    |  I2CM B  |  22(SCL)  |  GPIOD_7    |  -                  1            /dev/i2c-1   | 
 +| :::       | :::      |  23(SDA)  |  GPIOD_6    | :::                | :::          | :::           | 
 +| :::        I2CM E  |  25(SCL)  |  GPIOZ_11    i2cm_e            |  4            /dev/i2c-4   | 
 +| :::       | :::      |  26(SDA)  |  GPIOZ_12   | :::                | :::          | :::           |
  
-^  I2C   ^  PIN & GPIO Number                                                DT Overlays Node  ^  Bus Number  ^  Device Node  ^ +===== Enable I2C =====
-| I2C A  | SCL - PIN22 - GPIODV_25 (#474)\\ SDA - PIN23 - GPIODV_24 (#473)  |  i2c0              |  1            /dev/i2c-1   | +
-| I2C B  | SCL - PIN25 - GPIODV_27 (#476)\\ SDA - PIN26 - GPIODV_26 (#475)  |  -                  2            /dev/i2c-2   |+
  
 +In order to use the I2C, you need to enable the I2C function via [[products:sbc:common:configurations:device-tree-overlay|Device Tree Overlay]].
  
-<tabbox VIM3/3L>+<tabbox VIM1/2/3/3L/Edge1>
  
-^  I2C    ^  PIN & GPIO Number                                              DT Overlays Node  ^  Bus Number  ^  Device Node  ^ +Edit ''/boot/env.txt'' to add the i2c node to ''overlays'' node if it doesn't exist.
-| I2CM 3  | SCL - PIN22 - GPIOA_15 (#475)\\ SDA - PIN23 - GPIOA_14 (#474)  |  i2c3              |  3           |  /dev/i2c-3   | +
-| I2C AO  | SCL - PIN25 - GPIOAO_2 (#498)\\ SDA - PIN26 - GPIOAO_3 (#499)  |  -                  4            /dev/i2c-4   |+
  
-<tabbox VIM4>+Take VIM3 as an example to enable ''I2CM 3'', you need to add ''i2c3'' node to ''overlays'' node if it doesn't exist.
  
-^  I2C    ^  PIN & GPIO Number                                              DT Overlays Node  ^  Bus Number  ^  Device Node  ^ +```shell 
-| I2CM F  | SCL - PIN22 - GPIOY_17 (#501)\\ SDA - PIN23 - GPIOY_18 (#502)  |  i2cm_f            |  5            /dev/i2c-5   | +overlays=uart4 pwm_ao_a pwm_f i2c3 
-| I2CM A  | SCL - PIN25 - GPIOT_20 (#466)\\ SDA - PIN26 - GPIOT_21 (#467)  |  i2cm_a            |  0            /dev/i2c-0   |+```
  
-^  I2C     PIN & GPIO Number                                      ^  DT Overlays Node  ^  Bus Number  ^  Device Node  ^ +After reboot, you will see the I2C device node.
-| I2CM F  | SCL(22) - GPIOY_17 (#501)\\ SDA (23) - GPIOY_18 (#502)  |  i2cm_f            |  5            /dev/i2c-5   | +
-| I2CM A  | SCL(25) - GPIOT_20 (#466)\\ SDA(26) - GPIOT_21 (#467)    i2cm_a            |  0            /dev/i2c-0   |+
  
 +```shell
 +$ ls /dev/i2c-3
 +/dev/i2c-3
 +```
  
-</tabbox>+<tabbox VIM3 with 5.15 kernel>
  
-===== Enabel I2C =====+Edit ''/boot/dtb/amlogic/kvim3.dtb.overlay.env'' to add i2c node to ''fdt_overlays'' node if it doesn't exist.
  
-In order to use the I2C, you need to enable the I2C function via [[products:sbc:common:configurations:device-tree-overlay|Device Tree Overlay]]. 
  
-<tabbox VIM1/2/3/3L/Edge1> +e.g. To enable ''I2CM 3'', you need to add ''i2c3'' to node ''fdt_overlays'' if it doesn't exist.
- +
-Edit ''/boot/env.txt'' to add the i2c node to ''overlays'' node. +
- +
-Take VIM3 as an example to enable ''i2c3'':+
  
 ```shell ```shell
-overlays=uart4 pwm_ao_a pwm_f i2c3+fdt_overlays=i2c3 
 ``` ```
  
 After reboot, you will see the I2C device node. After reboot, you will see the I2C device node.
 +
 +<tabbox VIM3L with 5.15 kernel>
 +
 +Edit ''/boot/dtb/amlogic/kvim3l.dtb.overlay.env'' to add i2c node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. To enable ''I2CM 3'', you need to add ''i2c3'' to node ''fdt_overlays'' if it doesn't exist.
  
 ```shell ```shell
-$ ls /dev/i2c-3 +fdt_overlays=i2c3 
-/dev/i2c-3+
 ``` ```
 +
 +After reboot, you will see the I2C device node.
  
 <tabbox VIM4> <tabbox VIM4>
  
-Edit ''/boot/dtb/amlogic/kvim4.dtb.overlay.env'' to add i2c node to ''fdt_overlays'' node.+Edit ''/boot/dtb/amlogic/kvim4.dtb.overlay.env'' to add i2c node to ''fdt_overlays'' node if it doesn't exist.
  
  
-e.g. Enable ''I2CM A'', you need to add ''i2cm_a'' to node ''fdt_overlays''.+e.g. To enable ''I2CM A'', you need to add ''i2cm_a'' to node ''fdt_overlays'' if it doesn't exist.
  
 ```shell ```shell
Line 71: Line 91:
 $ ls /dev/i2c-0 $ ls /dev/i2c-0
 /dev/i2c-0 /dev/i2c-0
 +```
 +
 +<tabbox VIM1S>
 +
 +Edit ''/boot/dtb/amlogic/kvim1s.dtb.overlay.env'' to add i2c node to ''fdt_overlays'' node if it doesn't exist.
 +
 +
 +e.g. To enable ''I2CM E'', you need to add ''i2cm_e'' to node ''fdt_overlays'' if it doesn't exist.
 +
 +```shell
 +fdt_overlays=i2cm_e
 +
 +```
 +
 +After reboot, you will see the I2C device node.
 +
 +```shell
 +$ ls /dev/i2c-4
 +/dev/i2c-4
 ``` ```
  
 </tabbox> </tabbox>
 +
 +===== I2C Usage =====
 +
 +Please check the [[https://manpages.ubuntu.com/manpages/jammy/en/man8/i2cdetect.8.html|I2C Usage]].
  
  
 ===== Disable I2C to Use GPIO ===== ===== Disable I2C to Use GPIO =====
  
-If you want to use normal GPIO instead of I2C, you can remove the I2C node in device tree overlays configration file+If you want to use normal GPIO instead of I2C, you can remove the I2C node in [[products:sbc:common:configurations:device-tree-overlay|Device Tree Overlay]]
Last modified: 2022/07/12 04:51 by nick