Power & Source of Big Ideas

i2c bus speed

Moderators: chensy, FATechsupport

What is the i2c bus speed? 100kHz? 400kHz? 1MHz? Is there a way to configure the bus speed?
Which bus? They are set to different speeds.

The .dts files in the kernel source set the I2C bus speeds. Looking at android source file rk3399-nanopi4-common.dtsi we have:

&i2c0 {
status = "okay";
i2c-scl-rising-time-ns = <160>;
i2c-scl-falling-time-ns = <30>;
clock-frequency = <400000>;

&i2c1 {
status = "okay";
i2c-scl-rising-time-ns = <150>;
i2c-scl-falling-time-ns = <30>;
clock-frequency = <200000>;


&i2c2 {
status = "okay";
};

&i2c4 {
status = "okay";
i2c-scl-rising-time-ns = <160>;
i2c-scl-falling-time-ns = <30>;
clock-frequency = <400000>;



I think the ones that don't specify clock speed default to 100KHz.

Mike
Thanks for the info. Follow up: How do I set the i2c speed? The rk3399 datasheet suggests that the buses can operate at 1MHz. As an example, I'm able to change the Raspberry Pi i2c bus speed by modifying /boot/config.txt and setting a dtparam.

As a note for others, I also verified these speeds by checking the device-tree:

Code: Select all

/proc/device-tree/i2c*/clock-frequency


Note that the frequencies are binary packed, so I had to use the following script:

Code: Select all

import pathlib
import struct
for p in pathlib.Path('/proc/device-tree').glob('i2c*'):
    print(p.name, (p / 'status').open().read(), end=' ')
    freq_p = p / 'clock-frequency'
    if freq_p.exists():
        print('freq =', struct.unpack(">I", freq_p.open('rb').read()), end='')
    print()


The output matches @mpanetta's response:

Code: Select all

i2c@ff3c0000 okay freq = (400000,)
i2c@ff3d0000 okay freq = (400000,)
i2c@ff3e0000 disabled
i2c@ff110000 okay freq = (200000,)
i2c@ff120000 okay
i2c@ff130000 disabled
i2c@ff140000 disabled
i2c@ff150000 disabled
i2c@ff160000 okay
I'm not sure the NanoPC's OS versions support DT overlays yet. So you would have to modify the kernel dts files and then rebuild and load.

If it does support DT overlays I would love to know!

Mike

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 825 on Wed Aug 28, 2019 3:18 pm

Users browsing this forum: No registered users and 2 guests