Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:vim2:applications:gpio:i2c

VIM2 I2C

Introduction

This page introduces the usage of I2C bus on 40-Pin Header.

I2C Information

I2C PIN GPIO Name DT Overlays Node Bus Number Device Node
VIM1/2 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

Enable I2C

In order to use the I2C, you need to enable the I2C function via Device Tree Overlay.

VIM1/2/3/3L/Edge1

Edit /boot/env.txt to add the i2c node to overlays node if it doesn't exist.

Take VIM3 as an example to enable I2CM 3, you need to add i2c3 node to overlays node if it doesn't exist.

overlays=uart4 pwm_ao_a pwm_f i2c3

After reboot, you will see the I2C device node.

$ ls /dev/i2c-3
/dev/i2c-3

VIM3 with 5.15 kernel

Edit /boot/dtb/amlogic/kvim3.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.

fdt_overlays=i2c3

After reboot, you will see the I2C device node.

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.

fdt_overlays=i2c3

After reboot, you will see the I2C device node.

VIM4

Edit /boot/dtb/amlogic/kvim4.dtb.overlay.env to add i2c node to fdt_overlays node if it doesn't exist.

e.g. To enable I2CM A, you need to add i2cm_a to node fdt_overlays if it doesn't exist.

fdt_overlays=i2cm_a

After reboot, you will see the I2C device node.

$ ls /dev/i2c-0
/dev/i2c-0

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.

fdt_overlays=i2cm_e

After reboot, you will see the I2C device node.

$ ls /dev/i2c-4
/dev/i2c-4

I2C Usage

Please check the I2C Usage.

Disable I2C to Use GPIO

If you want to use normal GPIO instead of I2C, you can remove the I2C node in Device Tree Overlay.

2022/06/29 09:38
Last modified: 2022/10/20 02:37 by nick