xBiohazardx
Posts: 1
Joined: Tue Apr 27, 2021 2:00 pm

CM3+ cant use i2c0 on GPIO 28&29

Wed May 12, 2021 10:31 am

Hello,

I am using a CM3+ with 2 devices on the i2c0 bus, which is on GPIO 28 and 29. As in the datasheet of the CM specified, the ALT0 function of these pins is SDA0 and SCL0.

Enabling dtparam=i2c_vc=on in /boot/config.txt creates the i2cdetect entries: i2c-11, i2c-10, i2c-0
If I run i2cdetect -y 10 my i2c devices get detected.

I don't want to use this multiplexed i2c bus. So I added dtoverlay=i2c0,pins_28_29 to use the i2c0 bus on GPIO 28 and 29 and removed dtparam=i2c_vc=0n, because /boot/overlays/README states that I shoudnt use dtparam=i2c_vc=on and dtoverlay=i2c0 simultaneously:
Change i2c0 pin usage. Not all pin combinations are usable on all
platforms - platforms other then Compute Modules can only use this
to disable transaction combining.
Do NOT use in conjunction with dtparam=i2c_vc=on. From the 5.4 kernel
onwards the base DT includes the use of i2c_mux_pinctrl to expose two
muxings of BSC0 - GPIOs 0&1, and whichever combination is used for the
camera and display connectors. This overlay disables that mux and
configures /dev/i2c0 to point at whichever set of pins is requested.
dtparam=i2c_vc=on will try and enable the mux, so combining the two
will cause conflicts.
But raspi-gpio get doesnt show that the bus is on GPIO 28&29:

Code: Select all

GPIO 28: level=1 fsel=0 func=INPUT
GPIO 29: level=1 fsel=0 func=INPUT
The i2c-11, i2c-10 entries aren't shown anymore. If I now run

Code: Select all

 i2cdetect -y 0 
it runs pretty slowly, probably because of pin timeouts and doesn't detect my devices.

The relevant part of

Code: Select all

vcdbg log msg
shows that the overlay file is beiing loaded:
dtdebug: Opened overlay file 'overlays/i2c0.dtbo'
005526.557: brfs: File read: /mfs/sd/overlays/i2c0.dtbo
005540.895: Loaded overlay 'i2c0'
005540.913: dtparam: pins_28_29=1
005541.221: dtdebug: found override pins_28_29
005543.624: dtdebug: fragment 1 disabled
005544.678: dtdebug: fragment 3 disabled
005544.778: dtdebug: fragment 4 disabled
005544.876: dtdebug: fragment 5 disabled
005551.673: dtdebug: merge_fragment(/soc/i2c@7e205000,/fragment@0/__overlay__)
005551.700: dtdebug: +prop(status)
005552.325: dtdebug: +prop(pinctrl-0)
005553.038: dtdebug: merge_fragment() end
005553.138: dtdebug: fragment 1 disabled
005558.041: dtdebug: merge_fragment(/soc/gpio@7e200000/i2c0,/fragment@2/__overlay__)
005558.069: dtdebug: +prop(brcm,pins)
005558.701: dtdebug: +prop(brcm,function)
005559.345: dtdebug: merge_fragment() end
005559.447: dtdebug: fragment 3 disabled
005559.549: dtdebug: fragment 4 disabled
005559.646: dtdebug: fragment 5 disabled
005565.724: dtdebug: merge_fragment(/soc/i2c0mux,/fragment@6/__overlay__)
005565.751: dtdebug: +prop(status)
005566.361: dtdebug: merge_fragment() end
005566.794: dtdebug: merge_fragment(/aliases,/fragment@7/__overlay__)
005566.818: dtdebug: +prop(i2c0)
005567.756: dtdebug: merge_fragment() end
005568.521: brfs: File read: 1651 bytes
So why aren't GPIO 28 & 29 defined as SDA and SCL?

uname -a:
Linux raspberrypi 5.10.31-v7+ #1412 SMP Wed Apr 21 15:44:09 BST 2021 armv7l GNU/Linux
Thank you for your help

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11209
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM3+ cant use i2c0 on GPIO 28&29

Wed May 12, 2021 3:44 pm

It looks like we've missed out a

Code: Select all

pinctrl-names = "default";
from the i2c0if when switching back to "no mux" mode.

The patch

Code: Select all

--- a/arch/arm/boot/dts/overlays/i2c0-overlay.dts
+++ b/arch/arm/boot/dts/overlays/i2c0-overlay.dts
@@ -8,6 +8,7 @@
                target = <&i2c0if>;
                __overlay__ {
                        status = "okay";
+                       pinctrl-names = "default";
                        pinctrl-0 = <&i2c0_pins>;
                };
        };
seems to fix it for me on a CM4 with pins_44_45 (28&29 are used by ethernet on CM4).
I'll sort a PR.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 11209
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: CM3+ cant use i2c0 on GPIO 28&29

Wed May 12, 2021 4:36 pm

Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Device Tree”