MX6 i2C linux driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MX6 i2C linux driver

3,833 Views
karstenklein
Contributor I

Hi all,

I currently work with the MCIMMX6Q-SDB board from Freescale. The kernel is taken from Yocto/Dylan core-image-base as it is, without change in config.

I tried to write a small userspace-application which uses the accelerator MMA8451 via I2C.

I figured out how the MMA is connected to the CPU and tried to do the following:

dev = open ("/dev/i2c-0", O_RDWR);   

   

    if (dev < 0) {

   err = errno;
   perror("==> ERROR  open:");  
   printf("errno = %d\n", err);
   close(dev);
   exit (1);

    }

   

    if (ioctl(dev, I2C_SLAVE, I2C_DEV_ADR_MMA8451) < 0) {

   err = errno;
   perror("==> Error ioctl:");  
   printf("errno = %d\n", err);
   close(dev);  
   exit (1);

    }

The syscall ioclt comes up with the following error;

==> Error ioctl:: Device or resource busy

errno = 16

If I use

if (ioctl(dev, I2C_SLAVE_FORCE, I2C_DEV_ADR_MMA8451) < 0) {

instead, the I2C basicly works.

After some search, I found the following:

root@imx6qsabresd:/sys/devices/virtual/input/input3# cat name

mma845x

So this makes me thinking, that there is a virtual device driver in the system which uses the i2c-driver as well.

But I cant find any informations about this.

Does anyone have experience on that ?

Best regards

Karsten

Tags (4)
0 Kudos
3 Replies

1,151 Views
YixingKong
Senior Contributor IV

Klein

This discussion is closed since no activity. If you still need help, please feel free to reply with an update to this discussion, or create another discussion.

Thanks,

Yixing

0 Kudos

1,151 Views
YixingKong
Senior Contributor IV

Klein

Had your issue got resolved? If yes, we are going to close the discussion in 3 days. If you still need help, please feel

free to reply with an update to this discussion.

Thanks,
Yixing

0 Kudos

1,151 Views
raymondwang
Senior Contributor I

If your register i2c device with same address in board init,userland /dev/i2c-x access will report device busy.

See details in drivers/i2c/i2c-dev.c

/* NOTE:  devices set up to work with "new style" drivers

  * can't use I2C_SLAVE, even when the device node is not

  * bound to a driver.  Only I2C_SLAVE_FORCE will work.

  *

  * Setting the PEC flag here won't affect kernel drivers,

  * which will be using the i2c_client node registered with

  * the driver model core.  Likewise, when that client has

  * the PEC flag already set, the i2c-dev driver won't see

  * (or use) this setting.

  */

  if ((arg > 0x3ff) ||

     (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f))

  return -EINVAL;

  if (cmd == I2C_SLAVE && i2cdev_check_addr(client->adapter, arg))

  return -EBUSY;

  /* REVISIT: address could become busy later */

  client->addr = arg;

0 Kudos