I am implementing a driver for Flex PIM4328PD component.
What function should I use for so-called “Block Write-Block Read Process Call” based communication, such as PMBus, SMBus, or at least i2c repeated start framing ?
“reg” would be the PMbus command (e.g. MFR_ID) and “size” the expected number of bytes to read from the device. This should be one more than the data size (e.g. 8+1), since the first data byte from the device will contain the number of data bytes.
For a block write you can use the following function, however this should be less common in a sensor driver:
Again, “reg” is the PMBus command, “pdata” is a pointer to the data to write and “size” is the number of bytes. The first byte should contain the number of data bytes to be written according to the SMBus specification.
In both cases the “addr” parameter should contain the I2C address of the device (8-bit address format) in the lower byte, the upper byte encodes the I2C bus to use (1 for the MGT bus, 2 for the SNS bus).
Sadly your proposition does not work
With this method, the coefficients I get for temperature reading are: 0xFFFFFFFFFF, but they should be 0xFE0000197F.
According to my local expert, and also PMBus and SMBus specifications, an i2c repeated start is mandatory to communicate properly with our PIM.
I’m afraid there was a misunderstanding, I thought you wanted to do a block read (which should work with the existing functions). However the PMBus COEFFICIENTS command that you apparently want to use is different: the host performs a write cycle with 4 bytes to the slave followed by a repeated start and a read of a given number of bytes. The function I suggested previously only writes a single byte before the repeated start and the read cycle. Could you therefore please try the following function instead:
i2c_dev_read_4bytesReg(unsigned short addr, unsigned int wr_data, unsigned char *rd_data, unsigned char size)
The <wr_data> parameter should be set as follows, where in an unsigned char with the command code according to the PMBus specification.
The parameter should be set to one more than the number of bytes than you expect to read (i.e. 6 in the case of the COEFFICIENTS command), or two more in the case there is a PEC byte. The fist byte in <rd_data> will be the number of bytes output from the device (i.e. 5) followed by the coefficients data and possibly a PEC byte.
Could you please give this a try? I hope there is no mistake, but we do unfortunately not have any board with a device that supports the PMBus COEFFICIENTS command, so we can’t really test it.