-
Notifications
You must be signed in to change notification settings - Fork 1.7k
SMBus block process call and block read feature not supported. #1812
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
Comments
(Linux kernel issue, not firmware) Both I2C_SMBUS_BLOCK_PROC_CALL and I2C_FUNC_SMBUS_READ_BLOCK_DATA rely on the read length being controlled by the first byte of the response. The flag I2C_M_RECV_LEN is passed in to the driver to signify that the first byte should be taken as the length. https://elixir.free-electrons.com/linux/latest/source/drivers/i2c/i2c-core-smbus.c#L395 Currently for i2c-bcm2835 the read length MUST be configured as part of the request, and read data is stored in a FIFO within the hardware block. Whilst not technically within the SMBus protocol, I would suspect that configuring the read for the maximum length expected, and then looking at the first word to find out how many bytes were actually supplied by the peripheral may work. You may get the peripheral NAKing later bytes which could stop that working (the FIFO won't be read). |
And to answer your question directly:
Yes, but no. Adding the flag to the |
@6by9 and @pelwell If so, is it possible to do bit-bang control of I2C on Linux application level to implement SMBus block read or SMBus block process call? I mean that operate the I2C controller register directly with mapping the memory of it. With this way, it seems the key issue is when will it send out NACK bit based on the value of first readout bytes in the FIFO. |
There is the i2c-gpio driver to bit bang the full I2C protocol. It does support I2C_FUNC_SMBUS_READ_BLOCK_DATA and I2C_FUNC_SMBUS_BLOCK_PROC_CALL. As I've said, you may find that your device allows you to do just an overlong read and it doesn't NAK the additional bytes, but that will be down to the implementation in your specific SMBus device. |
@6by9 Thanks a lot |
I'm using the raspberry pi OS with kernel 6.1.21-v8+ on raspberry 4B, found that it doesn't support the SMBus block process call and SMBus block read with i2cdetect -F command.
pi@raspberrypi:~ $ 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
It seems that in function static u32 bcm2835_i2c_func(struct i2c_adapter *adap), it doesn't set the I2C_SMBUS_BLOCK_PROC_CALL and I2C_FUNC_SMBUS_READ_BLOCK_DATA
return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
Can I add above two macro definitons directly in above line to let raspberry OS support SMBus block process call and SMBus block read ?
Or some extra work should be done to support above two features?
BTW, Per my understanding, the I2C_FUNC_SMBUS_READ_BLOCK_DATA is very similar as I2C_FUNC_SMBUS_READ_I2C_BLOCK , the only difference is the first byte response from I2C slave refers to data length for I2C_FUNC_SMBUS_READ_BLOCK_DATA
The text was updated successfully, but these errors were encountered: