I’m trying to set the bus speed for i2c-2 to 400000. I’m running kernel 4.4.68-ti-r107 on a Beaglebone Black. So farI’ve tried
-
modifying am335x-boneblack.dtb to set the speed to 400000
-
recompiling the kernel (after modifying i2c-core.c).
in i2c_parse_fw_timings() i set t->bus_freq to 400000 explicitly.
Neither of these had any affect on the bus speed.
I’ve been searching for a couple days, and can’t see another way to do it, can the bus speed actually be changed somehow?
Thanks
Joe
Have you verified that you are atleast booting the same *.dtb that you
are modifiing:
You can check the live tree via:
root@beaglebone:~# fdtdump /sys/firmware/devicetree/base/ocp/i2c@4802a000/
/* dump of live tree at /sys/firmware/devicetree/base/ocp/i2c@4802a000 */
/ {
reg = <0x4802a000 0x00001000>;
name = "i2c";
interrupts = <0x00000047>;
pinctrl-0;
compatible = "ti,omap4-i2c";
clock-frequency = <0x000186a0>;
status = "okay";
#address-cells = <0x00000001>;
ti,hwmods = "i2c2";
phandle = <0x000000a9>;
#size-cells = <0x00000000>;
pinctrl-names = "default";
linux,phandle = <0x000000a9>;
};
and then i2c2's bus frequency:
root@beaglebone:~# dmesg | grep i2c | grep 4802a000
[ 42.615491] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
Regards,
Have you verified that you are atleast booting the same *.dtb that you
are modifiing:
You can check the live tree via:
root@beaglebone:~# fdtdump /sys/firmware/devicetree/base/ocp/i2c@4802a000/
/* dump of live tree at /sys/firmware/devicetree/base/ocp/i2c@4802a000 */
/ {
reg = <0x4802a000 0x00001000>;
name = “i2c”;
interrupts = <0x00000047>;
pinctrl-0;
compatible = “ti,omap4-i2c”;
clock-frequency = <0x000186a0>;
status = “okay”;
#address-cells = <0x00000001>;
ti,hwmods = “i2c2”;
phandle = <0x000000a9>;
#size-cells = <0x00000000>;
pinctrl-names = “default”;
linux,phandle = <0x000000a9>;
};
That doesn’t work for me:
bbb2g# fdtdump /sys/firmware/devicetree/base/ocp/i2c@4819c000/
Couldn’t open blob from ‘/sys/firmware/devicetree/base/ocp/i2c@4819c000/’: Is a directory
FATAL ERROR: could not read: /sys/firmware/devicetree/base/ocp/i2c@4819c000/
However (I think I forgot to mention that I also modified /lib/firmware/BB-I2C2-00A0.dtbo)
fdtdump /lib/firmware/BB-I2C2-00A0.dtbo > /home/jhalpin/BB-I2C2-00A0.dtbo.dump
Does work and shows the bus speed to be 400000, but dmesg still says 100000. Wierd
/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;
part-number = “BB-I2C2”;
version = “00A0”;
exclusive-use = “P9.19”, “P9.20”, “i2c2”;
fragment@0 {
target = <0xffffffff>;
overlay {
pinmux_bb_i2c2_pins {
pinctrl-single,pins = <0x00000178 0x00000073 0x0000017c 0x00000073>;
linux,phandle = <0x00000001>;
phandle = <0x00000001>;
};
};
};
fragment@1 {
target = <0xffffffff>;
overlay {
status = “okay”;
pinctrl-names = “default”;
pinctrl-0 = <0x00000001>;
clock-frequency = <0x00061a80>;
#address-cells = <0x00000001>;
#size-cells = <0x00000000>;
};
};
symbols {
bb_i2c2_pins = “/fragment@0/overlay/pinmux_bb_i2c2_pins”;
};
fixups {
am33xx_pinmux = “/fragment@0:target:0”;
i2c2 = “/fragment@1:target:0”;
};
local_fixups {
fragment@1 {
overlay {
pinctrl-0 = <0x00000000>;
};
};
};
};
Thanks
Joe
I am trying to do the same for i2c-2 to 400000 on kernel 4.4.68-ti-r106 on a Beaglebone Green wireless without recompiling the kernel.
I have modified clock to 400000 in univ-bbgw-00A0.dts and run ./install.sh(changing clock in BB-I2C1-00A0.dts and BB-I2C2-00A0.dts and adding these capes to capemgr does not have effect).
There is the result after reboot:
1.534882] omap_i2c 44e0b000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins, deferring probe
[ 1.534938] omap_i2c 4819c000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c2_pins, deferring probe
[ 2.137847] i2c /dev entries driver
[ 2.373848] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/input/input0
[ 2.400988] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[ 2.404366] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[ 15.453692] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 400 kHz
[ 1942.909929] omap_i2c 4802a000.i2c: timeout waiting for bus ready
But I should use “P9.19”, “P9.20” for I2C at 400kHz instead of 100kHz.
Please, can somebody help solve the puzzle?
Thanks in advance!
inspired by https://quadcopterdiaries.wordpress.com/2016/03/29/changing-i2c-bus-rate-on-beaglebone-black/)
Set 400kHz bitrate for i2c-2 on Beaglebone Green Wireless:
-
Decompile the /boot/dtbs/4.4.68-ti-r106# am335x-boneblack-uboot.dtb file with: dtc -I dtb -O dts -o am335x-boneblack-uboot.dts am335x-boneblack-uboot.dtb
-
Edit the source file. Look for I2C definitions with a clock-frequency parameter. 0x61A80 is 400KHz and 0x186A0 is 100KHz. Change the second I2C (the one with clock-frequency of 100KHz) to 0x61a80.
-
Recompile the source file with: /boot/dtbs/4.4.68-ti-r106# dtc -I dts -O dtb -o am335x-boneblack-uboot.dtb am335x-boneblack-uboot.dts
-
Make sure you have the proper file at /boot/dtbs//am335x-boneblack.dtb (wrong extensions here won’t let your BBB boot).
-
Reboot
-
Check dmesg to verify that the I2C bus is now running at 400KHz.
root@beaglebone:~# dmesg |grep i2c
[ 1.534908] omap_i2c 44e0b000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins, deferring probe
[ 1.534964] omap_i2c 4819c000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c2_pins, deferring probe
[ 2.138650] i2c /dev entries driver
[ 2.373860] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/input/input0
[ 2.400992] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
[ 2.404378] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 400 kHz
[ 14.689395] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
Following your example I’m trying to set 400KHz on my i2c-1 too. I have a Beaglebone Black WIRELESS that loads am335x-boneblack-uboot.dtb as overlay.
UBOOT: U-Boot SPL 2017.09-00003-g11d92ba68a (Sep 21 2017 - 10:40:17)Trying to boot fr - Pastebin.com
- Decompilation: dtc -I dtb -O dts -o am335x-boneblack-uboot.dts am335x-boneblack-uboot.dtb
- Actually my i2c-1 is disabled. WHY?
i2c@4802a000 {
compatible = “ti,omap4-i2c”;
#address-cells = <0x1>;
#size-cells = <0x0>;
ti,hwmods = “i2c2”;
reg = <0x4802a000 0x1000>;
interrupts = <0x47>;
status = “disabled”;
linux,phandle = <0xa6>;
phandle = <0xa6>;
};
I edited it with
status = “okay”;
clock-frequency = <0x61A80>;
-
Compiling: root@beaglebone:/boot/dtbs/4.4.91-ti-r139# dtc -I dts -O dtb -o am335x-boneblack-uboot.dtb am335x-boneblack-uboot.dts
-
Reboot
i2c-2 still 100KHz. Why?
debian@beaglebone:~$ dmesg | grep i2c
[ 1.617222] omap_i2c 44e0b000.i2c: could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c0_pins, deferring probe
[ 1.618167] omap_i2c 4802a000.i2c: bus 1 rev0.11 at 100 kHz
[ 1.619474] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[ 2.341082] i2c /dev entries driver
[ 2.572081] input: tps65217_pwr_but as /devices/platform/ocp/44e0b000.i2c/i2c-0/0-0024/input/input0
[ 2.598709] omap_i2c 44e0b000.i2c: bus 0 rev0.11 at 400 kHz
I am having the same issue with my BBB. Modifying the device tree with values that should run the I2C clock to 400 kHz does not seem to change the speed upon rebooting. I validated that the .dtb was modified by unpacking it into a .dts again to check if the value was 400 kHz.
Is this method of modifying the device tree not effective anymore in the latest images of Debian?
Check your serial boot log, are you booting what you expect?
Regards,
Heres the boot log:
https://pastebin.com/fgkRkCRv
It seems to say that the I2C busses are set at 100 kHz because “could not find pctldev for node /ocp/l4_wkup@44c00000/scm@210000/pinmux@800/pinmux_i2c2_pins”
I was on the IRC a little while ago and was told to modify the am335x-boneblack-uboot.dtb file instead as these newer releases are Uboot releases.
Doing so actually solved my issue of not being able to change the i2c frequency of i2c-2.
Big shout out to zmatt for the help!