UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
3,046 Views
Registered: ‎03-22-2017

PS I2C problems in Linux

Hi All

 

I am trying to communicate with an I2C  ADC (ADS7828) on my MicroZED board via the supplied Linux (Kernel 3.8).

I am using the I2C-0 on MIO 14 and 15. I have setup the I2C device in Vivado.

I have testet the hardware in standalone, and everything is running fine.

 

I am running Xilinx 2016.4

 

My devicetree I2C entry:

 

ps7_i2c_1: ps7-i2c@e0004000 {
bus-id = <0>;
compatible = "xlnx,ps7-i2c-1.00.a";
i2c-clk = <400000>;
interrupt-parent = <1>;
interrupts = <0 48 4>;
reg = <0xe0004000 0x1000>;
xlnx,has-interrupt = <0x0>;
xlnx,i2c-reset = "<Select>";
#address-cells = <1>;
#size-cells = <0>;
adc@48 {
  compatible = "ADS,ADS7828";
  reg = <0x48>;
};

I have the entry i dev: /dev/i2c-0 and if I run 'i2cdetect -l' i get:

 

 

i2c-0   i2c             XILINX I2C at e0004000                  I2C adapter

My test code:

 

 

  printf ("Open\n");
  if ((I2C_Device = open("/dev/i2c-0", O_RDWR)) < 0)
  {
    printf("Cannot Open I2C Master Device\n");
    exit(1);
  }

  printf ("Set address\n");
  if (ioctl (I2C_Device, I2C_SLAVE, ADC_ADDR) < 0)
  {
    printf("Cannot set I2C address\n");
    exit(1);
  }

  printf ("Write\n");
  Adc_Addr = 0x8CU;
  if (write (I2C_Device, &Adc_Addr, 1) != 1)
  {
    printf("I2C write failed\n");
    exit(1);
  }
  close (I2C_Device);

  printf ("Done!\n");

My problem is in Linux, when I try to write a value to the I2C device the code locks up and nothing happens on the pins.

 

Thanks!

 

0 Kudos
2 Replies
Moderator
Moderator
2,985 Views
Registered: ‎07-31-2012

Re: PS I2C problems in Linux

Hi,

 

Looks like switch is missing in in device tree.

Could you refer to http://www.wiki.xilinx.com/Cadence+I2C+Driver ?

 

Regards

Praveen


-------------------------------------------------------------------------
Don’t forget to reply, kudo, and accept as solution.
-------------------------------------------------------------------------
0 Kudos
Highlighted
2,931 Views
Registered: ‎03-22-2017

Re: PS I2C problems in Linux

Thanks for the answer!

 

I have tried:

-Add a switch to the device tree.

-Remove the i2c adc device from the device tree.

 

Nothing seems to help. I have alsp tried to run 

zynq> i2cdetect -r 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
0 1 2 3 4 5 6 7 8 9 a b c d e f
00:

in both device tree cases, the command locks up and i have to ctrl-c to stop the execution. And nothing happens on the SDA and SCL lines.

0 Kudos