raspberrypi / firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5.14k stars 1.68k forks source link

SMBus Block Read #1103

Open AntonioSanta opened 5 years ago

AntonioSanta commented 5 years ago

Hello I have seen the issue https://github.com/raspberrypi/firmware/issues/828 but anyway I still can find that recent kernel doesn't provide support for SMBus read block. See attachement for output from I2cdetect -F 1. In the overlay folder I can see there is I2c1-bcm2708.dtbo . am I missing something I should do to enable this SMBus read block ? thank you i2cdetect_output

pelwell commented 5 years ago

Please add dtoverlay=i2c1-bcm2708,combine=off and retest.

AntonioSanta commented 5 years ago

by adding this line

dtoverlay=i2c1-bcm2708,combine=off

as last line on the config.txt in the Boot folder I get the same result from i2cdetect -F 1. SMBus Block Read no

I am using this system :

screenshot from 2019-01-29 12-01-40

pelwell commented 5 years ago

Both drivers report their functionality as including I2C_FUNC_SMBUS_EMUL, about which the documentation says:

Handles all SMBus commands that can be emulated by a real I2C adapter (using the transparent emulation layer)

The relevant header file defines the symbol thus:

#define I2C_FUNC_SMBUS_EMUL     (I2C_FUNC_SMBUS_QUICK | \
                     I2C_FUNC_SMBUS_BYTE | \
                     I2C_FUNC_SMBUS_BYTE_DATA | \
                     I2C_FUNC_SMBUS_WORD_DATA | \
                     I2C_FUNC_SMBUS_PROC_CALL | \
                     I2C_FUNC_SMBUS_WRITE_BLOCK_DATA | \
                     I2C_FUNC_SMBUS_I2C_BLOCK | \
                     I2C_FUNC_SMBUS_PEC)

In other words, an I2C controller can emulate an SMBUS controller for most things, including Block Write, but not Block Read.

AntonioSanta commented 5 years ago

thank you for the link, that's interesting, which file is that define in ? so previous https://github.com/raspberrypi/firmware/issues/828 is not possible to solve as well, I thought from those messages that it was possible in some way. do you know if it is because of an hardware limitation of the I2c controller compatibility with SMBus block read or if it is just because it was chosen not to implement it ? thanks

dognotdog commented 4 years ago

I just wanted to add that read_i2c_block_data() might work in lieu of read_block_data() despite the SMBus block read not being supported if you know the number of bytes to expect, and don't have to rely on the controller detecting it. The basic structure of the read looks to be the same on the i2c bus, except that the count field is ignored by the hardware/driver and passed on to the application. (caveat: I've only tested this with an MCU slave that hasn't been tested against a proper SMBus controller)