cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
simozz
Mentor
Mentor
395 Views
Registered: ‎05-14-2017

Linux I2C driver

Hello,

I am trying to use PS I2C on an UltraZED SOM, Linux OS, but I can't see any signal on SDA and SCL lines when I try to read or write from it.

The I2C is enabled from Vivado

Screenshot_2020-12-09_16-31-15.png

From petalinux default generated device-tree, I2C0 is linked to I2C1:

Screenshot_2020-12-09_16-32-56.png

in fact, i2cdetect tool detects the I2C controller as i2c0:

Screenshot_2020-12-09_16-35-02.png

The default I2C1 (enabled on Vivado) DT is the following:

		i2c1: i2c@ff030000 {
			compatible = "cdns,i2c-r1p14", "cdns,i2c-r1p10";
			status = "disabled";
			interrupt-parent = <&gic>;
			interrupts = <0 18 4>;
			reg = <0x0 0xff030000 0x0 0x1000>;
			#address-cells = <1>;
			#size-cells = <0>;
			power-domains = <&zynqmp_firmware 38>;
		};

 

Is it needed to add something more to the device-tree code to work with I2C on PS ?

pinctrl is not declared for it. Could it be the root of the problem ?

Any hint ?

Thanks.

s.

0 Kudos
4 Replies
patocarr
Teacher
Teacher
375 Views
Registered: ‎01-28-2008

Hi @simozz 

  I had to add a clock frequency property to the I2C entry in the devicetree, to have the Cadence driver respond properly. Before this, no devices would show up on the i2cdetect -r  command. I did not need the pinctrl.

&i2c0 {
  status = "okay";
  clock-frequency = <100000>;
};

 

Thanks,

-Pat

Give kudos if helpful. Accept as solution if it solves your problem.
https://tuxengineering.com/blog

simozz
Mentor
Mentor
354 Views
Registered: ‎05-14-2017

Hello @patocarr,

>> I did not need the pinctrl.

Thanks for the info.

Actually, the i2c status okay and clock frequency are set in pcw.dtsi (automatically included from system-top.dts). I forgot to mention it in my 1st post.

s.

 

Tags (3)
0 Kudos
patocarr
Teacher
Teacher
309 Views
Registered: ‎01-28-2008

Hi @simozz 

  This one should be quite obvious to mention, but I2C needs pull-ups on sda and scl in order to work. Just making sure you've checked it.

Thanks,

-Pat

 

Give kudos if helpful. Accept as solution if it solves your problem.
https://tuxengineering.com/blog

0 Kudos
simozz
Mentor
Mentor
247 Views
Registered: ‎05-14-2017

Hello @patocarr ,

Of course I have the pull up resistor on both lines.

s.

0 Kudos