1. Edited the xillinux-zedboard.dts file to recompile the device tree with following i2c information.
- Code: Select all
i2c0: i2c@e0004000 {
compatible = "xlnx,ps7-i2c-1.00.a"; // calls out a xlnx driver already present in xillinux
reg = <0xE0004000 0x1000>; // memory address and size, fixed by Zynq HW for I2C0
bus-id = <0>;
clocks = <&clkc 38>; // ref to sys clk #38 = I2C clock. Simply <4000000> didn’t work
i2c-clk = <100000>; // 100kHz standard slow I2C
interrupt-parent = <&ps7_scugic_0>;
interrupts = <0 25 4>;
#address-cells = <1>; //default
#size-cells = <0>; // default
};
2. Installed i2c-tools using following command:
- apt-get install i2c-tools
3. The part of program developed to access the i2c was as follows:
- Code: Select all
char *fname = "/dev/i2c-0";
Fdiic = open(fname, O_RDWR);
printf ("Fdiic = %d",Fdiic);
if(Fdiic < 0) {
printf("\nError initializing IIC");
return -1;
}
Status = ioctl(Fdiic, I2C_SLAVE, ltc2657_address>>0);
if(Status < 0) {
printf("\n Unable to set the address\n");
return -1;
}
The execution gives error as:
- Code: Select all
Fdiic = -1
Error initializing IIC
4. The /dev contains i2c-0 files has following permission:
- crw------- 1 root root 89, 0 Feb 11 16:30 i2c-0
crw-rw---- 1 root i2c 89, 1 Feb 11 16:30 i2c-1
crw-rw---- 1 root i2c 89, 2 Feb 11 16:30 i2c-2
crw-rw---- 1 root i2c 89, 3 Feb 11 16:30 i2c-3
crw-rw---- 1 root i2c 89, 4 Feb 11 16:30 i2c-4
crw-rw---- 1 root i2c 89, 5 Feb 11 16:30 i2c-5
crw-rw---- 1 root i2c 89, 6 Feb 11 16:30 i2c-6
crw-rw---- 1 root i2c 89, 7 Feb 11 16:30 i2c-7
- crw-rw-rw- 1 root root 89, 0 Feb 11 16:30 i2c-0
crw-rw-rw- 1 root i2c 89, 1 Feb 11 16:30 i2c-1