The i2c bus gets disabled without sending a stop condition. This violates i2c timing on the clock line. Fix this and include all related functions (rk_i2c_send_start_bit, rk_i2c_send_stop_bit, rk_i2c_disable) onto the same level. Signed-off-by: Gerald Loacker <gerald.loacker@xxxxxxxxxxxxxx> --- drivers/i2c/busses/i2c-rockchip.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/i2c/busses/i2c-rockchip.c b/drivers/i2c/busses/i2c-rockchip.c index 23bf4a55d7..1bca3e9913 100644 --- a/drivers/i2c/busses/i2c-rockchip.c +++ b/drivers/i2c/busses/i2c-rockchip.c @@ -222,10 +222,6 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, dev_dbg(dev, "rk_i2c_read: chip = %d, reg = %d, r_len = %d, b_len = %d\n", chip, reg, r_len, b_len); - err = rk_i2c_send_start_bit(i2c); - if (err) - return err; - writel(I2C_MRXADDR_SET(1, chip << 1 | 1), ®s->mrxaddr); if (r_len == 0) { writel(0, ®s->mrxraddr); @@ -294,8 +290,6 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, i2c_exit: if (err) rk_i2c_show_regs(i2c); - rk_i2c_disable(i2c); - return err; } @@ -315,9 +309,6 @@ static int rk_i2c_write(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, dev_dbg(dev, "rk_i2c_write: chip = %d, reg = %d, r_len = %d, b_len = %d\n", chip, reg, r_len, b_len); - err = rk_i2c_send_start_bit(i2c); - if (err) - return err; while (bytes_remain_len) { if (bytes_remain_len > RK_I2C_FIFO_SIZE) @@ -370,8 +361,6 @@ static int rk_i2c_write(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len, i2c_exit: if (err) rk_i2c_show_regs(i2c); - rk_i2c_disable(i2c); - return err; } @@ -387,6 +376,11 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, struct i2c_msg *msg = &msgs[i]; dev_dbg(dev, "i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len); + + ret = rk_i2c_send_start_bit(i2c); + if (ret) + break; + if (msg->flags & I2C_M_RD) { ret = rk_i2c_read(i2c, msg->addr, 0, 0, msg->buf, msg->len); @@ -394,6 +388,9 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, ret = rk_i2c_write(i2c, msg->addr, 0, 0, msg->buf, msg->len); } + + rk_i2c_send_stop_bit(i2c); + if (ret) { dev_dbg(dev, "i2c_write: error sending: %pe\n", ERR_PTR(ret)); @@ -402,9 +399,7 @@ static int rockchip_i2c_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, } } - rk_i2c_send_stop_bit(i2c); rk_i2c_disable(i2c); - return ret < 0 ? ret : nmsgs; } -- 2.37.2