Enable i2c-4 on Apalis Imx8QM (pins 251/253)

We are using the additional Apalis I2C port on pins 251/253 on a custom carrier board. We have used the port in the past with the older BSP (pre 5.0). I am having trouble getting the port to enumerate in Linux with the newer BSP >5.0. I am testing my devicetree modifications on the IXORA carrier board. My customized DTB builds fine, the device boots, and there are no I2C error messaged in the boot log. But there is no indication that the additional I2C port attempted to enumerate.

Here are my Device tree modifications to imx8qm-apalis-ixora-v1.1.dtsi

&dma_subsys{
	i2c4_lpcg: clock-controller@5ac40000 {
		compatible = "fsl,imx8qxp-lpcg";
		reg = <0x5ac40000 0x10000>;
		#clock-cells = <1>;
		clocks = <&clk IMX_SC_R_I2C_4 IMX_SC_PM_CLK_PER>,
			 <&dma_ipg_clk>;
		bit-offset = <0 16>;
		clock-output-names = "i2c4_lpcg_clk",
				     "i2c4_lpcg_ipg_clk";
		power-domains = <&pd IMX_SC_R_I2C_4>;
	};

	i2c4: i2c@5a840000 {
		reg = <0x5a840000 0x4000>;
		interrupts = <GIC_SPI 224 IRQ_TYPE_LEVEL_HIGH>;
		interrupt-parent = <&gic>;
		clocks = <&i2c4_lpcg 0>,
			 <&i2c4_lpcg 1>;
		clock-names = "per", "ipg";
		assigned-clocks = <&clk IMX_SC_R_I2C_4 IMX_SC_PM_CLK_PER>;
		assigned-clock-rates = <24000000>;
		power-domains = <&pd IMX_SC_R_I2C_4>;
		status = "disabled";
	};
};

&iomuxc {
apalis-imx8qm {
	pinctrl_lpi2c4: lpi2c4grp {
		fsl,pins = <
			IMX8QM_ENET1_MDC_DMA_I2C4_SCL           0xc600004c
			IMX8QM_ENET1_MDIO_DMA_I2C4_SDA          0xc600004c
		>;
	};
};
};  

&i2c4 {
#address-cells = <1>;
#size-cells = <0>;
clock-frequency = <100000>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpi2c4>;
status = "okay";
};

The system boot and I do not see any I2C errors
The new device is in /proc/device-tree

 root@apalis-imx8:/proc/device-tree/bus@5a000000/i2c@5a840000# ls
    #address-cells        assigned-clocks  clocks            name           power-domains
    #size-cells           clock-frequency  interrupt-parent  pinctrl-0      reg
    assigned-clock-rates  clock-names      interrupts        pinctrl-names  status
    root@apalis-imx8:/proc/device-tree/bus@5a000000/i2c@5a840000# cat status
    okay

But I do not see anything enumerated in the /dev or with i2cdetect

root@apalis-imx8:~# i2cdetect -l
i2c-3   i2c             5a810000.i2c                            I2C adapter
i2c-4   i2c             5a820000.i2c                            I2C adapter
i2c-2   i2c             5a800000.i2c                            I2C adapter
i2c-5   i2c             5a830000.i2c                            I2C adapter
root@apalis-imx8:~#

Any insights as to what I am missing would be greatly appreciated.

Thanks

I found this post

Which looks like the original post might apply to my problem. Unfortunately I can not access the original post and response.

(https://www.toradex.com/community/questions/56756/enabling-i2c4-i2c-6-in-apalis-11b.html?childToView=56838#answer-56838)

When I click on the like it say “Access denied”

Hi @mccandlt,

Some users may post their queries as private, depending on how they want to handle the support.

Please, confirm precisely:

  • Which version of the BSP 5.0 are you using.
  • Which version of Ixora carrier board are you using.

Then, while the original post is still private, try its solution to see if it will work for you.

From @jeremias.tx:

I think I believe I found the problem after digging into the kernel source. The following line from your dmesg was the vital clue I needed: i2c4_clk: failed to attached the power domain -2.

I took a look at the power domain driver for the i.MX8 and it turns out that by default for each interface like I2C only a certain amount of interfaces are allowed by default. For the lpi2c interface this maximum amount is 4. Which is why when you tried to add the 5th I2C with i2c4 it fails to attach a power domain properly which causes it to then fail as you saw.

So I simply increased this maximum amount for lpi2c from 4 to 5 in the driver at this line: scu-pd.c « imx « firmware « drivers - linux-toradex.git - Linux kernel for Apalis, Colibri and Verdin modules

I then did a test build and tada it seemed to work:

root@apalis-imx8:~# dmesg | grep i2c
[    0.723264] i2c /dev entries driver
[    0.988380] imx-lpi2c 5a800000.i2c: can't get pinctrl, bus recovery not supported
[    0.988611] i2c i2c-2: LPI2C adapter registered
[    1.032102] i2c i2c-3: LPI2C adapter registered
[    1.035623] i2c i2c-4: LPI2C adapter registered
[    1.036614] i2c i2c-5: LPI2C adapter registered
[    1.037638] i2c i2c-6: LPI2C adapter registered
[    1.283677] debugfs: Directory 'mipi1-i2c1' with parent 'pm_genpd' already present!
[    1.291437] debugfs: Directory 'mipi1-i2c0' with parent 'pm_genpd' already present!
root@apalis-imx8:~# ls -l /dev/i2c-*
crw-------    1 root     root       89,   2 Nov 14 06:31 /dev/i2c-2
crw-------    1 root     root       89,   3 Nov 14 06:31 /dev/i2c-3
crw-------    1 root     root       89,   4 Nov 14 06:31 /dev/i2c-4
crw-------    1 root     root       89,   5 Nov 14 06:31 /dev/i2c-5
crw-------    1 root     root       89,   6 Nov 14 06:31 /dev/i2c-6

Please note I haven’t tested this too thoroughly so I’m unsure if there’s any adverse effects due to the change I made in the power domain driver. But so far it seems stable.

Anyways here’s the full diff/patch of the changes I did to bring up i2c4 in the Linux kernel, for your reference: link text .

I hope this works for you as well, let me know if you experience any unforeseen issues with the changes and we can take a closer look.

Best Regards,
Jeremias

Please let us know if it worked for you.

Best regards,
André Curvello

André,

This Link you suggested fixed my problem:
root@apalis-imx8:~# i2cdetect -l
i2c-3 i2c 5a810000.i2c I2C adapter
i2c-6 i2c 5a840000.i2c I2C adapter
i2c-4 i2c 5a820000.i2c I2C adapter
i2c-2 i2c 5a800000.i2c I2C adapter
i2c-5 i2c 5a830000.i2c I2C adapter

i2c-6 above is the I2C4 on Apalis pins 251/253.

Thank You Very Much!

Regards,
Brian Weir

Thanks for update!

Thank you. This looks like it is working.

-Todd

Perfect. Thanks for the update.