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!


axi_iic driver issue

Posts: 173
Registered: ‎06-21-2013

axi_iic driver issue

Hi all,


I am using the linux-xlnx kernel version 4.0 via the meta-xilinx layer in yocto.  The hardware I am developing on has an axi_iic peripheral with a single slave microchip mcp23017 device on the I2C bus.  My associated device tree snippet is shown below.


axi_iic_0: axi_iic@70020000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "xlnx,xps-iic-2.00.a";
interrupt-parent = <&intc>;
interrupts = <0 31 4>;
reg = <0x70020000 0x4000>;
xlnx,family = "zynq";
xlnx,clk-freq = <100000000>;
xlnx,iic-freq = <100000>;
xlnx,scl-inertial-delay = <0x0>;
xlnx,sda-inertial-delay = <0x0>;
xlnx,ten-bit-adr = <0x0>;


&axi_iic_0 {
status = "okay";
gpio@20 {
compatible = "microchip,mcp23017";
#gpio-cells = <2>;
reg = <0x20>;


My associated kernel configuration for this device is




I have been following the example posted on http://www.wiki.xilinx.com/Linux+I2C+Driver and I am able to use the open and ioctl functions as per


int i2c_open (Xuint8 slaveAddress ) {
int Status;

if (pthread_mutex_init(&lock, NULL) != 0)
printf("\n mutex init failed\n");
return 1;
* Open the device.
Fdiic = open("/dev/i2c-1", O_RDWR);
if(Fdiic < 0)
printf("Cannot open the IIC device\n");

return 1;

if (ioctl(Fdiic, I2C_SLAVE, slaveAddress) < 0) {
/* ERROR HANDLING; you can check errno to see what went wrong */
return 1;

return 0;



The issue occurs when I try to use the close (), read () or write () functions.  What is strange is that these functions don't appear to be present in the associated <linux/i2c-dev.h> which may be the problem.  Eclipse gives me a warning that these are declared implicitly.  Which header file is used the define these functions?


The axi_iic appears as i2c-1 


Basic testing response below 


ls /dev/*i2c*
/dev/i2c-0 /dev/i2c-1


i2cdetect -l gives

i2c-0 i2c Cadence I2C at e0005000 I2C adapter
i2c-1 i2c xiic-i2c I2C adapter

And finally

i2cdetect -F 1
Functionalities implemented by /dev/i2c-1:
I2C yes
SMBus Quick Command yes
SMBus Send Byte yes
SMBus Receive Byte yes
SMBus Write Byte yes
SMBus Read Byte yes
SMBus Write Word yes
SMBus Read Word yes
SMBus Process Call yes
SMBus Block Write yes
SMBus Block Read no
SMBus Block Process Call no
SMBus PEC yes
I2C Block Write yes
I2C Block Read yes


I would be very grateful if anyone could provide me with some pointers regarding this issue.












Posts: 74
Registered: ‎12-03-2015

Re: axi_iic driver issue

There are two i2c-dev.h files. One is the kernel file and the other is from the i2c-tools module.

You have to include the i2c-tools module in the rootfs. This works for Petalinux v2015.4 and linux kernel 4.4.

Run: petalinux-config -c rootfs
Select: -> Filesystem Packages -> base -> i2c-tools

When you do petalinux-build, the I2C package will be downloaded and built into the rootfs. A new include file, i2c-dev-user.h, will be in the <proj-dir>/build/linux/rootfs/stage/usr/include/linux/ directory. This file  has all the i2c_smbus read and write functions in it.

The configuration parameters needed:

The kernel documentation is worth a read also: