Skip to content
Commit 97d6db60 authored by Quanyang Wang's avatar Quanyang Wang Committed by Bruce Ashfield
Browse files

i2c: cadence: keep bus_hold_flag unless I2C_M_NOSTART is set

When using i2c_smbus_read_byte_data to read one byte from a
slave device, because of the commit d358def7


("i2c: cadence: Fix the hold bit setting"), the transaction becomes:

S Addr Wr [A] Comm [A] P S Addr Rd [A] [Data] NA P
                       ^
                CR_HOLD bit as 0

This will result that the read operation fails and will read "0xff" from
the slave device. In the SMBus protocol, it stipulates that it must follow
that command with a repeated START condition as below:

S Addr Wr [A] Comm [A] Sr Addr Rd [A] [Data] NA P

So add a check if I2C_M_NOSTART is set in flags. If set, clear the
CR_HOLD bit, or else keep CR_HOLD bit to be 1 to make sure that
the read operation begins with a repeated START.

Signed-off-by: default avatarQuanyang Wang <quanyang.wang@windriver.com>
Signed-off-by: default avatarBruce Ashfield <bruce.ashfield@gmail.com>
parent d26d99cd
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment