I2C anyone? I didn't get it running

Hi,

well I’m not exactly a noob but the R2 frequently makes me feel like one. Just received a couple of tiny lcd-displays and level converters and wanted to play around a bit.

I activated I2C in config.txt and modprobed i2c-dev.

But now i2cdetect does not detect anything. Am I missing something?

  • which i2c do you want to use?
  • using the 40pin-gpio?
  • which kernel?

then you have to enable i2c in the dts(i), too…

https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/tree/arch/arm/boot/dts/mt7623.dtsi

	i2c0: i2c@11007000 {
		compatible = "mediatek,mt7623-i2c",
			     "mediatek,mt6577-i2c";
		reg = <0 0x11007000 0 0x70>,
		      <0 0x11000200 0 0x80>;
		interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_LOW>;
		clock-div = <16>;
		clocks = <&pericfg CLK_PERI_I2C0>,
			 <&pericfg CLK_PERI_AP_DMA>;
		clock-names = "main", "dma";
		#address-cells = <1>;
		#size-cells = <0>;
		status = "disabled";
	};

	i2c1: i2c@11008000 {
		compatible = "mediatek,mt7623-i2c",
			     "mediatek,mt6577-i2c";
		reg = <0 0x11008000 0 0x70>,
		      <0 0x11000280 0 0x80>;
		interrupts = <GIC_SPI 45 IRQ_TYPE_LEVEL_LOW>;
		clock-div = <16>;
		clocks = <&pericfg CLK_PERI_I2C1>,
			 <&pericfg CLK_PERI_AP_DMA>;
		clock-names = "main", "dma";
		#address-cells = <1>;
		#size-cells = <0>;
		status = "disabled";
	};

	i2c2: i2c@11009000 {
		compatible = "mediatek,mt7623-i2c",
			     "mediatek,mt6577-i2c";
		reg = <0 0x11009000 0 0x70>,
		      <0 0x11000300 0 0x80>;
		interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_LOW>;
		clock-div = <16>;
		clocks = <&pericfg CLK_PERI_I2C2>,
			 <&pericfg CLK_PERI_AP_DMA>;
		clock-names = "main", "dma";
		#address-cells = <1>;
		#size-cells = <0>;
		status = "disabled";
	};

if you have done that, you have to enable that in the dts for bananapi:

example for i2c0, do same for others

&i2c0 {
	status = "okay";
};

then look through your boot-log if device is found, you can use the number (e.g. 11007000 for i2c0) to find entry with grep in /var/log/messages

So after all, I have to recompile the kernel, which I’d like to avoid. And I do not understand why there is no sd-image with everything compiled in waiting to be enabled by config?

I have not tried it…it’s only a possibility…i have to enable uart like this way.

The problem is: if any of this special-functions enabled,the pins cannot be used as normal gpio…

Thank you much Frank. I’ll have to take a look. Maybe I was too early to order a R2. It’s a nice piece of hardware performing quite good. But I get the feeling the complete system is no more than an early alpha status. Shouldn’t there simply be a MTxxxx-i2c module???

I do appreciate your work very much, but I don’t feel like a kernel-programmer so I won’t be able to help much.

When I got my first Banana I was very excited about the price/performance ratio and everything worked out of the box. Maybe I expected to much.

as i said, the problem is not the module for i2c…that could be loaded later…the problem is the static dtb appended to kernel,that cannot be changed after build

Still being somehow disappointed, I solved the problem putting an Arduino in between :wink:

Can you send me the circuit and config/code via pm?

Should be on it’s way.

Hi Thomas

An I2C controller can be routed to different sets of gpio, below is the default configuration for I2C0, I2C1 and I2C2. For your problem, which I2C controller do you use? are there two pull-up resisters on both SCL and SDA signals?

i2c0_pins_a: i2c0@0 {
	pins1 {
		pinmux = <MT7623_PIN_75_SDA0_FUNC_SDA0>,
			 <MT7623_PIN_76_SCL0_FUNC_SCL0>;
		bias-disable;
	};
};

i2c1_pins_a: i2c1@0 {
	pins1 {
		pinmux = <MT7623_PIN_57_SDA1_FUNC_GPIO57>,
			 <MT7623_PIN_58_SCL1_FUNC_GPIO58>,
			 <MT7623_PIN_243_UCTS2_FUNC_SDA1>,
			 <MT7623_PIN_242_URTS2_FUNC_SCL1>;
		bias-disable;
	};
};

i2c2_pins_a: i2c2@0 {
	pins1 {
		pinmux = <MT7623_PIN_77_SDA2_FUNC_SDA2>,
			 <MT7623_PIN_78_SCL2_FUNC_SCL2>;
		bias-disable;
	};
};

I’m sorry, Gary, but this doesn’t help me much. But I am confident in waiting for an OS Image where I2C and things like that are configurable without the need to recompile the Kernel which I am not able to.

Thanks much for your good will. :slight_smile:

Hi Thomas

I think the i2c driver in Ubuntu image is available, after installing we can use i2c-dectect, i2c-get and i2c-set to operate i2c device which is connected one of I2C busses.

Hi Gary,

so I should load some module and things start working? What would I have to do?

Sorry for my stupid question :slight_smile:

Does i2c work without being activated in kernel or is it enabled in ubuntu-image?

Where is i2c2? Found only 0 and 1 on gpio