Skip to content

Linux I2C Driver unable to read register in adt7420 #2518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jmacagba opened this issue Apr 1, 2025 · 1 comment
Open

Linux I2C Driver unable to read register in adt7420 #2518

jmacagba opened this issue Apr 1, 2025 · 1 comment

Comments

@jmacagba
Copy link

jmacagba commented Apr 1, 2025

In both linux_i2c_read and linux_i2c_write, the stop_bit condition is ignored;

  • However, as per my understanding, this is crucial for I2C communication, since we might need a repeated start condition on certain use cases.

The error I have encountered is when reading a register for adt7420 which is always 0.

Image

  • From what I understand,
    • LOC 453 will write the register address (that needs to be read) and a stop_bit should not be generated (However, when using Linux Platform, stop_bit does not do anything)
    • LOC 456, will read back the register value and a stop_bit should be generated (However, when using Linux Platform, stop_bit does not do anything)
  • I think the issue is with using write() and read() for I2C, which cannot use/implement stop_bit (where in each write/read might automatically send a stop_bit)
    • Note: I was able to replicate this issue in a simple C Program
  • Instead, I have found that using ioctl(file,I2C_RDWR, &packets); or __s32 i2c_smbus_read_byte_data(int file, __u8 command); are working alternatives
@buha
Copy link
Contributor

buha commented Apr 4, 2025

Hi, I checked the current implementation of our I2C API for the linux userspace platform, and indeed, the stop_bit is ignored.

https://github.com/analogdevicesinc/no-OS/blob/main/drivers/platform/linux/linux_i2c.c#L160

This is definitely something that needs to be fixed, we will do it but I can't offer a timeline right now. If you would like to contribute and make a pull request that would be awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants