Customized I2C not detected

Dear all,

I followed this guideline:

and I created a new dtb where I introduced a new i2c2 device:

Unfortunately I still have no new i2c device detected using i2cdetect -l and looking the dmesg (which I attached).
The error showed is:

[    0.121913] imx7d-pinctrl 302c0000.iomuxc-lpsr: unable to find group for node i2c2grp
[    0.121965] imx-i2c: probe of 30a30000.i2c failed with error -22 

I read this documentation
http://git.toradex.com/cgit/linux-toradex.git/tree/Documentation/devicetree/bindings/pinctrl?h=toradex_4.14-2.0.x-imx
But looks like settings is correct.
Have you got any idea about the above i2c failure issue?
Thanks in advance

link text

You need to create pinctrl_i2c2 group. Please check how it’s done for pinctrl_i2c1

    pinctrl_i2c1: i2c1-grp {
		fsl,pins = <
			MX7D_PAD_LPSR_GPIO1_IO05__I2C1_SDA	0x4000007f
			MX7D_PAD_LPSR_GPIO1_IO04__I2C1_SCL	0x4000007f
		>;
	};

Alex, thank you for the comment. Nevertheless I didn’t get the point.
Whether you refer to this part of code. Both i2c2grp and i2c1-grp are not created there.But it was created before, otherwise there was an error during compilation time. Or am I wrong?

Dear @andreat

I think you would need to add an entry that looks as follows:

&i2c2 {
	clock-frequency = <100000>;
	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_i2c2>;
	pinctrl-1 = <&pinctrl_i2c2_recovery>;
	scl-gpios = <&gpio4 10 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
	sda-gpios = <&gpio4 11 (GPIO_ACTIVE_HIGH | GPIO_OPEN_DRAIN)>;
};

&iomuxc_lpsr {
	pinctrl_i2c2: i2c2-grp {
		fsl,pins = <
			MX7D_PAD_I2C2_SDA__I2C2_SDA		0x4000007f
			MX7D_PAD_I2C2_SCL__I2C2_SCL		0x4000007f
		>;
	};

	pinctrl_i2c2_recovery: i2c2-grp {
		fsl,pins = <
			MX7D_PAD_I2C2_SDA__GPIO4_IO11   0x4000007f
			MX7D_PAD_I2C2_SCL__GPIO4_IO10	0x4000007f
		>;
	};
};

The first line enables i2c2. The two pinctrl entries then configure the pinmuxing of the specific pins. Normally pinctrl_i2c2 is used (default) if the bus needs to recover the pinctrl_i2c2_recovery settings are used. In the later scenario it basically configures the pins as GPIO to do the recovery.

I hope this helps.

Regards,
Stefan

Thanks Stefan, unfortunately the code which you posted didn’t work on my board.

Below my solution. Let me know if you think could be optimized.

&i2c2 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c2>;
        clock-frequency = <100000>;
        status = "okay";
};

&iomuxc_lpsr  {
        compatible = "fsl,imx7d-iomuxc-lpsr";
        reg = <0x302c0000 0x10000>;
        fsl,input-sel = <&iomuxc>;
        pinctrl_i2c2: i2c2grp {
                fsl,pins = <
                MX7D_PAD_GPIO1_IO06__I2C2_SCL      0x4000007f
                MX7D_PAD_GPIO1_IO07__I2C2_SDA      0x4000007f
                >;
        };
};

Hi @andreat

What exactly did not work?
Do you have any error log?

For the optimization of your code, you can delete the lines 9-11, since they are already included in the file imx7s.dtsi.

Best regards,
Jaski

What exactly did not work?
Do you have any error log?
Simply Stefan snippet code didn’t find the new i2c. You can try on a Colibri Evaluation Board V3 and add a new device on i2c2 bus.
I already provided my working solution.
It is correct that lines 9-11 are already included and I cut out them, thanks.

Perfect that it works. Thanks for feedback.

Best regards,
Jaski