This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux: I2C driver with polling management



Tool/software: Linux

Hello,

I have a question related to the topic that I mentioned some time ago: e2e.ti.com/.../

I have an AM335x CPU and I want to provide support for SMBus BlockRead, i.e. I2C_M_RECV_LEN flag in Linux environment.

I tried to use GPIO driver, but for some reason, my slave chip does not respond with ACK when I use GPIO driver for I2C. I temporarily connected two other slave devices on the same bus (pins) and they ACKed properly...


I also tried to implement polling mechanism into the i2c-omap.c driver in my Kernel (3.14.39), but I have few questions to TI experts about the requirements that I have to fulfill in order to get it working as expected.

1. At first, in the currently implemented IRQ-driven I2C transmission, the FIFOs are configured for a certain length. Please correct me if I am wrong, but the FIFO length cannot be changed in the middle of I2C transaction. Does this apply also when I want to use polling management?

2. Do I have to disable all interrupts, or is it enough if I just disable RRDY and ARDY interrupts and poll for them? In such approach, the NACK or any other interrupt would be handled as it is now, in the interrupt handler function. Is it correct, or should I also handle for example NACK interrupt in my polling loop?

3. Has TI tried to implement the polling mechanism in I2C Linux driver? If so, is it available somewhere?

Best regards,

Rafal Fabich

  • Hi Rafal,

    1. At first, in the currently implemented IRQ-driven I2C transmission, the FIFOs are configured for a certain length. Please correct me if I am wrong, but the FIFO length cannot be changed in the middle of I2C transaction. Does this apply also when I want to use polling management?

    I think your understanding is correct. I am not sure if it is advisable to change the FIFO length during i2c transaction.

    2. Do I have to disable all interrupts, or is it enough if I just disable RRDY and ARDY interrupts and poll for them? In such approach, the NACK or any other interrupt would be handled as it is now, in the interrupt handler function. Is it correct, or should I also handle for example NACK interrupt in my polling loop?

    See Section 21.3.14.2 FIFO Polling Mode Operation:
    "In FIFO polled mode (I2C_IRQENABLE_SET.XRDY_IE and I2C_IRQENABLE_SET.RRDY_IE disabled
    and DMA disabled)"
    The XRDY_IE, RRDY_IE & DMA need to be disabled.

    3. Has TI tried to implement the polling mechanism in I2C Linux driver? If so, is it available somewhere?

    No, I am not aware of such driver.. You could check the RTOS, to see if it has the I2C polling integrated.

    Hope this helps.

    Best Regards,
    Yordan