Manipulate I2C bus speed

Moderators: mdrjr, odroid

Manipulate I2C bus speed

Unread postby ttsolov » Wed Jul 11, 2018 4:04 am

Hi,
is it possible to set different I2C bus speed under Android?

Thanks in advance.
ttsolov
 
Posts: 1
Joined: Wed Jul 11, 2018 4:00 am
languages_spoken: english

Re: Manipulate I2C bus speed

Unread postby odroid » Wed Jul 11, 2018 9:46 am

You need to modify the DeviceTree file in the Kernel source to adjust the I2C clock speed.
User avatar
odroid
Site Admin
 
Posts: 28292
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Manipulate I2C bus speed

Unread postby snorky35 » Fri Jul 13, 2018 6:01 pm

Hi guys,

I'm also in the same case : i would like to modify I2C speed from 400kHz (measured) to 100kHz as my PN512 is not detected using :
Code: Select all
i2cdetect -y 5
in adb shell.
I changed in "kernel/hardkernel/odroidxu3/arch/arm/boot/dts/exynos5422-odroidxu3.dts" the frequency with :
Code: Select all
i2c_1: i2c@12C70000 {
    samsung,i2c-max-bus-freq = <100000>;
    status = "okay";
};


But when i build (from scratch, clean build) and deploy, using an oscilloscope, i still have 400kHz (approx. 363kHz measured).
Is there something i'm doing wrong ?

(Moreover, i was not able to find where i2c_1 is mapped to /dev/i2c-5)
snorky35
 
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4

Re: Manipulate I2C bus speed

Unread postby odroid » Fri Jul 13, 2018 6:07 pm

Do you use Pin16/14 on 30pin header?
The device node number is different in Android Kernel 3.0 from generic Ubuntu Kernel 4.x.
Please look into this wiki page carefully.
https://wiki.odroid.com/old_product/acc ... nboard/i2c
User avatar
odroid
Site Admin
 
Posts: 28292
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Manipulate I2C bus speed

Unread postby snorky35 » Fri Jul 13, 2018 9:25 pm

Yes, i'm using pins 16 & 14 for respectively SDA and SCL, and i'm using Lineage OS 14.1 from voodik

Code: Select all
odroidxu3:/ # ll /sys/class/i2c-dev/                                                                                                                                                                         
total 0
drwxr-xr-x  2 root root 0 2018-07-13 12:19 .
drwxr-xr-x 50 root root 0 2018-07-13 12:19 ..
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-0 -> ../../devices/12ca0000.hsi2c/i2c-0/i2c-dev/i2c-0
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-1 -> ../../devices/12cb0000.hsi2c/i2c-1/i2c-dev/i2c-1
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-2 -> ../../devices/12e00000.hsi2c/i2c-2/i2c-dev/i2c-2
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-3 -> ../../devices/i2c_gpio.8/i2c-3/i2c-dev/i2c-3
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-4 -> ../../devices/12c60000.i2c/i2c-4/i2c-dev/i2c-4
lrwxrwxrwx  1 root root 0 2018-07-13 12:23 i2c-5 -> ../../devices/12c70000.i2c/i2c-5/i2c-dev/i2c-5


From what i can see, the section that i did modify (i2c_1 : I2C@12c70000) is mapped to /dev /i2c-5, so i don't understand why the SCL clock speed is still about 400kHz as you can see on the picture below

20180713_154908.jpg
20180713_154908.jpg (141.45 KiB) Viewed 96 times
snorky35
 
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4

Re: Manipulate I2C bus speed

Unread postby odroid » Sat Jul 14, 2018 10:24 am

I think you should modify i2c-4 entry instead of i2c-5. lrwxrwxrwx 1 root root 0 2018-07-13 12:23 i2c-4 -> ../../devices/12c60000.i2c/i2c-4/i2c-dev/i2c-4
User avatar
odroid
Site Admin
 
Posts: 28292
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Manipulate I2C bus speed

Unread postby snorky35 » Wed Jul 18, 2018 12:59 am

I've tried everything that is possible, even buy making tests using a Linux image, but with no more luck.
I will buy a level shifter and make a try, maybe the PN512 does not support I2C @ 1.8V (was not very clear in the datasheet)
I will let you know ... thank you for your help
snorky35
 
Posts: 26
Joined: Thu Nov 26, 2015 5:32 am
languages_spoken: english
ODROIDs: C1+ C2 XU4

Re: Manipulate I2C bus speed

Unread postby odroid » Wed Jul 18, 2018 9:06 am

We will try I2C 100Khz setting in Android 4.4 and let you know.
User avatar
odroid
Site Admin
 
Posts: 28292
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Manipulate I2C bus speed

Unread postby tobetter » Fri Jul 20, 2018 8:38 pm

snorky35 wrote:I've tried everything that is possible, even buy making tests using a Linux image, but with no more luck.
I will buy a level shifter and make a try, maybe the PN512 does not support I2C @ 1.8V (was not very clear in the datasheet)
I will let you know ... thank you for your help

I've tried to change the max frequency in DTS like yours and this gives me to run i2c at 61.27kHz.
Code: Select all
diff --git a/arch/arm/boot/dts/exynos5422-odroidxu3.dts b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
index 51f2ff6fa007..f394c740dbfb 100755
--- a/arch/arm/boot/dts/exynos5422-odroidxu3.dts
+++ b/arch/arm/boot/dts/exynos5422-odroidxu3.dts
@@ -433,7 +433,7 @@
        };
 
        i2c_1: i2c@12C70000 {
-               samsung,i2c-max-bus-freq = <400000>;
+               samsung,i2c-max-bus-freq = <100000>;
                status = "okay";
        };


Could you try this command if the value is affected? If your change is applied properly, this command will show you up 0x1b6a0 which is 100000 in decimal.
Code: Select all
# od -x /proc/device-tree/i2c@12C70000/samsung,i2c-max-bus-freq
0000000     0100    a086                                               
0000004
tobetter
 
Posts: 2229
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1


Return to Android

Who is online

Users browsing this forum: No registered users and 0 guests