Skip to contentSkip to conversation

Usage of i2c_-Tools in Barebox

DISCUSSION Marcel Behlau 3 participants 7 messages May 5, 2015 – May 22, 2015

lore
Share & tools
lore
#0 lore raw

Hi,

i'm using a phyFLEX-i.MX6 SBC and want to communicate with an external µC over I2C. I only want to read/set 1 register, so i tried to use the builtin i2c_read and i2c_write-Commands. The µC is connected to i2c-bus 1 of the device, so i tried to probe the hole bus with "i2c_bus 1 3 30". The command only answered with "i2c_probe: No such device". I tried also the busses 0-3, with the same result. I searched in the board.c sourcecode of the phyflex, but couldn't find i2c related stuff, so i think, i have to add the initalisation for the i2c.

Do i have to add the i2c-init in the boards/phytec-pfla02/board.c -file? Is there some documenation about this stuff?

Thank in advance,

Marcel

Signature · 18 lines
Dipl. Ing (FH) Marcel Behlau
(Software Developer)

ELFIN GmbH
Siegburger Straße 215
50679 Köln
Germany

Tel: +49 (221) 6778932-0
Fax: +49 (221) 6778932-2
[email protected]
www.elfin.de


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

Hi Marcel,

Quoted 12 lines · Marcel Behlau

Hi,

i'm using a phyFLEX-i.MX6 SBC and want to communicate with an external µC over I2C. I only want to read/set 1 register, so i tried to use the builtin i2c_read and i2c_write-Commands. The µC is connected to i2c-bus 1 of the device, so i tried to probe the hole bus with "i2c_bus 1 3 30". The command only answered with "i2c_probe: No such device". I tried also the busses 0-3, with the same result. I searched in the board.c sourcecode of the phyflex, but couldn't find i2c related stuff, so i think, i have to add the initalisation for the i2c.

Quoted 2 lines

Do i have to add the i2c-init in the boards/phytec-pfla02/board.c -file? Is there some documenation about this stuff?

The phyFLEX board is device tree based. You have to enable the i2c controller in the dts file (same as you would do in the kernel). Usually a:

&i2c0 {
	status = "okay";
};

Should be enough. You probably also have to add the proper pinctrl node.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hello,

Quoted 18 lines · Sascha Hauer
Quoted 10 lines · Marcel Behlau

i'm using a phyFLEX-i.MX6 SBC and want to communicate with an external µC over I2C. I only want to read/set 1 register, so i tried to use the builtin i2c_read and i2c_write-Commands. The µC is connected to i2c-bus 1 of the device, so i tried to probe the hole bus with "i2c_bus 1 3 30". The command only answered with "i2c_probe: No such device". I tried also the busses 0-3, with the same result. I searched in the board.c sourcecode of the phyflex, but couldn't find i2c related stuff, so i think, i have to add the initalisation for the i2c.

Quoted 2 lines

Do i have to add the i2c-init in the boards/phytec-pfla02/board.c -file? Is there some documenation about this stuff?

The phyFLEX board is device tree based. You have to enable the i2c controller in the dts file (same as you would do in the kernel). Usually a:

Quoted 5 lines
&i2c0 {
	status = "okay";
};

Should be enough. You probably also have to add the proper pinctrl node.

and enable the i2c driver. You might want to check the output of devinfo.

Best regards
Uwe

Signature · 7 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Hi,

many thanks for your help. I activated the i2c devices in the device tree, the pinctrl is already done in the imx6q.dtsi, which is included. The used pins are identically with the used pins on the SBC. devinfo told me, that the driver "i2c-fsl" is loaded. After rebuild barebox, it's possible to probe the bus, but the command only answered with an timeout:

barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ i2c_probe 1 83 83 probing i2c range 0x53 - 0x53 :
i2c2: <i2c_fsl_bus_busy> timeout waiting for I2C bus busy

I'm using barebox-2013.08.0, which is provided by the phytec-bsp.

Thanks in advance,

Marcel

Quoted 31 lines · Uwe Kleine-König

Hello,

Quoted 17 lines · Sascha Hauer
Quoted 10 lines · Marcel Behlau

