Search code examples
linux-kernelembedded-linuxi2cimx6nxp-microcontroller

Linux I2C communication issues


I'm working on a custom board based on the iMX6Q processor which uses the linux-imx kernel 4.9.11 (http://git.freescale.com/git/cgit.cgi/imx/linux-imx.git/?h=imx_4.9.11_1.0.0_ga). However, when I send an I2C message to one of the peripherals (I have 4 slaves on the i2c-2 bus, the processor is the unique master) the following error arises from the controller:

[ 82.972843] i2c i2c-2: ioctl, cmd=0x703, arg=0x5c
[ 82.972854] i2c i2c-2: ioctl, cmd=0x720, arg=0x7ec06bbc
[ 82.972865] i2c i2c-2: master_xfer[0] R, addr=0x5c, len=1
[ 82.972871] i2c i2c-2: <i2c_imx_xfer>
[ 82.972877] i2c i2c-2: <i2c_imx_start>
[ 82.973053] i2c i2c-2: <i2c_imx_bus_busy>
[ 83.482804] i2c i2c-2: <i2c_imx_bus_busy> I2C bus is busy
[ 83.482810] i2c i2c-2: Trying i2c bus recovery
[ 83.482854] i2c i2c-2: <i2c_imx_start>
[ 83.483029] i2c i2c-2: <i2c_imx_bus_busy>
[ 83.992804] i2c i2c-2: <i2c_imx_bus_busy> I2C bus is busy
[ 83.992816] i2c i2c-2: <i2c_imx_xfer> exit with: error: -110

Taking a look over with the oscilloscope, I can see that the bus is high when in idle state (as expected). Nevertheless, when I try to begin a transfer the master sets the start condition on the bus, then, the bus remains low (both, SDA and SCL) until the transfer times out and the driver warns that the bus is busy with a timeout error (though it really isn't!). I know it is not a HW issue/bug, since I can manage to communicate via I2C through U-Boot (and older kernel versions, e.g. 4.1.15).

I have already checked the I2C kernel configuration and it seems to be okay. Also, the I2C bus controller is properly configured in the device tree.

PD: The default kernel configuration (imx_v7_defconfig) is not working.

Thank you!

Cheers,

Daniel


Solution

  • The issue has gone. I just had to change the i2c pin configuration (in the Device Tree) from 0x1b8b0 to 0x4001b8b1...It's still strange because those bits (Mask 0xFFFE0000) are marked as reserved in the iMX.6Q reference manual, though they seem not so reserved...In addition, the very same Device Tree file worked without problems with older Kernel versions...

    Whatever the case, it is working as expected right now!