i'm using a phyFLEX-i.MX6 SBC and want to communicate with an external µC over I2C. I only want to read/set 1 register, so i tried to use the builtin i2c_read and i2c_write-Commands. The µC is connected to i2c-bus 1 of the device, so i tried to probe the hole bus with "i2c_bus 1 3 30". The command only answered with "i2c_probe: No such device". I tried also the busses 0-3, with the same result. I searched in the board.c sourcecode of the phyflex, but couldn't find i2c related stuff, so i think, i have to add the initalisation for the i2c.

Quoted 2 lines

Do i have to add the i2c-init in the boards/phytec-pfla02/board.c -file? Is there some documenation about this stuff?

The phyFLEX board is device tree based. You have to enable the i2c controller in the dts file (same as you would do in the kernel). Usually a:

Quoted 5 lines
&i2c0 {
	status = "okay";
};

Should be enough. You probably also have to add the proper pinctrl node.

and enable the i2c driver. You might want to check the output of devinfo.

Best regards
Uwe

Signature · 18 lines
Dipl. Ing (FH) Marcel Behlau
(Software Developer)

ELFIN GmbH
Siegburger Straße 215
50679 Köln
Germany

Tel: +49 (221) 6778932-0
Fax: +49 (221) 6778932-2
[email protected]
www.elfin.de


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 9 lines · Marcel Behlau

Hi,

many thanks for your help. I activated the i2c devices in the device tree, the pinctrl is already done in the imx6q.dtsi, which is included. The used pins are identically with the used pins on the SBC. devinfo told me, that the driver "i2c-fsl" is loaded. After rebuild barebox, it's possible to probe the bus, but the command only answered with an timeout:

Quoted 3 lines

barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ i2c_probe 1 83 83 probing i2c range 0x53 - 0x53 :
i2c2: <i2c_fsl_bus_busy> timeout waiting for I2C bus busy

I *think* this means that the levels on the bus do not properly follow what the controller wants to do. Maybe pullup missing? An oscilloscope might help here.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

Hi,

i found the problem. The Pad Mux Register (0x20E008C and 0x20E0090) are not initialised. In both registers is a 0x00000005 (reset value), instead of 0x00000016. I think, i must specify the value of the mux register in the device tree, too. How can i do this?

Thank in advance,

Marcel

md 0x20E008C-0x20E0093

Quoted 19 lines · Sascha Hauer
Quoted 9 lines · Marcel Behlau

Hi,

many thanks for your help. I activated the i2c devices in the device tree, the pinctrl is already done in the imx6q.dtsi, which is included. The used pins are identically with the used pins on the SBC. devinfo told me, that the driver "i2c-fsl" is loaded. After rebuild barebox, it's possible to probe the bus, but the command only answered with an timeout:

Quoted 3 lines

barebox@Phytec phyFLEX-i.MX6 Quad Carrier-Board:/ i2c_probe 1 83 83 probing i2c range 0x53 - 0x53 :
i2c2: <i2c_fsl_bus_busy> timeout waiting for I2C bus busy

I *think* this means that the levels on the bus do not properly follow what the controller wants to do. Maybe pullup missing? An oscilloscope might help here.

Sascha

Signature · 18 lines
Dipl. Ing (FH) Marcel Behlau
(Software Developer)

ELFIN GmbH
Siegburger Straße 215
50679 Köln
Germany

Tel: +49 (221) 6778932-0
Fax: +49 (221) 6778932-2
[email protected]
www.elfin.de


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw
Quoted 6 lines · Marcel Behlau

Hi,

i found the problem. The Pad Mux Register (0x20E008C and 0x20E0090) are not initialised. In both registers is a 0x00000005 (reset value), instead of 0x00000016. I think, i must specify the value of the mux register in the device tree, too. How can i do this?

You have to add a pinctrl node, like this:

&iomuxc {
	imx6s-riotboard {
		pinctrl_i2c1_2: i2c1grp-2 {
			fsl,pins = <
				MX6QDL_PAD_EIM_EB2__I2C2_SCL 0x4001b8b1
				MX6QDL_PAD_EIM_D16__I2C2_SDA 0x4001b8b1
			>;
		};
	};
};

...

&i2c1 {
	pinctrl-0 = <&pinctrl_i2c1_2>;
};

See dts/Bindings/pinctrl/fsl,imx-pinctrl.txt and dts/Bindings/pinctrl/fsl,imx6q-pinctrl.txt for a documentation what the 0x4001b8b1 value means. In short bit30 is for the SION bit and the remaing bits are for the PAD_CTL register.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox